CrossMasterDelayService implements DelayActionListener, BiDirectionSupport { @Override public void onAction(DelayActionContext context) { RedisHealthCheckInstance instance = context.instance(); RedisInstanceInfo info = instance.getRedisInstanceInfo(); String targetDcId = info.getDcId(); DcClusterShard key = new DcClusterShard(currentDcId, info.getClusterId(), info.getShardId()); if (!currentDcId.equalsIgnoreCase(targetDcId)) { if (!crossMasterDelays.containsKey(key)) crossMasterDelays.put(key, Maps.newConcurrentMap()); crossMasterDelays.get(key).put(targetDcId, Pair.of(context.instance().getRedisInstanceInfo().getHostPort(), context.getResult())); } }  @Override void onAction(DelayActionContext context); @Override void stopWatch(HealthCheckAction action); Map<String, Pair<HostPort, Long>> getPeerMasterDelayFromCurrentDc(String clusterId, String shardId); Map<String, Pair<HostPort, Long>> getPeerMasterDelayFromSourceDc(String sourceDcId, String clusterId, String shardId); Map<String, Pair<HostPort, Long>> getPeerMasterDelayFromSourceDc(ClusterType clusterType, String sourceDcId, String clusterId, String shardId); UnhealthyInfoModel getCurrentDcUnhealthyMasters();  }
@Test public void testOnAction() { service.onAction(new DelayActionContext(instance, 10 * 1000 * 1000L)); Assert.assertEquals(Collections.singletonMap(remoteDcId, Pair.of(new HostPort(), 10L)), service.getPeerMasterDelayFromCurrentDc(clusterId, shardId)); Assert.assertEquals(Collections.singletonMap(remoteDcId, Pair.of(new HostPort(), 10L)), service.getPeerMasterDelayFromSourceDc(dcId, clusterId, shardId)); }