SlowDiskTracker { @VisibleForTesting public void updateSlowDiskReportAsync(long now) { if (isUpdateInProgress.compareAndSet(false, true)) { lastUpdateTime = now; new Thread(new Runnable() { @Override public void run() { slowDisksReport = getSlowDisks(diskIDLatencyMap, MAX_DISKS_TO_REPORT, now); cleanUpOldReports(now); isUpdateInProgress.set(false); } }).start(); } } SlowDiskTracker(Configuration conf, Timer timer); @VisibleForTesting static String getSlowDiskIDForReport(String datanodeID,
      String slowDisk); void addSlowDiskReport(String dataNodeID,
      SlowDiskReports dnSlowDiskReport); void checkAndUpdateReportIfNecessary(); @VisibleForTesting void updateSlowDiskReportAsync(long now); String getSlowDiskReportAsJsonString(); static final Logger LOG; }
@Test public void testEmptyReports() { tracker.updateSlowDiskReportAsync(timer.monotonicNow()); assertTrue(getSlowDisksReportForTesting(tracker).isEmpty()); }