use of com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO in project XHuiCloud by sindaZeng.
the class ClusterEntityUtils method wrapToAppClusterClientState.
public static List<AppClusterClientStateWrapVO> wrapToAppClusterClientState(List<ClusterUniversalStatePairVO> list) {
if (list == null || list.isEmpty()) {
return new ArrayList<>();
}
Map<String, AppClusterClientStateWrapVO> map = new HashMap<>();
for (ClusterUniversalStatePairVO stateVO : list) {
int mode = stateVO.getState().getStateInfo().getMode();
if (mode == ClusterStateManager.CLUSTER_CLIENT) {
String ip = stateVO.getIp();
String clientId = ip + '@' + stateVO.getCommandPort();
ClusterClientStateVO clientStateVO = stateVO.getState().getClient();
map.computeIfAbsent(clientId, v -> new AppClusterClientStateWrapVO().setId(clientId).setIp(ip).setState(clientStateVO).setCommandPort(stateVO.getCommandPort()));
}
}
return new ArrayList<>(map.values());
}
use of com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO 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());
}
Aggregations