public void update() { final Lock workLock = lock.writeLock(); workLock.lock(); try { final Collection<LeafCollectorCounter> counters = aggregation.values(); statistics = Aggregators.aggregate(counters); concurrency.set(computeConcurrency(counters)); updateConcurrency(concurrency.get()); } finally { workLock.unlock(); } }
public AggregatedCollectorCounter(final Key key, final Map<String, LeafCollectorCounter> counters) { super(key); aggregation.putAll(counters); update(); }
@Override // TODO: see if we shouldn't store it or if aggregation can be done on java side public AggregatedCollectorCounter getOrCreateCounter(final Counter.Key key) { final Map<String, LeafCollectorCounter> counters = new HashMap<String, LeafCollectorCounter>(); for (final String marker : markers()) { final LeafCollectorCounter c = getOrCreateCounter(key, marker); counters.put(marker, c); } return new AggregatedCollectorCounter(key, counters); }
@Override // TODO: see if we shouldn't store it or if aggregation can be done on java side public Collection<Counter> getCounters() { final Map<Counter.Key, Map<String, LeafCollectorCounter>> counters = new HashMap<Counter.Key, Map<String, LeafCollectorCounter>>(); for (final String marker : markers()) { for (final LeafCollectorCounter c : getCounters(marker)) { Map<String, LeafCollectorCounter> values = counters.get(c.getKey()); if (values == null) { values = new HashMap<String, LeafCollectorCounter>(); counters.put(c.getKey(), values); } values.put(marker, c); } } final Collection<Counter> c = new LinkedList<Counter>(); for (final Map.Entry<Counter.Key, Map<String, LeafCollectorCounter>> entry : counters.entrySet()) { c.add(new AggregatedCollectorCounter(entry.getKey(), entry.getValue())); } return c; }