public Bucket getUpdatedSnapshot() throws InterruptedException { updater.gotData.await(10, TimeUnit.SECONDS); Bucket s = receiver.getSnapshot(); long startedWaitingForSnapshot = System.currentTimeMillis(); // just waiting for the correct snapshot being constructed (yes, this is // necessary) while (s == null || s.entrySet().size() == 0) { if (System.currentTimeMillis() - startedWaitingForSnapshot > (10L * 1000L)) { throw new RuntimeException("Test timed out."); } Thread.sleep(10); s = receiver.getSnapshot(); } return s; }
@Override public MetricSnapshot latestSnapshot() { Bucket curr = metricReceiver.getSnapshot(); if (curr == null) { log.warning("no snapshot from instance of " + metricReceiver.getClass()); return null; } else { SnapshotConverter converter = new SnapshotConverter(curr); return converter.convert(); } }
@Override public void histogram(PrintStream output) { Bucket curr = metricReceiver.getSnapshot(); if (curr == null) { log.warning("no snapshot from instance of " + metricReceiver.getClass()); } else { SnapshotConverter converter = new SnapshotConverter(curr); converter.outputHistograms(output); } }