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..45bb61d61 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 @@ -134,7 +134,9 @@ void reportKeeperContainerInfo() { } 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/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/resource/DefaultCheckerConsoleServiceTest.java b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleServiceTest.java index 7cf88e817..c692cbf53 100644 --- a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleServiceTest.java +++ b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/resource/DefaultCheckerConsoleServiceTest.java @@ -1,15 +1,30 @@ package com.ctrip.xpipe.redis.checker.resource; import com.ctrip.xpipe.redis.checker.AbstractCheckerTest; +import com.ctrip.xpipe.redis.checker.controller.result.RetMessage; +import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; +import com.ctrip.xpipe.redis.core.console.ConsoleCheckerPath; import com.ctrip.xpipe.redis.core.entity.XpipeMeta; +import com.fasterxml.jackson.core.JsonProcessingException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; import java.net.InetAddress; +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** * @author lishanglin @@ -46,6 +61,33 @@ public void testGetXpipeMeta() throws Exception { Assert.assertEquals("GET", request.getMethod()); } + @Test + public void testReportKeeperContainerInfo() { + RestTemplate restTemplate = new RestTemplate(); + // 构造测试数据 + List keeperContainerUsedInfoModels = new ArrayList<>(); + keeperContainerUsedInfoModels.add(new KeeperContainerUsedInfoModel("1.1.1.1", "dc1", 1234, 1)); + keeperContainerUsedInfoModels.add(new KeeperContainerUsedInfoModel("2.2.2.2", "dc2", 5678, 2)); + + // 模拟 RestTemplate.postForEntity() 方法的返回结果 + ResponseEntity responseEntity = new ResponseEntity<>(HttpStatus.OK); + when(restTemplate.postForEntity( + anyString(), any(), eq(RetMessage.class), anyInt())).thenReturn(responseEntity); + + // 调用被测试的方法 + String console = "http://console-url"; + int index = 1; + service.reportKeeperContainerInfo(console, keeperContainerUsedInfoModels, index); + + // 验证 RestTemplate.postForEntity() 方法是否被正确调用 + verify(restTemplate).postForEntity( + eq(console + ConsoleCheckerPath.PATH_POST_KEEPER_CONTAINER_INFO_RESULT), + eq(keeperContainerUsedInfoModels), + eq(RetMessage.class), + eq(index) + ); + } + @Override protected String getXpipeMetaConfigFile() { return "dc-meta-test.xml"; 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/consoleportal/KeeperContainerInfoController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/KeeperContainerInfoController.java index d75ebb434..f70d4ffc7 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 @@ -1,9 +1,11 @@ package com.ctrip.xpipe.redis.console.controller.consoleportal; import com.ctrip.xpipe.redis.checker.controller.result.RetMessage; +import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.checker.model.DcClusterShardActive; import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; import com.ctrip.xpipe.redis.console.controller.AbstractConsoleController; +import com.ctrip.xpipe.redis.console.keeper.KeeperContainerOverloadCause; import com.ctrip.xpipe.redis.console.keeper.KeeperContainerUsedInfoAnalyzer; import com.ctrip.xpipe.redis.console.model.KeeperContainerInfoModel; import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel; @@ -12,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.lang.reflect.Member; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -102,4 +105,11 @@ public RetMessage beginToMigrateOverloadKeeperContainers(@RequestBody List getLastedAllReadyMigrateKeeperContainers() { return analyzer.getAllKeeperContainerUsedInfoModelsList(); } + + @RequestMapping(value = "/keepercontainer/max/fullSynchronizationTime", method = RequestMethod.GET) + public int getMaxKeeperContainerFullSynchronizationTime() { +// return analyzer.getMaxKeeperContainerFullSynchronizationTime(); + return 40; + } + } 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..2b7e59639 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,6 @@ public interface KeeperContainerUsedInfoAnalyzer { Map> getAllKeeperContainerUsedInfoModels(); List getAllKeeperContainerUsedInfoModelsList(); + + 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 c38142103..1104e1a73 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 @@ -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<>(); @@ -112,6 +114,12 @@ public List getAllKeeperContainerUsedInfoModelsLis 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()){ @@ -198,8 +206,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()); } @@ -311,14 +323,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; @@ -331,7 +342,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() @@ -357,7 +369,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())) { @@ -389,7 +401,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; @@ -466,15 +478,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; @@ -487,7 +497,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; @@ -524,7 +535,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); 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..85121491f 100644 --- a/redis/redis-console/src/main/resources/static/dist/bundle.js +++ b/redis/redis-console/src/main/resources/static/dist/bundle.js @@ -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/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_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..c52928026 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()}} 分钟
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..806c057a6 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 @@ -51,7 +51,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 +61,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); @@ -532,4 +532,38 @@ public void testMultiSrcMultiTargetWithFixed() { 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.getAllKeeperContainerUsedInfoModelsList().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