Skip to content

Commit

Permalink
replBacklogSize正确展示,loadingrdb状态正确展示
Browse files Browse the repository at this point in the history
  • Loading branch information
yifuzhou committed Aug 8, 2024
1 parent 5032c49 commit 6c1b59c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
import com.ctrip.xpipe.redis.core.meta.MetaCache;
import com.ctrip.xpipe.redis.core.protocal.pojo.AbstractRole;
import com.ctrip.xpipe.redis.core.protocal.pojo.Role;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.*;


@Component
Expand All @@ -42,31 +38,32 @@ public CommandFuture<Role> getRedisRole(String ip, int port, RedisSession.RollCa
@Override
public List<RedisRoleModel> getShardAllRedisRole(String dcId, String clusterId, String shardId) {
List<RedisMeta> redisOfDcClusterShard = metaCache.getRedisOfDcClusterShard(dcId, clusterId, shardId);
List<RedisRoleModel> models = new CopyOnWriteArrayList<>();
Map<HostPort, RedisRoleModel> models = new ConcurrentHashMap<>();
Map<HostPort, CommandFuture<Role>> futureMap = new HashMap<>();
redisOfDcClusterShard.forEach(redisMeta -> {
HostPort redis = new HostPort(redisMeta.getIp(), redisMeta.getPort());
CommandFuture<Role> redisRole = getRedisRole(redisMeta.getIp(), redisMeta.getPort(), new RedisSession.RollCallback() {
@Override
public void role(String role, Role detail) {
models.add(new RedisRoleModel(redisMeta.getIp(), redisMeta.getPort(), (AbstractRole) detail));
models.put(redis, new RedisRoleModel(redisMeta.getIp(), redisMeta.getPort(), (AbstractRole) detail));
}

@Override
public void fail(Throwable e) {
models.add(new RedisRoleModel(redisMeta.getIp(), redisMeta.getPort(),e));
models.put(redis, new RedisRoleModel(redisMeta.getIp(), redisMeta.getPort(),e));
}
});
futureMap.put(new HostPort(redisMeta.getIp(), redisMeta.getPort()), redisRole);
futureMap.put(redis, redisRole);
});

for (Map.Entry<HostPort, CommandFuture<Role>> entry : futureMap.entrySet()) {
try {
entry.getValue().get();
} catch (InterruptedException | ExecutionException e) {
models.add(new RedisRoleModel(entry.getKey().getHost(), entry.getKey().getPort(), e));
models.put(entry.getKey(), new RedisRoleModel(entry.getKey().getHost(), entry.getKey().getPort(), e));
}
}
return models;
return new ArrayList<>(models.values());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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',\n 'toastr', 'NgTableParams', 'AppUtil', '$interval'];\nfunction FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, HealthCheckService, toastr, NgTableParams, $interval) {\n $scope.masterRoles = [];\n $scope.slaveRoles = [];\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 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 response.forEach(function (item) {\n if (item.role.serverRole == \"SLAVE\") {\n $scope.slaveRoles.push(item);\n }\n else {\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 function doShowActions() {\n $scope.showActions = !$scope.showActions;\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',\n 'toastr', 'NgTableParams', 'AppUtil', '$interval'];\nfunction FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, HealthCheckService, 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 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 function doShowActions() {\n $scope.showActions = !$scope.showActions;\n }\n}\n\n\n//# sourceURL=webpack://XPipe-Console/./scripts/controllers/FullLinkHealthCheckCtl.ts?");

/***/ }),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt
toastr, NgTableParams, $interval) {
$scope.masterRoles = [];
$scope.slaveRoles = [];
$scope.unknownRoles = [];
$scope.shardCheckerHealthCheckResult = [];
$scope.showActions=false;
$scope.shardAllMeta = null;
Expand All @@ -34,10 +35,13 @@ function FullLinkHealthCheckCtl($rootScope, $scope, $window, $stateParams, Healt
HealthCheckService.getShardRedisRole($stateParams.currentDcName, $stateParams.clusterName, $stateParams.shardName).then(function (response) {
$scope.masterRoles = [];
$scope.slaveRoles = [];
$scope.unknownRoles = [];
response.forEach(function (item){
if (item.role.serverRole == "SLAVE") {
if (item.role == null) {
$scope.unknownRoles.push(item)
}else if (item.role.serverRole == "SLAVE") {
$scope.slaveRoles.push(item);
} else {
} else if (item.role.serverRole == "MASTER") {
$scope.masterRoles.push(item);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
</md-card-content>
</md-card>
</div>
<div ng-repeat="redis in unknownRoles">
<md-card md-theme="orange" md-theme-watch>
<md-card-title class="custom-card">
<md-card-title-text class="centered-text">
<div ng-show="showErrMsg" class="md-body-1" style="width: 100%; display: inline-block; word-break: break-all;">{{redis.err}}</div>
<div style="white-space: nowrap;">
<span>{{redis.host}}:{{redis.port}}</span>
</div>
</md-card-title-text>
</md-card-title>
</md-card>
</div>
</md-card-content>
</md-card>
<!--Keeper-->
Expand Down Expand Up @@ -104,7 +116,7 @@
</div>
<div style="white-space: nowrap;">
<span>replBacklogSize:</span>
<span style="margin-left: 20px;">{{keeper.replBacklogSize/1024/1024 | number:2}}G</span>
<span style="margin-left: 20px;">{{keeper.replBacklogSize/1024/1024/1024 | number:2}}G</span>
</div>
<div ng-repeat="keeperSlave in keeper.slaves">
<md-card md-theme="default" md-theme-watch>
Expand Down

0 comments on commit 6c1b59c

Please sign in to comment.