Updates the "available" metric for the given quota.
322836
def update_available(self, name):
        """"""
        quota = self.usages.get(name, {}).get('quota', float('inf'))
        available = quota - self.usages[name]['used']
        if available < 0:
            available = 0
        self.usages[name]['available'] = available
844243
public void resetQuotaAndRecoverEnforcement() {
        for(Integer nodeId: nodeIds) {
            boolean quotaEnforcement = mapNodeToQuotaEnforcingEnabled.get(nodeId);
            adminClient.metadataMgmtOps.updateRemoteMetadata(Arrays.asList(nodeId),
                                                             MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY,
                                                             Boolean.toString(quotaEnforcement));
        }
        for(String storeName: storeNames) {
            adminClient.quotaMgmtOps.rebalanceQuota(storeName);
        }
    }
904435
def _set_or_sum_metric(self, metrics, metric_path, value):
        """"""
        if metric_path in metrics:
            metrics[metric_path] += value
        else:
            metrics[metric_path] = value
369511
def _check_quota(self):
        
        self._request_remaining_quota_if_unset()
        if self.quota_estimate < self.quota_limit:
            raise BitQuotaExceeded(self.quota_estimate)
30073
private void addPathsWithAsyncUpdate(ChangesItem changesItem, String quotableParent)
   {
      boolean isAsyncUpdate;
      try
      {
         isAsyncUpdate = quotaPersister.isNodeQuotaOrGroupOfNodesQuotaAsync(rName, wsName, quotableParent);
      }
      catch (UnknownQuotaLimitException e)
      {
         isAsyncUpdate = true;
      }

      if (isAsyncUpdate)
      {
         changesItem.addPathWithAsyncUpdate(quotableParent);
      }
   }
9816
public void updateCount(String lastPrefix, int diff) {
        String statNode = Quotas.statPath(lastPrefix);
        DataNode node = nodes.get(statNode);
        StatsTrack updatedStat = null;
        if (node == null) {
            // should not happen
            LOG.error("Missing count node for stat " + statNode);
            return;
        }
        synchronized (node) {
            updatedStat = new StatsTrack(new String(node.data));
            updatedStat.setCount(updatedStat.getCount() + diff);
            node.data = updatedStat.toString().getBytes();
        }
        // now check if the counts match the quota
        String quotaNode = Quotas.quotaPath(lastPrefix);
        node = nodes.get(quotaNode);
        StatsTrack thisStats = null;
        if (node == null) {
            // should not happen
            LOG.error("Missing count node for quota " + quotaNode);
            return;
        }
        synchronized (node) {
            thisStats = new StatsTrack(new String(node.data));
        }
        if (thisStats.getCount() < updatedStat.getCount()) {
            LOG
                    .warn("Quota exceeded: " + lastPrefix + " count="
                            + updatedStat.getCount() + " limit="
                            + thisStats.getCount());
        }
    }
627902
@GuardedBy("lock")
  private void updateStats() {
    mInternalStatFs = updateStatsHelper(mInternalStatFs, mInternalPath);
    mExternalStatFs = updateStatsHelper(mExternalStatFs, mExternalPath);
    mLastRestatTime = SystemClock.uptimeMillis();
  }
256326
def load_quota(self, quota, TTL, interval):
        
        if quota is not None:
            self._quota = quota
        if TTL is not None:
            self._TTL = TTL
        if interval is not None:
            self._report_interval = interval / 10
1202149
def _update_heap(self, peer):
        """"""
        rank = self.rank_calculator.get_rank(peer)
        if rank == peer.rank:
            return

        peer.rank = rank
        self.peer_heap.update_peer(peer)
899740
def update(self, entries = {}, *args, **kwargs):
        
        if isinstance(entries, dict):
            entries = self._reject_reserved_keys(entries)

        for key, value in dict(entries, *args, **kwargs).items():
            if isinstance(value, dict):
                self.__dict__[key] = AttributeDict(value)
            else:
                self.__dict__[key] = value

        self._refresh()
561598
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CPMeasurementUnit updateCPMeasurementUnit(
		CPMeasurementUnit cpMeasurementUnit) {
		return cpMeasurementUnitPersistence.update(cpMeasurementUnit);
	}
471038
private void accumulatePersistedGlobalChanges(long delta)
   {
      long dataSize = 0;
      try
      {
         dataSize = quotaPersister.getGlobalDataSize();
      }
      catch (UnknownDataSizeException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace(e.getMessage(), e);
         }
      }

      long newDataSize = Math.max(dataSize + delta, 0); // to avoid possible inconsistency
      quotaPersister.setGlobalDataSize(newDataSize);
   }
642585
private function update_metrics() {
    $now = time();
    if (($this->metrics['interval_start'] + $this->config['streaming_metrics_interval']) > $now)
      return null;

    $this->metrics['mps'] = round( ($this->metrics['messages'] - $this->metrics['last_messages']) / $this->config['streaming_metrics_interval'], 2);
    $this->metrics['bps'] = round( ($this->metrics['bytes'] - $this->metrics['last_bytes']) / $this->config['streaming_metrics_interval'], 2);

    $this->metrics['last_bytes'] = $this->metrics['bytes'];
    $this->metrics['last_messages'] = $this->metrics['messages'];
    $this->metrics['interval_start'] = $now;
    return $this->metrics;
  }
161404
def add_quota(self, quota):
        """"""
        if quota.limit in (None, -1, float('inf')):
            # Handle "unlimited" quotas.
            self.usages[quota.name]['quota'] = float("inf")
            self.usages[quota.name]['available'] = float("inf")
        else:
            self.usages[quota.name]['quota'] = int(quota.limit)
15180
public void push(List<Metric> rawMetrics) {
    List<Metric> validMetrics = ValidCharacters.toValidValues(filter(rawMetrics));
    List<Metric> metrics = transformMetrics(validMetrics);

    LOGGER.debug("Scheduling push of {} metrics", metrics.size());
    final UpdateTasks tasks = getUpdateTasks(BasicTagList.EMPTY,
        identifyCountersForPush(metrics));
    final int maxAttempts = 5;
    int attempts = 1;
    while (!pushQueue.offer(tasks) && attempts <= maxAttempts) {
      ++attempts;
      final UpdateTasks droppedTasks = pushQueue.remove();
      LOGGER.warn("Removing old push task due to queue full. Dropping {} metrics.",
          droppedTasks.numMetrics);
      numMetricsDroppedQueueFull.increment(droppedTasks.numMetrics);
    }
    if (attempts >= maxAttempts) {
      LOGGER.error("Unable to push update of {}", tasks);
      numMetricsDroppedQueueFull.increment(tasks.numMetrics);
    } else {
      LOGGER.debug("Queued push of {}", tasks);
    }
  }
707413
public void updateMetrics() {
    Counters counters = getCounters();
    for (Counters.Group group : counters) {
      jobMetrics.setTag("group", group.getDisplayName());
      for (Counters.Counter counter : group) {
        jobMetrics.setTag("counter", counter.getDisplayName());
        jobMetrics.setMetric("value", (float) counter.getCounter());
        jobMetrics.update();
      }
    }
  }
1006317
public boolean updateMetric(Metric metric) {
        String metricName = metric.getName();
        checkMetricIsEmpty(metricName);
        QueryPart<Metric> queryPart = new Query<Metric>("metrics")
                .path(metricName, true);
        return httpClientManager.updateMetaData(queryPart, patch(metric));
    }