diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java index c4573d6fdb..b0553246f8 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java @@ -1,12 +1,21 @@ package com.ctrip.xpipe.redis.checker; import com.ctrip.xpipe.redis.core.entity.KeeperDiskInfo; +import com.ctrip.xpipe.redis.core.entity.KeeperInstanceMeta; import org.springframework.web.client.RestClientException; +import java.util.List; + public interface KeeperContainerService { KeeperDiskInfo getKeeperDiskInfo(String keeperContainerIp) throws RestClientException; boolean setKeeperContainerDiskIOLimit(String keeperContainerIp, int keeperContainerPort, int limitInByte); + List getAllKeepers(String keeperContainerIp); + + void resetKeeper(String activeKeeperIp, Long replId); + + void releaseRdb(String ip, int port, Long replId); + } 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 dc0a85c534..eca0948807 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 @@ -2,11 +2,19 @@ import com.ctrip.xpipe.redis.checker.KeeperContainerService; import com.ctrip.xpipe.redis.core.entity.KeeperDiskInfo; +import com.ctrip.xpipe.redis.core.entity.KeeperInstanceMeta; +import com.ctrip.xpipe.redis.core.entity.KeeperTransMeta; import com.ctrip.xpipe.redis.core.service.AbstractService; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClientException; +import java.util.List; + @Service public class DefaultKeeperContainerService extends AbstractService implements KeeperContainerService { @@ -27,4 +35,33 @@ public boolean setKeeperContainerDiskIOLimit(String keeperContainerIp, int keepe null, Boolean.class, keeperContainerIp, keeperContainerPort, limitInByte); return null != rst && rst; } + + @Override + public List getAllKeepers(String keeperContainerIp) { + return restTemplate.exchange(String.format("http://%s:8080/keepers", keeperContainerIp), HttpMethod.GET, null, + new ParameterizedTypeReference>() {}).getBody(); + } + + @Override + public void resetKeeper(String activeKeeperIp, Long replId) { + KeeperTransMeta keeperInstanceMeta = new KeeperTransMeta(); + keeperInstanceMeta.setReplId(replId); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity requestEntity = new HttpEntity<>(keeperInstanceMeta, headers); + restTemplate.exchange(String.format("http://%s:8080/keepers/election/reset", activeKeeperIp), + HttpMethod.POST, requestEntity, Void.class); + } + + @Override + public void releaseRdb(String ip, int port, Long replId) { + KeeperTransMeta keeperInstanceMeta = new KeeperTransMeta(); + keeperInstanceMeta.setReplId(replId); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity requestEntity = new HttpEntity<>(keeperInstanceMeta, headers); + restTemplate.exchange(String.format("http://%s:8080/keepers/rdb/release", ip), + HttpMethod.DELETE, requestEntity, Void.class); + } + } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java index 68166e792e..779cb016d5 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java @@ -10,7 +10,7 @@ import com.ctrip.xpipe.redis.console.model.KeeperRestElectionModel; import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel; import com.ctrip.xpipe.redis.console.service.ConfigService; -import com.ctrip.xpipe.redis.console.service.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -104,4 +104,14 @@ public RetMessage resetElection(@RequestBody KeeperRestElectionModel model){ } } + @RequestMapping(value = "/keepers/release/rdb", method = RequestMethod.POST) + public RetMessage releaseRdb(@RequestBody KeeperRestElectionModel model){ + try { + keeperContainerService.releaseRdb(model.getIp(), Integer.parseInt(model.getPort()), Long.parseLong(model.getShardId())); + return RetMessage.createSuccessMessage(); + } catch (Exception e) { + return RetMessage.createFailMessage(e.getMessage()); + } + } + } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java index 9157ef9653..85ae18a637 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java @@ -1,7 +1,7 @@ package com.ctrip.xpipe.redis.console.keeper.command; import com.ctrip.xpipe.command.AbstractCommand; -import com.ctrip.xpipe.redis.console.service.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerService; public class KeeperResetCommand extends AbstractCommand { 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 a52664dade..b93ec32df1 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 @@ -40,9 +40,5 @@ public interface KeeperContainerService { void updateKeeperContainerByInfoModel(KeeperContainerInfoModel keeperContainerInfoModel); - List getAllKeepers(String keeperContainerIp); - - void resetKeeper(String activeKeeperIp, Long replId); - Map keeperContainerIdDcMap(); } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java index 752c6ad93d..2d717acda3 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java @@ -460,25 +460,6 @@ public Integer doQuery() throws DalException { }); } - @Override - public List getAllKeepers(String keeperContainerIp) { - getOrCreateRestTemplate(); - return restTemplate.exchange(String.format("http://%s:8080/keepers", keeperContainerIp), HttpMethod.GET, null, - new ParameterizedTypeReference>() {}).getBody(); - } - - @Override - public void resetKeeper(String activeKeeperIp, Long replId) { - KeeperTransMeta keeperInstanceMeta = new KeeperTransMeta(); - keeperInstanceMeta.setReplId(replId); - getOrCreateRestTemplate(); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity requestEntity = new HttpEntity<>(keeperInstanceMeta, headers); - restTemplate.exchange(String.format("http://%s:8080/keepers/election/reset", activeKeeperIp), - HttpMethod.POST, requestEntity, Void.class); - } - @Override public Map keeperContainerIdDcMap() { Map keeperContainerIdDcMap = new HashMap<>(); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceWithoutDB.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceWithoutDB.java index 907349c0aa..03b73c9978 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceWithoutDB.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceWithoutDB.java @@ -181,22 +181,6 @@ public void updateKeeperContainerByInfoModel(KeeperContainerInfoModel keeperCont throw new UnsupportedOperationException(); } - @Override - public List getAllKeepers(String keeperContainerIp) { - throw new UnsupportedOperationException(); - } - - @Override - public void resetKeeper(String activeKeeperIp, Long replId) { - KeeperTransMeta keeperInstanceMeta = new KeeperTransMeta(); - keeperInstanceMeta.setReplId(replId); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity requestEntity = new HttpEntity<>(keeperInstanceMeta, headers); - restTemplate.exchange(String.format("http://%s:8080/keepers/election/reset", activeKeeperIp), - HttpMethod.POST, requestEntity, Void.class); - } - @Override public Map keeperContainerIdDcMap() { Map keeperContainerIdDcMap = new HashMap<>(); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java index 6623647f51..f0853fc092 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java @@ -16,6 +16,7 @@ import com.ctrip.xpipe.redis.console.model.*; import com.ctrip.xpipe.redis.console.repository.AzGroupClusterRepository; import com.ctrip.xpipe.redis.console.service.*; +import com.ctrip.xpipe.redis.console.service.impl.KeeperContainerServiceImpl; import com.ctrip.xpipe.redis.console.service.model.ShardModelService; import com.ctrip.xpipe.utils.ObjectUtils; import com.ctrip.xpipe.utils.VisibleForTesting; @@ -26,6 +27,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ctrip.xpipe.redis.checker.KeeperContainerService; import javax.annotation.PostConstruct; import javax.annotation.Resource; @@ -55,7 +57,9 @@ public class ShardModelServiceImpl implements ShardModelService{ @Autowired private ReplDirectionService replDirectionService; @Autowired - private KeeperContainerService keeperContainerService; + private KeeperContainerServiceImpl keeperContainerServiceImpl; + @Autowired + private KeeperContainerService keeperContainerService; @Autowired private AzGroupClusterRepository azGroupClusterRepository; @Autowired @@ -124,7 +128,7 @@ public List getMultiShardModel(final String dcName, final String clu return shardModels; } - Map containerIdDcMap = keeperContainerService.keeperContainerIdDcMap(); + Map containerIdDcMap = keeperContainerServiceImpl.keeperContainerIdDcMap(); for (int i = 0; i < shards.size(); i++) { ShardTbl shardInfo = shards.get(i); Future dcClusterShardFuture = dcClusterShardFutures.get(i); 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 e5c5467656..6be3de9f98 100644 --- a/redis/redis-console/src/main/resources/static/dist/bundle.js +++ b/redis/redis-console/src/main/resources/static/dist/bundle.js @@ -9153,7 +9153,7 @@ eval("angular\n .module('index')\n .controller('DcListCtl', DcListCtl);\nD \*******************************************************/ /***/ (() => { -eval("angular\n .module('index')\n .controller('FullLinkHealthCheckCtl', FullLinkHealthCheckCtl)\n .config(function ($mdThemingProvider) {\n $mdThemingProvider.theme('green').backgroundPalette('light-green');\n $mdThemingProvider.theme('red').backgroundPalette('red');\n $mdThemingProvider.theme('orange').backgroundPalette('orange');\n});\nFullLinkHealthCheckCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', 'HealthCheckService', 'KeeperContainerService',\n 'toastr', 'NgTableParams', 'AppUtil', '$interval'];\nfunction FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, HealthCheckService, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.masterRoles = [];\n $scope.slaveRoles = [];\n $scope.unknownRoles = [];\n $scope.shardCheckerHealthCheckResult = [];\n $scope.showActions = false;\n $scope.shardAllMeta = null;\n $scope.shardKeeperState = [];\n $scope.redisRoleHealthCheck = redisRoleHealthCheck;\n $scope.shardCheckerGroupHealthCheck = shardCheckerGroupHealthCheck;\n $scope.doShowActions = doShowActions;\n $scope.getShardAllMeta = getShardAllMeta;\n $scope.getShardKeeperState = getShardKeeperState;\n $scope.resetElection = resetElection;\n $scope.disableResetElection = false;\n $scope.getDisableResetElection = getDisableResetElection;\n $scope.resetElectionErr = null;\n $scope.getResetElectionErr = getResetElectionErr;\n redisRoleHealthCheck();\n shardCheckerGroupHealthCheck();\n getShardAllMeta();\n getShardKeeperState();\n function redisRoleHealthCheck() {\n HealthCheckService.getShardRedisRole($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.masterRoles = [];\n $scope.slaveRoles = [];\n $scope.unknownRoles = [];\n response.forEach(function (item) {\n if (item.role == null) {\n $scope.unknownRoles.push(item);\n }\n else if (item.role.serverRole == \"SLAVE\") {\n $scope.slaveRoles.push(item);\n }\n else if (item.role.serverRole == \"MASTER\") {\n $scope.masterRoles.push(item);\n }\n });\n });\n }\n function shardCheckerGroupHealthCheck() {\n HealthCheckService.getShardCheckerHealthCheck($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardCheckerHealthCheckResult = [];\n response.forEach(function (item) {\n $scope.shardCheckerHealthCheckResult.push(item);\n });\n });\n }\n function getShardAllMeta() {\n HealthCheckService.getShardAllMeta($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardAllMeta = null;\n $scope.shardAllMeta = response;\n });\n }\n function getShardKeeperState() {\n HealthCheckService.getShardKeeperState($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardKeeperState = [];\n response.forEach(function (item) {\n $scope.shardKeeperState.push(item);\n });\n });\n }\n var timer = null;\n function resetElection(ip, port) {\n $scope.disableResetElection = true;\n KeeperContainerService.resetElection(ip, port, $stateParams.shardId).then(function (response) {\n if (response.state != 0) {\n $scope.disableResetElection = false;\n $scope.resetElectionErr = response.message;\n $('#resetElectionErr').modal('show');\n }\n else {\n if (!timer) {\n timer = setTimeout(function () {\n clearTimeout(timer);\n timer = null;\n $scope.disableResetElection = false;\n }, 5000);\n }\n }\n }).catch(function (error) {\n $scope.disableResetElection = false;\n $scope.resetElectionErr = \"Status Code:\" + error.status + \" \" + error.statusText + \"\\n\" + error.data.exception;\n $('#resetElectionErr').modal('show');\n });\n }\n function getResetElectionErr() {\n return $scope.resetElectionErr;\n }\n function doShowActions() {\n $scope.showActions = !$scope.showActions;\n }\n function getDisableResetElection() {\n return $scope.disableResetElection;\n }\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/FullLinkHealthCheckCtl.ts?"); +eval("angular\n .module('index')\n .controller('FullLinkHealthCheckCtl', FullLinkHealthCheckCtl)\n .config(function ($mdThemingProvider) {\n $mdThemingProvider.theme('green').backgroundPalette('light-green');\n $mdThemingProvider.theme('red').backgroundPalette('red');\n $mdThemingProvider.theme('orange').backgroundPalette('orange');\n});\nFullLinkHealthCheckCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', 'HealthCheckService', 'KeeperContainerService',\n 'toastr', 'NgTableParams', 'AppUtil', '$interval'];\nfunction FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, HealthCheckService, KeeperContainerService, toastr, NgTableParams, $interval) {\n $scope.masterRoles = [];\n $scope.slaveRoles = [];\n $scope.unknownRoles = [];\n $scope.shardCheckerHealthCheckResult = [];\n $scope.showActions = false;\n $scope.shardAllMeta = null;\n $scope.shardKeeperState = [];\n $scope.redisRoleHealthCheck = redisRoleHealthCheck;\n $scope.shardCheckerGroupHealthCheck = shardCheckerGroupHealthCheck;\n $scope.doShowActions = doShowActions;\n $scope.getShardAllMeta = getShardAllMeta;\n $scope.getShardKeeperState = getShardKeeperState;\n $scope.releaseRdb = releaseRdb;\n $scope.resetElection = resetElection;\n $scope.disableResetElection = false;\n $scope.disableReleaseRdb = false;\n $scope.getDisableResetElection = getDisableResetElection;\n $scope.getDisableReleaseRdb = getDisableReleaseRdb;\n $scope.resetElectionErr = null;\n $scope.releaseRdbErr = null;\n $scope.getResetElectionErr = getResetElectionErr;\n $scope.getReleaseRdbErr = getReleaseRdbErr;\n redisRoleHealthCheck();\n shardCheckerGroupHealthCheck();\n getShardAllMeta();\n getShardKeeperState();\n function redisRoleHealthCheck() {\n HealthCheckService.getShardRedisRole($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.masterRoles = [];\n $scope.slaveRoles = [];\n $scope.unknownRoles = [];\n response.forEach(function (item) {\n if (item.role == null) {\n $scope.unknownRoles.push(item);\n }\n else if (item.role.serverRole == \"SLAVE\") {\n $scope.slaveRoles.push(item);\n }\n else if (item.role.serverRole == \"MASTER\") {\n $scope.masterRoles.push(item);\n }\n });\n });\n }\n function shardCheckerGroupHealthCheck() {\n HealthCheckService.getShardCheckerHealthCheck($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardCheckerHealthCheckResult = [];\n response.forEach(function (item) {\n $scope.shardCheckerHealthCheckResult.push(item);\n });\n });\n }\n function getShardAllMeta() {\n HealthCheckService.getShardAllMeta($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardAllMeta = null;\n $scope.shardAllMeta = response;\n });\n }\n function getShardKeeperState() {\n HealthCheckService.getShardKeeperState($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {\n $scope.shardKeeperState = [];\n response.forEach(function (item) {\n $scope.shardKeeperState.push(item);\n });\n });\n }\n var rdbTimer = null;\n function releaseRdb(ip, port) {\n $scope.disableReleaseRdb = true;\n KeeperContainerService.releaseRdb(ip, port, $stateParams.shardId).then(function (response) {\n if (response.state != 0) {\n $scope.disableReleaseRdb = false;\n $scope.releaseRdbErr = response.message;\n $('#releaseRdbErr').modal('show');\n }\n else {\n if (!rdbTimer) {\n rdbTimer = setTimeout(function () {\n clearTimeout(rdbTimer);\n rdbTimer = null;\n $scope.disableReleaseRdb = false;\n }, 3000);\n }\n }\n }).catch(function (error) {\n $scope.disableReleaseRdb = false;\n $scope.releaseRdbErr = \"Status Code:\" + error.status + \" \" + error.statusText + \"\\n\" + error.data.exception;\n $('#releaseRdbErr').modal('show');\n });\n }\n var timer = null;\n function resetElection(ip, port) {\n $scope.disableResetElection = true;\n KeeperContainerService.resetElection(ip, port, $stateParams.shardId).then(function (response) {\n if (response.state != 0) {\n $scope.disableResetElection = false;\n $scope.resetElectionErr = response.message;\n $('#resetElectionErr').modal('show');\n }\n else {\n if (!timer) {\n timer = setTimeout(function () {\n clearTimeout(timer);\n timer = null;\n $scope.disableResetElection = false;\n }, 5000);\n }\n }\n }).catch(function (error) {\n $scope.disableResetElection = false;\n $scope.resetElectionErr = \"Status Code:\" + error.status + \" \" + error.statusText + \"\\n\" + error.data.exception;\n $('#resetElectionErr').modal('show');\n });\n }\n function getResetElectionErr() {\n return $scope.resetElectionErr;\n }\n function getReleaseRdbErr() {\n return $scope.releaseRdbErr;\n }\n function doShowActions() {\n $scope.showActions = !$scope.showActions;\n }\n function getDisableResetElection() {\n return $scope.disableResetElection;\n }\n function getDisableReleaseRdb() {\n return $scope.disableReleaseRdb;\n }\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/FullLinkHealthCheckCtl.ts?"); /***/ }), @@ -9463,7 +9463,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_diskTypes: {\n method: 'GET',\n url: '/console/keepercontainer/diskType',\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 get_all_available_zone_info_models_by_dc: {\n method: 'GET',\n url: '/console/az/dcs/tbl/:dcId',\n isArray: true\n },\n begin_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/begin'\n },\n migrate_keeper_task_terminate: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/terminate'\n },\n stop_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/stop'\n },\n reset_election: {\n method: 'POST',\n url: '/api/keepers/election/reset/:ip/:port/:shardId'\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 getAllAvailableZoneInfoModelsByDc(dcId) {\n var d = $q.defer();\n resource.get_all_available_zone_info_models_by_dc({\n dcId: dcId\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 getAllDiskTypes() {\n var d = $q.defer();\n resource.get_all_diskTypes({}, 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, diskType) {\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 diskType: diskType\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, diskType) {\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 diskType: diskType\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 function migrateKeeperTaskTerminate() {\n var d = $q.defer();\n resource.migrate_keeper_task_terminate({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function resetElection(ip, port, shardId) {\n var d = $q.defer();\n resource.reset_election({\n ip: ip,\n port: port,\n shardId: shardId\n }, 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 getAllAvailableZoneInfoModelsByDc: getAllAvailableZoneInfoModelsByDc,\n findAvailableKeepersByDcAzAndOrg: findAvailableKeepersByDcAzAndOrg,\n getAllInfos: getAllInfos,\n getAllOrganizations: getAllOrganizations,\n getAllDiskTypes: getAllDiskTypes,\n addKeepercontainer: addKeepercontainer,\n updateKeepercontainer: updateKeepercontainer,\n getAllOverloadKeepercontainer: getAllOverloadKeepercontainer,\n getAllKeepercontainerUsedInfo: getAllKeepercontainerUsedInfo,\n getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n beginToMigrateOverloadKeeperContainers: beginToMigrateOverloadKeeperContainers,\n migrateKeeperTaskTerminate: migrateKeeperTaskTerminate,\n resetElection: resetElection\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_diskTypes: {\n method: 'GET',\n url: '/console/keepercontainer/diskType',\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 get_all_available_zone_info_models_by_dc: {\n method: 'GET',\n url: '/console/az/dcs/tbl/:dcId',\n isArray: true\n },\n begin_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/begin'\n },\n migrate_keeper_task_terminate: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/terminate'\n },\n stop_to_migrate_overload_keepercontainer: {\n method: 'POST',\n url: '/console/keepercontainer/overload/migration/stop'\n },\n reset_election: {\n method: 'POST',\n url: '/api/keepers/election/reset/:ip/:port/:shardId'\n },\n release_rdb: {\n method: 'POST',\n url: '/api/keepers/release/rdb/:ip/:port/:shardId'\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 getAllAvailableZoneInfoModelsByDc(dcId) {\n var d = $q.defer();\n resource.get_all_available_zone_info_models_by_dc({\n dcId: dcId\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 getAllDiskTypes() {\n var d = $q.defer();\n resource.get_all_diskTypes({}, 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, diskType) {\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 diskType: diskType\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, diskType) {\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 diskType: diskType\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 function migrateKeeperTaskTerminate() {\n var d = $q.defer();\n resource.migrate_keeper_task_terminate({}, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function resetElection(ip, port, shardId) {\n var d = $q.defer();\n resource.reset_election({\n ip: ip,\n port: port,\n shardId: shardId\n }, function (result) {\n d.resolve(result);\n }, function (result) {\n d.reject(result);\n });\n return d.promise;\n }\n function releaseRdb(ip, port, shardId) {\n var d = $q.defer();\n resource.release_rdb({\n ip: ip,\n port: port,\n shardId: shardId\n }, 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 getAllAvailableZoneInfoModelsByDc: getAllAvailableZoneInfoModelsByDc,\n findAvailableKeepersByDcAzAndOrg: findAvailableKeepersByDcAzAndOrg,\n getAllInfos: getAllInfos,\n getAllOrganizations: getAllOrganizations,\n getAllDiskTypes: getAllDiskTypes,\n addKeepercontainer: addKeepercontainer,\n updateKeepercontainer: updateKeepercontainer,\n getAllOverloadKeepercontainer: getAllOverloadKeepercontainer,\n getAllKeepercontainerUsedInfo: getAllKeepercontainerUsedInfo,\n getOverloadKeeperContainerMigrationProcess: getOverloadKeeperContainerMigrationProcess,\n beginToMigrateOverloadKeeperContainers: beginToMigrateOverloadKeeperContainers,\n migrateKeeperTaskTerminate: migrateKeeperTaskTerminate,\n resetElection: resetElection,\n releaseRdb: releaseRdb\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/FullLinkHealthCheckCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/FullLinkHealthCheckCtl.ts index 8d27e0120a..765b883464 100644 --- a/redis/redis-console/src/main/resources/static/scripts/controllers/FullLinkHealthCheckCtl.ts +++ b/redis/redis-console/src/main/resources/static/scripts/controllers/FullLinkHealthCheckCtl.ts @@ -25,11 +25,16 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt $scope.doShowActions = doShowActions; $scope.getShardAllMeta = getShardAllMeta; $scope.getShardKeeperState = getShardKeeperState; + $scope.releaseRdb = releaseRdb; $scope.resetElection = resetElection; $scope.disableResetElection = false; + $scope.disableReleaseRdb = false; $scope.getDisableResetElection = getDisableResetElection; + $scope.getDisableReleaseRdb = getDisableReleaseRdb; $scope.resetElectionErr = null; + $scope.releaseRdbErr = null; $scope.getResetElectionErr = getResetElectionErr; + $scope.getReleaseRdbErr = getReleaseRdbErr; redisRoleHealthCheck(); shardCheckerGroupHealthCheck(); @@ -78,6 +83,30 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt }) } + let rdbTimer = null; + function releaseRdb(ip, port) { + $scope.disableReleaseRdb = true; + KeeperContainerService.releaseRdb(ip, port, $stateParams.shardId).then(function (response) { + if (response.state != 0) { + $scope.disableReleaseRdb = false; + $scope.releaseRdbErr = response.message; + $('#releaseRdbErr').modal('show'); + } else { + if (!rdbTimer) { + rdbTimer = setTimeout(() => { + clearTimeout(rdbTimer); + rdbTimer = null; + $scope.disableReleaseRdb = false; + }, 3000); + } + } + }).catch(function (error){ + $scope.disableReleaseRdb = false; + $scope.releaseRdbErr = "Status Code:" + error.status + " " + error.statusText + "\n" + error.data.exception; + $('#releaseRdbErr').modal('show'); + }) + } + let timer = null; function resetElection(ip, port) { $scope.disableResetElection = true; @@ -106,6 +135,10 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt return $scope.resetElectionErr; } + function getReleaseRdbErr() { + return $scope.releaseRdbErr; + } + function doShowActions() { $scope.showActions = !$scope.showActions; } @@ -114,4 +147,8 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt return $scope.disableResetElection; } + function getDisableReleaseRdb() { + return $scope.disableReleaseRdb; + } + } \ 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 13ae73947c..1e14554b18 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 @@ -80,6 +80,10 @@ angular reset_election:{ method:'POST', url:'/api/keepers/election/reset/:ip/:port/:shardId' + }, + release_rdb:{ + method:'POST', + url:'/api/keepers/release/rdb/:ip/:port/:shardId' } }); @@ -304,6 +308,21 @@ angular return d.promise; } + function releaseRdb(ip, port, shardId) { + var d = $q.defer(); + resource.release_rdb({ + ip:ip, + port:port, + shardId:shardId + }, + function (result) { + d.resolve(result); + }, function (result) { + d.reject(result); + }); + return d.promise; + } + return { findAvailableKeepersByDc : findAvailableKeepersByDc, findAvailableKeepersByDcAndCluster : findAvailableKeepersByDcAndCluster, @@ -320,6 +339,7 @@ angular getOverloadKeeperContainerMigrationProcess : getOverloadKeeperContainerMigrationProcess, beginToMigrateOverloadKeeperContainers : beginToMigrateOverloadKeeperContainers, migrateKeeperTaskTerminate : migrateKeeperTaskTerminate, - resetElection: resetElection + resetElection: resetElection, + releaseRdb: releaseRdb } }]); diff --git a/redis/redis-console/src/main/resources/static/views/index/full_link_health_check.html b/redis/redis-console/src/main/resources/static/views/index/full_link_health_check.html index 5baabe0215..90d2d92903 100644 --- a/redis/redis-console/src/main/resources/static/views/index/full_link_health_check.html +++ b/redis/redis-console/src/main/resources/static/views/index/full_link_health_check.html @@ -107,6 +107,9 @@ reset Election + + release rdb +
@@ -147,6 +150,10 @@ xpipe-detail="getResetElectionErr()" xpipe-show-cancel-btn="true"> + +
diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java index b4557eff3f..d44405b440 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java @@ -300,34 +300,6 @@ public void testUpdateKeeperContainerByInfoModel() { } - @Test - public void getAllKeepersTest() { - RestTemplate restTemplate = Mockito.mock(RestTemplate.class); - keeperContainerService.setRestTemplate(restTemplate); - ResponseEntity> response = Mockito.mock(ResponseEntity.class); - List list = new ArrayList<>(); - Mockito.when(response.getBody()).thenReturn(list); - Mockito.when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), Mockito.isNull(), Mockito.any(ParameterizedTypeReference.class))).thenReturn(response); - List allKeepers = keeperContainerService.getAllKeepers("keeperContainerIp"); - Assert.assertEquals(list, allKeepers); - } - - @Test - public void resetKeepersTest() { - KeeperTransMeta keeperInstanceMeta = new KeeperInstanceMeta(); - KeeperMeta meta = new KeeperMeta(); - meta.setIp(""); - keeperInstanceMeta.setKeeperMeta(meta); - RestTemplate restTemplate = Mockito.mock(RestTemplate.class); - keeperContainerService.setRestTemplate(restTemplate); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - - HttpEntity requestEntity = new HttpEntity<>(keeperInstanceMeta, headers); - Mockito.when(restTemplate.exchange(anyString(), eq(HttpMethod.POST), eq(requestEntity), eq(Void.class))).thenReturn(null); - keeperContainerService.resetKeeper(keeperInstanceMeta.getKeeperMeta().getIp(), keeperInstanceMeta.getReplId()); - } - @Test public void testUpdateKeeperContainerByInfoModelFail() { KeeperContainerInfoModel keeper = keeperContainerService.findKeeperContainerInfoModelById(30);