Skip to content

Commit

Permalink
add cat log when migrate keepers (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
songyuyuyu authored Nov 22, 2023
1 parent 9d398da commit bca2261
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class AutoMigrateOverloadKeeperContainerAction extends AbstractCrossDcInt

private final List<ALERT_TYPE> alertType = Lists.newArrayList(ALERT_TYPE.KEEPER_MIGRATION_FAIL, ALERT_TYPE.KEEPER_MIGRATION_SUCCESS);

private final static String KEEPER_MIGRATION_SUCCESS = "keeper_migration_success";
public final static String KEEPER_MIGRATION_SUCCESS = "keeper_migration_success";

private final static String KEEPER_MIGRATION_FAIL = "keeper_migration_fail";
public final static String KEEPER_MIGRATION_FAIL = "keeper_migration_fail";

@Override
protected void doAction() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ctrip.xpipe.redis.console.service.impl;

import com.ctrip.xpipe.monitor.CatEventMonitor;
import com.ctrip.xpipe.redis.checker.model.DcClusterShard;
import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel;
import com.ctrip.xpipe.redis.console.model.ShardModel;
Expand All @@ -16,6 +17,9 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.ctrip.xpipe.redis.console.keeper.AutoMigrateOverloadKeeperContainerAction.KEEPER_MIGRATION_FAIL;
import static com.ctrip.xpipe.redis.console.keeper.AutoMigrateOverloadKeeperContainerAction.KEEPER_MIGRATION_SUCCESS;

@Component
public class DefaultKeeperContainerMigrationService implements KeeperContainerMigrationService {

Expand All @@ -41,7 +45,6 @@ public void beginMigrateKeeperContainers(List<MigrationKeeperContainerDetailMode
List<DcClusterShard> migrateShards = keeperContainer.getMigrateShards();
if (CollectionUtils.isEmpty(migrateShards)) continue;


String srcKeeperContainerIp = keeperContainer.getSrcKeeperContainer().getKeeperIp();
for (DcClusterShard migrateShard : migrateShards) {
ShardModel shardModel = shardModelService.getShardModel(migrateShard.getDcId(),
Expand All @@ -53,8 +56,16 @@ public void beginMigrateKeeperContainers(List<MigrationKeeperContainerDetailMode
logger.debug("[beginMigrateKeeperContainers] begin migrate shard {} from srcKeeperContainer:{} to targetKeeperContainer:{}",
migrateShard, srcKeeperContainerIp, keeperContainer.getTargetKeeperContainer().getKeeperIp());
if (shardModelService.migrateShardKeepers(migrateShard.getDcId(), migrateShard.getClusterId(), shardModel,
srcKeeperContainerIp, keeperContainer.getTargetKeeperContainer().getKeeperIp()))
srcKeeperContainerIp, keeperContainer.getTargetKeeperContainer().getKeeperIp())) {
keeperContainer.migrateKeeperCompleteCountIncrease();
CatEventMonitor.DEFAULT.logEvent(KEEPER_MIGRATION_SUCCESS, String.format("dc:%s, cluster:%s, shard:%s, src:%s, target:%s",
migrateShard.getDcId(), migrateShard.getClusterId(), migrateShard.getShardId(), srcKeeperContainerIp,
keeperContainer.getTargetKeeperContainer().getKeeperIp()));
} else {
CatEventMonitor.DEFAULT.logEvent(KEEPER_MIGRATION_FAIL, String.format("dc:%s, cluster:%s, shard:%s, src:%s, target:%s",
migrateShard.getDcId(), migrateShard.getClusterId(), migrateShard.getShardId(), srcKeeperContainerIp,
keeperContainer.getTargetKeeperContainer().getKeeperIp()));
}
}
}
isBegin.set(false);
Expand Down

0 comments on commit bca2261

Please sign in to comment.