Skip to content

Commit

Permalink
Merge pull request #937 from ctripcorp/feature/keeper_msg_collect
Browse files Browse the repository at this point in the history
Feature/keeper msg collect
  • Loading branch information
LanternLee authored Feb 25, 2025
2 parents 0f6fe18 + a2f1d7c commit 1ed4d95
Show file tree
Hide file tree
Showing 128 changed files with 1,430 additions and 3,478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import com.ctrip.xpipe.api.email.EmailResponse;
import com.ctrip.xpipe.api.migration.OuterClientService;
import com.ctrip.xpipe.api.server.Server;
import com.ctrip.xpipe.endpoint.HostPort;
import com.ctrip.xpipe.redis.checker.alert.AlertMessageEntity;
import com.ctrip.xpipe.redis.checker.healthcheck.RedisHealthCheckInstance;
import com.ctrip.xpipe.redis.checker.model.CheckerStatus;
import com.ctrip.xpipe.redis.checker.model.HealthCheckResult;
import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel;
import com.ctrip.xpipe.redis.checker.model.ProxyTunnelInfo;
import com.ctrip.xpipe.redis.checker.model.*;
import com.ctrip.xpipe.redis.core.entity.SentinelMeta;
import com.ctrip.xpipe.redis.core.entity.XpipeMeta;
import com.fasterxml.jackson.annotation.JsonIgnore;
Expand All @@ -27,15 +25,13 @@ public interface CheckerConsoleService {

XpipeMeta getXpipeAllMeta(String console) throws SAXException, IOException;

XpipeMeta getXpipeDcAllMeta(String console, String dcName) throws SAXException, IOException;

List<ProxyTunnelInfo> getProxyTunnelInfos(String console);

void ack(String console, CheckerStatus checkerStatus);

void report(String console, HealthCheckResult result);

void reportKeeperContainerInfo(String console, List<KeeperContainerUsedInfoModel> keeperContainerUsedInfoModels, int index);
void reportKeeperContainerInfo(String console, Map<HostPort, RedisMsg> redisMsgMap, int index);

boolean isClusterOnMigration(String console, String clusterId);

Expand All @@ -51,8 +47,6 @@ public interface CheckerConsoleService {

boolean isAlertSystemOn(String console);

boolean isKeeperBalanceInfoCollectOn(String console);

Date getClusterCreateTime(String console, String clusterId);

Map<String, Date> loadAllClusterCreateTime(String console);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public interface PersistenceCache {

boolean isAlertSystemOn();

boolean isKeeperBalanceInfoCollectOn();

Date getClusterCreateTime(String clusterId);

Map<String, Date> loadAllClusterCreateTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,27 +470,6 @@ public ALERT_LEVEL getAlertLevel() {
return ALERT_LEVEL.HIGH;
}
},
KEEPER_BALANCE_INFO_COLLECT_ON("keeper balance info collect is turning on", EMAIL_XPIPE_ADMIN) {
@Override
public boolean urgent() {
return true;
}

@Override
public boolean reportRecovery() {
return false;
}

@Override
public DetailDesc detailDesc() {
return new DetailDesc("自动匀keeper信息收集打开", "");
}

@Override
public ALERT_LEVEL getAlertLevel() {
return ALERT_LEVEL.HIGH;
}
},
AUTO_MIGRATION_NOT_ALLOW("auto migration not allow", EMAIL_XPIPE_ADMIN) {
@Override
public boolean urgent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public interface CheckerDbConfig {

boolean isSentinelAutoProcess();

boolean isKeeperBalanceInfoCollectOn();

boolean shouldSentinelCheck(String cluster);

Set<String> sentinelCheckWhiteList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class CommonConfigBean extends AbstractConfigBean {

public static final String KEY_META_SYNC_EXTERNAL_DC = "meta.sync.external.dc";

public static final String KEY_KEEPERCONTAINER_DISK_INFO_COLLECT_INTERVAL_MILLS = "keeper.disk.info.collect.interval";

private String defaultRouteChooseStrategyType = RouteChooseStrategyFactory.RouteStrategyType.CRC32_HASH.name();

public CommonConfigBean() {
Expand Down Expand Up @@ -84,6 +86,10 @@ public String getClusterExcludedRegex() {
return getProperty(KEY_ALERT_CLUSTER_EXCLUDED_REGEX, "");
}

public long getKeeperContainerDiskInfoCollectIntervalMilli() {
return getLongProperty(KEY_KEEPERCONTAINER_DISK_INFO_COLLECT_INTERVAL_MILLS, 10 * 60 * 1000L);
}

public String getDBAEmails() {
return getProperty(KEY_DBA_EMAILS, "[email protected]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public boolean isSentinelAutoProcess() {
return persistenceCache.isSentinelAutoProcess();
}

@Override
public boolean isKeeperBalanceInfoCollectOn() {
return persistenceCache.isKeeperBalanceInfoCollectOn();
}

@Override
public boolean shouldSentinelCheck(String cluster) {
if (StringUtil.isEmpty(cluster)) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
import com.ctrip.xpipe.redis.checker.controller.result.ActionContextRetMessage;
import com.ctrip.xpipe.redis.checker.healthcheck.*;
import com.ctrip.xpipe.redis.checker.healthcheck.actions.interaction.*;
import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.info.RedisUsedMemoryCollector;
import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.infoStats.KeeperFlowCollector;
import com.ctrip.xpipe.redis.checker.healthcheck.actions.redisinfo.RedisMsgCollector;
import com.ctrip.xpipe.redis.checker.healthcheck.actions.redisconf.AbstractRedisConfigRuleAction;
import com.ctrip.xpipe.redis.checker.healthcheck.stability.StabilityHolder;
import com.ctrip.xpipe.redis.checker.model.DcClusterShard;
import com.ctrip.xpipe.redis.checker.model.DcClusterShardKeeper;
import com.ctrip.xpipe.redis.checker.model.RedisMsg;
import com.ctrip.xpipe.redis.core.meta.MetaCache;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.concurrent.ConcurrentMap;

/**
* @author lishanglin
Expand All @@ -38,10 +35,7 @@ public class CheckerHealthController {
private DefaultPsubPingActionCollector defaultPsubPingActionCollector;

@Autowired
private RedisUsedMemoryCollector redisUsedMemoryCollector;

@Autowired
private KeeperFlowCollector keeperFlowCollector;
private RedisMsgCollector redisMsgCollector;

@Autowired
private HealthCheckInstanceManager instanceManager;
Expand Down Expand Up @@ -99,26 +93,6 @@ public String getClusterHealthCheckInstance(@PathVariable String clusterId) {
return Codec.DEFAULT.encode(model);
}

@RequestMapping(value = "/health/check/keeper/{ip}/{port}", method = RequestMethod.GET)
public String getHealthCheckKeeper(@PathVariable String ip, @PathVariable int port) {
KeeperHealthCheckInstance instance = instanceManager.findKeeperHealthCheckInstance(new HostPort(ip, port));
if(instance == null) {
return "Not found";
}
HealthCheckInstanceModel model = buildHealthCheckInfo(instance);
return Codec.DEFAULT.encode(model);
}

@RequestMapping(value = "/health/check/redis-for-assigned-action/{ip}/{port}", method = RequestMethod.GET)
public String getHealthCheckRedisInstanceForAssignedAction(@PathVariable String ip, @PathVariable int port) {
RedisHealthCheckInstance instance = instanceManager.findRedisInstanceForAssignedAction(new HostPort(ip, port));
if(instance == null) {
return "Not found";
}
HealthCheckInstanceModel model = buildHealthCheckInfo(instance);
return Codec.DEFAULT.encode(model);
}

@RequestMapping(value = "/health/check/redis-for-ping-action/{ip}/{port}", method = RequestMethod.GET)
public String getHealthCheckRedisInstanceForPingAction(@PathVariable String ip, @PathVariable int port) {
RedisHealthCheckInstance instance = instanceManager.findRedisInstanceForPsubPingAction(new HostPort(ip, port));
Expand Down Expand Up @@ -167,14 +141,9 @@ public Map<HostPort, HealthStatusDesc> getHealthCheckInstanceCluster(@RequestBod
return result;
}

@GetMapping("/health/keeper/status/all")
public ConcurrentMap<String, Map<DcClusterShardKeeper, Long>> getAllKeeperFlows() {
return keeperFlowCollector.getHostPort2InputFlow();
}

@GetMapping("/health/redis/used-memory/all")
public ConcurrentMap<DcClusterShard, Long> getAllDclusterShardUsedMemory() {
return redisUsedMemoryCollector.getDcClusterShardUsedMemory();
@GetMapping("/health/redis/msg/all")
public Map<HostPort, RedisMsg> getAllRedisMsg() {
return redisMsgCollector.getRedisMasterMsgMap();
}

private HealthCheckInstanceModel buildHealthCheckInfo(HealthCheckInstance<?> instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.ctrip.xpipe.endpoint.HostPort;
import com.ctrip.xpipe.redis.core.entity.ClusterMeta;
import com.ctrip.xpipe.redis.core.entity.KeeperMeta;
import com.ctrip.xpipe.redis.core.entity.RedisMeta;
import com.ctrip.xpipe.redis.core.entity.XpipeMeta;

Expand All @@ -17,40 +16,24 @@ public interface HealthCheckInstanceManager {

RedisHealthCheckInstance getOrCreate(RedisMeta redis);

RedisHealthCheckInstance getOrCreateRedisInstanceForAssignedAction(RedisMeta redis);

RedisHealthCheckInstance getOrCreateRedisInstanceForPsubPingAction(RedisMeta redis);

KeeperHealthCheckInstance getOrCreate(KeeperMeta keeper);

ClusterHealthCheckInstance getOrCreate(ClusterMeta cluster);

RedisHealthCheckInstance findRedisHealthCheckInstance(HostPort hostPort);

RedisHealthCheckInstance findRedisInstanceForAssignedAction(HostPort hostPort);

RedisHealthCheckInstance findRedisInstanceForPsubPingAction(HostPort hostPort);

KeeperHealthCheckInstance findKeeperHealthCheckInstance(HostPort hostPort);

ClusterHealthCheckInstance findClusterHealthCheckInstance(String clusterId);

RedisHealthCheckInstance remove(HostPort hostPort);

KeeperHealthCheckInstance removeKeeper(HostPort hostPort);

RedisHealthCheckInstance removeRedisInstanceForAssignedAction(HostPort hostPort);

RedisHealthCheckInstance removeRedisInstanceForPingAction(HostPort hostPort);

ClusterHealthCheckInstance remove(String cluster);

List<RedisHealthCheckInstance> getAllRedisInstance();

List<KeeperHealthCheckInstance> getAllKeeperInstance();

List<RedisHealthCheckInstance> getAllRedisInstanceForAssignedAction();

List<ClusterHealthCheckInstance> getAllClusterInstance();

boolean checkInstancesMiss(XpipeMeta xpipeMeta);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1ed4d95

Please sign in to comment.