diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java index f27305791..f3b15d07e 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/controller/CheckerHealthController.java @@ -52,14 +52,6 @@ public class CheckerHealthController { @Autowired private StabilityHolder siteStability; - @Autowired - private KeeperContainerInfoReporter keeperContainerInfoReporter; - - @RequestMapping(value = "/reportKeeperContainerInfo", method = RequestMethod.GET) - public void reportKeeperContainerInfo() { - keeperContainerInfoReporter.reportKeeperContainerInfo(); - } - @RequestMapping(value = "/health/{ip}/{port}", method = RequestMethod.GET) public HEALTH_STATE getHealthState(@PathVariable String ip, @PathVariable int port) { if (siteStability.isSiteStable()) return defaultDelayPingActionCollector.getState(new HostPort(ip, port)); diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/healthcheck/actions/keeper/infoStats/KeeperFlowCollector.java index 2b1e07793..1c86e0040 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 @@ -3,7 +3,6 @@ import com.ctrip.xpipe.redis.checker.healthcheck.HealthCheckAction; import com.ctrip.xpipe.redis.checker.healthcheck.KeeperInstanceInfo; import com.ctrip.xpipe.redis.checker.healthcheck.KeeperSupport; -import com.ctrip.xpipe.redis.checker.model.DcClusterShard; import com.ctrip.xpipe.redis.checker.model.DcClusterShardActive; import com.ctrip.xpipe.redis.core.protocal.cmd.InfoResultExtractor; import com.ctrip.xpipe.utils.MapUtils; @@ -29,7 +28,7 @@ public void onAction(KeeperInfoStatsActionContext context) { KeeperInstanceInfo info = context.instance().getCheckInfo(); long keeperFlow = extractor.getKeeperInstantaneousInputKbps().longValue(); Map keeperContainerResult = MapUtils.getOrCreate(hostPort2InputFlow, info.getHostPort().getHost(), ConcurrentHashMap::new); - keeperContainerResult.put(new DcClusterShardActive(info.getDcId(), info.getClusterId(), info.getShardId(), extractor.getKeeperRole(), info.getHostPort().getPort()), keeperFlow); + keeperContainerResult.put(new DcClusterShardActive(info.getDcId(), info.getClusterId(), info.getShardId(), extractor.getKeeperActive(), info.getHostPort().getPort()), keeperFlow); } catch (Throwable throwable) { logger.error("get instantaneous input kbps of keeper:{} error: ", context.instance().getCheckInfo().getHostPort(), throwable); } diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java index 43f7a7d10..da4890d18 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 @@ -142,6 +142,8 @@ public void reportKeeperContainerInfo() { .setDiskUsed(keeperDiskInfo.spaceUsageInfo.use); } catch (RestClientException e){ logger.error("[reportKeeperContainerInfo] getKeeperDiskInfo error, keeperIp: {}", keeperIp); + } catch (Throwable e) { + logger.error("[reportKeeperContainerInfo] getKeeperDiskInfo error", e); } model.setDetailInfo(detailInfo) .setActiveKeeperCount(activeKeeperCount) diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java index 47c86fab7..2d75d738e 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/model/DcClusterShardActive.java @@ -67,7 +67,7 @@ public int hashCode() { @Override public String toString() { - return getDcId() + SPLITTER + getClusterId() + SPLITTER + getShardId() + SPLITTER + isActive() + SPLITTER + getPort(); + return new StringBuilder().append(getDcId()).append(SPLITTER).append(getClusterId()).append(SPLITTER).append(getShardId()).append(SPLITTER).append(isActive()).append(SPLITTER).append(getPort()).toString(); } } 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 83be108f9..2dda9c48d 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 @@ -324,7 +324,7 @@ Map analyzeKeeperContainerStandard KeeperContainerOverloadStandardModel keeperContainerOverloadStandard = config.getKeeperContainerOverloadStandards().get(currentDc); double loadFactor = config.getKeeperContainerOverloadFactor(); KeeperContainerOverloadStandardModel defaultOverloadStandard = getDefaultStandard(keeperContainerOverloadStandard, loadFactor); - logger.debug("[analyzeKeeperContainerUsedInfo] keeperContainerDefaultOverloadStandard: {}", defaultOverloadStandard); + logger.info("[analyzeKeeperContainerUsedInfo] keeperContainerDefaultOverloadStandard: {}", defaultOverloadStandard); for (KeeperContainerUsedInfoModel keeperContainerUsedInfoModel : allKeeperContainerUsedInfoModelsList) { KeeperContainerOverloadStandardModel realKeeperContainerOverloadStandard = getRealStandard(keeperContainerOverloadStandard, defaultOverloadStandard, keeperContainerUsedInfoModel, loadFactor); keeperContainerUsedInfoModel.setInputFlowStandard(realKeeperContainerOverloadStandard.getFlowOverload()); 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 6cd90013c..f2110ec6c 100644 --- a/redis/redis-console/src/main/resources/static/dist/bundle.js +++ b/redis/redis-console/src/main/resources/static/dist/bundle.js @@ -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 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 $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 $scope.fullSynchronizationTime = response.message;\n });\n });\n $scope.getKeepercontainerFullSynchronizationTime = function () {\n return $scope.fullSynchronizationTime;\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 row.activeRedisUsedMemoryPercentage = $scope.getActivePercentage(row.activeRedisUsedMemory, row.totalRedisUsedMemory) * 100;\n row.activeRedisUsedMemoryStandardPercentage = $scope.getActivePercentage(row.activeRedisUsedMemory, row.redisUsedMemoryStandard) * 100;\n row.activeInputFlowPercentage = $scope.getActivePercentage(row.activeInputFlow, row.totalInputFlow) * 100;\n row.activeInputFlowStandardPercentage = $scope.getActivePercentage(row.activeInputFlow, row.inputFlowStandard) * 100;\n });\n });\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.originData\n });\n }\n KeeperContainerService.getKeepercontainerFullSynchronizationTime().then(function (response) {\n $scope.fullSynchronizationTime = response.message;\n });\n });\n $scope.getKeepercontainerFullSynchronizationTime = function () {\n return $scope.fullSynchronizationTime;\n };\n $scope.getActivePercentage = function (active, total) {\n if (total === 0) {\n return 0;\n }\n return active / total;\n };\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/KeepercontainerUsedInfoCtl.ts?"); /***/ }), 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 7f437ed49..2d23c98f2 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 @@ -25,6 +25,10 @@ function KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, K if (matchingData) { Object.assign(row, matchingData); } + row.activeRedisUsedMemoryPercentage = $scope.getActivePercentage(row.activeRedisUsedMemory, row.totalRedisUsedMemory)*100; + row.activeRedisUsedMemoryStandardPercentage = $scope.getActivePercentage(row.activeRedisUsedMemory, row.redisUsedMemoryStandard)*100; + row.activeInputFlowPercentage = $scope.getActivePercentage(row.activeInputFlow, row.totalInputFlow)*100; + row.activeInputFlowStandardPercentage = $scope.getActivePercentage(row.activeInputFlow, row.inputFlowStandard)*100; }); }); } @@ -47,4 +51,11 @@ function KeepercontainerUsedInfoCtl($rootScope, $scope, $window, $stateParams, K return $scope.fullSynchronizationTime; } + $scope.getActivePercentage = function (active, total) { + if (total === 0) { + return 0; + } + return active/total; + } + } \ No newline at end of file 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 1d8f9ee6e..24bf2c88c 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 @@ -21,12 +21,12 @@ {{info.azName}} {{info.activeRedisUsedMemory/1024/1024 | number:2}} {{(info.totalRedisUsedMemory-info.activeRedisUsedMemory)/1024/1024 | number:2}} - {{info.activeRedisUsedMemory/info.totalRedisUsedMemory*100 | number:2}}% - {{info.activeRedisUsedMemory/info.redisUsedMemoryStandard*100 | number:2}}% + {{info.activeRedisUsedMemoryPercentage | number:2}}% + {{info.activeRedisUsedMemoryStandardPercentage | number:2}}% {{info.activeInputFlow/1024/8 | number:2}} {{(info.totalInputFlow-info.activeInputFlow)/1024/8 | number:2}} - {{info.activeInputFlow/info.totalInputFlow*100 | number:2}}% - {{info.activeInputFlow/info.inputFlowStandard*100 | number:2}}% + {{info.activeInputFlowPercentage | number:2}}% + {{info.activeInputFlowStandardPercentage | number:2}}% {{info.activeKeeperCount}} {{info.totalKeeperCount-info.activeKeeperCount}} diff --git a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java index 7dafa8838..3d8043d9d 100644 --- a/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java +++ b/redis/redis-core/src/main/java/com/ctrip/xpipe/redis/core/protocal/cmd/InfoResultExtractor.java @@ -1,6 +1,5 @@ package com.ctrip.xpipe.redis.core.protocal.cmd; -import com.ctrip.xpipe.utils.VisibleForTesting; import com.google.common.base.Function; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,7 +26,7 @@ public class InfoResultExtractor { private static final String KEY_SWAP_USED_DB_SIZE = "swap_used_db_size"; private static final String KEY_USED_MEMORY ="used_memory"; private static final String KEY_MAX_MEMORY ="maxmemory"; - private static final String KEY_KEEPER_ROLE = "state"; + private static final String KEY_KEEPER_ACTIVE = "state"; protected static Logger logger = LoggerFactory.getLogger(InfoResultExtractor.class); @@ -121,7 +120,7 @@ public long getSyncPartialErr() { public Long getSwapUsedDbSize() { return extractAsLong(KEY_SWAP_USED_DB_SIZE);} - public boolean getKeeperRole() { return "ACTIVE".equals(extract(KEY_KEEPER_ROLE)); } + public boolean getKeeperActive() { return "ACTIVE".equals(extract(KEY_KEEPER_ACTIVE)); } public long getMasterReplOffset() { Long result = extractAsLong(KEY_MASTER_REPL_OFFSET); diff --git a/redis/redis-proxy/src/main/java/com/ctrip/xpipe/redis/proxy/tunnel/DefaultTunnelManager.java b/redis/redis-proxy/src/main/java/com/ctrip/xpipe/redis/proxy/tunnel/DefaultTunnelManager.java index ab44d62fb..7f70b1fca 100644 --- a/redis/redis-proxy/src/main/java/com/ctrip/xpipe/redis/proxy/tunnel/DefaultTunnelManager.java +++ b/redis/redis-proxy/src/main/java/com/ctrip/xpipe/redis/proxy/tunnel/DefaultTunnelManager.java @@ -87,7 +87,9 @@ protected void doClean() { if (!channel.isActive()) { Tunnel tunnel = cache.remove(channel); try { - tunnel.release(); + if (tunnel != null) { + tunnel.release(); + } } catch (Exception e) { logger.error("[cleaner] tunnel release tunnel{} error", tunnel, e); }