public List<Pair<String, Long>> getTop(int n) { final List<Pair<String, Long>> countsSnapshot = Lists.newArrayListWithCapacity(this.counts.size()); // no updates are allowed while I'm holding this lock, so move fast this.lock.writeLock().lock(); try { for(Entry<String, Counter> entry : this.counts.entrySet()) { countsSnapshot.add(Pair.newPair(entry.getKey(), entry.getValue().get())); } } finally { this.lock.writeLock().unlock(); } Collections.sort(countsSnapshot, new Comparator<Pair<String, Long>>() { @Override public int compare(Pair<String, Long> a, Pair<String, Long> b) { return b.getSecond().compareTo(a.getSecond()); } }); return countsSnapshot.subList(0, Math.min(n, countsSnapshot.size())); }
public Counter getUpdatesBlockedMsHighWater() { return this.updatesBlockedMsHighWater; }
public static void updateWriteRequests(HRegion region, long numWrites) { Counter writeRequestsCount = region.writeRequestsCount; if (writeRequestsCount != null) writeRequestsCount.add(numWrites); }
public static void updateReadRequests(HRegion region, long numReads) { Counter readRequestsCount = region.readRequestsCount; if (readRequestsCount != null) readRequestsCount.add(numReads); }