From 158358fcd81ea7be5500c94e9526e214501b1299 Mon Sep 17 00:00:00 2001 From: yifuzhou Date: Tue, 17 Dec 2024 17:04:52 +0800 Subject: [PATCH] allow migration cross region requested from xpipe-console --- redis/redis-console/src/main/resources/static/dist/bundle.js | 2 +- .../static/scripts/controllers/ActiveDcMigrationIndexCtl.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 42750e69fa..1560f5348d 100644 --- a/redis/redis-console/src/main/resources/static/dist/bundle.js +++ b/redis/redis-console/src/main/resources/static/dist/bundle.js @@ -9013,7 +9013,7 @@ eval("angular\n .module('index')\n .controller('ActiveDcMigrationEventList \**********************************************************/ /***/ (() => { -eval("angular\n .module('index')\n .controller('ActiveDcMigrationIndexCtl', ActiveDcMigrationIndexCtl);\nActiveDcMigrationIndexCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', '$interval', 'AppUtil',\n 'toastr', 'NgTableParams', 'ClusterService', 'DcService', 'MigrationService', 'ClusterType'];\nfunction ActiveDcMigrationIndexCtl($rootScope, $scope, $window, $stateParams, $interval, AppUtil, toastr, NgTableParams, ClusterService, DcService, MigrationService, ClusterType) {\n $scope.sourceDcSelected = sourceDcSelected;\n $scope.targetDcSelected = targetDcSelected;\n $scope.availableTargetDcs = availableTargetDcs;\n $scope.preMigrate = preMigrate;\n $scope.doMigrate = doMigrate;\n $scope.clusterOrgNameSelected = clusterOrgNameSelected;\n $scope.getMasterUnhealthyClusters = getMasterUnhealthyClusters;\n $scope.migrationSysCheckResp = {};\n $scope.enableMigrationButton = false;\n init();\n var SUCCESS_STATE = 0;\n var WARNING_STATE = 1;\n function init() {\n checkMigrationSystem();\n DcService.loadAllDcs().then(function (data) {\n $scope.dcs = data;\n ClusterService.getInvolvedOrgs().then(function (result) {\n $scope.organizations = result;\n $scope.organizations.push({ \"orgName\": \"不选择\" });\n });\n if (!!$stateParams.clusters && $stateParams.clusters.length > 0) {\n showClusters($stateParams.clusters);\n }\n else if ($stateParams.clusterName != undefined) {\n ClusterService.load_cluster($stateParams.clusterName).then(showCluster);\n }\n else {\n MigrationService.getDefaultMigrationCluster().then(showCluster);\n }\n });\n intervalRetriveInfo();\n }\n function focusDcByCluster(cluster) {\n $scope.sourceDcInfo = $scope.dcs.filter(function (dcInfo) {\n return dcInfo.id === cluster.activedcId;\n })[0];\n }\n function showCluster(cluster) {\n showClusters([cluster]);\n }\n function showClusters(clusters) {\n if (!clusters || clusters.length == 0)\n return;\n focusDcByCluster(clusters[0]);\n var clusterNames = clusters.map(function (c) { return c.clusterName; });\n ClusterService.findClustersByNames.apply(ClusterService, clusterNames).then(function (result) {\n $scope.clusters = result.filter(function (c) { return ClusterType.lookup(c.clusterType).supportMigration && !!c.activedcId && !!$scope.sourceDcInfo && c.activedcId == $scope.sourceDcInfo.id; });\n $scope.tableParams.reload();\n });\n }\n $scope.$on('$destroy', function () {\n $interval.cancel($scope.scheduledWork);\n });\n $scope.scheduledWork;\n function intervalRetriveInfo() {\n $scope.scheduledWork = $interval(checkMigrationSystem, 1500);\n }\n function checkMigrationSystem() {\n MigrationService.checkMigrationSystem().then(function (value) {\n $scope.migrationSysCheckResp = value;\n if (value.state === SUCCESS_STATE) {\n $scope.enableMigrationButton = true;\n $scope.migrationSysCheckResp.success = true;\n }\n else if (value.state === WARNING_STATE) {\n $scope.enableMigrationButton = true;\n $scope.migrationSysCheckResp.warning = true;\n }\n else {\n $scope.enableMigrationButton = false;\n $scope.migrationSysCheckResp.error = true;\n }\n });\n }\n $scope.showErrorMessage = function () {\n if ($scope.migrationSysCheckResp.message) {\n $('#errorMessage').modal('show');\n }\n };\n $scope.hideErrorMessage = function () {\n $scope.migrationSysCheckResp.message = '';\n $('#errorMessage').modal('hide');\n };\n $scope.clusterOrgName = '';\n function clusterOrgNameSelected() {\n var dcName = $scope.sourceDc;\n if (dcName) {\n sourceDcSelected();\n }\n }\n $scope.masterUnhealthyClusters = [];\n $scope.masterUnhealthyClusterStateLevels = [\n { \"name\": \"至少一个Master不可用\", \"level\": \"LEAST_ONE_DOWN\" },\n { \"name\": \"25%以上Master不可用\", \"level\": \"QUARTER_DOWN\" },\n { \"name\": \"50%以上Master不可用\", \"level\": \"HALF_DOWN\" },\n { \"name\": \"75%以上Master不可用\", \"level\": \"THREE_QUARTER_DOWN\" },\n { \"name\": \"100%Master不可用\", \"level\": \"FULL_DOWN\" },\n { \"name\": \"不选\", \"level\": \"NORMAL\" }\n ];\n $scope.masterUnhealthyClusterState = '';\n function getMasterUnhealthyClusters() {\n var level = $scope.masterUnhealthyClusterState;\n if (level && level !== \"NORMAL\") {\n ClusterService.getMasterUnhealthyClusters(level)\n .then(function (targetClusters) {\n $scope.masterUnhealthyClusters = targetClusters;\n if ($scope.sourceDc) {\n sourceDcSelected();\n }\n });\n }\n else if (level === \"NORMAL\") {\n $scope.masterUnhealthyClusters = [];\n if ($scope.sourceDc) {\n sourceDcSelected();\n }\n }\n }\n function sourceDcSelected() {\n var dcName = $scope.sourceDc;\n var orgName = $scope.clusterOrgName;\n var clusterNameFilter = $scope.masterUnhealthyClusters;\n var level = $scope.masterUnhealthyClusterState;\n $scope.sourceDcInfo = $scope.dcs.filter(function (dcInfo) {\n return dcInfo.dcName === dcName;\n })[0];\n ClusterService.findClustersByActiveDcName(dcName).then(function (data) {\n var result = data;\n if (orgName && orgName !== \"不选择\") {\n result = result.filter(function (localCluster) {\n return localCluster.clusterOrgName === orgName;\n });\n }\n if (level && level !== \"NORMAL\") {\n result = result.filter(function (localCluster) {\n return clusterNameFilter.includes(localCluster.clusterName);\n });\n }\n $scope.clusters = result.filter(function (c) { return ClusterType.lookup(c.clusterType).supportMigration; });\n $scope.tableParams.reload();\n });\n }\n function targetDcSelected(cluster) {\n if (cluster.targetDc == \"-\") {\n cluster.selected = false;\n }\n else {\n cluster.selected = true;\n }\n }\n function availableTargetDcs(cluster) {\n var dcs = [];\n cluster.dcClusterInfo.forEach(function (dcCluster) {\n if (dcCluster.dcInfo.dcName !== $scope.sourceDcInfo.dcName && dcCluster.dcInfo.zoneId === $scope.sourceDcInfo.zoneId) {\n dcs.push(dcCluster.dcInfo);\n }\n });\n return dcs;\n }\n function preMigrate() {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n var targetedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected && (cluster.targetDc !== \"-\");\n });\n if (!(selectedClusters.length === targetedClusters.length)) {\n $('#createEventWithLostConfirm').modal('show');\n }\n else {\n doMigrate();\n }\n }\n function doMigrate() {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected && (cluster.targetDc !== \"-\");\n });\n var migrationClusters = [];\n selectedClusters.forEach(function (cluster) {\n migrationClusters.push({\n clusterId: cluster.id,\n sourceDcId: cluster.activedcId,\n destinationDcId: getDcId(cluster.targetDc),\n cluster: cluster,\n });\n });\n MigrationService.createEvent(migrationClusters)\n .then(function (result) {\n $('#createEventWithLostConfirm').modal('hide');\n toastr.success('创建成功');\n $window.location.href = '/#/migration_event_details/' + result.value;\n }, function (result) {\n toastr.error(AppUtil.errorMsg(result), '创建失败');\n });\n }\n function getDcId(destinationDc) {\n var res = -1;\n $scope.dcs.forEach(function (dc) {\n if (dc.dcName === destinationDc) {\n res = dc.id;\n }\n });\n return res;\n }\n $scope.sourceDc = '';\n $scope.clusters = [];\n $scope.sourceDcInfo = {};\n $scope.toggle = function (cluster) {\n cluster.selected = !cluster.selected;\n };\n $scope.isIndeterminate = function () {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n return (selectedClusters.length !== $scope.clusters.length) &&\n (selectedClusters.length > 0);\n };\n $scope.isChecked = function () {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n return (selectedClusters.length === $scope.clusters.length) &&\n (selectedClusters.length !== 0);\n };\n $scope.toggleAll = function () {\n if ($scope.isIndeterminate()) {\n $scope.clusters.forEach(function (cluster) {\n cluster.selected = true;\n });\n }\n else {\n $scope.clusters.forEach(function (cluster) {\n cluster.selected = !cluster.selected;\n });\n }\n };\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10\n }, {\n filterDelay: 100,\n getData: function (params) {\n // TODO [marsqing] paging control\n // params.total(1);\n return $scope.clusters;\n }\n });\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/ActiveDcMigrationIndexCtl.ts?"); +eval("angular\n .module('index')\n .controller('ActiveDcMigrationIndexCtl', ActiveDcMigrationIndexCtl);\nActiveDcMigrationIndexCtl.$inject = ['$rootScope', '$scope', '$window', '$stateParams', '$interval', 'AppUtil',\n 'toastr', 'NgTableParams', 'ClusterService', 'DcService', 'MigrationService', 'ClusterType'];\nfunction ActiveDcMigrationIndexCtl($rootScope, $scope, $window, $stateParams, $interval, AppUtil, toastr, NgTableParams, ClusterService, DcService, MigrationService, ClusterType) {\n $scope.sourceDcSelected = sourceDcSelected;\n $scope.targetDcSelected = targetDcSelected;\n $scope.availableTargetDcs = availableTargetDcs;\n $scope.preMigrate = preMigrate;\n $scope.doMigrate = doMigrate;\n $scope.clusterOrgNameSelected = clusterOrgNameSelected;\n $scope.getMasterUnhealthyClusters = getMasterUnhealthyClusters;\n $scope.migrationSysCheckResp = {};\n $scope.enableMigrationButton = false;\n init();\n var SUCCESS_STATE = 0;\n var WARNING_STATE = 1;\n function init() {\n checkMigrationSystem();\n DcService.loadAllDcs().then(function (data) {\n $scope.dcs = data;\n ClusterService.getInvolvedOrgs().then(function (result) {\n $scope.organizations = result;\n $scope.organizations.push({ \"orgName\": \"不选择\" });\n });\n if (!!$stateParams.clusters && $stateParams.clusters.length > 0) {\n showClusters($stateParams.clusters);\n }\n else if ($stateParams.clusterName != undefined) {\n ClusterService.load_cluster($stateParams.clusterName).then(showCluster);\n }\n else {\n MigrationService.getDefaultMigrationCluster().then(showCluster);\n }\n });\n intervalRetriveInfo();\n }\n function focusDcByCluster(cluster) {\n $scope.sourceDcInfo = $scope.dcs.filter(function (dcInfo) {\n return dcInfo.id === cluster.activedcId;\n })[0];\n }\n function showCluster(cluster) {\n showClusters([cluster]);\n }\n function showClusters(clusters) {\n if (!clusters || clusters.length == 0)\n return;\n focusDcByCluster(clusters[0]);\n var clusterNames = clusters.map(function (c) { return c.clusterName; });\n ClusterService.findClustersByNames.apply(ClusterService, clusterNames).then(function (result) {\n $scope.clusters = result.filter(function (c) { return ClusterType.lookup(c.clusterType).supportMigration && !!c.activedcId && !!$scope.sourceDcInfo && c.activedcId == $scope.sourceDcInfo.id; });\n $scope.tableParams.reload();\n });\n }\n $scope.$on('$destroy', function () {\n $interval.cancel($scope.scheduledWork);\n });\n $scope.scheduledWork;\n function intervalRetriveInfo() {\n $scope.scheduledWork = $interval(checkMigrationSystem, 1500);\n }\n function checkMigrationSystem() {\n MigrationService.checkMigrationSystem().then(function (value) {\n $scope.migrationSysCheckResp = value;\n if (value.state === SUCCESS_STATE) {\n $scope.enableMigrationButton = true;\n $scope.migrationSysCheckResp.success = true;\n }\n else if (value.state === WARNING_STATE) {\n $scope.enableMigrationButton = true;\n $scope.migrationSysCheckResp.warning = true;\n }\n else {\n $scope.enableMigrationButton = false;\n $scope.migrationSysCheckResp.error = true;\n }\n });\n }\n $scope.showErrorMessage = function () {\n if ($scope.migrationSysCheckResp.message) {\n $('#errorMessage').modal('show');\n }\n };\n $scope.hideErrorMessage = function () {\n $scope.migrationSysCheckResp.message = '';\n $('#errorMessage').modal('hide');\n };\n $scope.clusterOrgName = '';\n function clusterOrgNameSelected() {\n var dcName = $scope.sourceDc;\n if (dcName) {\n sourceDcSelected();\n }\n }\n $scope.masterUnhealthyClusters = [];\n $scope.masterUnhealthyClusterStateLevels = [\n { \"name\": \"至少一个Master不可用\", \"level\": \"LEAST_ONE_DOWN\" },\n { \"name\": \"25%以上Master不可用\", \"level\": \"QUARTER_DOWN\" },\n { \"name\": \"50%以上Master不可用\", \"level\": \"HALF_DOWN\" },\n { \"name\": \"75%以上Master不可用\", \"level\": \"THREE_QUARTER_DOWN\" },\n { \"name\": \"100%Master不可用\", \"level\": \"FULL_DOWN\" },\n { \"name\": \"不选\", \"level\": \"NORMAL\" }\n ];\n $scope.masterUnhealthyClusterState = '';\n function getMasterUnhealthyClusters() {\n var level = $scope.masterUnhealthyClusterState;\n if (level && level !== \"NORMAL\") {\n ClusterService.getMasterUnhealthyClusters(level)\n .then(function (targetClusters) {\n $scope.masterUnhealthyClusters = targetClusters;\n if ($scope.sourceDc) {\n sourceDcSelected();\n }\n });\n }\n else if (level === \"NORMAL\") {\n $scope.masterUnhealthyClusters = [];\n if ($scope.sourceDc) {\n sourceDcSelected();\n }\n }\n }\n function sourceDcSelected() {\n var dcName = $scope.sourceDc;\n var orgName = $scope.clusterOrgName;\n var clusterNameFilter = $scope.masterUnhealthyClusters;\n var level = $scope.masterUnhealthyClusterState;\n $scope.sourceDcInfo = $scope.dcs.filter(function (dcInfo) {\n return dcInfo.dcName === dcName;\n })[0];\n ClusterService.findClustersByActiveDcName(dcName).then(function (data) {\n var result = data;\n if (orgName && orgName !== \"不选择\") {\n result = result.filter(function (localCluster) {\n return localCluster.clusterOrgName === orgName;\n });\n }\n if (level && level !== \"NORMAL\") {\n result = result.filter(function (localCluster) {\n return clusterNameFilter.includes(localCluster.clusterName);\n });\n }\n $scope.clusters = result.filter(function (c) { return ClusterType.lookup(c.clusterType).supportMigration; });\n $scope.tableParams.reload();\n });\n }\n function targetDcSelected(cluster) {\n if (cluster.targetDc == \"-\") {\n cluster.selected = false;\n }\n else {\n cluster.selected = true;\n }\n }\n function availableTargetDcs(cluster) {\n var dcs = [];\n cluster.dcClusterInfo.forEach(function (dcCluster) {\n if (dcCluster.dcInfo.dcName !== $scope.sourceDcInfo.dcName) {\n dcs.push(dcCluster.dcInfo);\n }\n });\n return dcs;\n }\n function preMigrate() {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n var targetedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected && (cluster.targetDc !== \"-\");\n });\n if (!(selectedClusters.length === targetedClusters.length)) {\n $('#createEventWithLostConfirm').modal('show');\n }\n else {\n doMigrate();\n }\n }\n function doMigrate() {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected && (cluster.targetDc !== \"-\");\n });\n var migrationClusters = [];\n selectedClusters.forEach(function (cluster) {\n migrationClusters.push({\n clusterId: cluster.id,\n sourceDcId: cluster.activedcId,\n destinationDcId: getDcId(cluster.targetDc),\n cluster: cluster,\n });\n });\n MigrationService.createEvent(migrationClusters)\n .then(function (result) {\n $('#createEventWithLostConfirm').modal('hide');\n toastr.success('创建成功');\n $window.location.href = '/#/migration_event_details/' + result.value;\n }, function (result) {\n toastr.error(AppUtil.errorMsg(result), '创建失败');\n });\n }\n function getDcId(destinationDc) {\n var res = -1;\n $scope.dcs.forEach(function (dc) {\n if (dc.dcName === destinationDc) {\n res = dc.id;\n }\n });\n return res;\n }\n $scope.sourceDc = '';\n $scope.clusters = [];\n $scope.sourceDcInfo = {};\n $scope.toggle = function (cluster) {\n cluster.selected = !cluster.selected;\n };\n $scope.isIndeterminate = function () {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n return (selectedClusters.length !== $scope.clusters.length) &&\n (selectedClusters.length > 0);\n };\n $scope.isChecked = function () {\n var selectedClusters = $scope.clusters.filter(function (cluster) {\n return cluster.selected;\n });\n return (selectedClusters.length === $scope.clusters.length) &&\n (selectedClusters.length !== 0);\n };\n $scope.toggleAll = function () {\n if ($scope.isIndeterminate()) {\n $scope.clusters.forEach(function (cluster) {\n cluster.selected = true;\n });\n }\n else {\n $scope.clusters.forEach(function (cluster) {\n cluster.selected = !cluster.selected;\n });\n }\n };\n $scope.tableParams = new NgTableParams({\n page: 1,\n count: 10\n }, {\n filterDelay: 100,\n getData: function (params) {\n // TODO [marsqing] paging control\n // params.total(1);\n return $scope.clusters;\n }\n });\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/ActiveDcMigrationIndexCtl.ts?"); /***/ }), diff --git a/redis/redis-console/src/main/resources/static/scripts/controllers/ActiveDcMigrationIndexCtl.ts b/redis/redis-console/src/main/resources/static/scripts/controllers/ActiveDcMigrationIndexCtl.ts index 4041075dc0..492a6b500e 100644 --- a/redis/redis-console/src/main/resources/static/scripts/controllers/ActiveDcMigrationIndexCtl.ts +++ b/redis/redis-console/src/main/resources/static/scripts/controllers/ActiveDcMigrationIndexCtl.ts @@ -175,7 +175,7 @@ function ActiveDcMigrationIndexCtl($rootScope, $scope, $window, $stateParams, $i var dcs = []; cluster.dcClusterInfo.forEach(function(dcCluster) { - if(dcCluster.dcInfo.dcName !== $scope.sourceDcInfo.dcName && dcCluster.dcInfo.zoneId === $scope.sourceDcInfo.zoneId) { + if(dcCluster.dcInfo.dcName !== $scope.sourceDcInfo.dcName) { dcs.push(dcCluster.dcInfo); } });