|
@@ -1,23 +1,21 @@
|
|
|
package com.tsi.comm.server.controller;
|
|
package com.tsi.comm.server.controller;
|
|
|
|
|
|
|
|
import com.tsi.comm.server.config.ApplicationConfig;
|
|
import com.tsi.comm.server.config.ApplicationConfig;
|
|
|
-import com.tsi.comm.server.config.DatabaseConfig;
|
|
|
|
|
import com.tsi.comm.server.config.TsiCvimServerConfig;
|
|
import com.tsi.comm.server.config.TsiCvimServerConfig;
|
|
|
-import com.tsi.comm.server.repository.ApplicationRepository;
|
|
|
|
|
|
|
+import com.tsi.comm.server.repository.TsiAlarmManager;
|
|
|
import com.tsi.comm.server.repository.TsiNodeManager;
|
|
import com.tsi.comm.server.repository.TsiNodeManager;
|
|
|
import com.tsi.comm.server.repository.TsiSessionManager;
|
|
import com.tsi.comm.server.repository.TsiSessionManager;
|
|
|
import com.tsi.comm.server.vo.TsiNodeVo;
|
|
import com.tsi.comm.server.vo.TsiNodeVo;
|
|
|
import com.tsi.comm.server.xnet.NettyUtils;
|
|
import com.tsi.comm.server.xnet.NettyUtils;
|
|
|
import com.tsi.common.utils.TimeUtils;
|
|
import com.tsi.common.utils.TimeUtils;
|
|
|
-import io.netty.channel.Channel;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -29,11 +27,12 @@ public class TsiCommServerRestController {
|
|
|
private final TsiCvimServerConfig serverConfig;
|
|
private final TsiCvimServerConfig serverConfig;
|
|
|
private final TsiNodeManager nodeManager;
|
|
private final TsiNodeManager nodeManager;
|
|
|
private final TsiSessionManager sessionManager;
|
|
private final TsiSessionManager sessionManager;
|
|
|
|
|
+ private final TsiAlarmManager alarmManager;
|
|
|
|
|
|
|
|
@GetMapping(value = "/info", produces = {"application/json; charset=utf8"})
|
|
@GetMapping(value = "/info", produces = {"application/json; charset=utf8"})
|
|
|
public String info() {
|
|
public String info() {
|
|
|
String sep = System.lineSeparator();
|
|
String sep = System.lineSeparator();
|
|
|
- String heading = "----------------------------------------------------------------------------------------------------------------------------------";
|
|
|
|
|
|
|
+ String heading = "------------------------------------------------------------------------------------------------------------------------------------------------------";
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(heading).append(sep);
|
|
sb.append(heading).append(sep);
|
|
@@ -54,12 +53,12 @@ public class TsiCommServerRestController {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
sdf.setTimeZone(java.util.TimeZone.getTimeZone("GMT+9"));
|
|
sdf.setTimeZone(java.util.TimeZone.getTimeZone("GMT+9"));
|
|
|
|
|
|
|
|
- sb.append(String.format(" SEQ[U] %10s %4s %7s %19s %19s %9s %6s %19s Remote-Address", "Node ID", "INTC", "Connect", "Connect Time", "Disconnect Time", "Connected", "Closed", "Last-Recv-Time")).append(sep);
|
|
|
|
|
|
|
+ sb.append(String.format(" SEQ[U] %10s %4s %7s %19s %19s %9s %6s %19s IP Address Remote-Address", "Node ID", "INTC", "Connect", "Connect Time", "Disconnect Time", "Connected", "Closed", "Last-Recv-Time")).append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
sb.append(heading).append(sep);
|
|
|
|
|
|
|
|
int ii = 1;
|
|
int ii = 1;
|
|
|
for (Map.Entry<Long, TsiNodeVo> obj : this.nodeManager.getTsiNodeVoMap().entrySet()) {
|
|
for (Map.Entry<Long, TsiNodeVo> obj : this.nodeManager.getTsiNodeVoMap().entrySet()) {
|
|
|
- TsiNodeVo node = obj.getValue();
|
|
|
|
|
|
|
+ final TsiNodeVo node = obj.getValue();
|
|
|
String check = (node.isInstalled() ? "Y" : "N");
|
|
String check = (node.isInstalled() ? "Y" : "N");
|
|
|
check = check + (node.isSendNode() ? "Y" : "N");
|
|
check = check + (node.isSendNode() ? "Y" : "N");
|
|
|
check = check + (node.isSendTest() ? "Y" : "N");
|
|
check = check + (node.isSendTest() ? "Y" : "N");
|
|
@@ -89,43 +88,47 @@ public class TsiCommServerRestController {
|
|
|
String disconnectTm = sdf.format(new Date(node.getDisconnectTm()));
|
|
String disconnectTm = sdf.format(new Date(node.getDisconnectTm()));
|
|
|
String lastCommTm = sdf.format(new Date(node.getLastCommTm()));
|
|
String lastCommTm = sdf.format(new Date(node.getLastCommTm()));
|
|
|
|
|
|
|
|
- sb.append(String.format(" %5d%3s %10s %4s %7s %19s %19s %9d %6d %19s %s",
|
|
|
|
|
- ii++, unknownNode, node.getKey(), check, connect, connectTm, disconnectTm, node.getConnectCount().get(), node.getDisconnectCount().get(), lastCommTm, info)).append(sep);
|
|
|
|
|
|
|
+ sb.append(String.format(" %5d%3s %10s %4s %7s %19s %19s %9d %6d %19s %-17s %s",
|
|
|
|
|
+ ii++, unknownNode, node.getKey(), check, connect, connectTm, disconnectTm, node.getConnectCount().get(),
|
|
|
|
|
+ node.getDisconnectCount().get(), lastCommTm, node.getIpAddr(), info)).append(sep);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
sb.append(heading).append(sep);
|
|
sb.append(heading).append(sep);
|
|
|
sb.append(String.format(" Total Nodes: %d EA, Registered: %d EA, Unknown: %d EA, Connected: %d EA", nodeCount, registered, unknown, connected)).append(sep);
|
|
sb.append(String.format(" Total Nodes: %d EA, Registered: %d EA, Unknown: %d EA, Connected: %d EA", nodeCount, registered, unknown, connected)).append(sep);
|
|
|
|
|
+ sb.append(String.format(" Unknown Nodes: %d EA, Unknown Node Buffers: %d EA, Unknown Ip Address: %d EA, Duplication Connect: %d EA",
|
|
|
|
|
+ this.alarmManager.getUnknownNodeCount(), this.alarmManager.getUnknownNodeBufCount(),
|
|
|
|
|
+ this.alarmManager.getUnknownIpAddrCount(), this.alarmManager.getDupConnectCount())).append(sep);
|
|
|
|
|
+// sb.append(heading).append(sep);
|
|
|
sb.append(String.format(" Channel: %d EA, Session: %d EA", this.sessionManager.getChannelCount(), this.sessionManager.getCount())).append(sep);
|
|
sb.append(String.format(" Channel: %d EA, Session: %d EA", this.sessionManager.getChannelCount(), this.sessionManager.getCount())).append(sep);
|
|
|
sb.append(heading).append(sep);
|
|
sb.append(heading).append(sep);
|
|
|
|
|
|
|
|
- Set<Long> nodeIdSet = new HashSet<>();
|
|
|
|
|
- ConcurrentHashMap<Channel, TsiNodeVo> channelNodeMap = this.sessionManager.getChannelNodeMap();
|
|
|
|
|
- for (Map.Entry<Channel, TsiNodeVo> entry : channelNodeMap.entrySet()) {
|
|
|
|
|
- Channel channel = entry.getKey();
|
|
|
|
|
- TsiNodeVo nodeVo = entry.getValue();
|
|
|
|
|
- Long nodeId = nodeVo.getNodeId();
|
|
|
|
|
-
|
|
|
|
|
- TsiNodeVo dbNode = this.nodeManager.getTsiNodeVoMap().get(nodeId);
|
|
|
|
|
- String ip = NettyUtils.getRemoteIpAddress(channel);
|
|
|
|
|
- String dbIp = dbNode == null ? "" : dbNode.getIpAddr();
|
|
|
|
|
-
|
|
|
|
|
- if (dbNode == null) {
|
|
|
|
|
- sb.append(String.format("Not Found Node: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- if (!dbNode.isConnect()) {
|
|
|
|
|
- sb.append(String.format("Network state error: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (nodeIdSet.contains(nodeId)) {
|
|
|
|
|
- sb.append(String.format("Dup Channel: %d %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
- } else {
|
|
|
|
|
- nodeIdSet.add(nodeId);
|
|
|
|
|
- }
|
|
|
|
|
- if (!ip.equals(dbIp)) {
|
|
|
|
|
- sb.append(String.format("IP Not Match: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// Set<Long> nodeIdSet = new HashSet<>();
|
|
|
|
|
+// ConcurrentHashMap<Channel, TsiNodeVo> channelNodeMap = this.sessionManager.getChannelNodeMap();
|
|
|
|
|
+// for (Map.Entry<Channel, TsiNodeVo> entry : channelNodeMap.entrySet()) {
|
|
|
|
|
+// Channel channel = entry.getKey();
|
|
|
|
|
+// TsiNodeVo nodeVo = entry.getValue();
|
|
|
|
|
+// Long nodeId = nodeVo.getNodeId();
|
|
|
|
|
+//
|
|
|
|
|
+// TsiNodeVo dbNode = this.nodeManager.getTsiNodeVoMap().get(nodeId);
|
|
|
|
|
+// String ip = NettyUtils.getRemoteIpAddress(channel);
|
|
|
|
|
+// String dbIp = dbNode == null ? "" : dbNode.getIpAddr();
|
|
|
|
|
+//
|
|
|
|
|
+// if (dbNode == null) {
|
|
|
|
|
+// sb.append(String.format("Not Found Node: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
+// }
|
|
|
|
|
+// else {
|
|
|
|
|
+// if (!dbNode.isConnect()) {
|
|
|
|
|
+// sb.append(String.format("Network state error: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// if (nodeIdSet.contains(nodeId)) {
|
|
|
|
|
+// sb.append(String.format("Dup Channel: %d %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// nodeIdSet.add(nodeId);
|
|
|
|
|
+// }
|
|
|
|
|
+// if (!ip.equals(dbIp)) {
|
|
|
|
|
+// sb.append(String.format("IP Not Match: %d, %s/%s", nodeId, ip, dbIp)).append(sep);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
return sb.toString();
|
|
return sb.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|