CurrentDcSentinelHelloCollector extends DefaultSentinelHelloCollector { @Override protected boolean isHelloMasterInWrongDc(SentinelHello hello) { HostPort hostPort = hello.getMasterAddr(); String targetDc = metaCache.getDc(hostPort); return !currentDc.equalsIgnoreCase(targetDc); }    }
@Test public void testIsHelloMasterInWrongDc() { HostPort remoteDcMAster = new HostPort("127.0.0.1", 7379); SentinelHello hello = new SentinelHello(sentinels.iterator().next(), remoteDcMAster, sentinelMonitorName); Mockito.when(metaCache.getDc(remoteDcMAster)).thenReturn("remote-dc"); Assert.assertTrue(collector.isHelloMasterInWrongDc(hello)); }