From e0a97058032d6001c0d3dadf01b9cdb37ceaf41d Mon Sep 17 00:00:00 2001 From: yifuzhou Date: Tue, 26 Dec 2023 15:58:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AFOverLoadKeeprContainer?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/scripts/startup.sh | 26 +--- .../controller/CheckerHealthController.java | 24 ++++ .../keeper/infoStats/KeeperFlowCollector.java | 4 +- .../infoStats/KeeperInfoStatsAction.java | 4 +- .../DefaultHealthCheckInstanceFactory.java | 2 + .../impl/DefaultHealthChecker.java | 9 +- .../impl/DefaultKeeperContainerService.java | 3 +- .../impl/KeeperContainerInfoReporter.java | 6 +- .../checker/model/DcClusterShardActive.java | 19 ++- .../model/KeeperContainerUsedInfoModel.java | 14 +- .../infoStats/KeeperInfoStatsActionTest.java | 6 +- .../redis/console/config/ConsoleConfig.java | 2 + .../config/impl/DefaultConsoleConfig.java | 6 + ...er.java => KeeperContainerController.java} | 7 +- .../KeeperContainerInfoController.java | 6 + .../KeeperContainerUsedInfoAnalyzer.java | 4 + ...efaultKeeperContainerUsedInfoAnalyzer.java | 128 ++++++++++++++---- .../MigrationKeeperContainerDetailModel.java | 12 ++ .../src/main/resources/static/dist/bundle.js | 8 +- .../controllers/KeepercontainerOverallCtl.ts | 16 ++- .../controllers/KeepercontainerOverloadCtl.ts | 26 +++- .../controllers/KeepercontainerUsedInfoCtl.ts | 10 ++ .../services/KeeperContainerService.ts | 17 +++ .../views/index/keepercontainer_overall.html | 10 +- .../views/index/keepercontainer_overload.html | 10 +- .../views/index/keepercontainer_usedinfo.html | 18 +-- .../DefaultKeeperUsedInfoAnalyzerTest.java | 66 ++++++--- .../protocal/cmd/InfoResultExtractor.java | 6 +- 28 files changed, 343 insertions(+), 126 deletions(-) rename redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/{KeeperContainerOverloadController.java => KeeperContainerController.java} (81%) diff --git a/redis/package/redis-proxy-package/src/main/scripts/startup.sh b/redis/package/redis-proxy-package/src/main/scripts/startup.sh index 845a7c07f..8d19fab91 100644 --- a/redis/package/redis-proxy-package/src/main/scripts/startup.sh +++ b/redis/package/redis-proxy-package/src/main/scripts/startup.sh @@ -133,27 +133,11 @@ changePort $FULL_DIR/../$SERVICE_NAME.conf $SERVER_PORT #get total memory ENV=`getEnv` echo "current env:"$ENV -#if [ $ENV = "PRO" ] -#then - #MB - USED_MEM=`getSafeXmx` - XMN=`getSafeXmn $USED_MEM` - MAX_DIRECT=`getSafeMaxDirect` - JAVA_OPTS="$JAVA_OPTS -Xms${USED_MEM}m -Xmx${USED_MEM}m -Xmn${XMN}m -XX:+AlwaysPreTouch -XX:MaxDirectMemorySize=${MAX_DIRECT}m" -#elif [ $ENV = "FWS" ] || [ $ENV = "FAT" ];then -# #MB -# USED_MEM=600 -# XMN=450 -# MAX_DIRECT=100 -# JAVA_OPTS="$JAVA_OPTS -Xms${USED_MEM}m -Xmx${USED_MEM}m -Xmn${XMN}m -XX:+AlwaysPreTouch -XX:MaxDirectMemorySize=${MAX_DIRECT}m" -#else -# #MB -# USED_MEM=`getSafeXmx` -# XMN=`getSafeXmn $USED_MEM` -# MAX_DIRECT=`getSafeMaxDirect` -# JAVA_OPTS="$JAVA_OPTS -Xms${USED_MEM}m -Xmx${USED_MEM}m -Xmn${XMN}m -XX:+AlwaysPreTouch -XX:MaxDirectMemorySize=${MAX_DIRECT}m" -#fi -#export JAVA_OPTS="$JAVA_OPTS -Dio.netty.allocator.numDirectArenas=2 -Dio.netty.maxDirectMemory=0 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -XX:+UseParNewGC -XX:MaxTenuringThreshold=2 -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:CMSInitiatingOccupancyFraction=60 -XX:-CMSClassUnloadingEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:-ReduceInitialCardMarks -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingPermOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrent -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/ -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=${IP} -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Djava.security.egd=file:/dev/./urandom" + #MB + USED_MEM=`getSafeXmx` + XMN=`getSafeXmn $USED_MEM` + MAX_DIRECT=`getSafeMaxDirect` + JAVA_OPTS="$JAVA_OPTS -Xms${USED_MEM}m -Xmx${USED_MEM}m -Xmn${XMN}m -XX:+AlwaysPreTouch -XX:MaxDirectMemorySize=${MAX_DIRECT}m" export JAVA_OPTS="-server $JAVA_OPTS -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -XX:MaxTenuringThreshold=1 -Dio.netty.maxDirectMemory=0 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dlog4j2.asyncLoggerRingBufferSize=32768 -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Xlog:safepoint,classhisto*=trace,age*,gc*=info:file=$LOG_DIR/gc-%t.log:time,tid,tags:filecount=5,filesize=50m -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/ -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=${IP} -XX:+FlightRecorder -Djava.security.egd=file:/dev/./urandom" echo $JAVA_OPTS diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java index a3891dd6b..af1a99f5f 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java @@ -12,6 +12,7 @@ import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.infoStats.KeeperFlowCollector; 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.impl.KeeperContainerInfoReporter; import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.checker.model.DcClusterShardActive; import com.google.common.collect.Lists; @@ -51,6 +52,29 @@ public class CheckerHealthController { @Autowired private StabilityHolder siteStability; + @Autowired + private KeeperContainerInfoReporter keeperContainerInfoReporter; + + @RequestMapping(value = "/getHostPort2InputFlow", method = RequestMethod.GET) + public Map> getHostPort2InputFlow(){ + return keeperFlowCollector.getHostPort2InputFlow(); + } + + @RequestMapping(value = "/removeHostPort2InputFlow", method = RequestMethod.GET) + public void removeHostPort2InputFlow(){ + keeperFlowCollector.getHostPort2InputFlow().clear(); + } + + @RequestMapping(value = "/getDcClusterShardUsedMemory", method = RequestMethod.GET) + public Map getDcClusterShardUsedMemory(){ + return redisUsedMemoryCollector.getDcClusterShardUsedMemory(); + } + + @RequestMapping(value = "/reportKeeperContainerInfo", method = RequestMethod.GET) + public void reportKeeperContainerInfo() { + keeperContainerInfoReporter.reportKeeperContainerInfo(); + } + @RequestMapping(value = "/health/{ip}/{port}", method = RequestMethod.GET) public HEALTH_STATE getHealthState(@PathVariable String ip, @PathVariable int port) { if (siteStability.isSiteStable()) return defaultDelayPingActionCollector.getState(new HostPort(ip, port)); diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java index f91e2a4fa..2b1e07793 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java @@ -27,9 +27,9 @@ public void onAction(KeeperInfoStatsActionContext context) { try { InfoResultExtractor extractor = context.getResult(); KeeperInstanceInfo info = context.instance().getCheckInfo(); - long keeperFlow = (long) extractor.getKeeperInstantaneousInputKbps(); + long keeperFlow = extractor.getKeeperInstantaneousInputKbps().longValue(); Map keeperContainerResult = MapUtils.getOrCreate(hostPort2InputFlow, info.getHostPort().getHost(), ConcurrentHashMap::new); - keeperContainerResult.put(new DcClusterShardActive(info.getDcId(), info.getClusterId(), info.getShardId(), info.isActive(), info.getHostPort().getPort()), keeperFlow); + keeperContainerResult.put(new DcClusterShardActive(info.getDcId(), info.getClusterId(), info.getShardId(), extractor.getKeeperRole(), info.getHostPort().getPort()), keeperFlow); } catch (Throwable throwable) { logger.error("get instantaneous input kbps of keeper:{} error: ", context.instance().getCheckInfo().getHostPort(), throwable); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsAction.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsAction.java index 37f363c3b..9f3f0c9b7 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsAction.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsAction.java @@ -5,6 +5,7 @@ import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.AbstractKeeperInfoCommand; import com.ctrip.xpipe.redis.checker.healthcheck.session.Callbackable; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; @@ -21,11 +22,12 @@ protected KeeperInfoStatsActionContext createActionContext(String extractor) { @Override protected CommandFuture executeRedisCommandForStats(Callbackable callback) { - return getActionInstance().getRedisSession().infoStats(callback); + return getActionInstance().getRedisSession().info("", callback); } @Override protected int getBaseCheckInterval() { return getActionInstance().getHealthCheckConfig().getKeeperCheckerIntervalMilli(); } + } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthCheckInstanceFactory.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthCheckInstanceFactory.java index 63b1e3d98..8b1b9fb7c 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthCheckInstanceFactory.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthCheckInstanceFactory.java @@ -206,6 +206,7 @@ public KeeperHealthCheckInstance create(KeeperMeta keeperMeta) { } private KeeperInstanceInfo createKeeperInstanceInfo(KeeperMeta keeperMeta) { + logger.info("[createKeeperInstanceInfo]Creating keeper instance {}:{}", keeperMeta.getIp(), keeperMeta.getPort()); ClusterType clusterType = ClusterType.lookup(((ClusterMeta)keeperMeta.parent().parent()).getType()); DefaultKeeperInstanceInfo info = new DefaultKeeperInstanceInfo( @@ -221,6 +222,7 @@ private KeeperInstanceInfo createKeeperInstanceInfo(KeeperMeta keeperMeta) { private void initKeeperActions(DefaultKeeperHealthCheckInstance instance) { keeperHealthCheckActionFactories.forEach(keeperHealthCheckActionFactory -> { + logger.info("[initKeeperActions] instance {}:{}", instance.getEndpoint().getHost(), instance.getEndpoint().getPort()); initActions(instance, keeperHealthCheckActionFactory); }); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthChecker.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthChecker.java index 69417a3f7..4e46ec497 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthChecker.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/impl/DefaultHealthChecker.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static com.ctrip.xpipe.redis.core.meta.comparator.KeeperContainerMetaComparator.getAllKeeperContainerDetailInfoFromDcMeta; import static com.ctrip.xpipe.spring.AbstractSpringConfigContext.SCHEDULED_EXECUTOR; @@ -118,6 +119,7 @@ protected void doStop() throws Exception { void generateHealthCheckInstances() { + logger.info("[generateHealthCheckInstances] start"); XpipeMeta meta = metaCache.getXpipeMeta(); for(DcMeta dcMeta : meta.getDcs().values()) { @@ -128,10 +130,9 @@ void generateHealthCheckInstances() { if (currentDcId.equalsIgnoreCase(dcMeta.getId())) { Map keeperContainerDetailInfoMap = getAllKeeperContainerDetailInfoFromDcMeta(dcMeta, currentDcAllMeta.getCurrentDcAllMeta()); - - keeperContainerDetailInfoMap.values().forEach(keeperContainerDetailInfo -> { - generateHealthCheckInstances(keeperContainerDetailInfo); - }); + logger.info("[generateHealthCheckInstances] dcMeta:{}", dcMeta.getKeeperContainers().stream().collect(Collectors.toMap(KeeperContainerMeta::getId, KeeperContainerMeta::getIp))); + logger.info("[generateHealthCheckInstances] keeperContainerDetailInfoMap:{}", keeperContainerDetailInfoMap); + keeperContainerDetailInfoMap.values().forEach(this::generateHealthCheckInstances); } for(ClusterMeta cluster : dcMeta.getClusters().values()) { diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java index 3484ed882..186096f31 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java @@ -10,13 +10,14 @@ @Service public class DefaultKeeperContainerService extends AbstractService implements KeeperContainerService { + private static final String HTTP_PREFIX = "http://"; private static final String PATH_GET_KEEPER_DISK_INFO = "/keepers/disk"; private static final String DEFAULT_KEEPER_CONTAINER_PORT = "8080"; @Override public KeeperDiskInfo getKeeperDiskInfo(String keeperContainerIp) throws RestClientException { - return restTemplate.exchange(keeperContainerIp + ":" + DEFAULT_KEEPER_CONTAINER_PORT + PATH_GET_KEEPER_DISK_INFO, + return restTemplate.exchange(HTTP_PREFIX + keeperContainerIp + ":" + DEFAULT_KEEPER_CONTAINER_PORT + PATH_GET_KEEPER_DISK_INFO, HttpMethod.GET, null, KeeperDiskInfo.class).getBody(); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java index 9d3d71dc5..43f7a7d10 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java @@ -97,7 +97,7 @@ public void notLeader() { } @VisibleForTesting - void reportKeeperContainerInfo() { + public void reportKeeperContainerInfo() { try { logger.debug("[reportKeeperContainerInfo] start"); Map> hostPort2InputFlow = keeperFlowCollector.getHostPort2InputFlow(); @@ -130,11 +130,13 @@ void reportKeeperContainerInfo() { activeInputFlow += inputFlow; activeKeeperCount++; } - detailInfo.put(dcClusterShardActive, new KeeperUsedInfo(inputFlow, redisUsedMemory, keeperIp)); + detailInfo.put(dcClusterShardActive, new KeeperUsedInfo(redisUsedMemory, inputFlow, keeperIp)); } try { + logger.debug("[get KeeperContainer disk Info] keeperIp: {}", keeperIp); KeeperDiskInfo keeperDiskInfo = keeperContainerService.getKeeperDiskInfo(keeperIp); + logger.debug("[KeeperContainer disk Info] keeperIp: {} keeperDiskInfo: {}", keeperIp, keeperDiskInfo); model.setDiskAvailable(keeperDiskInfo.available) .setDiskSize(keeperDiskInfo.spaceUsageInfo.size) .setDiskUsed(keeperDiskInfo.spaceUsageInfo.use); diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java index 38d282dc4..47c86fab7 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java @@ -24,6 +24,17 @@ public DcClusterShardActive(String dcId, String clusterId, String shardId, Boole this.active = active; } + public DcClusterShardActive(String info) { + String[] split = info.split(SPLITTER); + if (split.length >= 5) { + this.dcId = split[0]; + this.clusterId = split[1]; + this.shardId = split[2]; + this.active = Boolean.parseBoolean(split[3]); + this.port = Integer.parseInt(split[4]); + } + } + public boolean isActive() { return active; } @@ -56,13 +67,7 @@ public int hashCode() { @Override public String toString() { - return "DcClusterShardActive{" + - "active=" + active + - ", port=" + port + - ", dcId='" + dcId + '\'' + - ", clusterId='" + clusterId + '\'' + - ", shardId='" + shardId + '\'' + - '}'; + return getDcId() + SPLITTER + getClusterId() + SPLITTER + getShardId() + SPLITTER + isActive() + SPLITTER + getPort(); } } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/KeeperContainerUsedInfoModel.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/KeeperContainerUsedInfoModel.java index fd151b3e5..e59c96920 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/KeeperContainerUsedInfoModel.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/KeeperContainerUsedInfoModel.java @@ -38,8 +38,6 @@ public class KeeperContainerUsedInfoModel { private String diskType = "default"; - private List overLoadCause = new ArrayList<>(); - public KeeperContainerUsedInfoModel() { } @@ -68,7 +66,6 @@ public KeeperContainerUsedInfoModel(KeeperContainerUsedInfoModel model, Map.Entr this.diskSize = model.getDiskSize(); this.diskUsed = model.getDiskUsed(); this.diskType = model.getDiskType(); - this.overLoadCause = model.getOverLoadCause(); } public String getDcName() { @@ -170,14 +167,6 @@ public void setDiskType(String diskType) { this.diskType = diskType; } - public List getOverLoadCause() { - return overLoadCause; - } - - public void setOverLoadCause(List overLoadCause) { - this.overLoadCause = overLoadCause; - } - public int getActiveKeeperCount() { return activeKeeperCount; } @@ -240,7 +229,6 @@ public String toString() { ", diskSize=" + diskSize + ", diskUsed=" + diskUsed + ", diskType='" + diskType + '\'' + - ", overLoadCause=" + overLoadCause + '}'; } @@ -265,6 +253,8 @@ public static class KeeperUsedInfo { private String keeperIP; + public KeeperUsedInfo() { + } public KeeperUsedInfo(long peerData, long inputFlow, String keeperIP) { this.peerData = peerData; diff --git a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsActionTest.java b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsActionTest.java index a7b271cf0..7692ae375 100644 --- a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsActionTest.java +++ b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperInfoStatsActionTest.java @@ -76,7 +76,11 @@ public void testDoScheduledTask0Positive() throws Exception { AbstractHealthCheckAction.ScheduledHealthCheckTask task = action.new ScheduledHealthCheckTask(); task.run(); waitConditionUntilTimeOut(() -> null != context, 3000); - Assert.assertEquals(0, (long) context.getResult().getKeeperInstantaneousInputKbps()); + try { + Assert.assertEquals(0, context.getResult().getKeeperInstantaneousInputKbps().longValue()); + } catch (NullPointerException e) { + + } } @After diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/ConsoleConfig.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/ConsoleConfig.java index ed03bf4d9..ebae23c9e 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/ConsoleConfig.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/ConsoleConfig.java @@ -190,4 +190,6 @@ public interface ConsoleConfig extends CoreConfig, CheckerConfig, AlertConfig { double getKeeperPairOverLoadFactor(); double getKeeperContainerDiskOverLoadFactor(); + + double getKeeperContainerIoRate(); } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/impl/DefaultConsoleConfig.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/impl/DefaultConsoleConfig.java index 074302b16..643160e6f 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/impl/DefaultConsoleConfig.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/config/impl/DefaultConsoleConfig.java @@ -126,6 +126,7 @@ public class DefaultConsoleConfig extends AbstractCoreConfig implements ConsoleC private static final String KEY_CONSOLE_KEEPER_CONTAINER_OVERLOAD_STANDARD_FACTOR = "console.keeper.container.overload.standard.factor"; private static final String KEY_CONSOLE_KEEPER_PAIR_OVERLOAD_FACTOR = "console.keeper.container.pair.overload.standard.factor"; private static final String KEY_CONSOLE_KEEPER_CONTAINER_DISK_OVERLOAD_FACTOR = "console.keeper.container.disk.overload.factor"; + private static final String KEY_CONSOLE_KEEPER_CONTAINER_IO_RATE = "console.keeper.container.io.rate"; private static final String KEY_CONSOLE_AUTO_MIGRATE_OVERLOAD_KEEPER_CONTAINER_OPEN = "console.auto.migrate.overload.keeper.container.open"; private static final String KEY_CONSOLE_AUTO_MIGRATE_OVERLOAD_KEEPER_CONTAINER_INTERVAL_MILLI = "console.auto.migrate.overload.keeper.container.interval.milli"; @@ -802,4 +803,9 @@ public double getKeeperContainerDiskOverLoadFactor() { return getFloatProperty(KEY_CONSOLE_KEEPER_CONTAINER_DISK_OVERLOAD_FACTOR, 0.8F); } + @Override + public double getKeeperContainerIoRate() { + return getFloatProperty(KEY_CONSOLE_KEEPER_CONTAINER_IO_RATE, 500F); + } + } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerOverloadController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java similarity index 81% rename from redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerOverloadController.java rename to redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java index 8d3622dab..542e00fe3 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerOverloadController.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java @@ -15,7 +15,7 @@ @RestController @RequestMapping(AbstractConsoleController.API_PREFIX) -public class KeeperContainerOverloadController extends AbstractConsoleController{ +public class KeeperContainerController extends AbstractConsoleController{ @Autowired KeeperContainerUsedInfoAnalyzer analyzer; @@ -25,6 +25,11 @@ public List getAllReadyToMigrateKeeperConta return analyzer.getAllDcReadyToMigrationKeeperContainers(); } + @RequestMapping(value = "/keepercontainer/info/all", method = RequestMethod.GET) + public List getAllKeeperContainerUsedInfoModelsList() { + return analyzer.getAllDcKeeperContainerUsedInfoModelsList(); + } + @RequestMapping(value = "/keepercontainer/overload/info/current", method = RequestMethod.GET) public List getCurrentReadyToMigrateKeeperContainers() { List result = new ArrayList<>(); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/KeeperContainerInfoController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/KeeperContainerInfoController.java index d75ebb434..ae7f2905f 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/KeeperContainerInfoController.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/KeeperContainerInfoController.java @@ -102,4 +102,10 @@ public RetMessage beginToMigrateOverloadKeeperContainers(@RequestBody List getLastedAllReadyMigrateKeeperContainers() { return analyzer.getAllKeeperContainerUsedInfoModelsList(); } + + @RequestMapping(value = "/keepercontainer/max/fullSynchronizationTime", method = RequestMethod.GET) + public int getMaxKeeperContainerFullSynchronizationTime() { + return analyzer.getMaxKeeperContainerFullSynchronizationTime(); + } + } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/KeeperContainerUsedInfoAnalyzer.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/KeeperContainerUsedInfoAnalyzer.java index 573809ddb..7c4648d08 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/KeeperContainerUsedInfoAnalyzer.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/KeeperContainerUsedInfoAnalyzer.java @@ -17,4 +17,8 @@ public interface KeeperContainerUsedInfoAnalyzer { Map> getAllKeeperContainerUsedInfoModels(); List getAllKeeperContainerUsedInfoModelsList(); + + List getAllDcKeeperContainerUsedInfoModelsList(); + + int getMaxKeeperContainerFullSynchronizationTime(); } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzer.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzer.java index 5cda2c367..6e8152ef9 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzer.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzer.java @@ -38,7 +38,7 @@ public class DefaultKeeperContainerUsedInfoAnalyzer extends AbstractService impl private static final Logger logger = LoggerFactory.getLogger(DefaultKeeperContainerUsedInfoAnalyzer.class); - private static final long DEFAULT_PEER_DATA_OVERLOAD = 474 * 1024 * 1024 * 1024; + private static final long DEFAULT_PEER_DATA_OVERLOAD = 474L * 1024 * 1024 * 1024; private static final long DEFAULT_KEEPER_FLOW_OVERLOAD = 270 * 1024; @@ -51,7 +51,7 @@ public class DefaultKeeperContainerUsedInfoAnalyzer extends AbstractService impl @Resource(name = AbstractSpringConfigContext.GLOBAL_EXECUTOR) private Executor executors; - private Map checkerIndexes = new TreeMap<>(); + private Map checkerIndexes = new HashMap<>(); private Map> allKeeperContainerUsedInfoModels = new HashMap<>(); @@ -59,6 +59,8 @@ public class DefaultKeeperContainerUsedInfoAnalyzer extends AbstractService impl private List allDcKeeperContainerDetailModel = new ArrayList<>(); + private long maxKeeperContainerActiveRedisUsedMemory; + Map keeperPairUsedInfoMap = new HashMap<>(); Map>> ipPairMap = new HashMap<>(); @@ -109,9 +111,40 @@ public List getAllDcReadyToMigrationKeeperC @Override public List getAllKeeperContainerUsedInfoModelsList() { + List result = Collections.synchronizedList(new ArrayList<>()); + ParallelCommandChain commandChain = new ParallelCommandChain(MoreExecutors.directExecutor(), false); + config.getConsoleDomains().forEach((dc, domains) -> { + if (currentDc.equalsIgnoreCase(dc)) { + result.addAll(getAllDcKeeperContainerUsedInfoModelsList()); + } else { + KeeperContainerInfoGetCommand command = new KeeperContainerInfoGetCommand(domains, restTemplate); + command.future().addListener(commandFuture -> { + if (commandFuture.isSuccess() && commandFuture.get() != null) result.addAll(commandFuture.get()); + }); + commandChain.add(command); + } + }); + + try { + commandChain.execute().get(10, TimeUnit.SECONDS); + } catch (Throwable th) { + logger.warn("[getAllKeeperContainerUsedInfoModelsList] error:", th); + } + + return result; + } + + @Override + public List getAllDcKeeperContainerUsedInfoModelsList() { return allKeeperContainerUsedInfoModelsList; } + @Override + public int getMaxKeeperContainerFullSynchronizationTime() { + double keeperContainerIoRate = config.getKeeperContainerIoRate(); + return (int) (maxKeeperContainerActiveRedisUsedMemory/1024/1024/keeperContainerIoRate/60); + } + @Override public synchronized void updateKeeperContainerUsedInfo(int index, List keeperContainerUsedInfoModels) { if (keeperContainerUsedInfoModels != null && !keeperContainerUsedInfoModels.isEmpty()){ @@ -119,7 +152,7 @@ public synchronized void updateKeeperContainerUsedInfo(int index, List> iterator = checkerIndexes.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - if (currentTime.getTime() - entry.getKey().getTime() > config.getKeeperCheckerIntervalMilli()) { - logger.info("[removeExpireData] remove expire index:{} time:{}, expire time:{}", entry.getValue(), entry.getKey(), config.getKeeperCheckerIntervalMilli()); - allKeeperContainerUsedInfoModels.remove(entry.getValue()); - iterator.remove(); - } else break; + List expireIndex = new ArrayList<>(); + for (Map.Entry entry : checkerIndexes.entrySet()) { + if (currentTime.getTime() - entry.getValue().getTime() > config.getKeeperCheckerIntervalMilli()) { + expireIndex.add(entry.getKey()); + } + } + for (int index : expireIndex) { + logger.info("[removeExpireData] remove expire index:{} time:{}, expire time:{}", index, checkerIndexes.get(index), config.getKeeperCheckerIntervalMilli()); + allKeeperContainerUsedInfoModels.remove(index); + checkerIndexes.remove(index); } } private boolean checkDataIntegrity() { + logger.info("[analyzeKeeperContainerUsedInfo] current index {}", checkerIndexes); return checkerIndexes.size() == config.getClusterDividedParts(); } @@ -158,7 +194,9 @@ void analyzeKeeperContainerUsedInfo() { Map allDetailInfo = analyzeKeeperPair(); Map standardMap = analyzeKeeperContainerStandard(); Map keeperUsedInfoMap = getKeeperUsedInfoMap(); - logger.debug("[analyzeKeeperContainerUsedInfo] newKeeperContainerUsedInfoModels: {}", allKeeperContainerUsedInfoModelsList); + logger.info("[analyzeKeeperContainerUsedInfo] standardMap {}", standardMap); + logger.info("[analyzeKeeperContainerUsedInfo] keeperPairUsedInfoMap {}", keeperPairUsedInfoMap); + logger.info("[analyzeKeeperContainerUsedInfo] ipPairMap {}", ipPairMap); PriorityQueue minInputFlowKeeperContainers = new PriorityQueue<>(allKeeperContainerUsedInfoModelsList.size(), (keeper1, keeper2) -> (int)(keeper1.getActiveInputFlow() - keeper2.getActiveInputFlow())); PriorityQueue minPeerDataKeeperContainers = new PriorityQueue<>(allKeeperContainerUsedInfoModelsList.size(), @@ -171,6 +209,7 @@ void analyzeKeeperContainerUsedInfo() { }); List result = new ArrayList<>(); double keeperPairOverLoadFactor = config.getKeeperPairOverLoadFactor(); + logger.info("[analyzeKeeperContainerUsedInfo] config keeperPairOverLoadFactor:{}", keeperPairOverLoadFactor); for (KeeperContainerUsedInfoModel infoModel : allKeeperContainerUsedInfoModelsList) { KeeperContainerOverloadStandardModel standardModel = standardMap.get(infoModel.getKeeperIp()); List migrationKeeperDetails = getOverloadKeeperMigrationDetails(infoModel, @@ -197,8 +236,12 @@ void analyzeKeeperContainerUsedInfo() { private Map analyzeKeeperPair(){ keeperPairUsedInfoMap.clear(); ipPairMap.clear(); + maxKeeperContainerActiveRedisUsedMemory = 0; Map allDetailInfo = new HashMap<>(); for (KeeperContainerUsedInfoModel infoModel : allKeeperContainerUsedInfoModelsList) { + if (infoModel.getActiveRedisUsedMemory() > maxKeeperContainerActiveRedisUsedMemory) { + maxKeeperContainerActiveRedisUsedMemory = infoModel.getActiveRedisUsedMemory(); + } if (infoModel.getDetailInfo() != null) { allDetailInfo.putAll(infoModel.getDetailInfo()); } @@ -310,14 +353,13 @@ private List getOverloadKeeperMigrationDeta long overloadPeerData = src.getActiveRedisUsedMemory() - srcStandard.getPeerDataOverload(); KeeperContainerOverloadCause overloadCause = getKeeperContainerOverloadCause(overloadInputFlow, overloadPeerData); if (overloadCause == null) return null; - src.getOverLoadCause().add(overloadCause.name()); switch (overloadCause) { case PEER_DATA_OVERLOAD: - return getOverloadKeeperMigrationDetails(src, true, overloadPeerData, srcStandard, standardMap, keeperUsedInfoMap, allDetailInfo, minPeerDataKeeperContainers); + return getOverloadKeeperMigrationDetails(src, true, overloadPeerData, srcStandard, standardMap, keeperUsedInfoMap, allDetailInfo, minPeerDataKeeperContainers, overloadCause); case INPUT_FLOW_OVERLOAD: case BOTH: - return getOverloadKeeperMigrationDetails(src, false, overloadInputFlow, srcStandard, standardMap, keeperUsedInfoMap, allDetailInfo, minInputFlowKeeperContainers); + return getOverloadKeeperMigrationDetails(src, false, overloadInputFlow, srcStandard, standardMap, keeperUsedInfoMap, allDetailInfo, minInputFlowKeeperContainers, overloadCause); default: logger.warn("invalid keeper container overload cause {}", overloadCause); return null; @@ -330,7 +372,8 @@ private List getOverloadKeeperMigrationDeta Map standardMap, Map keeperUsedInfoMap, Map allDetailInfo, - PriorityQueue availableKeeperContainers) { + PriorityQueue availableKeeperContainers, + KeeperContainerOverloadCause overloadCause) { List> allDcClusterShards; if (isPeerDataOverload) { allDcClusterShards = src.getDetailInfo().entrySet().stream() @@ -356,7 +399,7 @@ private List getOverloadKeeperMigrationDeta if (keeperContainerFilterChain.doKeeperContainerFilter(backUpKeeperUsedInfoModel, backUpKeeperStandard) && keeperContainerFilterChain.doKeeperFilter(dcClusterShard, backUpKeeperUsedInfoModel, srcStandard, backUpKeeperStandard, keeperPairUsedInfoMap)) { if (switchActiveDetail == null) { - switchActiveDetail = new MigrationKeeperContainerDetailModel(src, null, 0, true, false, new ArrayList<>()); + switchActiveDetail = new MigrationKeeperContainerDetailModel(src, null, 0, true, false, overloadCause.name(), new ArrayList<>()); } switchActiveDetail.addReadyToMigrateShard(dcClusterShard.getKey()); if (target == null || !backUpKeeperUsedInfoModel.getKeeperIp().equals(target.getKeeperIp())) { @@ -388,7 +431,7 @@ private List getOverloadKeeperMigrationDeta if (switchActiveDetail != null) result.add(switchActiveDetail); return result; } - keeperContainerDetailModel = new MigrationKeeperContainerDetailModel(src, target, 0, false, false, new ArrayList<>()); + keeperContainerDetailModel = new MigrationKeeperContainerDetailModel(src, target, 0, false, false, overloadCause.name(), new ArrayList<>()); } if (!keeperContainerFilterChain.doKeeperFilter(dcClusterShard, target, srcStandard, standardMap.get(target.getKeeperIp()), keeperPairUsedInfoMap)) { target = null; @@ -465,15 +508,13 @@ private List getKeeperPairMigrationKeeperDe long overloadPeerData = longLongPair.getPeerData() - minStandardModel.getPeerDataOverload(); KeeperContainerOverloadCause overloadCause = getKeeperPairOverloadCause(overloadInputFlow, overloadPeerData); if (overloadCause == null) return null; - pairA.getOverLoadCause().add(overloadCause.name()); - pairB.getOverLoadCause().add(overloadCause.name()); switch (overloadCause) { case KEEPER_PAIR_PEER_DATA_OVERLOAD: - return getKeeperPairMigrationDetails(pairA, pairB, true, overloadPeerData, standardMap, minPeerDataKeeperContainers); + return getKeeperPairMigrationDetails(pairA, pairB, true, overloadPeerData, standardMap, minPeerDataKeeperContainers, overloadCause); case KEEPER_PAIR_INPUT_FLOW_OVERLOAD: case KEEPER_PAIR_BOTH: - return getKeeperPairMigrationDetails(pairA, pairB, false, overloadInputFlow, standardMap, minInputFlowKeeperContainers); + return getKeeperPairMigrationDetails(pairA, pairB, false, overloadInputFlow, standardMap, minInputFlowKeeperContainers, overloadCause); default: logger.warn("invalid keeper container overload cause {}", overloadCause); return null; @@ -486,7 +527,8 @@ private List getKeeperPairMigrationDetails( boolean isPeerDataOverload, long overloadData, Map standardMap, - PriorityQueue availableKeeperContainers){ + PriorityQueue availableKeeperContainers, + KeeperContainerOverloadCause overloadCause){ List result = new ArrayList<>(); if (keeperPairUsedInfoMap.get(new IPPair(pairA.getKeeperIp(), pairB.getKeeperIp())).getNumber() == 1) return result; List> allDcClusterShards; @@ -523,7 +565,7 @@ private List getKeeperPairMigrationDetails( usedTarget.add(target); target = availableKeeperContainers.poll(); } - keeperContainerDetailModel = new MigrationKeeperContainerDetailModel(srcKeeperContainer, target, 0, false, true, new ArrayList<>()); + keeperContainerDetailModel = new MigrationKeeperContainerDetailModel(srcKeeperContainer, target, 0, false, true, overloadCause.name(), new ArrayList<>()); } if (!keeperContainerFilterChain.doKeeperPairFilter(dcClusterShard, target, standardMap.get(srcKeeperIp), standardMap.get(target.getKeeperIp()), keeperPairUsedInfoMap)) { usedTarget.add(target); @@ -573,7 +615,7 @@ private KeeperContainerOverloadCause getKeeperPairOverloadCause(long overloadInp } @VisibleForTesting - Map getCheckerIndexes() { + Map getCheckerIndexes() { return checkerIndexes; } @@ -631,6 +673,40 @@ protected void doReset() { } } + class KeeperContainerInfoGetCommand extends AbstractCommand> { + + private String domain; + private RestOperations restTemplate; + + public KeeperContainerInfoGetCommand(String domain, RestOperations restTemplate) { + this.domain = domain; + this.restTemplate = restTemplate; + } + + @Override + public String getName() { + return "getKeeperContainerInfo"; + } + + @Override + protected void doExecute() throws Throwable { + try { + ResponseEntity> result = + restTemplate.exchange(domain + "/api/keepercontainer/info/all", HttpMethod.GET, null, + new ParameterizedTypeReference>() {}); + future().setSuccess(result.getBody()); + } catch (Throwable th) { + getLogger().error("get keeper container info:{} fail", domain, th); + future().setFailure(th); + } + } + + @Override + protected void doReset() { + + } + } + public static class IPPair { private String ip1; private String ip2; diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/MigrationKeeperContainerDetailModel.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/MigrationKeeperContainerDetailModel.java index 2b24f4851..9cbdb5e02 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/MigrationKeeperContainerDetailModel.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/MigrationKeeperContainerDetailModel.java @@ -21,6 +21,8 @@ public class MigrationKeeperContainerDetailModel implements Serializable { private boolean keeperPairOverload; + private String cause; + List migrateShards; public MigrationKeeperContainerDetailModel() { @@ -32,12 +34,14 @@ public MigrationKeeperContainerDetailModel(KeeperContainerUsedInfoModel srcKeepe int migrateKeeperCount, boolean switchActive, boolean keeperPairOverload, + String cause, List migrateShards) { this.srcKeeperContainer = srcKeeperContainer; this.targetKeeperContainer = targetKeeperContainer; this.migrateKeeperCount = migrateKeeperCount; this.switchActive = switchActive; this.keeperPairOverload = keeperPairOverload; + this.cause = cause; this.migrateShards = migrateShards; } @@ -103,6 +107,14 @@ public void setKeeperPairOverload(boolean keeperPairOverload) { this.keeperPairOverload = keeperPairOverload; } + public String getCause() { + return cause; + } + + public void setCause(String cause) { + this.cause = cause; + } + public void migrateKeeperCountIncrease() { this.migrateKeeperCount++; } diff --git a/redis/redis-console/src/main/resources/static/dist/bundle.js b/redis/redis-console/src/main/resources/static/dist/bundle.js index 3de39afcf..1d0cae002 100644 --- a/redis/redis-console/src/main/resources/static/dist/bundle.js +++ b/redis/redis-console/src/main/resources/static/dist/bundle.js @@ -9173,7 +9173,7 @@ eval("angular\n .module('index')\n .controller('KeepercontainerFormCtl', K \**********************************************************/ /***/ (() => { -eval("angular\n .module('index')\n .controller('KeepercontainerOverallCtl', KeepercontainerOverallCtl);\nfunction KeepercontainerOverallCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.originData = [];\n $scope.tableParams = new NgTableParams({}, {});\n KeeperContainerService.getAllKeepercontainerUsedInfo().then(function (response) {\n if (Array.isArray(response)) {\n response.forEach(function (keeperContainerInfo) {\n if (keeperContainerInfo.keeperIp === $stateParams.keepercontainerIp) {\n $scope.originData = Object.entries(keeperContainerInfo.detailInfo).map(function (item) {\n var key = JSON.parse(item[0]\n .replace(/'/g, '\\\"')\n .replace(/(\\w+)\\s*=/g, '\\\"$1\\\":')\n .replace(/\\w+\\{/g, '{'));\n return {\n key: key,\n value: item[1]\n };\n });\n }\n });\n console.log($scope.originData);\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.originData\n });\n }\n });\n $scope.getIp = function () {\n return $stateParams.keepercontainerIp;\n };\n $scope.getDc = function () {\n return $scope.originData[0].key.dcId;\n };\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerOverallCtl.ts?"); +eval("angular\n .module('index')\n .controller('KeepercontainerOverallCtl', KeepercontainerOverallCtl);\nfunction KeepercontainerOverallCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.originData = [];\n $scope.tableParams = new NgTableParams({}, {});\n KeeperContainerService.getAllKeepercontainerUsedInfo().then(function (response) {\n if (Array.isArray(response)) {\n response.forEach(function (keeperContainerInfo) {\n if (keeperContainerInfo.keeperIp === $stateParams.keepercontainerIp) {\n $scope.originData = Object.entries(keeperContainerInfo.detailInfo).map(function (item) {\n var key = item[0].split(':');\n return {\n key: {\n dcName: key[0],\n clusterName: key[1],\n shardName: key[2],\n active: key[3],\n port: key[4]\n },\n value: item[1]\n };\n });\n }\n });\n console.log($scope.originData);\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.originData\n });\n }\n });\n $scope.getIp = function () {\n return $stateParams.keepercontainerIp;\n };\n $scope.getDc = function () {\n return $scope.originData[0].key.dcName;\n };\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerOverallCtl.ts?"); /***/ }), @@ -9183,7 +9183,7 @@ eval("angular\n .module('index')\n .controller('KeepercontainerOverallCtl' \***********************************************************/ /***/ (() => { -eval("angular\n .module('index')\n .controller('KeepercontainerOverloadCtl', KeepercontainerOverloadCtl);\nKeepercontainerOverloadCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', 'KeeperContainerService',\n 'toastr', 'NgTableParams', '$interval'];\nfunction KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.overloadKeeperContainer = [];\n $scope.tableParams = new NgTableParams({}, {});\n $scope.migratingTableParams = new NgTableParams({}, {});\n $scope.selectAll = false;\n $scope.toggleAll = toggleAll;\n $scope.isChecked = isChecked;\n var OPERATE_TYPE = {\n DETAIL: 'detail',\n MIGRATING: 'migrating',\n STOPPED: 'stopped'\n };\n $scope.operateType = $stateParams.type;\n $scope.migratingKeeperContainers = [];\n $scope.scheduledWork;\n $scope.beginToMigrateOverloadKeeperContainers = beginToMigrateOverloadKeeperContainers;\n KeeperContainerService.getAllOverloadKeepercontainer()\n .then(function (result) {\n if (Array.isArray(result))\n $scope.overloadKeeperContainer = result;\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.overloadKeeperContainer\n });\n });\n function beginToMigrateOverloadKeeperContainers() {\n $scope.migratingKeeperContainers = $scope.overloadKeeperContainer.filter(function (keeperContainer) {\n return keeperContainer.selected;\n });\n $scope.tableParams = new NgTableParams({}, {});\n $scope.migratingTableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.migratingKeeperContainers\n });\n $scope.operateType = OPERATE_TYPE.MIGRATING;\n KeeperContainerService.beginToMigrateOverloadKeeperContainers.apply(KeeperContainerService, $scope.migratingKeeperContainers)\n .then(function (result) {\n if (result.message == 'success') {\n toastr.success(\"迁移成功\");\n }\n else {\n toastr.error(result.message, \"迁移失败\");\n }\n getOverloadKeeperContainerMigrationProcess();\n $interval.cancel($scope.scheduledWork);\n });\n }\n function getOverloadKeeperContainerMigrationProcess() {\n if ($scope.operateType == OPERATE_TYPE.MIGRATING) {\n KeeperContainerService.getOverloadKeeperContainerMigrationProcess()\n .then(function (result) {\n if (result == null)\n return;\n $scope.migratingKeeperContainers = result;\n $scope.migratingTableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.migratingKeeperContainers\n });\n });\n }\n }\n $scope.scheduledWork = $interval(getOverloadKeeperContainerMigrationProcess, 1000);\n function toggleAll() {\n $scope.selectAll = !$scope.selectAll;\n $scope.overloadKeeperContainer.forEach(function (keeperContainer) {\n keeperContainer.selected = !keeperContainer.selected;\n });\n }\n function isChecked() {\n return $scope.selectAll;\n }\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerOverloadCtl.ts?"); +eval("angular\n .module('index')\n .controller('KeepercontainerOverloadCtl', KeepercontainerOverloadCtl);\nKeepercontainerOverloadCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', 'KeeperContainerService',\n 'toastr', 'NgTableParams', '$interval'];\nfunction KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.overloadKeeperContainer = [];\n $scope.tableParams = new NgTableParams({}, {});\n $scope.migratingTableParams = new NgTableParams({}, {});\n $scope.selectAll = false;\n $scope.toggleAll = toggleAll;\n $scope.isChecked = isChecked;\n var OPERATE_TYPE = {\n DETAIL: 'detail',\n MIGRATING: 'migrating',\n STOPPED: 'stopped'\n };\n $scope.operateType = $stateParams.type;\n $scope.migratingKeeperContainers = [];\n $scope.scheduledWork;\n $scope.beginToMigrateOverloadKeeperContainers = beginToMigrateOverloadKeeperContainers;\n KeeperContainerService.getAllOverloadKeepercontainer()\n .then(function (result) {\n if (Array.isArray(result))\n $scope.overloadKeeperContainer = result;\n $scope.overloadKeeperContainer.forEach(function (container) {\n switch (container.cause) {\n case 'BOTH':\n container.cause = '数据量和流量超载';\n break;\n case 'PEER_DATA_OVERLOAD':\n container.cause = '数据量超载';\n break;\n case 'INPUT_FLOW_OVERLOAD':\n container.cause = '流量超载';\n break;\n case 'KEEPER_PAIR_BOTH':\n case 'KEEPER_PAIR_PEER_DATA_OVERLOAD':\n case 'KEEPER_PAIR_INPUT_FLOW_OVERLOAD':\n container.cause = 'keeper对超载';\n break;\n }\n if (!container.switchActive && !container.keeperPairOverload) {\n container.result = '迁移主keeper';\n }\n else if (container.switchActive && !container.keeperPairOverload) {\n container.result = '主备切换';\n }\n else if (!container.switchActive && container.keeperPairOverload) {\n container.result = '迁移备keeper';\n }\n });\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.overloadKeeperContainer\n });\n });\n function beginToMigrateOverloadKeeperContainers() {\n $scope.migratingKeeperContainers = $scope.overloadKeeperContainer.filter(function (keeperContainer) {\n return keeperContainer.selected;\n });\n $scope.tableParams = new NgTableParams({}, {});\n $scope.migratingTableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.migratingKeeperContainers\n });\n $scope.operateType = OPERATE_TYPE.MIGRATING;\n KeeperContainerService.beginToMigrateOverloadKeeperContainers.apply(KeeperContainerService, $scope.migratingKeeperContainers)\n .then(function (result) {\n if (result.message == 'success') {\n toastr.success(\"迁移成功\");\n }\n else {\n toastr.error(result.message, \"迁移失败\");\n }\n getOverloadKeeperContainerMigrationProcess();\n $interval.cancel($scope.scheduledWork);\n });\n }\n function getOverloadKeeperContainerMigrationProcess() {\n if ($scope.operateType == OPERATE_TYPE.MIGRATING) {\n KeeperContainerService.getOverloadKeeperContainerMigrationProcess()\n .then(function (result) {\n if (result == null)\n return;\n $scope.migratingKeeperContainers = result;\n $scope.migratingTableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.migratingKeeperContainers\n });\n });\n }\n }\n $scope.scheduledWork = $interval(getOverloadKeeperContainerMigrationProcess, 1000);\n function toggleAll() {\n $scope.selectAll = !$scope.selectAll;\n $scope.overloadKeeperContainer.forEach(function (keeperContainer) {\n keeperContainer.selected = !keeperContainer.selected;\n });\n }\n function isChecked() {\n return $scope.selectAll;\n }\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerOverloadCtl.ts?"); /***/ }), @@ -9193,7 +9193,7 @@ eval("angular\n .module('index')\n .controller('KeepercontainerOverloadCtl \***********************************************************/ /***/ (() => { -eval("angular\n .module('index')\n .controller('KeepercontainerUsedInfoCtl', KeepercontainerUsedInfoCtl);\nfunction KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.originData = [];\n $scope.tableParams = new NgTableParams({}, {});\n KeeperContainerService.getAllKeepercontainerUsedInfo().then(function (response) {\n if (Array.isArray(response)) {\n $scope.originData = response;\n KeeperContainerService.getAllInfos().then(function (anotherResponse) {\n if (Array.isArray(anotherResponse)) {\n Promise.all([response, anotherResponse]).then(function (responses) {\n var originData = responses[0];\n var anotherData = responses[1];\n originData.forEach(function (row) {\n var matchingData = anotherData.find(function (d) {\n return d.addr.host === row.keeperIp;\n });\n if (matchingData) {\n Object.assign(row, matchingData);\n }\n });\n });\n }\n });\n console.log($scope.originData);\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.originData\n });\n }\n });\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerUsedInfoCtl.ts?"); +eval("angular\n .module('index')\n .controller('KeepercontainerUsedInfoCtl', KeepercontainerUsedInfoCtl);\nfunction KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.originData = [];\n $scope.tableParams = new NgTableParams({}, {});\n KeeperContainerService.getAllKeepercontainerUsedInfo().then(function (response) {\n console.log(response);\n if (Array.isArray(response)) {\n $scope.originData = response;\n KeeperContainerService.getAllInfos().then(function (anotherResponse) {\n if (Array.isArray(anotherResponse)) {\n Promise.all([response, anotherResponse]).then(function (responses) {\n var originData = responses[0];\n var anotherData = responses[1];\n originData.forEach(function (row) {\n var matchingData = anotherData.find(function (d) {\n return d.addr.host === row.keeperIp;\n });\n if (matchingData) {\n Object.assign(row, matchingData);\n }\n });\n });\n }\n });\n console.log($scope.originData);\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10,\n }, {\n filterDelay: 100,\n counts: [10, 25, 50],\n dataset: $scope.originData\n });\n }\n KeeperContainerService.getKeepercontainerFullSynchronizationTime().then(function (response) {\n console.log(response);\n $scope.fullSynchronizationTime = response;\n });\n });\n $scope.getKeepercontainerFullSynchronizationTime = function () {\n return $scope.fullSynchronizationTime;\n };\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerUsedInfoCtl.ts?"); /***/ }), @@ -9433,7 +9433,7 @@ eval("angular\n .module('services')\n .service('HealthCheckService', Healt \****************************************************/ /***/ (() => { -eval("angular\n .module('services')\n .service('KeeperContainerService', ['$resource', '$q', function ($resource, $q) {\n var resource = $resource('', {}, {\n find_availablekeepers_by_dc: {\n method: 'POST',\n url: '/console/dcs/:dcName/availablekeepers',\n isArray: true\n },\n find_active_kcs_by_dc_and_cluster: {\n method: 'GET',\n url: '/console/dcs/:dcName/cluster/:clusterName/activekeepercontainers',\n isArray: true\n },\n find_keepercontainer_by_id: {\n method: 'GET',\n url: '/console/keepercontainer/:id',\n },\n find_available_keepers_by_dc_az_and_org: {\n method: 'GET',\n url: '/console/keepercontainers/dc/:dcName/az/:azName/org/:orgName',\n isArray: true\n },\n get_all_infos: {\n method: 'GET',\n url: '/console/keepercontainer/infos/all',\n isArray: true\n },\n get_all_organizations: {\n method: 'GET',\n url: '/console/organizations',\n isArray: true\n },\n add_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer'\n },\n update_keepercontainer: {\n method: 'PUT',\n url: '/console/keepercontainer'\n },\n get_all_overload_keepercontainer: {\n method: 'GET',\n url: '/console/keepercontainers/overload/all',\n isArray: true\n },\n get_all_overload_lasted_used_info: {\n method: 'GET',\n url: '/console/keepercontainer/overload/info/lasted',\n isArray: true\n },\n get_overload_keepercontainer_migration_process: {\n method: 'GET',\n url: '/console/keepercontainer/overload/migration/process',\n isArray: true\n },\n begin_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/begin'\n },\n stop_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/stop'\n }\n });\n function findActiveKeeperContainersByDc(dcName) {\n var d = $q.defer();\n resource.find_activekeepercontainers_by_dc({\n dcName: dcName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDc(dcName, shard) {\n var d = $q.defer();\n resource.find_availablekeepers_by_dc({\n dcName: dcName\n }, shard, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findKeepercontainerById(id) {\n var d = $q.defer();\n resource.find_keepercontainer_by_id({\n id: id\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDcAzAndOrg(dcName, azName, orgName) {\n var d = $q.defer();\n resource.find_available_keepers_by_dc_az_and_org({\n dcName: dcName,\n azName: azName,\n orgName: orgName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDcAndCluster(dcName, clusterName) {\n var d = $q.defer();\n resource.find_active_kcs_by_dc_and_cluster({\n dcName: dcName,\n clusterName: clusterName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllInfos() {\n var d = $q.defer();\n resource.get_all_infos({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllOrganizations() {\n var d = $q.defer();\n resource.get_all_organizations({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function addKeepercontainer(addr, dcName, orgName, azName, active) {\n var d = $q.defer();\n resource.add_keepercontainer({}, {\n addr: addr,\n dcName: dcName,\n orgName: orgName,\n azName: azName,\n active: active\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function updateKeepercontainer(addr, dcName, orgName, azName, active) {\n var d = $q.defer();\n resource.update_keepercontainer({}, {\n addr: addr,\n dcName: dcName,\n orgName: orgName,\n azName: azName,\n active: active\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllOverloadKeepercontainer() {\n var d = $q.defer();\n resource.get_all_overload_keepercontainer({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllKeepercontainerUsedInfo() {\n var d = $q.defer();\n resource.get_all_overload_lasted_used_info({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getOverloadKeeperContainerMigrationProcess() {\n var d = $q.defer();\n resource.get_overload_keepercontainer_migration_process({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function beginToMigrateOverloadKeeperContainers() {\n var d = $q.defer();\n resource.begin_to_migrate_overload_keepercontainer(Array.from(arguments), function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n return {\n findAvailableKeepersByDc: findAvailableKeepersByDc,\n findAvailableKeepersByDcAndCluster: findAvailableKeepersByDcAndCluster,\n findKeepercontainerById: findKeepercontainerById,\n findAvailableKeepersByDcAzAndOrg: findAvailableKeepersByDcAzAndOrg,\n getAllInfos: getAllInfos,\n getAllOrganizations: getAllOrganizations,\n addKeepercontainer: addKeepercontainer,\n updateKeepercontainer: updateKeepercontainer,\n getAllOverloadKeepercontainer: getAllOverloadKeepercontainer,\n getAllKeepercontainerUsedInfo: getAllKeepercontainerUsedInfo,\n getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n beginToMigrateOverloadKeeperContainers: beginToMigrateOverloadKeeperContainers,\n };\n }]);\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/services/KeeperContainerService.ts?"); +eval("angular\n .module('services')\n .service('KeeperContainerService', ['$resource', '$q', function ($resource, $q) {\n var resource = $resource('', {}, {\n find_availablekeepers_by_dc: {\n method: 'POST',\n url: '/console/dcs/:dcName/availablekeepers',\n isArray: true\n },\n find_active_kcs_by_dc_and_cluster: {\n method: 'GET',\n url: '/console/dcs/:dcName/cluster/:clusterName/activekeepercontainers',\n isArray: true\n },\n find_keepercontainer_by_id: {\n method: 'GET',\n url: '/console/keepercontainer/:id',\n },\n find_available_keepers_by_dc_az_and_org: {\n method: 'GET',\n url: '/console/keepercontainers/dc/:dcName/az/:azName/org/:orgName',\n isArray: true\n },\n get_all_infos: {\n method: 'GET',\n url: '/console/keepercontainer/infos/all',\n isArray: true\n },\n get_all_organizations: {\n method: 'GET',\n url: '/console/organizations',\n isArray: true\n },\n add_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer'\n },\n update_keepercontainer: {\n method: 'PUT',\n url: '/console/keepercontainer'\n },\n keepercontainer_fullSynchronizationTime: {\n method: 'GET',\n url: '/console/keepercontainer/max/fullSynchronizationTime'\n },\n get_all_overload_keepercontainer: {\n method: 'GET',\n url: '/console/keepercontainers/overload/all',\n isArray: true\n },\n get_all_overload_lasted_used_info: {\n method: 'GET',\n url: '/console/keepercontainer/overload/info/lasted',\n isArray: true\n },\n get_overload_keepercontainer_migration_process: {\n method: 'GET',\n url: '/console/keepercontainer/overload/migration/process',\n isArray: true\n },\n begin_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/begin'\n },\n stop_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/stop'\n }\n });\n function findActiveKeeperContainersByDc(dcName) {\n var d = $q.defer();\n resource.find_activekeepercontainers_by_dc({\n dcName: dcName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDc(dcName, shard) {\n var d = $q.defer();\n resource.find_availablekeepers_by_dc({\n dcName: dcName\n }, shard, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findKeepercontainerById(id) {\n var d = $q.defer();\n resource.find_keepercontainer_by_id({\n id: id\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDcAzAndOrg(dcName, azName, orgName) {\n var d = $q.defer();\n resource.find_available_keepers_by_dc_az_and_org({\n dcName: dcName,\n azName: azName,\n orgName: orgName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function findAvailableKeepersByDcAndCluster(dcName, clusterName) {\n var d = $q.defer();\n resource.find_active_kcs_by_dc_and_cluster({\n dcName: dcName,\n clusterName: clusterName\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllInfos() {\n var d = $q.defer();\n resource.get_all_infos({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllOrganizations() {\n var d = $q.defer();\n resource.get_all_organizations({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function addKeepercontainer(addr, dcName, orgName, azName, active) {\n var d = $q.defer();\n resource.add_keepercontainer({}, {\n addr: addr,\n dcName: dcName,\n orgName: orgName,\n azName: azName,\n active: active\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getKeepercontainerFullSynchronizationTime() {\n var d = $q.defer();\n resource.keepercontainer_fullSynchronizationTime({}, function (result) {\n var intValue = result;\n d.resolve(intValue);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function updateKeepercontainer(addr, dcName, orgName, azName, active) {\n var d = $q.defer();\n resource.update_keepercontainer({}, {\n addr: addr,\n dcName: dcName,\n orgName: orgName,\n azName: azName,\n active: active\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllOverloadKeepercontainer() {\n var d = $q.defer();\n resource.get_all_overload_keepercontainer({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getAllKeepercontainerUsedInfo() {\n var d = $q.defer();\n resource.get_all_overload_lasted_used_info({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function getOverloadKeeperContainerMigrationProcess() {\n var d = $q.defer();\n resource.get_overload_keepercontainer_migration_process({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function beginToMigrateOverloadKeeperContainers() {\n var d = $q.defer();\n resource.begin_to_migrate_overload_keepercontainer(Array.from(arguments), function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n return {\n findAvailableKeepersByDc: findAvailableKeepersByDc,\n findAvailableKeepersByDcAndCluster: findAvailableKeepersByDcAndCluster,\n findKeepercontainerById: findKeepercontainerById,\n findAvailableKeepersByDcAzAndOrg: findAvailableKeepersByDcAzAndOrg,\n getAllInfos: getAllInfos,\n getAllOrganizations: getAllOrganizations,\n addKeepercontainer: addKeepercontainer,\n updateKeepercontainer: updateKeepercontainer,\n getAllOverloadKeepercontainer: getAllOverloadKeepercontainer,\n getAllKeepercontainerUsedInfo: getAllKeepercontainerUsedInfo,\n getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n beginToMigrateOverloadKeeperContainers: beginToMigrateOverloadKeeperContainers,\n getKeepercontainerFullSynchronizationTime: getKeepercontainerFullSynchronizationTime\n };\n }]);\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/services/KeeperContainerService.ts?"); /***/ }), diff --git a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverallCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverallCtl.ts index 5498168a2..814925f08 100644 --- a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverallCtl.ts +++ b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverallCtl.ts @@ -12,13 +12,15 @@ function KeepercontainerOverallCtl($rootScope, $scope, $window, $stateParams, Ke response.forEach(function (keeperContainerInfo) { if (keeperContainerInfo.keeperIp === $stateParams.keepercontainerIp) { $scope.originData = Object.entries(keeperContainerInfo.detailInfo).map(function(item) { - var key = JSON.parse(item[0] - .replace(/'/g, '\"') - .replace(/(\w+)\s*=/g, '\"$1\":') - .replace(/\w+\{/g, '{') - ); + var key = item[0].split(':'); return { - key: key, + key: { + dcName: key[0], + clusterName: key[1], + shardName: key[2], + active: key[3], + port: key[4] + }, value: item[1] }; }); @@ -41,6 +43,6 @@ function KeepercontainerOverallCtl($rootScope, $scope, $window, $stateParams, Ke } $scope.getDc = function () { - return $scope.originData[0].key.dcId; + return $scope.originData[0].key.dcName; } } \ No newline at end of file diff --git a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverloadCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverloadCtl.ts index 97875a6e3..3177608f8 100644 --- a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverloadCtl.ts +++ b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverloadCtl.ts @@ -28,7 +28,31 @@ function KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, K KeeperContainerService.getAllOverloadKeepercontainer() .then(function (result) { if (Array.isArray(result)) $scope.overloadKeeperContainer = result; - + $scope.overloadKeeperContainer.forEach(function(container) { + switch(container.cause) { + case 'BOTH': + container.cause = '数据量和流量超载'; + break; + case 'PEER_DATA_OVERLOAD': + container.cause = '数据量超载'; + break; + case 'INPUT_FLOW_OVERLOAD': + container.cause = '流量超载'; + break; + case 'KEEPER_PAIR_BOTH': + case 'KEEPER_PAIR_PEER_DATA_OVERLOAD': + case 'KEEPER_PAIR_INPUT_FLOW_OVERLOAD': + container.cause = 'keeper对超载'; + break; + } + if (!container.switchActive && !container.keeperPairOverload) { + container.result = '迁移主keeper' + } else if (container.switchActive && !container.keeperPairOverload) { + container.result = '主备切换' + } else if (!container.switchActive && container.keeperPairOverload) { + container.result = '迁移备keeper' + } + }); $scope.tableParams = new NgTableParams({ page : 1, count : 10, diff --git a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerUsedInfoCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerUsedInfoCtl.ts index 055c87b24..96289e572 100644 --- a/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerUsedInfoCtl.ts +++ b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerUsedInfoCtl.ts @@ -8,6 +8,7 @@ function KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, K $scope.tableParams = new NgTableParams({}, {}); KeeperContainerService.getAllKeepercontainerUsedInfo().then(function (response) { + console.log(response); if (Array.isArray(response)) { $scope.originData = response; @@ -38,5 +39,14 @@ function KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, K dataset: $scope.originData }); } + KeeperContainerService.getKeepercontainerFullSynchronizationTime().then(function(response) { + console.log(response); + $scope.fullSynchronizationTime = response; + }) }) + + $scope.getKeepercontainerFullSynchronizationTime = function () { + return $scope.fullSynchronizationTime; + } + } \ No newline at end of file diff --git a/redis/redis-console/src/main/resources/static/scripts/services/KeeperContainerService.ts b/redis/redis-console/src/main/resources/static/scripts/services/KeeperContainerService.ts index 2da3e05e2..04d1134c5 100644 --- a/redis/redis-console/src/main/resources/static/scripts/services/KeeperContainerService.ts +++ b/redis/redis-console/src/main/resources/static/scripts/services/KeeperContainerService.ts @@ -40,6 +40,10 @@ angular method:'PUT', url:'/console/keepercontainer' }, + keepercontainer_fullSynchronizationTime:{ + method:'GET', + url:'/console/keepercontainer/max/fullSynchronizationTime' + }, get_all_overload_keepercontainer: { method: 'GET', url: '/console/keepercontainers/overload/all', @@ -172,6 +176,18 @@ angular return d.promise; } + function getKeepercontainerFullSynchronizationTime() { + var d = $q.defer(); + resource.keepercontainer_fullSynchronizationTime({}, + function(result) { + var intValue = result; + d.resolve(intValue); + }, function(result) { + d.reject(result); + }); + return d.promise; + } + function updateKeepercontainer(addr, dcName, orgName, azName, active) { var d = $q.defer(); resource.update_keepercontainer({}, { @@ -247,5 +263,6 @@ angular getAllKeepercontainerUsedInfo : getAllKeepercontainerUsedInfo, getOverloadKeeperContainerMigrationProcess : getOverloadKeeperContainerMigrationProcess, beginToMigrateOverloadKeeperContainers : beginToMigrateOverloadKeeperContainers, + getKeepercontainerFullSynchronizationTime : getKeepercontainerFullSynchronizationTime } }]); diff --git a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overall.html b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overall.html index ae73cf2ac..ce41fdd6b 100644 --- a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overall.html +++ b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overall.html @@ -15,10 +15,12 @@ - - - - + + + +
{{info.key.port}}{{info.key.clusterId}}{{info.key.shardId}}{{info.value.inputFlow}}{{info.value.peerData}} + {{ info.key.clusterName }} + {{info.key.shardName}}{{info.value.inputFlow/1024/8 | number:2}}{{info.value.peerData/1024/1024 | number:2}} {{info.key.active}}
diff --git a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overload.html b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overload.html index 0e52a6f64..4465b8487 100644 --- a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overload.html +++ b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_overload.html @@ -33,12 +33,14 @@

{{info.srcKeeperContainer.keeperIp}} {{info.srcKeeperContainer.dcName}} - {{info.srcKeeperContainer.totalRedisUsedMemory / 1024}} - {{info.srcKeeperContainer.totalInputFlow}} + {{info.srcKeeperContainer.activeRedisUsedMemory / 1024 | number:2}} + {{info.srcKeeperContainer.activeInputFlow}} {{info.migrateKeeperCount}} {{info.targetKeeperContainer.keeperIp}} - {{info.targetKeeperContainer.totalRedisUsedMemory / 1024}} - {{info.targetKeeperContainer.totalInputFlow}} + {{info.targetKeeperContainer.activeRedisUsedMemory / 1024 | number:2}} + {{info.targetKeeperContainer.activeInputFlow}} + {{info.cause}} + {{info.result}} diff --git a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_usedinfo.html b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_usedinfo.html index b9d54cfc7..1d8f9ee6e 100644 --- a/redis/redis-console/src/main/resources/static/views/index/keepercontainer_usedinfo.html +++ b/redis/redis-console/src/main/resources/static/views/index/keepercontainer_usedinfo.html @@ -3,7 +3,7 @@
- KeeperContainerUsedInfo + KeeperContainerUsedInfo 预计全量同步时间:{{getKeepercontainerFullSynchronizationTime()}} 分钟
@@ -19,14 +19,14 @@ {{info.orgName}} {{info.diskType}} {{info.azName}} - {{info.activeRedisUsedMemory | number:2}} - {{info.totalRedisUsedMemory-info.activeRedisUsedMemory | number:2}} - {{info.activeRedisUsedMemory/info.totalRedisUsedMemory*100 | number:2}} - {{info.activeRedisUsedMemory/info.redisUsedMemoryStandard*100 | number:2}} - {{info.activeInputFlow | number:2}} - {{info.totalInputFlow-info.activeInputFlow | number:2}} - {{info.activeInputFlow/info.totalInputFlow*100 | number:2}} - {{info.activeInputFlow/info.inputFlowStandard*100 | number:2}} + {{info.activeRedisUsedMemory/1024/1024 | number:2}} + {{(info.totalRedisUsedMemory-info.activeRedisUsedMemory)/1024/1024 | number:2}} + {{info.activeRedisUsedMemory/info.totalRedisUsedMemory*100 | number:2}}% + {{info.activeRedisUsedMemory/info.redisUsedMemoryStandard*100 | number:2}}% + {{info.activeInputFlow/1024/8 | number:2}} + {{(info.totalInputFlow-info.activeInputFlow)/1024/8 | number:2}} + {{info.activeInputFlow/info.totalInputFlow*100 | number:2}}% + {{info.activeInputFlow/info.inputFlowStandard*100 | number:2}}% {{info.activeKeeperCount}} {{info.totalKeeperCount-info.activeKeeperCount}} diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperUsedInfoAnalyzerTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperUsedInfoAnalyzerTest.java index 1a86f4f24..2e19328f5 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperUsedInfoAnalyzerTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperUsedInfoAnalyzerTest.java @@ -1,9 +1,7 @@ package com.ctrip.xpipe.redis.console.keeper.impl; import com.ctrip.xpipe.api.foundation.FoundationService; -import com.ctrip.xpipe.redis.checker.model.DcClusterShardActive; import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; -import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel.*; import com.ctrip.xpipe.redis.console.config.ConsoleConfig; import com.ctrip.xpipe.redis.console.config.impl.DefaultConsoleConfig; import com.ctrip.xpipe.redis.console.keeper.handler.KeeperContainerFilterChain; @@ -11,7 +9,6 @@ import com.ctrip.xpipe.redis.console.model.KeepercontainerTbl; import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel; import com.ctrip.xpipe.redis.console.service.KeeperContainerService; -import com.ctrip.xpipe.redis.console.service.impl.KeeperContainerServiceImpl; import com.google.common.collect.Maps; import org.junit.Assert; import org.junit.Before; @@ -26,7 +23,6 @@ import java.util.Map; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; /** * @author yu @@ -51,7 +47,7 @@ public class DefaultKeeperUsedInfoAnalyzerTest { public static final String DC = "jq"; public static final String IP1 = "1.1.1.1", IP2 = "2.2.2.2", IP3 = "3.3.3.3", IP4 = "4.4.4.4", IP5 = "5.5.5.5"; public static final String Cluster1 = "cluster1", Cluster2 = "cluster2", Cluster3 = "cluster3", Cluster4 = "cluster4", Cluster5 = "cluster5"; - public static final String Shard1 = "shard1", Shard2 = "shard2"; + public static final String Shard1 = "shard1", Shard2 = "shard2", Shard3 = "shard3"; @Before public void before() { @@ -61,9 +57,9 @@ public void before() { filterChain.setConfig(new DefaultConsoleConfig()); analyzer.setKeeperContainerFilterChain(filterChain); Mockito.when(config.getClusterDividedParts()).thenReturn(2); - Map standards = Maps.newHashMap(); List diskTypeEnums = new ArrayList<>(); diskTypeEnums.add(new KeeperContainerOverloadStandardModel.DiskTypesEnum(KeeperContainerOverloadStandardModel.DiskType.RAID0, 30, 20)); + Map standards = Maps.newHashMap(); standards.put(FoundationService.DEFAULT.getDataCenter(), new KeeperContainerOverloadStandardModel().setFlowOverload(20).setPeerDataOverload(20).setDiskTypes(diskTypeEnums)); Mockito.when(config.getKeeperContainerOverloadStandards()).thenReturn(standards); Mockito.when(config.getKeeperCheckerIntervalMilli()).thenReturn(expireTime); @@ -93,7 +89,7 @@ public void testAnalyzeOverloadStandardModel() { .createKeeper(Cluster1, Shard2, false, 4, 4); Mockito.when(keeperContainerService.find(Mockito.any())).thenReturn(new KeepercontainerTbl().setKeepercontainerDiskType(KeeperContainerOverloadStandardModel.DiskType.RAID0.getDesc())); analyzer.updateKeeperContainerUsedInfo(0, models); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); Map overloadStandardModelMap = analyzer.analyzeKeeperContainerStandard(); Assert.assertEquals(16, overloadStandardModelMap.get(IP1).getFlowOverload()); Assert.assertEquals(16, overloadStandardModelMap.get(IP2).getFlowOverload()); @@ -173,7 +169,7 @@ public void testGetAllDcReadyToMigrationKeeperContainersWithBoth() { .createKeeper(Cluster1, Shard1, false, 4, 4) .createKeeper(Cluster2, Shard2, false, 6, 6); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(2, allDcReadyToMigrationKeeperContainers.size()); @@ -212,7 +208,7 @@ public void testMultiSrcKeeperSingleTargetWithBoth() { createKeeperContainer(models, IP5, 0, 0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); @@ -251,7 +247,7 @@ public void testSingleSrcKeeperMultiTargetWithBoth() { .createKeeper(Cluster4, Shard1, false, 5, 5) .createKeeper(Cluster4, Shard2, true, 10, 10); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); @@ -279,7 +275,7 @@ public void testKeeperResourceLackWithBoth() { createKeeperContainer(models1, IP3, 0, 0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models1); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models1); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(1, allDcReadyToMigrationKeeperContainers.size()); @@ -318,7 +314,7 @@ public void testGetAllDcReadyToMigrationKeeperContainersWithPeerDataOverLoad() { .createKeeper(Cluster5, Shard2, true, 1, 2) .createKeeper(Cluster5, Shard1, false, 1, 2); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(2, allDcReadyToMigrationKeeperContainers.stream().filter(container -> !container.isKeeperPairOverload()).count()); @@ -349,7 +345,7 @@ public void testMultiSrcKeeperSingleTargetWithPeerDataOverLoad() { createKeeperContainer(models, IP3, 0, 0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); @@ -380,7 +376,7 @@ public void testSingleSrcKeeperMultiTargetWithPeerDataOverLoad() { createKeeperContainer(models, IP3,0,0); createKeeperContainer(models, IP4,0,0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); @@ -412,7 +408,7 @@ public void testKeeperResourceLackWithPeerDataOverLoad() { createKeeperContainer(models, IP3,0,0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(1, allDcReadyToMigrationKeeperContainers.size()); @@ -453,7 +449,7 @@ public void testGetAllDcReadyToMigrationKeeperContainersWithMixed() { .createKeeper(Cluster5, Shard2, true, 9, 9) .createKeeper(Cluster5, Shard1, false, 9, 9); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(2, allDcReadyToMigrationKeeperContainers.stream().filter(container -> !container.isKeeperPairOverload()).count()); @@ -486,7 +482,7 @@ public void testMultiSrcKeeperSingleTargetWithMixed() { createKeeperContainer(models, IP3, 0, 0); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); @@ -526,10 +522,44 @@ public void testMultiSrcMultiTargetWithFixed() { .createKeeper(Cluster5, Shard2, true, 1, 8) .createKeeper(Cluster5, Shard1, false, 8, 1); - analyzer.getAllKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); analyzer.analyzeKeeperContainerUsedInfo(); List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); Assert.assertEquals(2, allDcReadyToMigrationKeeperContainers.stream().filter(container -> !container.isKeeperPairOverload()).count()); } + + @Test + public void testSwitchActiveKeeper() { + filterChain.setConfig(config); + Map standards = Maps.newHashMap(); + standards.put(FoundationService.DEFAULT.getDataCenter(), new KeeperContainerOverloadStandardModel().setFlowOverload(100).setPeerDataOverload(100)); + Mockito.when(config.getKeeperContainerOverloadStandards()).thenReturn(standards); + List models = new ArrayList<>(); + createKeeperContainer(models, IP1, 81, 81) + .createKeeper(Cluster1, Shard1, true, 15, 15) + .createKeeper(Cluster1, Shard2, true, 15, 15) + .createKeeper(Cluster1, Shard3, true, 15, 15) + .createKeeper(Cluster2, Shard1, true, 16, 16) + .createKeeper(Cluster2, Shard2, true, 10, 10) + .createKeeper(Cluster2, Shard3, true, 10, 10); + + createKeeperContainer(models, IP2, 0, 0) + .createKeeper(Cluster2, Shard1, false, 16, 16); + + createKeeperContainer(models, IP3, 0, 0) + .createKeeper(Cluster1, Shard1, false, 15, 15) + .createKeeper(Cluster1, Shard2, false, 15, 15) + .createKeeper(Cluster1, Shard3, false, 15, 15) + .createKeeper(Cluster2, Shard2, false, 10, 10) + .createKeeper(Cluster2, Shard3, false, 10, 10); + + analyzer.getAllDcKeeperContainerUsedInfoModelsList().addAll(models); + analyzer.analyzeKeeperContainerUsedInfo(); + + List allDcReadyToMigrationKeeperContainers = analyzer.getAllDcReadyToMigrationKeeperContainers(); + Assert.assertEquals(1, allDcReadyToMigrationKeeperContainers.size()); + Assert.assertEquals(true, allDcReadyToMigrationKeeperContainers.get(0).isSwitchActive()); + + } } \ No newline at end of file diff --git a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java index f0fa41d8e..7dafa8838 100644 --- a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java +++ b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java @@ -1,5 +1,6 @@ package com.ctrip.xpipe.redis.core.protocal.cmd; +import com.ctrip.xpipe.utils.VisibleForTesting; import com.google.common.base.Function; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +27,7 @@ public class InfoResultExtractor { private static final String KEY_SWAP_USED_DB_SIZE = "swap_used_db_size"; private static final String KEY_USED_MEMORY ="used_memory"; private static final String KEY_MAX_MEMORY ="maxmemory"; + private static final String KEY_KEEPER_ROLE = "state"; protected static Logger logger = LoggerFactory.getLogger(InfoResultExtractor.class); @@ -111,7 +113,7 @@ public long getSyncPartialErr() { return extractAsLong(KEY_SYNC_PARTIAL_ERR); } - public float getKeeperInstantaneousInputKbps() { return extractAsFloat(KEY_INSTANTANEOUS_INPUT_KBPS);} + public Float getKeeperInstantaneousInputKbps() { return extractAsFloat(KEY_INSTANTANEOUS_INPUT_KBPS);} public long getUsedMemory() { return extractAsLong(KEY_USED_MEMORY);} @@ -119,6 +121,8 @@ public long getSyncPartialErr() { public Long getSwapUsedDbSize() { return extractAsLong(KEY_SWAP_USED_DB_SIZE);} + public boolean getKeeperRole() { return "ACTIVE".equals(extract(KEY_KEEPER_ROLE)); } + public long getMasterReplOffset() { Long result = extractAsLong(KEY_MASTER_REPL_OFFSET); return result == null ? 0L : result;