DefaultDcMetaChangeManager extends AbstractStartStoppable implements DcMetaChangeManager, MetaComparatorVisitor<ClusterMeta> { @Override public void visitAdded(ClusterMeta added) { if (!isInterestedInCluster(added)) { return; } ClusterMetaVisitor clusterMetaVisitor = new ClusterMetaVisitor(new ShardMetaVisitor(new RedisMetaVisitor(addConsumer))); clusterMetaVisitor.accept(added); } DefaultDcMetaChangeManager(HealthCheckInstanceManager instanceManager); @Override void compare(DcMeta future); @Override void visitAdded(ClusterMeta added); @Override void visitModified(MetaComparator comparator); @Override void visitRemoved(ClusterMeta removed);  }
@Test public void visitAddOneWayCluster() { manager.visitAdded(getDcMeta("oy").findCluster("cluster2")); verify(instanceManager, never()).getOrCreate(any()); Set<HostPort> expectedRedises = Sets.newHashSet(new HostPort("127.0.0.1", 8100), new HostPort("127.0.0.1", 8101)); manager.visitAdded(getDcMeta("oy").findCluster("cluster1")); verify(instanceManager, times(2)).getOrCreate(any()); Assert.assertEquals(expectedRedises, addedRedises); }
@Test public void visitAddBiDirectionCluster() { manager.visitAdded(getDcMeta("oy").findCluster("cluster4")); verify(instanceManager, never()).getOrCreate(any()); Set<HostPort> expectedRedises = Sets.newHashSet(new HostPort("10.0.0.1", 6379), new HostPort("10.0.0.2", 6379)); manager.visitAdded(getDcMeta("jq").findCluster("cluster3")); manager.visitAdded(getDcMeta("oy").findCluster("cluster3")); verify(instanceManager, times(2)).getOrCreate(any()); Assert.assertEquals(expectedRedises, addedRedises); }