Bladeren bron

tb_tsc_comm_tps_hs schema change

shjung 2 weken geleden
bovenliggende
commit
4790b1b09a

+ 2 - 1
tsi-comm-server/src/main/java/com/tsi/comm/server/repository/TsiSessionManager.java

@@ -31,7 +31,8 @@ public class TsiSessionManager {
         return (int) this.sessions.decrement();
     }
     public int get() {
-        return (int) this.sessions.get();
+        return this.channelNodeMap.size();
+//        return (int) this.sessions.get();
     }
 
     public void addChannel(Channel channel, TsiNodeVo vo) {

+ 2 - 1
tsi-comm-server/src/main/java/com/tsi/comm/server/repository/TsiTpmsManager.java

@@ -54,10 +54,11 @@ public class TsiTpmsManager {
         this.readBPD.add(packet.getBuf().length);
     }
 
-    public void resetSecond(int serverId) {
+    public void resetSecond(int serverId, String hostName) {
         CommStatusVo stat = new CommStatusVo(AbstractDbmsVo.DBMS_TPMS_STAT_1S);
         long trans = this.readTPS.reset();  // read transaction
         long bytes = this.readBPS.reset();  // read bytes
+        stat.setHostName(hostName);
         stat.setId(serverId);
         stat.setTrans(trans);
         stat.setBytes(bytes);

+ 22 - 12
tsi-comm-server/src/main/java/com/tsi/comm/server/scheduler/ApplicationScheduler.java

@@ -9,6 +9,7 @@ import com.tsi.comm.server.repository.TsiAlarmManager;
 import com.tsi.comm.server.repository.TsiReportManager;
 import com.tsi.comm.server.repository.TsiTpmsManager;
 import com.tsi.comm.server.vo.TsiAlarmConfigVo;
+import com.tsi.comm.server.xnet.NetUtils;
 import com.tsi.common.utils.Elapsed;
 import com.tsi.common.utils.TimeUtils;
 import lombok.RequiredArgsConstructor;
@@ -18,6 +19,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.PostConstruct;
+
 @Slf4j
 @RequiredArgsConstructor
 @EnableScheduling
@@ -33,17 +36,24 @@ public class ApplicationScheduler {
     private final KafkaProducerService kafkaProducerService;
     private final KafkaConsumerService kafkaConsumerService;
 
-    @Scheduled(cron = "* * * * * *")  // 1초 주기 작업 실행
+    private String hostName;
+
+    @PostConstruct
+    void init() {
+        this.hostName = NetUtils.getHostName();
+    }
+
+    @Scheduled(cron = "0/5 * * * * *")  //
     public void staticsForPacketSecond() {
         if (!this.config.isStartup()) {
             return;
         }
-        Elapsed elapsed = new Elapsed();
-        this.tpmsManager.resetSecond(this.config.getServerId());
-        log.info("{}", String.format("%25s: %s", "staticsForPacketSecond", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
+//        Elapsed elapsed = new Elapsed();
+        this.tpmsManager.resetSecond(this.config.getServerId(), this.hostName);
+//        log.info("{}", String.format("%25s: %s", "staticsForPacketSecond", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
     }
 
-    @Scheduled(cron = "0/5 * * * * *")  // 5초 주기 작업 실행
+    @Scheduled(cron = "0/5 * * * * *")  //
     public void checkKafkaServerAlive() {
         if (!this.config.isStartup()) {
             return;
@@ -56,7 +66,7 @@ public class ApplicationScheduler {
         }
     }
 
-    @Scheduled(cron = "0/5 * * * * *")  // 5초 주기 작업 실행
+    @Scheduled(cron = "0/5 * * * * *")  //
     public void checkSessionTimeout() {
         if (!this.config.isStartup()) {
             return;
@@ -75,7 +85,7 @@ public class ApplicationScheduler {
             return;
         }
         this.reportManager.checkSessionTimeout(timeout);
-        log.info("{}", String.format("%25s: %s", "checkSessionTimeout", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
+//        log.info("{}", String.format("%25s: %s", "checkSessionTimeout", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
     }
 
     @Scheduled(cron = "0/30 * * * * *")  // 30초 주기 작업 실행
@@ -89,10 +99,10 @@ public class ApplicationScheduler {
         Elapsed elapsed = new Elapsed();
         this.reportManager.reportNodeSessions();
 //        TsiSessionManager.getInstance().reportChannelSessions();
-        log.info("{}", String.format("%25s: %s", "reportNodeSessionAlive", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
+//        log.info("{}", String.format("%25s: %s", "reportNodeSessionAlive", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
     }
 
-    @Scheduled(cron = "5/35 * * * * *")  // 30초 주기 작업 실행
+    @Scheduled(cron = "5/35 * * * * *")  //
     public void reportQueueInformation() {
         if (!this.config.isStartup()) {
             return;
@@ -100,7 +110,7 @@ public class ApplicationScheduler {
         if (this.trace.isQueueReport()) {
             Elapsed elapsed = new Elapsed();
             this.reportManager.reportQueueInfo(false);
-            log.info("{}", String.format("%25s: %s", "reportQueueInformation", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
+//            log.info("{}", String.format("%25s: %s", "reportQueueInformation", TimeUtils.elapsedTimeStr(elapsed.nanoSeconds())));
         }
         else {
             this.reportManager.reportQueueInfo(true);
@@ -119,7 +129,7 @@ public class ApplicationScheduler {
         }
     }
 
-    @Scheduled(cron = "0/10 * * * * *")  // 1분 주기 작업 실행
+    @Scheduled(cron = "10 * * * * *")  //
     public void loadTraceInfo() {
         if (!this.config.isStartup()) {
             return;
@@ -143,7 +153,7 @@ public class ApplicationScheduler {
         }
     }
 
-    @Scheduled(cron = "0 * * * * *")  // 1분 주기 작업 실행
+    @Scheduled(cron = "0 0/5 * * * *")  //
     public void loadBaseDatabase() {
         if (!this.config.isStartup()) {
             return;

+ 1 - 0
tsi-comm-server/src/main/java/com/tsi/comm/server/vo/mariadb/CommStatusVo.java

@@ -9,6 +9,7 @@ import lombok.ToString;
 @ToString
 public class CommStatusVo extends AbstractDbmsVo {
 
+    protected String hostName;
     protected int id;
     protected int sessions;
     protected long trans;

+ 7 - 0
tsi-comm-server/src/main/resources/mybatis/mapper/TsiCommServerMapper.xml

@@ -99,6 +99,13 @@
     </insert>
 
     <insert id="insertCommTpsHs" parameterType="com.tsi.comm.server.vo.mariadb.CommStatusVo">
+        <![CDATA[
+        INSERT INTO tb_tsc_comm_tps_hs (prcn_dt, host_name, sessions, trans, bytes)
+        VALUES (STR_TO_DATE(#{stat.eventDt},'%Y%m%d%H%i%S'), LEFT(#{stat.hostName}, 30), #{stat.sessions}, #{stat.trans}, #{stat.bytes})
+        ]]>
+    </insert>
+
+    <insert id="insertCommTpsHs_OLD" parameterType="com.tsi.comm.server.vo.mariadb.CommStatusVo">
         <![CDATA[
         INSERT INTO tb_tsc_comm_tps_hs (prcn_dt, sessions, trans, bytes)
         VALUES (STR_TO_DATE(#{stat.eventDt},'%Y%m%d%H%i%S'), #{stat.sessions}, #{stat.trans}, #{stat.bytes})