Search in sources :

Example 1 with Sampling

use of com.yammer.metrics.core.Sampling in project pinot by linkedin.

the class AggregatedPoolStats method refresh.

public void refresh() {
    int totalCreated = 0;
    int totalDestroyed = 0;
    int totalCreateErrors = 0;
    int totalDestroyErrors = 0;
    int totalBadDestroyed = 0;
    int totalTimedOut = 0;
    int checkedOut = 0;
    int maxPoolSize = 0;
    int minPoolSize = 0;
    int poolSize = 0;
    int sampleMaxCheckedOut = 0;
    int sampleMaxPoolSize = 0;
    int idleCount = 0;
    AggregatedHistogram<Sampling> waitTimeHist = new AggregatedHistogram<Sampling>();
    AggregatedHistogram<Sampling> createTimeHist = new AggregatedHistogram<Sampling>();
    for (PoolStatsProvider p : _poolStatsProvider) {
        PoolStats<T> s = p.getStats();
        totalCreated += s.getTotalCreated();
        totalDestroyed += s.getTotalBadDestroyed();
        totalCreateErrors += s.getTotalCreateErrors();
        totalDestroyErrors += s.getTotalDestroyErrors();
        totalBadDestroyed += s.getTotalBadDestroyed();
        totalTimedOut += s.getTotalTimedOut();
        checkedOut += s.getCheckedOut();
        maxPoolSize += s.getMaxPoolSize();
        minPoolSize += s.getMinPoolSize();
        poolSize += s.getPoolSize();
        sampleMaxCheckedOut += s.getSampleMaxCheckedOut();
        sampleMaxPoolSize += s.getSampleMaxPoolSize();
        idleCount += s.getIdleCount();
        waitTimeHist.add(s.getWaitTime().getHistogram());
        createTimeHist.add(s.getLifecycleStats().getCreateTime().getHistogram());
    }
    _totalCreated = totalCreated;
    _totalDestroyed = totalDestroyed;
    _totalBadDestroyed = totalBadDestroyed;
    _totalCreateErrors = totalCreateErrors;
    _totalDestroyErrors = totalDestroyErrors;
    _totalTimedOut = totalTimedOut;
    _checkedOut = checkedOut;
    _maxPoolSize = maxPoolSize;
    _minPoolSize = minPoolSize;
    _poolSize = poolSize;
    _sampleMaxCheckedOut = sampleMaxCheckedOut;
    _sampleMaxPoolSize = sampleMaxPoolSize;
    _idleCount = idleCount;
    _waitTime = new LatencyMetric(waitTimeHist);
    _lifecycleStats = new LifecycleStats(new LatencyMetric<AggregatedHistogram<Sampling>>(createTimeHist));
}
Also used : LatencyMetric(com.linkedin.pinot.common.metrics.LatencyMetric) AggregatedHistogram(com.linkedin.pinot.common.metrics.AggregatedHistogram) Sampling(com.yammer.metrics.core.Sampling)

Example 2 with Sampling

use of com.yammer.metrics.core.Sampling in project pinot by linkedin.

the class AggregatedHistogram method refresh.

/**
   * update all stats using underlying histograms
   */
public void refresh() {
    List<Double> values = new ArrayList<Double>();
    _min = Double.MAX_VALUE;
    _max = Double.MIN_VALUE;
    _sum = 0;
    double meanSum = 0.0;
    for (T hist : _histograms) {
        if (hist instanceof Histogram) {
            Histogram h = (Histogram) hist;
            _min = Math.min(_min, h.min());
            _max = Math.max(_max, h.max());
            _sum += h.sum();
            meanSum += h.mean();
        } else {
            AggregatedHistogram<Sampling> h = (AggregatedHistogram<Sampling>) hist;
            _min = Math.min(_min, h.min());
            _max = Math.max(_max, h.max());
            _sum += h.sum();
            meanSum += h.mean();
        }
        double[] val = hist.getSnapshot().getValues();
        for (double d : val) {
            values.add(d);
        }
    }
    if (!_histograms.isEmpty()) {
        _mean = meanSum / _histograms.size();
    }
    if (!values.isEmpty()) {
        double[] vals = new double[values.size()];
        int i = 0;
        for (Double d : values) {
            vals[i++] = d;
        }
        _snapshot = new Snapshot(vals);
    }
}
Also used : Snapshot(com.yammer.metrics.stats.Snapshot) Histogram(com.yammer.metrics.core.Histogram) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Sampling(com.yammer.metrics.core.Sampling)

Aggregations

Sampling (com.yammer.metrics.core.Sampling)2 AggregatedHistogram (com.linkedin.pinot.common.metrics.AggregatedHistogram)1 LatencyMetric (com.linkedin.pinot.common.metrics.LatencyMetric)1 Histogram (com.yammer.metrics.core.Histogram)1 Snapshot (com.yammer.metrics.stats.Snapshot)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1