use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity in project spring-boot-student by wyh-spring-ecosystem-student.
the class ClusterEntityUtils method wrapToClusterGroup.
public static List<ClusterGroupEntity> wrapToClusterGroup(List<ClusterUniversalStatePairVO> list) {
if (list == null || list.isEmpty()) {
return new ArrayList<>();
}
Map<String, ClusterGroupEntity> map = new HashMap<>();
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_SERVER) {
String serverAddress = getIp(ip);
int port = stateVO.getState().getServer().getPort();
map.computeIfAbsent(serverAddress, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(ip + '@' + stateVO.getCommandPort()).setIp(ip).setPort(port));
}
}
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_CLIENT) {
String targetServer = stateVO.getState().getClient().getClientConfig().getServerHost();
Integer targetPort = stateVO.getState().getClient().getClientConfig().getServerPort();
if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) {
continue;
}
ClusterGroupEntity group = map.computeIfAbsent(targetServer, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(targetServer).setIp(targetServer).setPort(targetPort));
group.getClientSet().add(ip + '@' + stateVO.getCommandPort());
}
}
return new ArrayList<>(map.values());
}
use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity in project XHuiCloud by sindaZeng.
the class ClusterAssignServiceImpl method unbindClusterServer.
@Override
public ClusterAppAssignResultVO unbindClusterServer(String app, String machineId) {
AssertUtil.assertNotBlank(app, "app cannot be blank");
AssertUtil.assertNotBlank(machineId, "machineId cannot be blank");
if (isMachineInApp(machineId)) {
return handleUnbindClusterServerNotInApp(app, machineId);
}
Set<String> failedSet = new HashSet<>();
try {
ClusterGroupEntity entity = clusterConfigService.getClusterUniversalStateForAppMachine(app, machineId).get(10, TimeUnit.SECONDS);
Set<String> toModifySet = new HashSet<>();
toModifySet.add(machineId);
if (entity.getClientSet() != null) {
toModifySet.addAll(entity.getClientSet());
}
// Modify mode to NOT-STARTED for all chosen token servers and associated token clients.
modifyToNonStarted(toModifySet, failedSet);
} catch (Exception ex) {
Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex;
LOGGER.error("Failed to unbind machine <{}>", machineId, e);
failedSet.add(machineId);
}
return new ClusterAppAssignResultVO().setFailedClientSet(failedSet).setFailedServerSet(new HashSet<>());
}
use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity in project XHuiCloud by sindaZeng.
the class ClusterEntityUtils method wrapToClusterGroup.
public static List<ClusterGroupEntity> wrapToClusterGroup(List<ClusterUniversalStatePairVO> list) {
if (list == null || list.isEmpty()) {
return new ArrayList<>();
}
Map<String, ClusterGroupEntity> map = new HashMap<>();
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_SERVER) {
String serverAddress = getIp(ip);
int port = stateVO.getState().getServer().getPort();
map.computeIfAbsent(serverAddress, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(ip + '@' + stateVO.getCommandPort()).setIp(ip).setPort(port));
}
}
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_CLIENT) {
String targetServer = stateVO.getState().getClient().getClientConfig().getServerHost();
Integer targetPort = stateVO.getState().getClient().getClientConfig().getServerPort();
if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) {
continue;
}
ClusterGroupEntity group = map.computeIfAbsent(targetServer, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(targetServer).setIp(targetServer).setPort(targetPort));
group.getClientSet().add(ip + '@' + stateVO.getCommandPort());
}
}
return new ArrayList<>(map.values());
}
use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity in project RuoYi-Cloud-Plus by JavaLionLi.
the class ClusterEntityUtils method wrapToClusterGroup.
public static List<ClusterGroupEntity> wrapToClusterGroup(List<ClusterUniversalStatePairVO> list) {
if (list == null || list.isEmpty()) {
return new ArrayList<>();
}
Map<String, ClusterGroupEntity> map = new HashMap<>();
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_SERVER) {
String serverAddress = getIp(ip);
int port = stateVO.getState().getServer().getPort();
String targetAddress = serverAddress + ":" + port;
map.computeIfAbsent(targetAddress, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(ip + '@' + stateVO.getCommandPort()).setIp(ip).setPort(port));
}
}
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
String ip = stateVO.getIp();
if (mode == ClusterStateManager.CLUSTER_CLIENT) {
String targetServer = stateVO.getState().getClient().getClientConfig().getServerHost();
Integer targetPort = stateVO.getState().getClient().getClientConfig().getServerPort();
if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) {
continue;
}
String targetAddress = targetServer + ":" + targetPort;
ClusterGroupEntity group = map.computeIfAbsent(targetAddress, v -> new ClusterGroupEntity().setBelongToApp(true).setMachineId(targetServer).setIp(targetServer).setPort(targetPort));
group.getClientSet().add(ip + '@' + stateVO.getCommandPort());
}
}
return new ArrayList<>(map.values());
}
use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity in project RuoYi-Cloud-Plus by JavaLionLi.
the class ClusterAssignServiceImpl method unbindClusterServer.
@Override
public ClusterAppAssignResultVO unbindClusterServer(String app, String machineId) {
AssertUtil.assertNotBlank(app, "app cannot be blank");
AssertUtil.assertNotBlank(machineId, "machineId cannot be blank");
if (isMachineInApp(machineId)) {
return handleUnbindClusterServerNotInApp(app, machineId);
}
Set<String> failedSet = new HashSet<>();
try {
ClusterGroupEntity entity = clusterConfigService.getClusterUniversalStateForAppMachine(app, machineId).get(10, TimeUnit.SECONDS);
Set<String> toModifySet = new HashSet<>();
toModifySet.add(machineId);
if (entity.getClientSet() != null) {
toModifySet.addAll(entity.getClientSet());
}
// Modify mode to NOT-STARTED for all chosen token servers and associated token clients.
modifyToNonStarted(toModifySet, failedSet);
} catch (Exception ex) {
Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex;
LOGGER.error("Failed to unbind machine <{}>", machineId, e);
failedSet.add(machineId);
}
return new ClusterAppAssignResultVO().setFailedClientSet(failedSet).setFailedServerSet(new HashSet<>());
}
Aggregations