@Test public void testAddListener() { final int[] count = {0}; monitor.addListener(new ClusterHealthMonitor.Listener() { @Override public void stateChange(String clusterId, ClusterHealthState pre, ClusterHealthState current) { logger.info("[stateChange][{}]{} -> {}", clusterId, pre, current); count[0]++; } }); fakeShardService("shard1", "shard2", "shard3", "shard4"); monitor.healthCheckMasterDown("shard1"); monitor.outerClientMasterDown("shard1"); monitor.outerClientMasterDown("shard1"); monitor.healthCheckMasterDown("shard2"); monitor.healthCheckMasterDown("shard4"); monitor.outerClientMasterDown("shard3"); Assert.assertEquals(4, count[0]); }
@Override public void addListener(Listener listener) { listeners.add(listener); }
DefaultClusterHealthMonitor implements ClusterHealthMonitor { @Override public void addListener(Listener listener) { listeners.add(listener); } }
DefaultClusterHealthMonitor implements ClusterHealthMonitor { @Override public void addListener(Listener listener) { listeners.add(listener); } DefaultClusterHealthMonitor(String clusterId, ShardService shardService); }
DefaultClusterHealthMonitor implements ClusterHealthMonitor { @Override public void addListener(Listener listener) { listeners.add(listener); } DefaultClusterHealthMonitor(String clusterId, ShardService shardService); @Override String getClusterId(); @Override void healthCheckMasterDown(String shardId); @Override void healthCheckMasterUp(String shardId); @Override void outerClientMasterDown(String shardId); @Override void outerClientMasterUp(String shardId); @Override void addListener(Listener listener); @Override void removeListener(Listener listener); @Override ClusterHealthState getState(); }
DefaultClusterHealthMonitor implements ClusterHealthMonitor { @Override public void addListener(Listener listener) { listeners.add(listener); } DefaultClusterHealthMonitor(String clusterId, ShardService shardService); @Override String getClusterId(); @Override void healthCheckMasterDown(String shardId); @Override void healthCheckMasterUp(String shardId); @Override void outerClientMasterDown(String shardId); @Override void outerClientMasterUp(String shardId); @Override void addListener(Listener listener); @Override void removeListener(Listener listener); @Override ClusterHealthState getState();  }