DefaultClusterHealthMonitorManager implements ClusterHealthMonitorManager { @Override public void healthCheckMasterUp(RedisHealthCheckInstance instance) { if(!monitors.containsKey(instance.getRedisInstanceInfo().getClusterId())) { logger.debug("[healthCheckMasterUp] Cluster is not warned before: {}", instance.getRedisInstanceInfo().getClusterId()); return; } DefaultClusterHealthMonitor monitor = getOrCreate(instance.getRedisInstanceInfo().getClusterId()); monitor.healthCheckMasterUp(instance.getRedisInstanceInfo().getShardId()); }  @Override void healthCheckMasterDown(RedisHealthCheckInstance instance); @Override void healthCheckMasterUp(RedisHealthCheckInstance instance); @Override void outerClientMasterDown(String clusterId, String shardId); @Override void outerClientMasterUp(String clusterId, String shardId); @Override Set<String> getWarningClusters(ClusterHealthState state); @Override Observer createHealthStatusObserver();  }
@Test public void testHealthCheckMasterUp() { testHealthCheckMasterDown(); RedisHealthCheckInstance instance = mock(RedisHealthCheckInstance.class); when(instance.getRedisInstanceInfo()).thenReturn(new DefaultRedisInstanceInfo("dc", "cluster", "shard8", null, "", ClusterType.ONE_WAY)); instance.getRedisInstanceInfo().isMaster(true); manager.healthCheckMasterUp(instance); Assert.assertEquals(Sets.newHashSet("cluster"), manager.getWarningClusters(ClusterHealthState.LEAST_ONE_DOWN)); Assert.assertEquals(Sets.newHashSet("cluster"), manager.getWarningClusters(ClusterHealthState.QUARTER_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.HALF_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.THREE_QUARTER_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.FULL_DOWN)); when(instance.getRedisInstanceInfo()).thenReturn(new DefaultRedisInstanceInfo("dc", "cluster", "shard3", null, "", ClusterType.ONE_WAY)); instance.getRedisInstanceInfo().isMaster(true); manager.healthCheckMasterUp(instance); when(instance.getRedisInstanceInfo()).thenReturn(new DefaultRedisInstanceInfo("dc", "cluster", "shard2", null, "", ClusterType.ONE_WAY)); instance.getRedisInstanceInfo().isMaster(true); manager.healthCheckMasterUp(instance); Assert.assertEquals(Sets.newHashSet("cluster"), manager.getWarningClusters(ClusterHealthState.LEAST_ONE_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.QUARTER_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.HALF_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.THREE_QUARTER_DOWN)); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.FULL_DOWN)); when(instance.getRedisInstanceInfo()).thenReturn(new DefaultRedisInstanceInfo("dc", "cluster", "shard1", null, "", ClusterType.ONE_WAY)); instance.getRedisInstanceInfo().isMaster(true); manager.healthCheckMasterUp(instance); Assert.assertEquals(Sets.newHashSet(), manager.getWarningClusters(ClusterHealthState.LEAST_ONE_DOWN)); }