shjung 2 năm trước cách đây
mục cha
commit
6a4db60619

+ 1 - 1
conf/debug.properties

@@ -1,5 +1,5 @@
 #system debug setting configuration...
-#Fri Aug 11 16:25:40 KST 2023
+#Sun Aug 13 12:28:17 KST 2023
 packet-info=10005
 packet-dump=x
 system-debug=true

+ 26 - 1
src/main/java/com/its/vms/config/DebugConfig.java

@@ -26,7 +26,32 @@ public class DebugConfig {
 
     @PostConstruct
     private void init() {
-        loadDebugInfo();
+        loadDefaultInfo();
+    }
+
+
+    public void loadDefaultInfo() {
+        try {
+            String workingDir = System.getProperty("user.dir");
+            FileInputStream in = null;
+            try {
+                in = new FileInputStream(workingDir + "/conf/debug.properties");
+            }
+            catch(Exception e) {
+                log.error("{}.loadDebugInfo: Exception1: {}", this.getClass().getSimpleName(), e.toString());
+                return;
+            }
+
+            Properties props = new Properties();
+            props.load(in);
+            in.close();
+
+            String isDebug  = props.getProperty("system-debug",  "false").trim();
+            this.isDebug = "true".equalsIgnoreCase(isDebug);
+        }
+        catch(Exception e) {
+            log.error("{}.loadDebugInfo: Exception2: {}", this.getClass().getSimpleName(), e.toString());
+        }
     }
 
     public void loadDebugInfo() {

+ 0 - 39
src/main/java/com/its/vms/domain/task/VmsTimeoutTask.java

@@ -1,39 +0,0 @@
-package com.its.vms.domain.task;
-
-import com.its.vms.dto.TbVmsCtlrDto;
-import lombok.extern.slf4j.Slf4j;
-import org.slf4j.MDC;
-
-import java.util.TimerTask;
-
-@Slf4j
-public class VmsTimeoutTask extends TimerTask {
-
-    private final TbVmsCtlrDto obj;
-    private final Long      packetNmbr;
-
-    public VmsTimeoutTask(TbVmsCtlrDto obj, Long packetNmbr) {
-        this.obj = obj;
-        this.packetNmbr = packetNmbr;
-    }
-
-    @Override
-    public void run() {
-
-        MDC.put("id", this.obj.getLogKey());
-
-        log.info("VmsTimeoutTask-run: packetNmbr: {}, obj: {}", this.packetNmbr, this.obj.getVmsCtlrNmbr());
-//        this.obj.removeRegisteredCommands(this.packetNmbr, false);
-//        TbVmsCtrlHs command = this.obj.getUserCommands(this.packetNmbr);
-//        if (command != null) {
-//            this.obj.removeUserCommands(this.packetNmbr);
-//            // TODO: 제어명령 성공 전송(실패)
-//            //command.setRspsType("5");  // 명령 실패(타임아웃)로 설정
-//            VmsCtlrMapper mapper = (VmsCtlrMapper) AppUtils.getBean(VmsCtlrMapper.class);
-//            mapper.updateVmsCtrlHs(command);
-//        }
-
-        MDC.remove(this.obj.getLogKey());
-        MDC.clear();
-    }
-}

+ 0 - 2
src/main/java/com/its/vms/service/VmsManageService.java

@@ -21,7 +21,6 @@ import com.its.vms.entity.TbVmsSchedule;
 import com.its.vms.process.DbmsData;
 import com.its.vms.process.DbmsDataProcess;
 import com.its.vms.process.DbmsDataType;
-import com.its.vms.xnettcp.vms.process.TcpServerRecvDataProcess;
 import com.its.vms.xnettcp.vms.process.TcpServerSendData;
 import com.its.vms.xnettcp.vms.protocol.VmsProtocolConst;
 import com.its.vms.xnettcp.vms.protocol.enums.eVmsFormObjectKind;
@@ -55,7 +54,6 @@ public class VmsManageService {
     private final VmsParkService parkService;
     private final DbmsDataProcess dbmsDataProcess;
 
-    private final TcpServerRecvDataProcess serverDataProcess;
     private int toggleFormSeq = 1;
 
     public void initVmsDsplPrst() {

+ 0 - 7
src/main/java/com/its/vms/ui/MainUI.java

@@ -209,10 +209,6 @@ public class MainUI {
                     repoService.getCtlrMap().forEach((key, obj) -> {
                         obj.resetConnectCount();
                     });
-//                    for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-//                        TbVmsCtlr obj = e.getValue();
-//                        obj.resetConnectCount();
-//                    }
                 }
                 super.mouseClicked(me);
             }
@@ -388,7 +384,6 @@ public class MainUI {
     public void updateCommSttsTotal() {
         int ctlrTotal = 0;
         int ctlrError = 0;
-        //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
         AppRepositoryService repoService = (AppRepositoryService) AppUtils.getBean(AppRepositoryService.class);
         for (Map.Entry<Long, TbVmsCtlrDto> e : repoService.getCtlrMap().entrySet()) {
             TbVmsCtlrDto obj = e.getValue();
@@ -412,10 +407,8 @@ public class MainUI {
 
     public void loadControllerInfo() {
         AppRepositoryService repoService = (AppRepositoryService) AppUtils.getBean(AppRepositoryService.class);
-        //log.info("MainUI.loadControllerInfo: start. {} EA.", AppRepository.getInstance().getCtlrMap().size());
         log.info("MainUI.loadControllerInfo: start. {} EA.", repoService.getCtlrMap().size());
         SortedMap<Long, TbVmsCtlrDto> ctlrMap = new TreeMap<>();
-        //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
         for (Map.Entry<Long, TbVmsCtlrDto> e : repoService.getCtlrMap().entrySet()) {
             TbVmsCtlrDto obj = e.getValue();
             if (StringUtils.equals("N", obj.getDelYn())) {

+ 0 - 108
src/main/java/com/its/vms/xnettcp/vms/codec/VmsTcpServerDecoder.java

@@ -1,108 +0,0 @@
-package com.its.vms.xnettcp.vms.codec;
-
-import com.its.app.utils.NettyUtils;
-import com.its.app.utils.SysUtils;
-import com.its.vms.config.CommunicationConfig;
-import com.its.vms.dto.TbVmsCtlrDto;
-import com.its.vms.service.AppRepositoryService;
-import com.its.vms.xnettcp.vms.handler.VmsServerIdleStateHandler;
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.slf4j.MDC;
-
-import java.util.List;
-
-@Slf4j
-@RequiredArgsConstructor
-public class VmsTcpServerDecoder extends ByteToMessageDecoder {
-
-    private final CommunicationConfig communicationConfig;
-    private final AppRepositoryService repoService;
-
-    @Override
-    protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> list) {
-
-        String ipAddress = NettyUtils.getRemoteIpAddress(ctx.channel());
-        Channel channel = ctx.channel();
-        TbVmsCtlrDto obj = this.repoService.getIpAddrMap(ipAddress);
-        if (obj == null) {
-            log.error("TcpServerDecoder.decode: Unknown Controller IP: {}. will be close.", ipAddress);
-            VmsServerIdleStateHandler.disconnectChannel(null, channel);
-            return;
-        }
-
-        MDC.put("id", obj.getLogKey());
-
-        if (!channel.isOpen() || !channel.isActive()) {
-            log.error("TcpServerDecoder.decode: {}, isOpen: {}, isActive: {}. [{}]", ipAddress, channel.isOpen(), channel.isActive(), obj.getLogKey());
-            VmsServerIdleStateHandler.disconnectChannel(obj, channel);
-            return;
-        }
-
-        int readableBytes = byteBuf.readableBytes();
-        log.debug("RECV_0: [{}]. ReadableBytes: {} Bytes, ReaderIndex: {}", ipAddress, readableBytes, byteBuf.readerIndex());
-        if (readableBytes == 0) {
-            log.error("RECV: {}. byteBuf.readableBytes() == 0. [{]{}]", ipAddress, obj.getLogKey());
-            return;
-        }
-        log.debug("RECV: Decoder: {}. [Readable:{}, RIDX:{}-WIDX:{}]", ipAddress, readableBytes, byteBuf.readerIndex(), byteBuf.writerIndex());
-
-        if (this.communicationConfig.isDumpRecv()) {
-            byte[] debugBytes = new byte[byteBuf.readableBytes()];
-            byteBuf.getBytes(byteBuf.readerIndex(), debugBytes);
-            log.debug("RECV: [{}], {} Bytes. {}", ipAddress, debugBytes.length, SysUtils.byteArrayToHex(debugBytes));
-        }
-
-//        int pktLength = 0;
-//        int authLength= 0;
-//        //int readerIndex = byteBuf.readerIndex();
-//        while (readableBytes > VmsTcpServerDecoder.DSRC_ASN1_PACKET_MIN_SIZE) {
-//
-//            byteBuf.markReaderIndex();
-//            byte[] inBytes = new byte[byteBuf.readableBytes()];
-//            byteBuf.readBytes(inBytes);
-//            DatexDataPacket datexDataPacket = new DatexDataPacket();
-//            try {
-//                try {
-//                    pktLength = datexDataPacket.decode(new ByteArrayInputStream(inBytes, 0, inBytes.length));
-//                }
-//                catch(IOException e) {
-//                    //log.warn("DsrcTcpServerDecoder.decode: RECV: decode error. {}, {}, inBytes: {}, pktLength: {}", ipAddress, e.getMessage(), inBytes, inBytes.length);
-//                    break;
-//                }
-//
-//                if (pktLength > readableBytes) {
-//                    //log.warn("RECV: Decoder: {}. [pktLength > readableBytes]", ipAddress);
-//                    //log.warn("RECV: Decoder: {}. [Readable:{}, RIDX:{}-WIDX:{}]. Packet Remain.", ipAddress, readableBytes, byteBuf.readerIndex(), byteBuf.writerIndex());
-//                    break;
-//                }
-//
-//                // 패킷 읽은 만큼 이동
-//                byteBuf.readerIndex(pktLength);
-//                byteBuf.markReaderIndex();
-//                byteBuf.discardReadBytes();
-//
-//                BerOctetString berOctetString = datexDataPacket.getDatexData();
-//                C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
-//                authLength = c2c.decode(new ByteArrayInputStream(berOctetString.value, 0, berOctetString.value.length));
-//                //log.info("RECV: Decoder: {}. ASN1 PACKET: {} Bytes, decodeLength: {} Bytes", ipAddress, pktLength, authLength);
-//                //log.info("RECV: Decoder: {}, C2CAuth: {}", ipAddress, c2c);
-//                obj.setLastRecvTime();
-//                list.add(c2c);
-//
-//                readableBytes = byteBuf.readableBytes();
-//            }
-//            catch(Exception e) {
-//                //log.error("TcpServerDecoder.decode: RECV: {}. Exception Error1: will be closed: {}. [{}]", ipAddress, e.toString(), obj.getLogKey());
-//                VmsServerIdleStateHandler.disconnectChannel(obj, channel);
-//            }
-//        }
-//        byteBuf.resetReaderIndex();
-        MDC.remove(obj.getLogKey());
-        MDC.clear();
-    }
-}