shjung 10 月之前
父节点
当前提交
2e5c388cee

+ 1 - 1
src/main/java/com/evp/app/common/utils/Elapsed.java

@@ -36,7 +36,7 @@ public class Elapsed {
 		long nanoSeconds = TimeUnit.NANOSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 
 		if (seconds > 0) {
-			return String.format("Elapsed: %,d sec. %3d ms. %d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
+			return String.format("Elapsed: %,d sec. %3d ms. %3d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
 		}
 		if (miliSeconds > 0) {
 			return String.format("Elapsed: %3d ms. %3d us. %3d ns.", miliSeconds, microSeconds, nanoSeconds);

+ 1 - 1
src/main/java/com/evp/app/common/utils/TimeUtils.java

@@ -30,7 +30,7 @@ public class TimeUtils {
         long nanoSeconds = TimeUnit.NANOSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 
         if (seconds > 0) {
-            return String.format("Elapsed: %,d sec. %3d ms. %d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
+            return String.format("Elapsed: %,d sec. %3d ms. %3d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
         }
         if (miliSeconds > 0) {
             return String.format("Elapsed: %3d ms. %3d us. %3d ns.", miliSeconds, microSeconds, nanoSeconds);

+ 9 - 9
src/main/java/com/evp/comm/server/controller/SigCommServerController.java

@@ -27,17 +27,17 @@ public class SigCommServerController {
         EvpsCenter center = ApplicationRepository.center;
 
         StringBuilder sb = new StringBuilder();
-        sb.append(heading + sep);
-        sb.append("UTIC Local Signal Communication Server" + sep);
-        sb.append(heading + sep);
+        sb.append(heading).append(sep);
+        sb.append("UTIC Local Signal Communication Server").append(sep);
+        sb.append(heading).append(sep);
         sb.append(String.format("%s, %s",
                 center.getCenterId(), center.getIpAddress() + sep));
-        sb.append(heading + sep);
+        sb.append(heading).append(sep);
         sb.append(String.format("%s %-15.15s %-8.8s %-20.20s %-20.20s %-20.20s %s",
                 "---", "IP Address", "Network",
                 "Connect Time", "Disconnect Time",
-                "Last Comm Time", "Center Name") + sep);
-        sb.append(heading + sep);
+                "Last Comm Time", "Center Name")).append(sep);
+        sb.append(heading).append(sep);
         int total = 0;
         int onLine = 0;
         List<String> keySet = new ArrayList<>(this.repo.getCenterMap().keySet());
@@ -60,9 +60,9 @@ public class SigCommServerController {
                     region.getCenterNm()) + sep);
 
         }
-        sb.append(heading + sep);
-        sb.append(String.format("Total : %d, OnLine(Connect): %d", total, onLine) + sep);
-        sb.append(heading + sep);
+        sb.append(heading).append(sep);
+        sb.append(String.format("Total : %d, OnLine(Connect): %d", total, onLine)).append(sep);
+        sb.append(heading).append(sep);
         return sb.toString();
     }
 

+ 30 - 27
src/main/java/com/evp/comm/server/repository/ApplicationRepository.java

@@ -19,6 +19,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -131,7 +133,6 @@ public class ApplicationRepository {
             List<TbEvpsCenter> lists  = this.mapper.selectAll();
             log.info("ApplicationRepository.loadCenterInfo: {} EA", lists.size());
             for (TbEvpsCenter entity : lists) {
-                log.info("ApplicationRepository.loadCenterInfo: {}.", entity);
                 EvpsCenter dto = entity.toDto();
                 EvpsCenter center = this.centerMap.get(dto.getCenterId());
                 if (center != null) {
@@ -143,9 +144,11 @@ public class ApplicationRepository {
                     }
                 }
                 else {
-                    this.centerMap.put(dto.getCenterId(), dto);
-                    this.ipAddrMap.put(dto.getIpAddress(), dto);
+                    center = dto;
+                    this.centerMap.put(dto.getCenterId(), center);
+                    this.ipAddrMap.put(dto.getIpAddress(), center);
                 }
+                log.info("ApplicationRepository.loadCenterInfo: NetStat: {}, {}.", center.getNetState().getState(), entity);
             }
         }
         catch (Exception e) {
@@ -178,29 +181,29 @@ public class ApplicationRepository {
             this.mapper.updateCommStateDisconnect(center.getCenterId());
         });
     }
-//
-//    public void reportChannelSessions() {
-//        log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-//        //log.info("Report Region Center Channel Sessions Information.");
-//        log.info("Center Name       IpAddress       Connect_Count   Connect_Time          Disconnect_Time       Remote_Address");
-//        log.info("----------------------------------------------------------------------------------------------------------------");
-//        List<String> keySet = new ArrayList<>(this.centerMap.keySet());
-//        Collections.sort(keySet);
-//        //this.centerMap.forEach((key, center) -> {
-//        for (String key : keySet) {
-//            EvpsCenter center = this.centerMap.get(key);
-//            String channelIpAddress = center.getNetState().isActive() ? NettyUtils.getRemoteAddress(center.getNetState().getChannel()) : "---";
-//            log.info("{}", String.format("%-6s %-9s %-15s %-7s %5d   %s   %s   %s",
-//                    center.getCenterId(),
-//                    center.getCenterNm(),
-//                    center.getIpAddress(),
-//                    center.getNetState().isActive(),
-//                    center.getNetState().getConnectCount(),
-//                    center.getNetState().getConnectTimeString(),
-//                    center.getNetState().getDisconnectTimeString(),
-//                    channelIpAddress));
-//        }
-//        log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-//    }
+
+    public void reportCenterSessions() {
+        //[Remote #(10.4.4.51:47734)]
+        log.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+        log.info("Center IpAddress       NetState Connected Connect_Time         Disconnect_Time      Remote_Address                    Name       ");
+        log.info("-----------------------------------------------------------------------------------------------------------------------------------------");
+        List<String> keySet = new ArrayList<>(this.centerMap.keySet());
+        Collections.sort(keySet);
+        //this.centerMap.forEach((key, center) -> {
+        for (String key : keySet) {
+            EvpsCenter center = this.centerMap.get(key);
+            String channelIpAddress = center.getNetState().isActive() ? NettyUtils.getRemoteAddress(center.getNetState().getChannel()) : "---";
+            log.info("{}", String.format("%-6s %-15s %-8s %9d %s  %s  %-33s %s",
+                    center.getCenterId(),
+                    center.getIpAddress(),
+                    center.getNetState().isActive(),
+                    center.getNetState().getConnectCount(),
+                    center.getNetState().getConnectTimeString(),
+                    center.getNetState().getDisconnectTimeString(),
+                    channelIpAddress,
+                    center.getCenterNm()));
+        }
+        log.info("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+    }
 
 }

+ 13 - 0
src/main/java/com/evp/comm/server/scheduler/ApplicationScheduler.java

@@ -31,6 +31,7 @@ public class ApplicationScheduler {
             log.error("ApplicationScheduler.updateProcessState: Exception {}", e.getMessage());
         }
     }
+
 //    @ScheduleElapsed
 //    @Async
 //    @Scheduled(cron = "20 * * * * *")  // 1분주기 작업 실행
@@ -44,6 +45,18 @@ public class ApplicationScheduler {
 //        }
 //    }
 
+//    @ScheduleElapsed
+//    @Async
+    @Scheduled(cron = "20 * * * * *")  // 1분주기 작업 실행
+    public void reportCenterSessions() {
+        try {
+            this.applicationRepository.reportCenterSessions();
+        }
+        catch(Exception e) {
+            log.error("ApplicationScheduler.reportCenterSessions: Exception {}", e.getMessage());
+        }
+    }
+
 //    @ScheduleElapsed
     @Async
     @Scheduled(cron = "10 0/5 * * * *")  // 5분주기 작업 실행

+ 1 - 1
src/test/java/com/evp/comm/server/EvpCommServerApplicationTests.java

@@ -75,7 +75,7 @@ public class EvpCommServerApplicationTests {
     void sendTopicService() {
         KafkaEvpsServiceDto data = KafkaEvpsServiceDto.builder()
                 .serviceId("99920240906124848")
-                .clctDt(TimeUtils.getCurrentDate())
+                //.clctDt(TimeUtils.getCurrentDate())
                 .evNo("373구2164")
                 .curLat(1.)
                 .curLng(2.)