CurrentDcSentinelHelloCollector extends DefaultSentinelHelloCollector { @Override protected Set<HostPort> getSentinels(RedisInstanceInfo info) { String dcId = info.getDcId(); String clusterId = info.getClusterId(); String shardId = info.getShardId(); if (!checkDcClusterShardExist(dcId, clusterId, shardId)) { return Collections.emptySet(); } DcMeta dcMeta = metaCache.getXpipeMeta().getDcs().get(dcId); ShardMeta shardMeta = dcMeta.getClusters().get(clusterId).getShards().get(shardId); SentinelMeta sentinelMeta = dcMeta.getSentinels().get(shardMeta.getSentinelId()); if (null == sentinelMeta) return Collections.emptySet(); return new HashSet<>(IpUtils.parseAsHostPorts(sentinelMeta.getAddress())); }    }
@Test public void testGetSentinels() { RedisInstanceInfo info = mockInstanceInfo("127.0.0.1", 6379); Set<HostPort> result = collector.getSentinels(info); Assert.assertEquals(sentinels, result); }