private void scheduleClusterChangeCheck(final ClusterServersConfig cfg) { monitorFuture = GlobalEventExecutor.INSTANCE.schedule( new Runnable() { @Override public void run() { List<URI> nodes = new ArrayList<URI>(); List<URI> slaves = new ArrayList<URI>(); AtomicReference<Throwable> lastException = new AtomicReference<Throwable>(); for (ClusterPartition partition : lastPartitions.values()) { if (!partition.isMasterFail()) { nodes.add(partition.getMasterAddress()); } Set<URI> partitionSlaves = new HashSet<URI>(partition.getSlaveAddresses()); partitionSlaves.removeAll(partition.getFailedSlaveAddresses()); slaves.addAll(partitionSlaves); } // master nodes first nodes.addAll(slaves); checkClusterState(cfg, nodes.iterator(), lastException); } }, cfg.getScanInterval(), TimeUnit.MILLISECONDS); }