MultiMasterDelayListener implements DelayActionListener, BiDirectionSupport { @Override public void onAction(DelayActionContext delayActionContext) { RedisHealthCheckInstance instance = delayActionContext.instance(); RedisInstanceInfo info = instance.getRedisInstanceInfo(); if (currentDcId.equalsIgnoreCase(delayActionContext.instance().getRedisInstanceInfo().getDcId())) return; String targetDcId = info.getDcId(); String clusterId = info.getClusterId(); String shardId = info.getShardId(); Long delayNano = delayActionContext.getResult(); long delayMilli = TimeUnit.NANOSECONDS.toMillis(delayNano); CrossMasterHealthStatus crossMasterLastHealthDelays = getOrCreateCrossMasterHealthStatus(clusterId, shardId); crossMasterLastHealthDelays.updateTargetMasterDelay(targetDcId, delayMilli, instance); }  @PostConstruct void postConstruct(); @PreDestroy void preDestroy(); @Override void onAction(DelayActionContext delayActionContext); @Override void stopWatch(HealthCheckAction action);  }
@Test public void testDelayRecovery() { testDelayUnhealthy(); Mockito.when(instance.getRedisInstanceInfo()).thenReturn(rbMasterInfo); multiMasterDelayListener.onAction(new DelayActionContext(instance, 0L)); Mockito.verify(alertManager, Mockito.times(1)).alert(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()); Mockito.when(instance.getRedisInstanceInfo()).thenReturn(oyMasterInfo); multiMasterDelayListener.onAction(new DelayActionContext(instance, 0L)); Mockito.verify(alertManager, Mockito.times(2)).alert(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()); Mockito.verify(alertManager, Mockito.times(1)).alert("cluster1", "shard1", null, CRDT_CROSS_DC_REPLICATION_UP, "replication become healthy from jq"); }