Bläddra i källkod

cluster update

hante 4 dagar sedan
förälder
incheckning
875d825cdc

+ 1 - 0
ggits-comm-server/build.gradle

@@ -41,6 +41,7 @@ dependencies {
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
     implementation 'com.oracle:ojdbc7:12.1.0.2'
     implementation 'org.springframework.kafka:spring-kafka'
+    implementation 'com.github.oshi:oshi-core:6.4.0'
 
     implementation 'io.netty:netty-all:4.1.52.Final'
 

+ 1 - 0
ggits-etlp-server/build.gradle

@@ -40,6 +40,7 @@ dependencies {
 
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
     implementation 'com.oracle:ojdbc7:12.1.0.2'
+    implementation 'com.github.oshi:oshi-core:6.4.0'
 
     implementation 'io.netty:netty-all:4.1.52.Final'
 

+ 3 - 1
ggits-etlp-server/src/main/java/com/sig/ggits/etlp/server/scheduler/ApplicationScheduler.java

@@ -1,6 +1,7 @@
 package com.sig.ggits.etlp.server.scheduler;
 
 import com.its.common.utils.Elapsed;
+import com.sig.ggits.etlp.server.cluster.ClusterConfig;
 import com.sig.ggits.etlp.server.config.ApplicationConfig;
 import com.sig.ggits.etlp.server.config.SchedulingConfig;
 import com.sig.ggits.etlp.server.health.SystemHealthService;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Component;
 public class ApplicationScheduler {
 
     private final ApplicationConfig config;
+    private final ClusterConfig clusterConfig;
     private final SchedulingConfig schedulingConfig;
     private final GgitsEtlpService service;
     private final ProcessStateService processStateService;
@@ -46,7 +48,7 @@ public class ApplicationScheduler {
             log.error("ApplicationScheduler.reload(application.yml): Exception {}", e.getMessage());
         }
 
-        if (this.schedulingConfig.isGgitsTsinfoEnable()) {
+        if (this.schedulingConfig.isGgitsTsinfoEnable() && this.clusterConfig.isMaster()) {
             try {
                 this.processStateService.updateGgitsTsinfoUnitSystStts(this.schedulingConfig.getGgitsTsinfoProcessId(), this.schedulingConfig.getGgitsTsinfoUrl());
             }

+ 2 - 2
ggits-etlp-server/src/main/java/com/sig/ggits/etlp/server/service/ProcessStateService.java

@@ -116,8 +116,8 @@ public class ProcessStateService {
                 this.tsInfoProcessState.setRegDate(strDate);
             }
         }
-        log.info("ProcessStateService.ggitsTsinfo: processId: {}, isRun(prev): {}({}), strDate: {}, errDesc: {}",
-                ggitsTsinfoProcessId, isRun, this.ggitsTsinfoRun, strDate, errDesc);
+        log.info("ProcessStateService.ggitsTsinfo: processId: {}, isRun(prev): {}({}), strDate: {}/{}, errDesc: {}",
+                ggitsTsinfoProcessId, isRun, this.ggitsTsinfoRun, strDate, this.tsInfoProcessState.getRegDate(), errDesc);
 
         this.tsInfoProcessState.setRunState(isRun ? ProcessStateDto.RUN_STATE.NORMAL.getValue() : ProcessStateDto.RUN_STATE.STOP.getValue());
         this.repo.updateTsinfoProcessState(this.tsInfoProcessState);

+ 1 - 5
ggits-etlp-server/src/main/resources/mybatis/mapper/sig/ProcessStateMapper.xml

@@ -51,15 +51,12 @@
     </update>
 
     <update id="updateTsinfoProcessState" parameterType="com.sig.common.dto.ProcessStateDto" timeout="10">
-        <![CDATA[
         UPDATE TB_PROCESS_STATE
         SET
             REGDATE    = SYSDATE,
-        ]]>
-        <if test="obj.regDate != 'X'">
+        <if test='obj.regDate != null and !obj.regDate.equals("X")'>
             STRDATE = TO_DATE(#{obj.regDate}, 'YYYY-MM-DD HH24:MI:SS'),
         </if>
-        <![CDATA[
             RUNSTATE   = #{obj.runState},
             RCVCNT     = #{obj.rcvCnt},
             SNDCNT     = #{obj.sndCnt},
@@ -67,7 +64,6 @@
             ERRDESC    = #{obj.errDesc},
             ERRTIMEGAP = #{obj.errTimeGap}
         WHERE PROCESSID = #{obj.processId}
-    ]]>
     </update>
 
 </mapper>

+ 1 - 0
ggits-tsinfo-server/build.gradle

@@ -40,6 +40,7 @@ dependencies {
 
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
     implementation 'com.oracle:ojdbc7:12.1.0.2'
+    implementation 'com.github.oshi:oshi-core:6.4.0'
 
 //    implementation 'io.netty:netty-all:4.1.52.Final'
     implementation 'io.netty:netty-buffer:4.1.52.Final'

+ 1 - 0
sig-comm-server/build.gradle

@@ -41,6 +41,7 @@ dependencies {
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
     implementation 'com.oracle:ojdbc7:12.1.0.2'
     implementation 'org.springframework.kafka:spring-kafka'
+    implementation 'com.github.oshi:oshi-core:6.4.0'
 
     implementation 'io.netty:netty-all:4.1.52.Final'
 

+ 2 - 0
sig-common/build.gradle

@@ -34,6 +34,8 @@ dependencies {
     implementation 'io.netty:netty-all:4.1.52.Final'
     implementation 'org.springframework.kafka:spring-kafka'
 
+    implementation 'com.github.oshi:oshi-core:6.4.0'
+
     implementation 'com.its:its-common:0.0.1'
 
     testImplementation platform('org.junit:junit-bom:5.10.0')

+ 15 - 3
sig-common/src/main/java/com/sig/common/utils/SystemHealth.java

@@ -82,9 +82,21 @@ public class SystemHealth {
 
         this.memUsage = (double) this.usedMemory / this.maxMemory * 100;
         // For Linux/Unix, Windows(Perhaps)
-        OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
-        this.cpuUsage = osBean.getSystemCpuLoad() * 100;
-        this.loadAverage = osBean.getSystemLoadAverage(); // 1분 평균
+        try {
+            OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
+            if (osBean != null) {
+                this.cpuUsage = osBean.getSystemCpuLoad() * 100;
+                this.loadAverage = osBean.getSystemLoadAverage(); // 1분 평균
+            }
+            else {
+                this.cpuUsage = 0;
+                this.loadAverage = 0;
+            }
+        }
+        catch (Throwable t) {
+            this.cpuUsage = 0;
+            this.loadAverage = 0;
+        }
 
         this.threadCount = ManagementFactory.getThreadMXBean().getThreadCount();
         this.peakThreadCount = ManagementFactory.getThreadMXBean().getPeakThreadCount();

+ 1 - 0
sig-todp-server/build.gradle

@@ -41,6 +41,7 @@ dependencies {
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
     implementation 'com.oracle:ojdbc7:12.1.0.2'
     implementation 'org.springframework.kafka:spring-kafka'
+    implementation 'com.github.oshi:oshi-core:6.4.0'
 
     implementation 'io.netty:netty-all:4.1.52.Final'