169 lines
7.2 KiB
Java
169 lines
7.2 KiB
Java
package kr.gmtc.eyesvmsg.scheduler;
|
|
|
|
import java.io.File;
|
|
import java.time.Duration;
|
|
import java.time.LocalDateTime;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import gmt.common.type.LogLevelType;
|
|
import gmt.common.util.GmtUtils;
|
|
import gmt.io.client.vo.ClientInfoVO;
|
|
import gmt.io.server.vo.ServerInfoVO;
|
|
import gmt.io.server.vo.ServiceClientVO;
|
|
import gmt.logger.GmtLogManager;
|
|
//import javafx.print.Collation;
|
|
import kr.gmtc.eyesvmsg.controller.MainController;
|
|
import kr.gmtc.eyesvmsg.scheduler.vo.ResourceVO;
|
|
import kr.gmtc.eyesvmsg.service.DbService;
|
|
|
|
@Component
|
|
public class ApplicationStartup {
|
|
// private static MainController controller;
|
|
private static String path = "";
|
|
|
|
@Value("${root}")
|
|
private String root;
|
|
|
|
@Resource(name = "rvo")
|
|
ResourceVO rvo;
|
|
|
|
@Resource(name = "dbService")
|
|
DbService dbService;
|
|
|
|
@Resource(name = "controller")
|
|
MainController controller;
|
|
|
|
@EventListener(ApplicationReadyEvent.class)
|
|
public void startTelnetServerAfterStartup() throws Exception {
|
|
rvo.setRootPath(root);
|
|
|
|
GmtLogManager logger = GmtLogManager.getInstance();
|
|
logger.writeLevelLog("[APPLICATION STARTUP] ... start", LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("[LAST UPDATE] 2021-10-07", LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("[VERSION] 1.0.0.21", LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("[SYSTEM] Initialize...", LogLevelType.LOG_INFO, "AllLog");
|
|
|
|
try {
|
|
if (!root.equals("") || root != null) {
|
|
path = root;
|
|
File file = new File(path);
|
|
if (!file.isDirectory()) {
|
|
path = "";
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
logger.writeLevelLog("[Main : root path]" + GmtUtils.getStatckTrace(e), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
|
|
logger.writeLevelLog("[SYSTEM] PATH : " + path, LogLevelType.LOG_INFO, "AllLog");
|
|
|
|
try {
|
|
controller.start();
|
|
} catch (Exception e) {
|
|
logger.writeLevelLog("Main : " + GmtUtils.getStatckTrace(e), LogLevelType.LOG_ERROR, "AllLog");
|
|
System.exit(0);
|
|
}
|
|
|
|
LocalDateTime startTime = LocalDateTime.now();
|
|
|
|
logger.writeLevelLog(String.format("================= %s System start... =================", controller.getSystemInfo().getName()), LogLevelType.LOG_INFO, "AllLog");
|
|
|
|
while (true) {
|
|
Duration duration = Duration.between(startTime, LocalDateTime.now());
|
|
if (duration.getSeconds() >= 60) {
|
|
startTime = LocalDateTime.now();
|
|
|
|
logger.writeLevelLog("===============================================",
|
|
LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog(" Monitoring info ",
|
|
LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("===============================================",
|
|
LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("1. Total RCVQ : " + controller.getCurrnetRecvQCount() + " / " + 100000, LogLevelType.LOG_INFO, "AllLog");
|
|
logger.writeLevelLog("2. Total SNDQ : " + controller.getCurrnetSendQCount() + " / " + 100000, LogLevelType.LOG_INFO, "AllLog");
|
|
|
|
try {
|
|
if (controller.clientAccess) {
|
|
CopyOnWriteArrayList<ClientInfoVO> clientInfoTmpList = new CopyOnWriteArrayList<ClientInfoVO>(controller.clientInfoList);
|
|
|
|
logger.writeLevelLog("3. Client Monitor Info..", LogLevelType.LOG_INFO, "AllLog");
|
|
for (int j = 0; j < clientInfoTmpList.size(); j++) {
|
|
controller.clientInfoList.clear();
|
|
logger.writeLevelLog(" - " + clientInfoTmpList.get(j).getName()
|
|
+ " [" + clientInfoTmpList.get(j).getIp()
|
|
+ " / " + clientInfoTmpList.get(j).getPort()
|
|
+ "] " + "Rcv - " + clientInfoTmpList.get(j).getMonitorInfo().getRecvMonitorCount()
|
|
+ "," + "Snd - " + clientInfoTmpList.get(j).getMonitorInfo().getSendMonitorCount()
|
|
+ "," + "QCnt - " + clientInfoTmpList.get(j).getMonitorInfo().getSendQCount()
|
|
+ "/" + clientInfoTmpList.get(j).getMonitorInfo().getSendQBufferCount()
|
|
, LogLevelType.LOG_INFO, "AllLog");
|
|
}
|
|
}
|
|
} catch (IndexOutOfBoundsException ie) {
|
|
logger.writeLevelLog("[ApplicationStartup - startTelnetServerAfterStartup : clientInfoList -" + ie.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
|
|
try {
|
|
if (controller.serverAccess) {
|
|
CopyOnWriteArrayList<ServerInfoVO> serverInfoTmpList = new CopyOnWriteArrayList<ServerInfoVO>(controller.serverInfoList);
|
|
|
|
logger.writeLevelLog("4. Server Monitor Info..", LogLevelType.LOG_INFO, "AllLog");
|
|
for (int j = 0; j < serverInfoTmpList.size(); j++) {
|
|
logger.writeLevelLog( " - " + serverInfoTmpList.get(j).getName()
|
|
+ " [" + serverInfoTmpList.get(j).getPort()
|
|
+ "] SC cnt - " + serverInfoTmpList.get(j).getServiceClientCount()
|
|
+ "," + " QCnt - " + serverInfoTmpList.get(j).getSndQcount()
|
|
+ "/" + serverInfoTmpList.get(j).getMaxSndQCount()
|
|
, LogLevelType.LOG_INFO, "AllLog");
|
|
}
|
|
|
|
}
|
|
} catch (IndexOutOfBoundsException ie) {
|
|
logger.writeLevelLog("[ApplicationStartup - startTelnetServerAfterStartup : serverInfoList -" + ie.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
|
|
try {
|
|
if (controller.serverScAccess) {
|
|
logger.writeLevelLog("5. Service Client Monitor Info..", LogLevelType.LOG_INFO, "AllLog");
|
|
ConcurrentHashMap<String, ServiceClientVO> serverScInfoTmpList = new ConcurrentHashMap<String, ServiceClientVO>(controller.serverScInfoList);
|
|
|
|
Object[] keys = serverScInfoTmpList.keySet().toArray();
|
|
for (int j = 0; j < keys.length; j++) {
|
|
try {
|
|
logger.writeLevelLog(" - " + serverScInfoTmpList.get(keys[j]).getName() + " ["
|
|
+ serverScInfoTmpList.get(keys[j]).getIp() + " / "
|
|
+ serverScInfoTmpList.get(keys[j]).getServicePort() + "] "
|
|
+ "Rcv - " + serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getRecvMonitorCount() + ","
|
|
+ "Snd - " + serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getSendMonitorCount() + ","
|
|
+ "RcvByte -" + serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getRecvMonitorByteSize() + ","
|
|
+ "SndByte -" + serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getSendMonitorByteSize() + ","
|
|
+ "Qcnt - " + serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getSendQCount() + "/"
|
|
+ serverScInfoTmpList.get(keys[j]).getMonitorInfoVO().getSendQBufferCount()
|
|
, LogLevelType.LOG_INFO, "AllLog");
|
|
} catch (Exception e) {
|
|
logger.writeLevelLog("Service Client display error : " + "TotalCount["+ String.valueOf(keys.length)+"] " + "Index["+ String.valueOf(j) +"] " + e.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception ie) {
|
|
logger.writeLevelLog("[ApplicationStartup - startTelnetServerAfterStartup : serverScInfoList -" + ie.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
}
|
|
try {
|
|
Thread.sleep(100);
|
|
} catch (InterruptedException e) {
|
|
logger.writeLevelLog("1 : " + e.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|