MultiMasterDelayListener implements DelayActionListener, BiDirectionSupport { @VisibleForTesting protected void checkAllHealthStatus() { Set<DcClusterShard> toDeleteClusterShard = new HashSet<>(); for (DcClusterShard dcClusterShard : multiMasterHealthStatus.keySet()) { if (!isDcClusterShardExist(dcClusterShard.getDcId(), dcClusterShard.getClusterId(), dcClusterShard.getShardId())) { toDeleteClusterShard.add(dcClusterShard); continue; } multiMasterHealthStatus.get(dcClusterShard).refreshCurrentMasterHealthStatus(); } toDeleteClusterShard.forEach(dcClusterShard -> { logger.debug("[checkAllHealthStatus] remove not exist cluster shard {}", dcClusterShard); multiMasterHealthStatus.remove(dcClusterShard); }); }  @PostConstruct void postConstruct(); @PreDestroy void preDestroy(); @Override void onAction(DelayActionContext delayActionContext); @Override void stopWatch(HealthCheckAction action);  }
@Test public void testDelayUnhealthy() { testAllDelayHealth(); sleep(delayDownMilli + 1); multiMasterDelayListener.checkAllHealthStatus(); Mockito.verify(alertManager, Mockito.times(1)).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_DOWN, "replication unhealthy from jq to [rb, oy]"); }
@Test public void testNotExistDcDelay() { testAllDelayHealth(); Mockito.when(metaCache.getXpipeMeta()).thenReturn(new XpipeMeta()); sleep(delayDownMilli + 1); multiMasterDelayListener.checkAllHealthStatus(); Mockito.verify(alertManager, Mockito.times(0)).alert(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyString()); }