CurrentDcSentinelCheckController extends CurrentDcCheckController implements SentinelActionController, BiDirectionSupport { public boolean shouldCheck(RedisHealthCheckInstance instance) { RedisInstanceInfo info = instance.getRedisInstanceInfo(); return super.shouldCheck(instance) && !(getRedisCntInCurrentDc(info.getClusterId(), info.getShardId()) > 1 && info.isMaster()); }  boolean shouldCheck(RedisHealthCheckInstance instance);  }
@Test public void testCheckLocalDcSlave() { Assert.assertTrue(controller.shouldCheck(instance)); Mockito.when(metaCache.getXpipeMeta()).thenReturn(mockXpipeMeta(1)); Assert.assertTrue(controller.shouldCheck(instance)); }
@Test public void testCheckLocalDcMaster() { Mockito.when(info.isMaster()).thenReturn(true); Assert.assertFalse(controller.shouldCheck(instance)); Mockito.when(metaCache.getXpipeMeta()).thenReturn(mockXpipeMeta(1)); Assert.assertTrue(controller.shouldCheck(instance)); }
@Test public void testCheckOtherDcRedis() { Mockito.when(info.getDcId()).thenReturn("remote-dc"); Assert.assertFalse(controller.shouldCheck(instance)); }