|
|
@@ -1,5 +1,7 @@
|
|
|
package com.sig.comm.server.controller;
|
|
|
|
|
|
+import com.its.common.cluster.vo.ClusterNET;
|
|
|
+import com.its.common.cluster.vo.ClusterNode;
|
|
|
import com.its.common.utils.TimeUtils;
|
|
|
import com.sig.comm.server.cluster.ClusterConfig;
|
|
|
import com.sig.comm.server.config.ApplicationConfig;
|
|
|
@@ -18,21 +20,22 @@ import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@RequiredArgsConstructor
|
|
|
-@RequestMapping("/info")
|
|
|
+@RequestMapping("")
|
|
|
public class SigCommServerRestController {
|
|
|
|
|
|
private final ApplicationConfig config;
|
|
|
private final ClusterConfig clusterConfig;
|
|
|
private final ApplicationRepository repo;
|
|
|
|
|
|
- @GetMapping(value = "", produces = {"application/json; charset=utf8"})
|
|
|
- public String info() {
|
|
|
+ @GetMapping(value = "/info", produces = {"application/json; charset=utf8"})
|
|
|
+ public String infoString() {
|
|
|
String sep = System.lineSeparator();
|
|
|
String heading = "-------------------------------------------------------------------------------------------------------------------------------------";
|
|
|
|
|
|
RegionCenter center = ApplicationRepository.center;
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
|
sb.append("UTIC Local Signal Communication Server").append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
|
@@ -42,11 +45,44 @@ public class SigCommServerRestController {
|
|
|
sb.append(String.format("%s, %s",
|
|
|
center.getRegionCd(), center.getIpAddress())).append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
|
+
|
|
|
+ // Cluster running information
|
|
|
+ int ii = 1;
|
|
|
+ if (this.clusterConfig.isEnabled()) {
|
|
|
+ List<Integer> clusterIds = new ArrayList<>(this.clusterConfig.getClusterMap().keySet());
|
|
|
+ Collections.sort(clusterIds);
|
|
|
+
|
|
|
+ sb.append(sep);
|
|
|
+ sb.append(heading).append(sep);
|
|
|
+ sb.append(String.format("Cluster Running Information: clusterNodeId: %d, %d EA", this.clusterConfig.getId(), this.clusterConfig.getClusterMap().size())).append(sep);
|
|
|
+ sb.append(heading).append(sep);
|
|
|
+ sb.append("SEQ nodeId IP Address Port isMaster masterNet syncNet lastSyncRecvTime lastSyncSendTime").append(sep);
|
|
|
+ sb.append(heading).append(sep);
|
|
|
+
|
|
|
+ for (Integer clusterId : clusterIds) {
|
|
|
+ ClusterNode clusterNode = this.clusterConfig.getClusterMap().get(clusterId);
|
|
|
+ sb.append(String.format("%3d %6.6s %-15.15s %-7.7s %-8.8s %-9.9s %-7.7s %s %s",
|
|
|
+ ii++,
|
|
|
+ this.clusterConfig.getId() == clusterNode.getId() ? "*"+clusterNode.getId() : ""+clusterNode.getId(),
|
|
|
+ clusterNode.getIp(),
|
|
|
+ ""+clusterNode.getPort(),
|
|
|
+ clusterNode.isMaster(),
|
|
|
+ clusterNode.getElectionState().getState() != ClusterNET.CLOSED ? "Up" : "Down",
|
|
|
+ clusterNode.getSyncState().getState() != ClusterNET.CLOSED ? "Up" : "Down",
|
|
|
+ clusterNode.getSyncState().getLastRecvTimeString(),
|
|
|
+ clusterNode.getSyncState().getLastSendTimeString()
|
|
|
+ )).append(sep);
|
|
|
+ }
|
|
|
+ sb.append(heading).append(sep);
|
|
|
+ }
|
|
|
+
|
|
|
+ sb.append(sep);
|
|
|
+ sb.append(heading).append(sep);
|
|
|
sb.append("SEQ REGION IP Address Network Connect Time Disconnect Time Last Comm Time Connected [TOD] Center Name").append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
|
int total = 0;
|
|
|
int onLine = 0;
|
|
|
- int ii = 1;
|
|
|
+ ii = 1;
|
|
|
List<String> keySet = new ArrayList<>(this.repo.getCenterMap().keySet());
|
|
|
Collections.sort(keySet);
|
|
|
DecimalFormat dF = new DecimalFormat("#,###");
|
|
|
@@ -62,7 +98,7 @@ public class SigCommServerRestController {
|
|
|
onLine++;
|
|
|
}
|
|
|
String tod = region.isSimulateFlag() ? " YES " : " NO ";
|
|
|
- sb.append(String.format("%3d %-6.6s %-15.15s %-8.8s %-20.20s %-20.20s %-20.20s %9s %s %s",
|
|
|
+ sb.append(String.format("%3d %6.6s %-15.15s %-8.8s %-20.20s %-20.20s %-20.20s %9s %s %s",
|
|
|
ii++,
|
|
|
region.getRegionCd(), region.getIpAddress(), commStatus,
|
|
|
region.getNetState().getConnectTimeString(), region.getNetState().getDisconnectTimeString(),
|