RedisMasterCheckActionFactory extends AbstractLeaderAwareHealthCheckActionFactory implements OneWaySupport, BiDirectionSupport { @Override public SiteLeaderAwareHealthCheckAction create(RedisHealthCheckInstance instance) { RedisMasterCheckAction action = new RedisMasterCheckAction(scheduled, instance, executors); ClusterType clusterType = instance.getRedisInstanceInfo().getClusterType(); action.addControllers(controllersByClusterType.get(clusterType)); action.addListeners(listenersByClusterType.get(clusterType)); return action; } @Autowired  RedisMasterCheckActionFactory(List<RedisMasterController> controllers, List<RedisMasterActionListener> listeners); @Override SiteLeaderAwareHealthCheckAction create(RedisHealthCheckInstance instance); @Override Class<? extends SiteLeaderAwareHealthCheckAction> support();  }
@Test public void testCreate() throws Exception { RedisHealthCheckInstance instance = instanceManager.getOrCreate(newRandomFakeRedisMeta()); RedisMasterCheckAction action = (RedisMasterCheckAction) factory.create(instance); logger.info("[isMaster] {}", instance.getRedisInstanceInfo().isMaster()); logger.info("[activeDc] {}", instance.getRedisInstanceInfo().getActiveDc()); checkActionController(action, ClusterType.ONE_WAY); action.doTask(); }
@Test public void testCreateForBiDirectionCluster() throws Exception { RedisHealthCheckInstance instance = newRandomRedisHealthCheckInstance("currentDc", ClusterType.BI_DIRECTION, 6379); RedisMasterCheckAction action = (RedisMasterCheckAction) factory.create(instance); checkActionController(action, ClusterType.BI_DIRECTION); action.doTask(); }