From 3b76c4a4ac6c4fc4d200019cb606ba03661a8a65 Mon Sep 17 00:00:00 2001 From: songyuyuyu <88360486+songyuyuyu@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:41:08 +0800 Subject: [PATCH] fix checker not report keeper result --- .../AbstractHealthCheckAction.java | 1 + .../keeper/info/RedisUsedMemoryCollector.java | 9 +- .../keeper/infoStats/KeeperFlowCollector.java | 5 +- ...erLeaderAwareHealthCheckActionFactory.java | 4 +- .../meta/DefaultDcMetaChangeManager.java | 4 +- .../impl/KeeperContainerInfoReporter.java | 14 ++- .../redis/checker/model/DcClusterShard.java | 21 ++-- .../checker/model/DcClusterShardPeer.java | 1 - .../DefaultCheckerConsoleService.java | 10 +- .../impl/KeeperContainerInfoReporterTest.java | 98 +++++++++++++++++++ .../redis/console/config/ConsoleConfig.java | 2 +- .../KeeperContainerOverloadController.java | 6 ++ .../api/checker/ConsoleCheckerController.java | 2 +- .../KeeperContainerInfoController.java | 2 +- .../consoleportal/RedisController.java | 3 +- .../KeeperContainerUsedInfoAnalyzer.java | 2 + ...efaultKeeperContainerUsedInfoAnalyzer.java | 23 ++++- .../KeeperContainerOverloadStandardModel.java | 20 ++-- .../MigrationKeeperContainerDetailModel.java | 11 +++ .../console/resources/AbstractMetaCache.java | 9 +- .../console/resources/DefaultMetaCache.java | 32 +++++- .../service/KeeperContainerService.java | 3 + .../impl/DefaultKeeperAdvancedService.java | 8 +- ...efaultKeeperContainerMigrationService.java | 9 +- .../impl/KeeperContainerServiceImpl.java | 15 +++ .../console/spring/CheckerContextConfig.java | 9 ++ .../src/main/resources/static/dist/bundle.js | 4 +- .../controllers/KeepercontainerOverloadCtl.ts | 81 ++++++++++----- .../services/KeeperContainerService.ts | 2 +- .../views/index/keepercontainer_overload.html | 72 +++++++++----- ...ltKeeperContainerUsedInfoAnalyzerTest.java | 7 +- .../core/console/ConsoleCheckerPath.java | 2 +- 32 files changed, 396 insertions(+), 95 deletions(-) create mode 100644 redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporterTest.java diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/AbstractHealthCheckAction.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/AbstractHealthCheckAction.java index 277e7fcda..205044ade 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/AbstractHealthCheckAction.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/AbstractHealthCheckAction.java @@ -51,6 +51,7 @@ public void doStart() { @Override public void doStop() { + logger.debug("[stopped][{}][{}], listener:{}, future:{}", getClass().getSimpleName(), instance.getCheckInfo(), listeners, future); if(future != null) { future.cancel(true); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/info/RedisUsedMemoryCollector.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/info/RedisUsedMemoryCollector.java index fd3ab670e..c1ed55146 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/info/RedisUsedMemoryCollector.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/info/RedisUsedMemoryCollector.java @@ -1,8 +1,7 @@ package com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.info; -import com.ctrip.xpipe.redis.checker.healthcheck.HealthCheckAction; -import com.ctrip.xpipe.redis.checker.healthcheck.KeeperSupport; -import com.ctrip.xpipe.redis.checker.healthcheck.RedisInstanceInfo; +import com.ctrip.xpipe.redis.checker.healthcheck.*; +import com.ctrip.xpipe.redis.checker.healthcheck.impl.DefaultRedisInstanceInfo; import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.core.protocal.cmd.InfoResultExtractor; import org.slf4j.Logger; @@ -34,7 +33,9 @@ public void onAction(RedisInfoActionContext context) { @Override public void stopWatch(HealthCheckAction action) { - + DefaultRedisInstanceInfo info = (DefaultRedisInstanceInfo) action.getActionInstance().getCheckInfo(); + logger.debug("[stopWatch] DcClusterShard: {}", new DcClusterShard(info.getDcId(), info.getClusterId(), info.getShardId())); + dcClusterShardUsedMemory.remove(new DcClusterShard(info.getDcId(), info.getClusterId(), info.getShardId())); } public ConcurrentMap getDcClusterShardUsedMemory() { 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 d385be6cf..027308d85 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 @@ -37,7 +37,10 @@ public void onAction(KeeperInfoStatsActionContext context) { @Override public void stopWatch(HealthCheckAction action) { - + KeeperInstanceInfo instanceInfo = (KeeperInstanceInfo) action.getActionInstance().getCheckInfo(); + logger.debug("stopWatch: {}", new DcClusterShard(instanceInfo.getDcId(), instanceInfo.getClusterId(), instanceInfo.getShardId())); + hostPort2InputFlow.get(instanceInfo.getHostPort().getHost()) + .remove(new DcClusterShard(instanceInfo.getDcId(), instanceInfo.getClusterId(), instanceInfo.getShardId())); } public ConcurrentMap> getHostPort2InputFlow() { diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/leader/AbstractKeeperLeaderAwareHealthCheckActionFactory.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/leader/AbstractKeeperLeaderAwareHealthCheckActionFactory.java index b53a9918b..b8eba1ca8 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/leader/AbstractKeeperLeaderAwareHealthCheckActionFactory.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/leader/AbstractKeeperLeaderAwareHealthCheckActionFactory.java @@ -24,8 +24,8 @@ protected List getAllInstances() { @Override protected void registerInstance(KeeperHealthCheckInstance instance) { ClusterType clusterType = instance.getCheckInfo().getClusterType(); - //TODO add hetero type - if (clusterType.equals(ClusterType.ONE_WAY) + + if ((clusterType.equals(ClusterType.ONE_WAY) || clusterType.equals(ClusterType.HETERO)) && AbstractKeeperLeaderAwareHealthCheckActionFactory.this instanceof KeeperSupport){ registerTo(instance); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/meta/DefaultDcMetaChangeManager.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/meta/DefaultDcMetaChangeManager.java index 3e6fa6a68..c77e74999 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/meta/DefaultDcMetaChangeManager.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/meta/DefaultDcMetaChangeManager.java @@ -90,10 +90,12 @@ public void compare(DcMeta future) { } if (currentDcId.equalsIgnoreCase(dcId)) { + DcMeta futureDcAllMeta = getCurrentDcMeta(dcId); KeeperContainerMetaComparator keeperContainerMetaComparator - = new KeeperContainerMetaComparator(current, future, currentDcAllMeta, getCurrentDcMeta(dcId)); + = new KeeperContainerMetaComparator(current, future, currentDcAllMeta, futureDcAllMeta); keeperContainerMetaComparator.compare(); keeperContainerMetaComparator.accept(new KeeperContainerMetaComparatorVisitor()); + currentDcAllMeta = futureDcAllMeta; } comparator.accept(this); 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 8aefaef34..7f58760a1 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 @@ -9,6 +9,7 @@ import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; import com.ctrip.xpipe.tuple.Pair; +import com.ctrip.xpipe.utils.VisibleForTesting; import com.ctrip.xpipe.utils.XpipeThreadFactory; import com.ctrip.xpipe.utils.job.DynamicDelayPeriodTask; import org.slf4j.Logger; @@ -43,10 +44,11 @@ public class KeeperContainerInfoReporter implements GroupCheckerLeaderAware { public KeeperContainerInfoReporter(RedisUsedMemoryCollector redisUsedMemoryCollector, CheckerConsoleService - checkerConsoleService, KeeperFlowCollector keeperFlowCollector) { + checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config) { this.redisUsedMemoryCollector = redisUsedMemoryCollector; this.keeperFlowCollector = keeperFlowCollector; this.checkerConsoleService = checkerConsoleService; + this.config = config; } @PostConstruct @@ -87,7 +89,8 @@ public void notLeader() { } } - private void reportKeeperContainerInfo() { + @VisibleForTesting + void reportKeeperContainerInfo() { try { logger.debug("[reportKeeperContainerInfo] start"); Map> hostPort2InputFlow = keeperFlowCollector.getHostPort2InputFlow(); @@ -103,14 +106,19 @@ private void reportKeeperContainerInfo() { for (Map.Entry entry : inputFlowMap.entrySet()) { totalInputFlow += entry.getValue(); Long redisUsedMemory = dcClusterShardUsedMemory.get(entry.getKey()); + if (redisUsedMemory == null) { + logger.warn("[reportKeeperContainerInfo] redisUsedMemory is null, dcClusterShard: {}", entry.getKey()); + redisUsedMemory = 0L; + } totalRedisUsedMemory += redisUsedMemory; detailInfo.put(entry.getKey(), new Pair<>(entry.getValue(), redisUsedMemory)); } model.setDetailInfo(detailInfo).setTotalInputFlow(totalInputFlow).setTotalRedisUsedMemory(totalRedisUsedMemory); + result.add(model); }); - + logger.debug("[reportKeeperContainerInfo] result: {}", result); checkerConsoleService.reportKeeperContainerInfo(config.getConsoleAddress(), result, config.getClustersPartIndex()); } catch (Throwable th) { logger.info("[reportKeeperContainerInfo] fail", th); diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShard.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShard.java index 3c353adfb..0873e1de8 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShard.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShard.java @@ -1,8 +1,11 @@ package com.ctrip.xpipe.redis.checker.model; +import java.io.Serializable; import java.util.Objects; -public class DcClusterShard { +public class DcClusterShard implements Serializable { + + protected static final String SPLITTER = ":"; protected String dcId; @@ -20,6 +23,15 @@ public DcClusterShard(String dcId, String clusterId, String shardId) { this.shardId = shardId; } + public DcClusterShard(String info) { + String[] split = info.split(SPLITTER); + if (split.length >= 3) { + this.dcId = split[0]; + this.clusterId = split[1]; + this.shardId = split[2]; + } + } + public DcClusterShard setDcId(String dcId) { this.dcId = dcId; return this; @@ -59,16 +71,11 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(dcId, clusterId, shardId); } @Override public String toString() { - return "DcClusterShard{" + - "dcId='" + dcId + '\'' + - ", clusterId='" + clusterId + '\'' + - ", shardId='" + shardId + '\'' + - '}'; + return getDcId() + SPLITTER + getClusterId() + SPLITTER + getShardId(); } } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardPeer.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardPeer.java index 15dce4069..980fbd93c 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardPeer.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardPeer.java @@ -4,7 +4,6 @@ import java.util.Objects; public final class DcClusterShardPeer extends DcClusterShard implements Serializable { - private static final String SPLITTER = ":"; private String peerDcId; diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleService.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleService.java index 6766ef958..d852df67b 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleService.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleService.java @@ -96,9 +96,13 @@ public void report(String console, HealthCheckResult result) { @Override public void reportKeeperContainerInfo(String console, List keeperContainerUsedInfoModels, int index) { - UriComponents comp = UriComponentsBuilder.fromHttpUrl(console + ConsoleCheckerPath.PATH_PUT_KEEPER_CONTAINER_INFO_RESULT) - .buildAndExpand(index); - restTemplate.put(comp.toString(), keeperContainerUsedInfoModels); + try { + restTemplate.postForEntity(console + ConsoleCheckerPath.PATH_POST_KEEPER_CONTAINER_INFO_RESULT, + keeperContainerUsedInfoModels, RetMessage.class, index); + + } catch (Throwable th) { + logger.error("report keeper used info fail : {}", index, th); + } } @VisibleForTesting diff --git a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporterTest.java b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporterTest.java new file mode 100644 index 000000000..af984adab --- /dev/null +++ b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporterTest.java @@ -0,0 +1,98 @@ +package com.ctrip.xpipe.redis.checker.impl; + +import com.ctrip.xpipe.redis.checker.CheckerConsoleService; +import com.ctrip.xpipe.redis.checker.config.CheckerConfig; +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.model.DcClusterShard; +import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; +import com.google.common.collect.Maps; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentMap; + +/** + * @author yu + *

+ * 2023/10/18 + */ +@RunWith(org.mockito.junit.MockitoJUnitRunner.class) +public class KeeperContainerInfoReporterTest { + + @InjectMocks + KeeperContainerInfoReporter keeperContainerInfoReporter; + + @Mock + RedisUsedMemoryCollector redisUsedMemoryCollector; + + @Mock + KeeperFlowCollector keeperFlowCollector; + + @Mock + CheckerConsoleService checkerConsoleService; + + @Mock + CheckerConfig config; + + @Captor + ArgumentCaptor> resultCaptor; + + @Before + public void befor() { + DcClusterShard dcClusterShard1 = new DcClusterShard("jq", "cluster1", "shard1"); + DcClusterShard dcClusterShard2 = new DcClusterShard("jq", "cluster1", "shard2"); + DcClusterShard dcClusterShard3 = new DcClusterShard("jq", "cluster2", "shard1"); + DcClusterShard dcClusterShard4 = new DcClusterShard("jq", "cluster2", "shard2"); + DcClusterShard dcClusterShard5 = new DcClusterShard("jq", "cluster3", "shard1"); + DcClusterShard dcClusterShard6 = new DcClusterShard("jq", "cluster3", "shard2"); + DcClusterShard dcClusterShard7 = new DcClusterShard("jq", "cluster3", "shard3"); + + ConcurrentMap> keeperFlowMap = Maps.newConcurrentMap(); + Map map1 = new HashMap<>(); + map1.put(dcClusterShard1, 2L); + map1.put(dcClusterShard4, 2L); + map1.put(dcClusterShard5, 2L); + keeperFlowMap.put("127.0.0.1", map1); + + Map map2 = new HashMap<>(); + map2.put(dcClusterShard2, 2L); + map2.put(dcClusterShard6, 2L); + keeperFlowMap.put("127.0.0.2", map2); + + Map map3 = new HashMap<>(); + map3.put(dcClusterShard3, 2L); + map3.put(dcClusterShard7, 2L); + keeperFlowMap.put("127.0.0.3", map3); + + Mockito.when(keeperFlowCollector.getHostPort2InputFlow()).thenReturn(keeperFlowMap); + + ConcurrentMap redisUsedMemoryMap = Maps.newConcurrentMap(); + redisUsedMemoryMap.put(dcClusterShard1, 1L); + redisUsedMemoryMap.put(dcClusterShard2, 2L); + redisUsedMemoryMap.put(dcClusterShard3, 3L); + redisUsedMemoryMap.put(dcClusterShard4, 4L); + redisUsedMemoryMap.put(dcClusterShard6, 6L); + redisUsedMemoryMap.put(dcClusterShard7, 7L); + + Mockito.when(redisUsedMemoryCollector.getDcClusterShardUsedMemory()).thenReturn(redisUsedMemoryMap); + Mockito.when(config.getConsoleAddress()).thenReturn("127.0.0.1"); + Mockito.when(config.getClustersPartIndex()).thenReturn(0); + + } + + @Test + public void testReportKeeperContainerInfo() { + keeperContainerInfoReporter.reportKeeperContainerInfo(); + Mockito.verify(checkerConsoleService, Mockito.times(1)) + .reportKeeperContainerInfo(Mockito.anyString(), resultCaptor.capture(), Mockito.anyInt()); + + Assert.assertEquals(3, resultCaptor.getValue().size()); + } +} 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 00b37702a..dc78c335e 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 @@ -179,7 +179,7 @@ public interface ConsoleConfig extends CoreConfig, CheckerConfig, AlertConfig { long getMigrationResultReportIntervalMill(); - boolean isAutoMigrateOverloadKeeperContainerOpen(); + boolean isAutoMigrateOverloadKeeperContainerOpen(); long getAutoMigrateOverloadKeeperContainerIntervalMilli(); 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/KeeperContainerOverloadController.java index 00e480dc7..de78edb71 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/KeeperContainerOverloadController.java @@ -1,6 +1,7 @@ package com.ctrip.xpipe.redis.console.controller.api; +import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; import com.ctrip.xpipe.redis.console.controller.AbstractConsoleController; import com.ctrip.xpipe.redis.console.keeper.KeeperContainerUsedInfoAnalyzer; import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel; @@ -22,4 +23,9 @@ public class KeeperContainerOverloadController extends AbstractConsoleController public List getAllReadyToMigrateKeeperContainers() { return analyzer.getAllDcReadyToMigrationKeeperContainers(); } + + @RequestMapping(value = "/keepercontainer/overload/info/current", method = RequestMethod.GET) + public List getCurrentReadyToMigrateKeeperContainers() { + return analyzer.getAllKeeperContainerUsedInfoModels(); + } } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/checker/ConsoleCheckerController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/checker/ConsoleCheckerController.java index 848611e46..2bf519878 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/checker/ConsoleCheckerController.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/checker/ConsoleCheckerController.java @@ -126,7 +126,7 @@ public void reportHealthCheckResult(HttpServletRequest request, @RequestBody Hea if (null != checkResult.getHeteroShardsDelay()) delayService.updateHeteroShardsDelays(checkResult.getHeteroShardsDelay()); } - @PutMapping(ConsoleCheckerPath.PATH_PUT_KEEPER_CONTAINER_INFO_RESULT) + @PostMapping(ConsoleCheckerPath.PATH_POST_KEEPER_CONTAINER_INFO_RESULT) public void reportHealthCheckResult(HttpServletRequest request, @PathVariable int index, @RequestBody List keeperContainerUsedInfoModels) { logger.debug("[reportHealthCheckResult][{}] {}", request.getRemoteAddr(), keeperContainerUsedInfoModels); if (keeperContainerUsedInfoModels == null || keeperContainerUsedInfoModels.isEmpty()) return; 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 bc79897c0..69e92bfa6 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 @@ -96,7 +96,7 @@ public RetMessage beginToMigrateOverloadKeeperContainers(@RequestBody List= model.getMaxMigrationKeeperNum()) { 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 526afcff1..6acb7a68c 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 @@ -12,4 +12,6 @@ public interface KeeperContainerUsedInfoAnalyzer { List getAllReadyToMigrationKeeperContainers(); List getAllDcReadyToMigrationKeeperContainers(); + + List getAllKeeperContainerUsedInfoModels(); } 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 d9ad2af39..d566308b6 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 @@ -37,6 +37,10 @@ public class DefaultKeeperContainerUsedInfoAnalyzer extends AbstractService impl private static final Logger logger = LoggerFactory.getLogger(DefaultKeeperContainerUsedInfoAnalyzer.class); + private static final int DEFAULT_PEER_DATA_OVERLOAD = 474 * 1024 * 1024 * 1024; + + private static final int DEFAULT_KEEPER_FLOW_OVERLOAD = 270 * 1024; + @Autowired private ConsoleConfig config; @@ -107,6 +111,7 @@ protected void doRun() throws Exception { @VisibleForTesting void analyzeKeeperContainerUsedInfo(List newKeeperContainerUsedInfoModels) { + logger.debug("[analyzeKeeperContainerUsedInfo] newKeeperContainerUsedInfoModels: {}", newKeeperContainerUsedInfoModels); PriorityQueue minInputFlowKeeperContainers = new PriorityQueue<>(newKeeperContainerUsedInfoModels.size(), (keeper1, keeper2) -> (int)(keeper1.getTotalInputFlow() - keeper2.getTotalInputFlow())); PriorityQueue minPeerDataKeeperContainers = new PriorityQueue<>(newKeeperContainerUsedInfoModels.size(), @@ -117,6 +122,13 @@ void analyzeKeeperContainerUsedInfo(List newKeeper }); KeeperContainerOverloadStandardModel keeperContainerOverloadStandard = config.getKeeperContainerOverloadStandards().get(currentDc); + if (keeperContainerOverloadStandard == null) { + logger.warn("[analyzeKeeperContainerUsedInfo] keeperContainerOverloadStandard from dc {} is null," + + " use default config", currentDc); + keeperContainerOverloadStandard = new KeeperContainerOverloadStandardModel() + .setFlowOverload(DEFAULT_KEEPER_FLOW_OVERLOAD).setPeerDataOverload(DEFAULT_PEER_DATA_OVERLOAD); + } + logger.debug("[analyzeKeeperContainerUsedInfo] keeperContainerOverloadStandard: {}", keeperContainerOverloadStandard); List result = new ArrayList<>(); for (KeeperContainerUsedInfoModel keeperContainerUsedInfoModel : newKeeperContainerUsedInfoModels) { long overloadInputFlow = keeperContainerUsedInfoModel.getTotalInputFlow() - keeperContainerOverloadStandard.getFlowOverload(); @@ -166,11 +178,14 @@ private List getMigrationKeeperDetails(Keep KeeperContainerUsedInfoModel target = null; MigrationKeeperContainerDetailModel keeperContainerDetailModel = null; + logger.debug("[analyzeKeeperContainerUsedInfo] src: {}, overlaodCause:{}, overloadData:{}, availableKeeperContainers:{} ", + src, isPeerDataOverload, overloadData, availableKeeperContainers); + for (Map.Entry> dcClusterShard : allDcClusterShards) { if (target == null ) { target = availableKeeperContainers.poll(); if (target == null) { - logger.warn("[getMigrationKeeperDetails] no available keeper containers {} for overload keeper container {}", + logger.warn("[analyzeKeeperContainerUsedInfo] no available keeper containers {} for overload keeper container {}", availableKeeperContainers, src); CatEventMonitor.DEFAULT.logEvent(KEEPER_RESOURCE_LACK, currentDc); return result; @@ -188,7 +203,7 @@ private List getMigrationKeeperDetails(Keep long targetPeerData = target.getTotalRedisUsedMemory() + dcClusterShard.getValue().getValue(); if (targetInputFlow > keeperContainerOverloadStandard.getFlowOverload() || targetPeerData > keeperContainerOverloadStandard.getPeerDataOverload()) { - logger.debug("[getMigrationKeeperDetails] target keeper container {} can not add shard {}", + logger.debug("[analyzeKeeperContainerUsedInfo] target keeper container {} can not add shard {}", target, dcClusterShard); if (keeperContainerDetailModel.getMigrateKeeperCount() != 0) result.add(keeperContainerDetailModel); target = null; @@ -231,8 +246,8 @@ Set getCheckerIndexes() { return checkerIndexes; } - @VisibleForTesting - List getAllKeeperContainerUsedInfoModels() { + @Override + public List getAllKeeperContainerUsedInfoModels() { return allKeeperContainerUsedInfoModels; } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/KeeperContainerOverloadStandardModel.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/KeeperContainerOverloadStandardModel.java index d2f92cd12..4376ba641 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/KeeperContainerOverloadStandardModel.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/model/KeeperContainerOverloadStandardModel.java @@ -2,25 +2,33 @@ public class KeeperContainerOverloadStandardModel { - private int peerDataOverload; + private long peerDataOverload; - private int flowOverload; + private long flowOverload; - public int getPeerDataOverload() { + public long getPeerDataOverload() { return peerDataOverload; } - public KeeperContainerOverloadStandardModel setPeerDataOverload(int peerDataOverload) { + public KeeperContainerOverloadStandardModel setPeerDataOverload(long peerDataOverload) { this.peerDataOverload = peerDataOverload; return this; } - public int getFlowOverload() { + public long getFlowOverload() { return flowOverload; } - public KeeperContainerOverloadStandardModel setFlowOverload(int flowOverload) { + public KeeperContainerOverloadStandardModel setFlowOverload(long flowOverload) { this.flowOverload = flowOverload; return this; } + + @Override + public String toString() { + return "KeeperContainerOverloadStandardModel{" + + "peerDataOverload=" + peerDataOverload + + ", flowOverload=" + flowOverload + + '}'; + } } 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 31fc5e4c0..98fa4cbcc 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 @@ -95,4 +95,15 @@ public int getMigrateKeeperCompleteCount() { public int hashCode() { return Objects.hash(srcKeeperContainer, targetKeeperContainer); } + + @Override + public String toString() { + return "MigrationKeeperContainerDetailModel{" + + "srcKeeperContainer=" + srcKeeperContainer + + ", targetKeeperContainer=" + targetKeeperContainer + + ", migrateKeeperCount=" + migrateKeeperCount + + ", migrateKeeperCompleteCount=" + migrateKeeperCompleteCount + + ", migrateShards=" + migrateShards + + '}'; + } } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/AbstractMetaCache.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/AbstractMetaCache.java index 86fcabe89..0528f19bb 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/AbstractMetaCache.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/AbstractMetaCache.java @@ -157,7 +157,7 @@ private int dcMasterCount(ClusterMeta dcCluster) { return masterCount.get(); } - protected XpipeMeta createDividedMeta(XpipeMeta full, Set reqClusters) { + protected XpipeMeta createDividedMeta(XpipeMeta full, Set reqClusters, Set requestKeeperContainers) { XpipeMeta part = new XpipeMeta(); for (DcMeta dcMeta: full.getDcs().values()) { DcMeta partDcMeta = new DcMeta(dcMeta.getId()).setLastModifiedTime(dcMeta.getLastModifiedTime()).setZone(dcMeta.getZone()); @@ -193,7 +193,12 @@ protected XpipeMeta createDividedMeta(XpipeMeta full, Set reqClusters) { partDcMeta.addCluster(partClusterMeta); } dcMeta.getSentinels().values().forEach(partDcMeta::addSentinel); - dcMeta.getKeeperContainers().forEach(partDcMeta::addKeeperContainer); + + dcMeta.getKeeperContainers().forEach(keeperContainerMeta -> { + if (requestKeeperContainers.contains(keeperContainerMeta.getId())) { + partDcMeta.addKeeperContainer(keeperContainerMeta); + } + }); dcMeta.getRoutes().forEach(partDcMeta::addRoute); dcMeta.getMetaServers().forEach(partDcMeta::addMetaServer); } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/DefaultMetaCache.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/DefaultMetaCache.java index ce6cba402..6125eb6d1 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/DefaultMetaCache.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/resources/DefaultMetaCache.java @@ -8,6 +8,7 @@ import com.ctrip.xpipe.redis.console.exception.DataNotFoundException; import com.ctrip.xpipe.redis.console.model.RedisCheckRuleTbl; import com.ctrip.xpipe.redis.console.service.ClusterService; +import com.ctrip.xpipe.redis.console.service.KeeperContainerService; import com.ctrip.xpipe.redis.console.service.RedisCheckRuleService; import com.ctrip.xpipe.redis.console.service.meta.DcMetaService; import com.ctrip.xpipe.redis.core.entity.DcMeta; @@ -48,6 +49,9 @@ public class DefaultMetaCache extends AbstractMetaCache implements MetaCache, Co @Autowired private ClusterService clusterService; + @Autowired + private KeeperContainerService keeperContainerService; + @Autowired private ConsoleConfig consoleConfig; @@ -58,6 +62,8 @@ public class DefaultMetaCache extends AbstractMetaCache implements MetaCache, Co private List> clusterParts; + private List> keeperContainerParts; + private ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1); private ScheduledFuture future; @@ -138,6 +144,7 @@ public void go() throws Exception { synchronized (this) { refreshClusterParts(); + refreshKeeperContainerParts(); XpipeMeta xpipeMeta = createXpipeMeta(dcMetas, redisCheckRuleMetas); refreshMeta(xpipeMeta); } @@ -167,6 +174,24 @@ private void refreshClusterParts() { } } + private void refreshKeeperContainerParts() { + try { + int parts = Math.max(1, consoleConfig.getClusterDividedParts()); + logger.debug("[refreshKeeperContainerParts] start parts {}", parts); + + List> newKeeperContainerParts = keeperContainerService.divideKeeperContainers(parts); + if (newKeeperContainerParts.size() < parts) { + logger.info("[refreshKeeperContainerParts] skip for parts miss, expect {}, actual {}", + parts, newKeeperContainerParts.size()); + return; + } + + this.keeperContainerParts = newKeeperContainerParts; + } catch (Throwable th) { + logger.warn("[refreshKeeperContainerParts] fail", th); + } + } + @Override public Map chooseDefaultRoutes(String clusterName, String srcDc, List dstDcs, int orgId) { return chooseRoutes(clusterName, srcDc, dstDcs, orgId, false); @@ -198,12 +223,15 @@ private RouteChooseStrategy getRouteChooseStrategy(RouteChooseStrategyFactory.Ro @Override public synchronized XpipeMeta getDividedXpipeMeta(int partIndex) { if (null == meta || null == clusterParts) throw new DataNotFoundException("data not ready"); - if (partIndex >= clusterParts.size()) throw new DataNotFoundException("no part " + partIndex); + if (partIndex >= clusterParts.size() || partIndex >= keeperContainerParts.size()) + throw new DataNotFoundException("no part " + partIndex); XpipeMeta xpipeMeta = getXpipeMeta(); Set requestClusters = clusterParts.get(partIndex); + Set requestKeeperContainers = keeperContainerParts.get(partIndex); + - return createDividedMeta(xpipeMeta, requestClusters); + return createDividedMeta(xpipeMeta, requestClusters, requestKeeperContainers); } @VisibleForTesting diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/KeeperContainerService.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/KeeperContainerService.java index 8a58f7c0a..2194cb5aa 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/KeeperContainerService.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/KeeperContainerService.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; +import java.util.Set; public interface KeeperContainerService { @@ -19,6 +20,8 @@ public interface KeeperContainerService { List findBestKeeperContainersByDcCluster(String dcName, String clusterName); List getKeeperContainerByAz(Long azId); + List> divideKeeperContainers(int partsCount); + List findAllInfos(); KeeperContainerInfoModel findKeeperContainerInfoModelById(long id); List findAvailableKeeperContainerInfoModelsByDcAzAndOrg(String dcName, String azName, String orgName); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperAdvancedService.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperAdvancedService.java index 540d9864d..2bd95ca4c 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperAdvancedService.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperAdvancedService.java @@ -73,6 +73,7 @@ public List findBestKeepers(String dcName, int beginPort, BiPre @Override public List getNewKeepers(String dcName, String clusterName, ShardModel shardModel, String srcKeeperContainerIp, String targetKeeperContainerIp) { List newKeepers = new ArrayList<>(); + logger.debug("[migrateKeepers] origin keepers {} from cluster:{}, dc:{}, shard:{}",shardModel.getKeepers(), clusterName, dcName, shardModel.getShardTbl().getShardName()); for (RedisTbl keeper : shardModel.getKeepers()) { if (!ObjectUtils.equals(keeper.getRedisIp(), srcKeeperContainerIp)) { newKeepers.add(keeper); @@ -84,14 +85,17 @@ public List getNewKeepers(String dcName, String clusterName, ShardMode } if (newKeepers.size() < 1) { - logger.info("[migrateKeepers] unexpected keepers {} from cluster:{}, dc:{}, shard:{}", + logger.warn("[migrateKeepers] unexpected keepers {} from cluster:{}, dc:{}, shard:{}", newKeepers, clusterName, dcName, shardModel.getShardTbl().getShardName()); return newKeepers; } long alreadyUsedAzId = keeperContainerService.find(newKeepers.get(0).getKeepercontainerId()).getAzId(); List bestKeepers = findBestKeepers(clusterName, dcName, targetKeeperContainerIp); + logger.debug("[migrateKeepers] best keepers {} from cluster:{}, dc:{}, shard:{}, targetKeeperContainerIp:{}, srcKeeperContainerIp:{}", + bestKeepers, clusterName, dcName, shardModel.getShardTbl().getShardName(), targetKeeperContainerIp, srcKeeperContainerIp); for (KeeperBasicInfo keeperSelected : bestKeepers) { + logger.debug("[migrateKeepers] keeperSelected {} , result:{}",keeperSelected, ObjectUtils.equals(keeperSelected.getHost(), srcKeeperContainerIp)); if (!ObjectUtils.equals(keeperSelected.getHost(), srcKeeperContainerIp) && keeperSelected.getKeeperContainerId() != newKeepers.get(0).getKeepercontainerId() && isDifferentAz(keeperSelected, alreadyUsedAzId, dcName)) { @@ -102,6 +106,8 @@ && isDifferentAz(keeperSelected, alreadyUsedAzId, dcName)) { break; } } + logger.debug("[migrateKeepers] new keepers {} from cluster:{}, dc:{}, shard:{}", + newKeepers, clusterName, dcName, shardModel.getShardTbl().getShardName()); return newKeepers; } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperContainerMigrationService.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperContainerMigrationService.java index eff4ad960..f88c326ce 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperContainerMigrationService.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/DefaultKeeperContainerMigrationService.java @@ -36,6 +36,7 @@ public void beginMigrateKeeperContainers(List alreadyMigrateShards = new HashSet<>(); for (MigrationKeeperContainerDetailModel keeperContainer : readyToMigrationKeeperContainers) { @@ -51,9 +52,11 @@ public void beginMigrateKeeperContainers(List @@ -438,6 +439,20 @@ public Map keeperContainerIdDcMap() { return keeperContainerIdDcMap; } + @Override + public List> divideKeeperContainers(int partsCount) { + List all = findAll(); + if (all == null) return Collections.emptyList(); + + List> result = new ArrayList<>(partsCount); + IntStream.range(0, partsCount).forEach(i -> result.add(new HashSet<>())); + + all.forEach(keeperContainer -> result.get((int) keeperContainer.getKeepercontainerId() % partsCount) + .add(keeperContainer.getKeepercontainerId())); + + return result; + } + @Override public List findAllInfos() { diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java index aa5790cb8..299fcd4ad 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java @@ -9,6 +9,8 @@ import com.ctrip.xpipe.redis.checker.config.CheckerDbConfig; import com.ctrip.xpipe.redis.checker.config.impl.DefaultCheckerDbConfig; import com.ctrip.xpipe.redis.checker.healthcheck.actions.interaction.HealthStateService; +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.ping.DefaultPingService; import com.ctrip.xpipe.redis.checker.healthcheck.actions.ping.PingService; import com.ctrip.xpipe.redis.checker.healthcheck.allleader.SentinelMonitorsCheckCrossDc; @@ -177,6 +179,13 @@ public HealthCheckReporter healthCheckReporter(CheckerConfig checkerConfig, Chec return new HealthCheckReporter(healthStateService, checkerConfig, checkerConsoleService, clusterServer, allCheckerLeaderElector, redisDelayManager, crossMasterDelayManager, pingService, clusterHealthManager, serverPort); } + + @Bean + @Profile(AbstractProfile.PROFILE_NAME_PRODUCTION) + public KeeperContainerInfoReporter keeperContainerInfoReporter(RedisUsedMemoryCollector redisUsedMemoryCollector, + CheckerConsoleService checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config) { + return new KeeperContainerInfoReporter(redisUsedMemoryCollector, checkerConsoleService, keeperFlowCollector, config); + } @Bean(name = "ALLCHECKER") @Profile(AbstractProfile.PROFILE_NAME_PRODUCTION) 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 86bdbe662..5e1f1a7e8 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('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 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 init();\n function init() {\n KeeperContainerService.getAllOverloadKeepercontainer()\n .then(function (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 }\n function beginToMigrateOverloadKeeperContainers() {\n $scope.migratingKeeperContainers = $scope.overloadKeeperContainer.filter(function (keeperContainer) {\n return keeperContainer;\n });\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 KeeperContainerService.beginToMigrateOverloadKeeperContainers.apply(KeeperContainerService, $scope.migratingKeeperContainers)\n .then(function (result) {\n $scope.operateType = OPERATE_TYPE.MIGRATING;\n $scope.scheduledWork = $interval(getOverloadKeeperContainerMigrationProcess, 10000);\n });\n }\n function getOverloadKeeperContainerMigrationProcess() {\n KeeperContainerService.getOverloadKeeperContainerMigrationProcess()\n .then(function (result) {\n if (result == null)\n return;\n $scope.migratingKeeperContainers = result;\n });\n }\n function stopToMigrateOverloadKeeperContainers() {\n if ($scope.operateType == OPERATE_TYPE.STOPPED)\n return;\n KeeperContainerService.stopToMigrateOverloadKeeperContainers();\n $interval.cancel($scope.scheduledWork);\n $scope.operateType = OPERATE_TYPE.STOPPED;\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 $scope.stopToMigrateOverloadKeeperContainers = stopToMigrateOverloadKeeperContainers;\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 stopToMigrateOverloadKeeperContainers() {\n if ($scope.operateType == OPERATE_TYPE.STOPPED)\n return;\n KeeperContainerService.stopToMigrateOverloadKeeperContainers();\n $interval.cancel($scope.scheduledWork);\n $scope.operateType = OPERATE_TYPE.STOPPED;\n }\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?"); /***/ }), @@ -9413,7 +9413,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_overload_keepercontainer_migration_process: {\n method: 'GET',\n url: '/console/keepercontainers/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 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 stopToMigrateOverloadKeeperContainers() {\n var d = $q.defer();\n resource.stop_to_migrate_overload_keepercontainer({}, {}, 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 getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n stopToMigrateOverloadKeeperContainers: stopToMigrateOverloadKeeperContainers,\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 get_all_overload_keepercontainer: {\n method: 'GET',\n url: '/console/keepercontainers/overload/all',\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 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 stopToMigrateOverloadKeeperContainers() {\n var d = $q.defer();\n resource.stop_to_migrate_overload_keepercontainer({}, {}, 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 getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n stopToMigrateOverloadKeeperContainers: stopToMigrateOverloadKeeperContainers,\n beginToMigrateOverloadKeeperContainers: beginToMigrateOverloadKeeperContainers,\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/KeepercontainerOverloadCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/KeepercontainerOverloadCtl.ts index b837a4a6e..a1ad21a4e 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 @@ -10,6 +10,9 @@ function KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, K $scope.overloadKeeperContainer = []; $scope.tableParams = new NgTableParams({}, {}); $scope.migratingTableParams = new NgTableParams({}, {}); + $scope.selectAll = false; + $scope.toggleAll = toggleAll; + $scope.isChecked = isChecked; var OPERATE_TYPE = { DETAIL: 'detail', @@ -20,29 +23,31 @@ function KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, K $scope.migratingKeeperContainers = []; $scope.scheduledWork; - init(); + $scope.beginToMigrateOverloadKeeperContainers = beginToMigrateOverloadKeeperContainers; + $scope.stopToMigrateOverloadKeeperContainers = stopToMigrateOverloadKeeperContainers; - function init() { - KeeperContainerService.getAllOverloadKeepercontainer() - .then(function (result) { - $scope.overloadKeeperContainer = result; + KeeperContainerService.getAllOverloadKeepercontainer() + .then(function (result) { + if (Array.isArray(result)) $scope.overloadKeeperContainer = result; + + $scope.tableParams = new NgTableParams({ + page : 1, + count : 10, + }, { + filterDelay: 100, + counts: [10, 25, 50], + dataset: $scope.overloadKeeperContainer + }); + }); - $scope.tableParams = new NgTableParams({ - page : 1, - count : 10, - }, { - filterDelay: 100, - counts: [10, 25, 50], - dataset: $scope.overloadKeeperContainer - }); - }); - } function beginToMigrateOverloadKeeperContainers() { $scope.migratingKeeperContainers = $scope.overloadKeeperContainer.filter(function(keeperContainer){ - return keeperContainer; + return keeperContainer.selected; }); + $scope.tableParams = new NgTableParams({}, {}); + $scope.migratingTableParams = new NgTableParams({ page : 1, count : 10, @@ -52,25 +57,55 @@ function KeepercontainerOverloadCtl($rootScope, $scope, $window, $stateParams, K dataset: $scope.migratingKeeperContainers }); + $scope.operateType = OPERATE_TYPE.MIGRATING; + KeeperContainerService.beginToMigrateOverloadKeeperContainers.apply(KeeperContainerService, $scope.migratingKeeperContainers) .then(result => { - $scope.operateType = OPERATE_TYPE.MIGRATING; - $scope.scheduledWork = $interval(getOverloadKeeperContainerMigrationProcess, 10000); + if(result.message == 'success' ) { + toastr.success("迁移成功"); + } else { + toastr.error(result.message, "迁移失败"); + } + getOverloadKeeperContainerMigrationProcess(); + $interval.cancel($scope.scheduledWork); }); } function getOverloadKeeperContainerMigrationProcess() { - KeeperContainerService.getOverloadKeeperContainerMigrationProcess() - .then(function (result) { - if (result == null) return; - $scope.migratingKeeperContainers = result; - }); + if ($scope.operateType == OPERATE_TYPE.MIGRATING) { + KeeperContainerService.getOverloadKeeperContainerMigrationProcess() + .then(function (result) { + if (result == null) return; + $scope.migratingKeeperContainers = result; + $scope.migratingTableParams = new NgTableParams({ + page : 1, + count : 10, + }, { + filterDelay: 100, + counts: [10, 25, 50], + dataset: $scope.migratingKeeperContainers + }); + }); + } } + $scope.scheduledWork = $interval(getOverloadKeeperContainerMigrationProcess, 1000); + function stopToMigrateOverloadKeeperContainers() { if ($scope.operateType == OPERATE_TYPE.STOPPED) return; KeeperContainerService.stopToMigrateOverloadKeeperContainers(); $interval.cancel($scope.scheduledWork); $scope.operateType = OPERATE_TYPE.STOPPED; } + + function toggleAll() { + $scope.selectAll = !$scope.selectAll; + $scope.overloadKeeperContainer.forEach(function (keeperContainer) { + keeperContainer.selected = !keeperContainer.selected; + }); + } + + function isChecked() { + return $scope.selectAll; + } } \ 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 901d9b0a1..ab2f7dea4 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 @@ -47,7 +47,7 @@ angular }, get_overload_keepercontainer_migration_process: { method: 'GET', - url: '/console/keepercontainers/overload/migration/process', + url: '/console/keepercontainer/overload/migration/process', isArray: true }, begin_to_migrate_overload_keepercontainer:{ 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 78b35c2e8..9ea7157d5 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 @@ -1,42 +1,68 @@

+ +

+ + + + + + OverloadKeeperContainer + >> 迁移中 +

+
- OverloadKeeperContainer - >> 迁移中 + + + + 取消全选 全选
-
- - - - - - - - - - - - - - -
- - - {{info.srcKeeperContainer.keeperIp}}{{info.srcKeeperContainer.dcName}}{{info.srcKeeperContainer.totalRedisUsedMemory}}{{info.srcKeeperContainer.totalInputFlow}}{{info.migrateKeeperCount}}{{info.targetKeeperContainer.keeperIp}}{{info.targetKeeperContainer.dcName}}<{{info.targetKeeperContainer.totalRedisUsedMemory}}
+
+ + + + + + + + + + + + + + +
+ + {{info.srcKeeperContainer.keeperIp}}{{info.srcKeeperContainer.dcName}}{{info.srcKeeperContainer.totalRedisUsedMemory}}{{info.srcKeeperContainer.totalInputFlow}}{{info.migrateKeeperCount}}{{info.targetKeeperContainer.keeperIp}}{{info.targetKeeperContainer.totalRedisUsedMemory}}{{info.targetKeeperContainer.totalInputFlow}}
+
+ + +
+ + + + + + + + +
{{info.srcKeeperContainer.keeperIp}}{{info.srcKeeperContainer.dcName}}{{info.targetKeeperContainer.keeperIp}}{{info.migrateKeeperCount}}{{info.migrateKeeperCompleteCount}}
+
diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzerTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzerTest.java index 26a914580..d72ed6bdd 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzerTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/keeper/impl/DefaultKeeperContainerUsedInfoAnalyzerTest.java @@ -1,5 +1,6 @@ package com.ctrip.xpipe.redis.console.keeper.impl; +import com.ctrip.xpipe.api.foundation.FoundationService; import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; import com.ctrip.xpipe.redis.console.config.ConsoleConfig; @@ -37,11 +38,15 @@ public class DefaultKeeperContainerUsedInfoAnalyzerTest { @Mock private ThreadPoolExecutor executor; + @Mock + private FoundationService service; + + @Before public void before() { Mockito.when(config.getClusterDividedParts()).thenReturn(2); Map standards = Maps.newHashMap(); - standards.put("jq", new KeeperContainerOverloadStandardModel().setFlowOverload(10).setPeerDataOverload(10)); + standards.put(FoundationService.DEFAULT.getDataCenter(), new KeeperContainerOverloadStandardModel().setFlowOverload(10).setPeerDataOverload(10)); Mockito.when(config.getKeeperContainerOverloadStandards()).thenReturn(standards); Mockito.doNothing().when(executor).execute(Mockito.any()); } diff --git a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/console/ConsoleCheckerPath.java b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/console/ConsoleCheckerPath.java index 82128db3a..5cdabc8e4 100644 --- a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/console/ConsoleCheckerPath.java +++ b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/console/ConsoleCheckerPath.java @@ -22,7 +22,7 @@ private ConsoleCheckerPath() {} public static final String PATH_PUT_HEALTH_CHECK_RESULT = "/api/health/check/result"; - public static final String PATH_PUT_KEEPER_CONTAINER_INFO_RESULT = "/api/keeperContainer/info/result/{index}"; + public static final String PATH_POST_KEEPER_CONTAINER_INFO_RESULT = "/api/keeperContainer/info/result/{index}"; public static final String PATH_PERSISTENCE = "/api/persistence/";