Skip to content

Commit

Permalink
report dest Redis as unhealthy instance in unhealthy bi_direction repl
Browse files Browse the repository at this point in the history
  • Loading branch information
lishanglin committed Feb 8, 2024
1 parent 58ed806 commit 3af08be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ public UnhealthyInfoModel getCurrentDcUnhealthyMasters() {
for (DcClusterShard dcClusterShard : crossMasterDelays.keySet()) {
if (!checkDcClusterShard(xpipeMeta, dcClusterShard)) continue;

for (Pair<HostPort, Long> targetDcDelay : crossMasterDelays.get(dcClusterShard).values()) {
Long delay = targetDcDelay.getValue();
if (null == delay || delay < 0 || delay == DelayAction.SAMPLE_LOST_BUT_PONG) {
unhealthyInfo.addUnhealthyInstance(dcClusterShard.getClusterId(), dcClusterShard.getDcId(),
dcClusterShard.getShardId(), findMasterOf(dcClusterShard, xpipeMeta), true);
for (Map.Entry<String, Pair<HostPort, Long>> crossDcDelay: crossMasterDelays.get(dcClusterShard).entrySet()) {
String targetDc = crossDcDelay.getKey();
HostPort targetMaster = crossDcDelay.getValue().getKey();
Long delay = crossDcDelay.getValue().getValue();
if (null == delay || delay < 0 || delay >= DelayAction.SAMPLE_LOST_BUT_PONG) {
unhealthyInfo.addUnhealthyInstance(dcClusterShard.getClusterId(), targetDc,
dcClusterShard.getShardId(), targetMaster, true);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void testCrossMasterReplicationHealthy() {

@Test
public void testCrossMasterReplicationUnhealthy() {
UnhealthyInfoModel.RedisHostPort expectedMaster = new UnhealthyInfoModel.RedisHostPort(new HostPort("127.0.0.1", 6379), true);
Mockito.when(instance.getCheckInfo()).thenReturn(new DefaultRedisInstanceInfo("oy", clusterId, shardId, new HostPort(), null, ClusterType.BI_DIRECTION));
UnhealthyInfoModel.RedisHostPort expectedMaster = new UnhealthyInfoModel.RedisHostPort(new HostPort("127.0.0.2", 6379), true);
Mockito.when(instance.getCheckInfo()).thenReturn(new DefaultRedisInstanceInfo("oy", clusterId, shardId, new HostPort("127.0.0.2", 6379), null, ClusterType.BI_DIRECTION));

service.onAction(new DelayActionContext(instance, DelayAction.SAMPLE_LOST_BUT_PONG));
UnhealthyInfoModel infoModel = service.getCurrentDcUnhealthyMasters();
Expand Down

0 comments on commit 3af08be

Please sign in to comment.