AutoSchedulingManager extends TimerTask { @Override public void run() { LOG.debug("Checking cluster keyspaces to identify which ones require repair schedules..."); Collection<Cluster> clusters = context.storage.getClusters(); for (Cluster cluster : clusters) { try { clusterRepairScheduler.scheduleRepairs(cluster); } catch (ReaperException | RuntimeException e) { LOG.error("Error while scheduling repairs for cluster {}", cluster, e); } } } private  AutoSchedulingManager(AppContext context);  AutoSchedulingManager(AppContext context, ClusterRepairScheduler clusterRepairScheduler); static synchronized void start(AppContext context); @Override void run();  }
@Test public void schedulesRepairForAllKeyspacesInAllClusters() throws Exception { context.storage.addCluster(CLUSTER_1); context.storage.addCluster(CLUSTER_2); repairAutoSchedulingManager.run(); verify(clusterRepairScheduler).scheduleRepairs(CLUSTER_1); verify(clusterRepairScheduler).scheduleRepairs(CLUSTER_2); }
@Test public void continueProcessingOtherClusterWhenSchedulingFailsForACluster() throws Exception { context.storage.addCluster(CLUSTER_1); context.storage.addCluster(CLUSTER_2); doThrow(new RuntimeException("throw for test purposes")).when(clusterRepairScheduler).scheduleRepairs(CLUSTER_1); repairAutoSchedulingManager.run(); verify(clusterRepairScheduler).scheduleRepairs(CLUSTER_1); verify(clusterRepairScheduler).scheduleRepairs(CLUSTER_2); }