### Question:
HddsVolumeChecker { public Set<HddsVolume> checkAllVolumes(Collection<HddsVolume> volumes) throws InterruptedException { final long gap = timer.monotonicNow() - lastAllVolumesCheck; if (gap < minDiskCheckGapMs) { numSkippedChecks.incrementAndGet(); if (LOG.isTraceEnabled()) { LOG.trace( "Skipped checking all volumes, time since last check {} is less " + "than the minimum gap between checks ({} ms).", gap, minDiskCheckGapMs); } return Collections.emptySet(); } lastAllVolumesCheck = timer.monotonicNow(); final Set<HddsVolume> healthyVolumes = new HashSet<>(); final Set<HddsVolume> failedVolumes = new HashSet<>(); final Set<HddsVolume> allVolumes = new HashSet<>(); final AtomicLong numVolumes = new AtomicLong(volumes.size()); final CountDownLatch latch = new CountDownLatch(1); for (HddsVolume v : volumes) { Optional<ListenableFuture<VolumeCheckResult>> olf = delegateChecker.schedule(v, null); LOG.info("Scheduled health check for volume {}", v); if (olf.isPresent()) { allVolumes.add(v); Futures.addCallback(olf.get(), new ResultHandler(v, healthyVolumes, failedVolumes, numVolumes, (ignored1, ignored2) -> latch.countDown()), MoreExecutors.directExecutor()); } else { if (numVolumes.decrementAndGet() == 0) { latch.countDown(); } } } if (!latch.await(maxAllowedTimeForCheckMs, TimeUnit.MILLISECONDS)) { LOG.warn("checkAllVolumes timed out after {} ms", maxAllowedTimeForCheckMs); } numAllVolumeChecks.incrementAndGet(); synchronized (this) { return new HashSet<>(Sets.difference(allVolumes, healthyVolumes)); } } HddsVolumeChecker(ConfigurationSource conf, Timer timer); Set<HddsVolume> checkAllVolumes(Collection<HddsVolume> volumes); boolean checkVolume(final HddsVolume volume, Callback callback); long getNumVolumeChecks(); long getNumAllVolumeChecks(); long getNumSkippedChecks(); static final int MAX_VOLUME_FAILURE_TOLERATED_LIMIT; static final Logger LOG; }### Answer:
@Test public void testCheckAllVolumes() throws Exception { LOG.info("Executing {}", testName.getMethodName()); final List<HddsVolume> volumes = makeVolumes( NUM_VOLUMES, expectedVolumeHealth); final HddsVolumeChecker checker = new HddsVolumeChecker(new OzoneConfiguration(), new FakeTimer()); checker.setDelegateChecker(new DummyChecker()); Set<HddsVolume> failedVolumes = checker.checkAllVolumes(volumes); LOG.info("Got back {} failed volumes", failedVolumes.size()); if (expectedVolumeHealth == null || expectedVolumeHealth == FAILED) { assertThat(failedVolumes.size(), is(NUM_VOLUMES)); } else { assertTrue(failedVolumes.isEmpty()); } for (HddsVolume volume : volumes) { verify(volume, times(1)).check(anyObject()); } }