浏览代码

add system health check

shjung 2 周之前
父节点
当前提交
b580069445

+ 6 - 7
.idea/workspace.xml

@@ -6,11 +6,10 @@
   <component name="ChangeListManager">
     <list default="true" id="137ea174-7fc0-49e0-a3b0-3deac854d820" name="Changes" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/utic-ptis-server/src/main/resources/mybatis/mapper/ProcessStateMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/utic-ptis-server/src/main/resources/mybatis/mapper/ProcessStateMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/utic-ptis-server/src/main/resources/mybatis/mapper/UticPtisServerMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/utic-ptis-server/src/main/resources/mybatis/mapper/UticPtisServerMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/controller/UticStatServerController.java" beforeDir="false" afterPath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/controller/UticStatServerController.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/service/UticStat04MinEtlpService.java" beforeDir="false" afterPath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/service/UticStat04MinEtlpService.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/utic-traf-server/src/main/resources/mybatis/mapper/utic/DwdbTrafficMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/utic-traf-server/src/main/resources/mybatis/mapper/utic/DwdbTrafficMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utic-ptis-server/src/main/java/com/utic/center/utic/ptis/server/scheduler/UticPtisServerScheduler.java" beforeDir="false" afterPath="$PROJECT_DIR$/utic-ptis-server/src/main/java/com/utic/center/utic/ptis/server/scheduler/ApplicationScheduler.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/scheduler/UticStatServerScheduler.java" beforeDir="false" afterPath="$PROJECT_DIR$/utic-stat-server/src/main/java/com/utic/center/utic/stat/server/scheduler/ApplicationScheduler.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utic-stat-server/src/main/resources/logback-spring.xml" beforeDir="false" afterPath="$PROJECT_DIR$/utic-stat-server/src/main/resources/logback-spring.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utic-traf-server/src/main/java/com/utic/center/utic/traf/server/scheduler/UticTrafServerScheduler.java" beforeDir="false" afterPath="$PROJECT_DIR$/utic-traf-server/src/main/java/com/utic/center/utic/traf/server/scheduler/ApplicationScheduler.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -239,7 +238,7 @@
     "node.js.selected.package.tslint": "(autodetect)",
     "nodejs_package_manager_path": "npm",
     "onboarding.tips.debug.path": "C:/KoROAD/UTIC-SIGNAL/utic-signal/ggits-tsinfo-server/src/main/java/com/sig/Main.java",
-    "project.structure.last.edited": "Problems",
+    "project.structure.last.edited": "SDKs",
     "project.structure.proportion": "0.0",
     "project.structure.side.proportion": "0.32302406",
     "run.configurations.included.in.services": "true",
@@ -647,7 +646,7 @@
       <workItem from="1760242883220" duration="6897000" />
       <workItem from="1760327252176" duration="2139000" />
       <workItem from="1760337299130" duration="612000" />
-      <workItem from="1760406508566" duration="15820000" />
+      <workItem from="1760406508566" duration="26997000" />
     </task>
     <servers />
   </component>

+ 6 - 6
utic-ptis-server/src/main/java/com/utic/center/utic/ptis/server/scheduler/UticPtisServerScheduler.java → utic-ptis-server/src/main/java/com/utic/center/utic/ptis/server/scheduler/ApplicationScheduler.java

@@ -26,15 +26,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
 @RequiredArgsConstructor
 @EnableScheduling
 @Component
-public class UticPtisServerScheduler {
+public class ApplicationScheduler {
 
-    private final HikariDataSource dataSource;
     private final ApplicationConfig config;
     private final UticPtisServerController controller;
     private final ProcessStateService processStateService;
 
     private final AtomicBoolean isScheduleRunning = new AtomicBoolean(false);
 
+    private final HikariDataSource dataSource;
     private final Map<Thread.State, Integer> stateCountMap = new EnumMap<>(Thread.State.class);
     private final SystemHealth systemHealth = new SystemHealth();
     private final DecimalFormat df = new DecimalFormat("#.##");
@@ -53,18 +53,18 @@ public class UticPtisServerScheduler {
             double cpuUsage = this.systemHealth.getCpuUsage();
             if (cpuUsage > this.config.getCpuLimits()) {
                 ApplicationRepository.processState.setErrDesc("CPU 사용율이 너무 높음: " + String.format("%.2f", cpuUsage));
-                log.warn("[SKIP] UticPtisServerScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
+                log.warn("[SKIP] ApplicationScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
                         this.config.getCpuLimits(), String.format("%.2f", cpuUsage));
                 loggingThreads();
                 return;
             }
         } catch (Exception e) {
-            log.error("UticPtisServerScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
         }
 
         // 이전 작업이 아직 실행 중이면 스킵(비동기 처리로 변경할 경우 대비-보혐)
         if (!this.isScheduleRunning.compareAndSet(false, true)) {
-            log.warn("UticPtisServerScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
+            log.warn("ApplicationScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
             return;
         }
 
@@ -74,7 +74,7 @@ public class UticPtisServerScheduler {
             this.controller.run();
             this.processStateService.processRunning();
         } catch (Exception e) {
-            log.error("UticPtisServerScheduler.scheduleProcess: Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: Exception {}", e.getMessage());
         }
         finally {
             this.isScheduleRunning.set(false); // 작업 완료 후 플래그 초기화

+ 6 - 6
utic-stat-server/src/main/java/com/utic/center/utic/stat/server/scheduler/UticStatServerScheduler.java → utic-stat-server/src/main/java/com/utic/center/utic/stat/server/scheduler/ApplicationScheduler.java

@@ -26,15 +26,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
 @RequiredArgsConstructor
 @EnableScheduling
 @Component
-public class UticStatServerScheduler {
+public class ApplicationScheduler {
 
-    private final HikariDataSource dataSource;
     private final ApplicationConfig config;
     private final ProcessStateService processStateService;
     private final UticStatServerController controller;
 
     private final AtomicBoolean isScheduleRunning = new AtomicBoolean(false);
 
+    private final HikariDataSource dataSource;
     private final Map<Thread.State, Integer> stateCountMap = new EnumMap<>(Thread.State.class);
     private final SystemHealth systemHealth = new SystemHealth();
     private final DecimalFormat df = new DecimalFormat("#.##");
@@ -53,18 +53,18 @@ public class UticStatServerScheduler {
             double cpuUsage = this.systemHealth.getCpuUsage();
             if (cpuUsage > this.config.getCpuLimits()) {
                 ApplicationRepository.processState.setErrDesc("CPU 사용율이 너무 높음: " + String.format("%.2f", cpuUsage));
-                log.warn("[SKIP] UticStatServerScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
+                log.warn("[SKIP] ApplicationScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
                         this.config.getCpuLimits(), String.format("%.2f", cpuUsage));
                 loggingThreads();
                 return;
             }
         } catch (Exception e) {
-            log.error("UticStatServerScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
         }
 
         // 이전 작업이 아직 실행 중이면 스킵(비동기 처리로 변경할 경우 대비-보혐)
         if (!this.isScheduleRunning.compareAndSet(false, true)) {
-            log.warn("UticStatServerScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
+            log.warn("ApplicationScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
             return;
         }
 
@@ -74,7 +74,7 @@ public class UticStatServerScheduler {
             this.controller.run();
             this.processStateService.processRunning();
         } catch (Exception e) {
-            log.error("UticStatServerScheduler.scheduleProcess: Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: Exception {}", e.getMessage());
         }
         finally {
             this.isScheduleRunning.set(false); // 작업 완료 후 플래그 초기화

+ 0 - 1
utic-stat-server/src/main/resources/logback-spring.xml

@@ -7,7 +7,6 @@
     <property name="PROJECT_NAME"    value="${PROJECT_PREFIX}-server"/>
     <property name="LOG_CHARSET"     value="UTF-8" />
     <property name="FILE_LOG_CHARSET" value="UTF-8" />
-<!--    <property name="FILE_LOG_CHARSET" value="EUC-KR" />-->
 
     <springProperty scope="context" name="LOGGING_PATH" source="logging.file.path"/>
     <property name="LOG_PATH" value="${LOGGING_PATH:-${user.dir}/logs/${PROJECT_NAME}}/"/>

+ 14 - 22
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/scheduler/UticTrafServerScheduler.java → utic-traf-server/src/main/java/com/utic/center/utic/traf/server/scheduler/ApplicationScheduler.java

@@ -28,17 +28,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 @Slf4j
 @EnableScheduling
 @Component
-public class UticTrafServerScheduler {
+public class ApplicationScheduler {
 
-//    @Autowired
-//    @Qualifier("dataSource")
-//    private HikariDataSource uticDataSource;
-//
-//    @Autowired
-//    @Qualifier("dwdbDataSource")
-//    private HikariDataSource dwdbDataSource;
-
-    private final DataSource uticDataSource;
     private final ApplicationConfig config;
     private final TraceConfig traceConfig;
     private final ProcessStateService processStateService;
@@ -46,17 +37,18 @@ public class UticTrafServerScheduler {
 
     private final AtomicBoolean isScheduleRunning = new AtomicBoolean(false);
 
+    private final DataSource dataSource;
     private final Map<Thread.State, Integer> stateCountMap = new EnumMap<>(Thread.State.class);
     private final SystemHealth systemHealth = new SystemHealth();
     private final DecimalFormat df = new DecimalFormat("#.##");
     private String scheduleTime;
 
-    public UticTrafServerScheduler(@Qualifier("dataSource") DataSource uticDataSource,
-                                   ApplicationConfig config,
-                                   TraceConfig traceConfig,
-                                   ProcessStateService processStateService,
-                                   UticTrafServerController controller) {
-        this.uticDataSource = uticDataSource;
+    public ApplicationScheduler(@Qualifier("dataSource") DataSource dataSource,
+                                ApplicationConfig config,
+                                TraceConfig traceConfig,
+                                ProcessStateService processStateService,
+                                UticTrafServerController controller) {
+        this.dataSource = dataSource;
         this.config = config;
         this.traceConfig = traceConfig;
         this.processStateService = processStateService;
@@ -76,18 +68,18 @@ public class UticTrafServerScheduler {
             double cpuUsage = this.systemHealth.getCpuUsage();
             if (cpuUsage > this.config.getCpuLimits()) {
                 ApplicationRepository.processState.setErrDesc("CPU 사용율이 너무 높음: " + String.format("%.2f", cpuUsage));
-                log.warn("[SKIP] UticTrafServerScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
+                log.warn("[SKIP] ApplicationScheduler.scheduleProcess: High CPU Usage, Limit({} %), Current({} %), Schedule Job SKIP...",
                         this.config.getCpuLimits(), String.format("%.2f", cpuUsage));
                 loggingThreads();
                 return;
             }
         } catch (Exception e) {
-            log.error("UticTrafServerScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: System Health Check Exception {}", e.getMessage());
         }
 
         // 이전 작업이 아직 실행 중이면 스킵(비동기 처리로 변경할 경우 대비-보혐)
         if (!this.isScheduleRunning.compareAndSet(false, true)) {
-            log.warn("UticTrafServerScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
+            log.warn("ApplicationScheduler.scheduleProcess: Previous Schedule Running. {}, {}", this.scheduleTime, TimeUtils.getCurrentTimeString());
             return;
         }
 
@@ -97,7 +89,7 @@ public class UticTrafServerScheduler {
             this.controller.run();
             this.processStateService.processRunning();
         } catch (Exception e) {
-            log.error("UticTrafServerScheduler.scheduleProcess: Exception {}", e.getMessage());
+            log.error("ApplicationScheduler.scheduleProcess: Exception {}", e.getMessage());
         }
         finally {
             this.isScheduleRunning.set(false); // 작업 완료 후 플래그 초기화
@@ -109,7 +101,7 @@ public class UticTrafServerScheduler {
             try {
                 this.traceConfig.loadTraceInfo();
             } catch(Exception e) {
-                log.error("UticTrafServerScheduler.scheduleTrace: Exception {}", e.getMessage());
+                log.error("ApplicationScheduler.scheduleTrace: Exception {}", e.getMessage());
             }
         }
     }
@@ -139,7 +131,7 @@ public class UticTrafServerScheduler {
     }
 
     private void logSessionStatus() {
-        HikariDataSource hikariDataSource = (HikariDataSource) this.uticDataSource;
+        HikariDataSource hikariDataSource = (HikariDataSource) this.dataSource;
         HikariPoolMXBean poolStats = hikariDataSource.getHikariPoolMXBean();
         int totalConnections = poolStats.getTotalConnections();
         int activeConnections = poolStats.getActiveConnections();