HANTE 3 månader sedan
förälder
incheckning
d17937581c

+ 1 - 0
conf/utic-traf-server.pid

@@ -0,0 +1 @@
+15328

+ 1 - 1
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/config/ApplicationConfig.java

@@ -23,7 +23,7 @@ public class ApplicationConfig {
     private String processId = "70030";
     private int errTimeGap = 120;
     private int prcsThreadCount = 10;
-    private int dbmsBatchSize = 1000;
+    private int dbmsBatchSize = 2000;
     private boolean loadingLink = false;
 
     private String bootingTime;

+ 0 - 3
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/controller/UticTrafServerController.java

@@ -141,9 +141,6 @@ public class UticTrafServerController {
             this.prcsAfterService.processing();
             jobInfo.setPrcsAfterTime(System.currentTimeMillis() - tmpStart);
             log.info(step);
-
-            // 제일 마지막에 처리
-            ApplicationRepository.swapTrafficCenterView();
         }
         finally {
             this.isRunning = false; // 현재 작업이 종료됨을 표시

+ 4 - 0
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/dao/mapper/utic/UticTrafficMapper.java

@@ -17,6 +17,10 @@ public interface UticTrafficMapper {
     int insertCenterRecv(@Param("centerId") String centerId, @Param("infoType") String infoType, @Param("seq") Integer seq, @Param("dataCnt") Integer dataCnt);
 
     int truncateTrafficCenter(@Param("tableName") String tableName);
+    void disableIndexes(@Param("tableName") String tableName);
+    void disablePrimaryKey(@Param("tableName") String tableName);
+    void rebuildIndexes(@Param("tableName") String tableName);
+    void enablePrimaryKey(@Param("tableName") String tableName);
     int insertTrafficCenter(@Param("tableName") String tableName, @Param("obj") LinkTrafCenterDto obj);
     int swapTrafficCenterView(@Param("sourceTable") String sourceTable);
 

+ 3 - 3
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/dao/repository/utic/UticTrafficRepository.java

@@ -49,9 +49,9 @@ public class UticTrafficRepository {
         return this.mapper.insertTrafficCenter(tableName, obj);
     }
 
-    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "TRAFFIC_CENTER", param = "VIEW-SWAP", param2 = "sourceTable")
-    public int swapTrafficCenterView(String sourceTable) {
-        return this.mapper.swapTrafficCenterView(sourceTable);
+    @SqlOperation(type = SqlOperation.SqlType.UPDATE, table = "TRAFFIC_CENTER(VIEW)", param = "currTable", param2 = "nextTable")
+    public int swapTrafficCenterView(String currTable, String nextTable) {
+        return this.mapper.swapTrafficCenterView(nextTable);
     }
 
 }

+ 2 - 3
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/repository/ApplicationRepository.java

@@ -1,7 +1,6 @@
 package com.utic.center.utic.traf.server.repository;
 
 import com.utic.center.common.dto.ProcessStateDto;
-import com.utic.center.common.utils.LogUtils;
 import com.utic.center.utic.traf.server.dto.BatchJobInfoDto;
 import com.utic.center.utic.traf.server.dto.TrafPrcsTimeDto;
 import lombok.Getter;
@@ -52,7 +51,7 @@ public class ApplicationRepository {
     }
 
     public static int PRCS_THREAD_COUNT = 10;
-    public static int DBMS_BATCH_SIZE = 1000;
+    public static int DBMS_BATCH_SIZE = 2000;
 
     public static List<BatchJobInfoDto> batchJobInfoList = new ArrayList<>();
 
@@ -115,6 +114,6 @@ public class ApplicationRepository {
     }
 
     private static void logActiveView() {
-        log.info("[INF] {}: Active-{}, Next-{}", LogUtils.elapsedLog("TRAFFIC_CENTER(VIEW)"), currTrafficCenter, nextTrafficCenter);
+//        log.info("[INF] {}: Active-{}, Next-{}", LogUtils.elapsedLog("TRAFFIC_CENTER(VIEW)"), currTrafficCenter, nextTrafficCenter);
     }
 }

+ 3 - 3
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/service/LinkTrafPrcsAfterService.java

@@ -2,7 +2,7 @@ package com.utic.center.utic.traf.server.service;
 
 import com.utic.center.common.annotation.ProcessingElapsed;
 import com.utic.center.common.service.AbstractProcessService;
-import com.utic.center.utic.traf.server.dao.mapper.dwdb.DwdbTrafficMapper;
+import com.utic.center.utic.traf.server.dao.repository.dwdb.DwdbTrafficRepository;
 import com.utic.center.utic.traf.server.dao.repository.utic.UticTrafficRepository;
 import com.utic.center.utic.traf.server.dto.DataCountDto;
 import com.utic.center.utic.traf.server.dto.ViewTextDto;
@@ -21,14 +21,14 @@ import org.springframework.stereotype.Service;
 public class LinkTrafPrcsAfterService implements AbstractProcessService {
 
     private final UticTrafficRepository uticRepo;
-    private final DwdbTrafficMapper dwdbRepo;
+    private final DwdbTrafficRepository dwdbRepo;
 
     @ProcessingElapsed(type="PRCS", name="교통정보 준비 작업", starting = false)
     @Override
     public boolean processing() {
 
         this.uticRepo.truncateTrafficLoc();         // 지역 교통정보 테이블 초기화
-        this.uticRepo.truncateTrafficCenter(ApplicationRepository.currTrafficCenter); // 이전 소통정보 테이블 초기화
+        this.uticRepo.truncateTrafficCenter(ApplicationRepository.nextTrafficCenter); // 작업 할 소통정보 테이블 초기화
 
         // DWDB TRAFFIC_CENTER_MM(TRAFFIC_CENTER_HIST) 초기화
         // 다음달 테이블을 truncate 한다.

+ 7 - 2
utic-traf-server/src/main/java/com/utic/center/utic/traf/server/service/LinkTrafSaveUticService.java

@@ -35,6 +35,7 @@ public class LinkTrafSaveUticService implements AbstractProcessService {
 
     private void initialize() {
 
+        log.info("[INF] {}: Current, Active({}), Next({})", LogUtils.elapsedLog("TRAFFIC_CENTER(VIEW)"), ApplicationRepository.currTrafficCenter, ApplicationRepository.nextTrafficCenter);
         this.jobResult.setTableName(ApplicationRepository.nextTrafficCenter);//        final long start = System.currentTimeMillis();
         this.jobResult.setEffects(0);
         this.jobResult.setElapsedTime(0);
@@ -53,7 +54,7 @@ public class LinkTrafSaveUticService implements AbstractProcessService {
 //        log.info("[INF] {}", LogUtils.elapsedLog("교통정보데이터 가공", System.currentTimeMillis() - start));
     }
 
-    @ProcessingElapsed(type="TRAFFIC", name="교통정보 CACHE 저장", starting = true)
+    @ProcessingElapsed(type="TRAFFIC", name="교통정보 저장", starting = true)
     @Override
     public boolean processing() {
         final long start = System.currentTimeMillis();
@@ -81,7 +82,11 @@ public class LinkTrafSaveUticService implements AbstractProcessService {
         }
 
         // VIEW 의 source table을 변경한다.
-        this.uticRepo.swapTrafficCenterView(ApplicationRepository.nextTrafficCenter);
+        this.uticRepo.swapTrafficCenterView(ApplicationRepository.currTrafficCenter, ApplicationRepository.nextTrafficCenter);
+
+        // 메모리의 TRAFFIC_CENTER Source Table 정보를 변경한다.
+        ApplicationRepository.swapTrafficCenterView();
+        log.info("[INF] {}: Changed, Active({}), Next({})", LogUtils.elapsedLog("TRAFFIC_CENTER(VIEW)"), ApplicationRepository.currTrafficCenter, ApplicationRepository.nextTrafficCenter);
 
         // 모든 작업이 완료된 후 결과를 출력
         log.info("[INF] {}", LogUtils.elapsedLog(jobTable, this.jobResult.getEffects(), System.currentTimeMillis() - start));

+ 1 - 1
utic-traf-server/src/main/resources/application.yml

@@ -53,7 +53,7 @@ application:
   loading-link: false
   err-time-gap: 120
   prcs-thread-count: 10
-  dbms-batch-size: 1000
+  dbms-batch-size: 2000
 
   thread-pool:
     dbms: 10

+ 22 - 0
utic-traf-server/src/main/resources/mybatis/mapper/utic/UticTrafficMapper.xml

@@ -56,6 +56,28 @@
         ]]>
     </update>
 
+    <!-- 1. Disable Indexes -->
+    <update id="disableIndexes">
+        ALTER INDEX ${tableName}_IDX1 UNUSABLE;
+        ALTER INDEX ${tableName}_IDX2 UNUSABLE;
+    </update>
+
+    <!-- 2. Disable Primary Key Constraint -->
+    <update id="disablePrimaryKey">
+        ALTER TABLE ${tableName} DISABLE CONSTRAINT PK_${tableName};
+    </update>
+
+    <!-- 4. Rebuild Indexes -->
+    <update id="rebuildIndexes">
+        ALTER INDEX ${tableName}_IDX1 REBUILD PARALLEL 4 NOLOGGING;
+        ALTER INDEX ${tableName}_IDX2 REBUILD PARALLEL 4 NOLOGGING;
+    </update>
+
+    <!-- 5. Enable Primary Key Constraint -->
+    <update id="enablePrimaryKey">
+        ALTER TABLE ${tableName} ENABLE CONSTRAINT PK_${tableName};
+    </update>
+
     <insert id="insertTrafficCenter">
         <![CDATA[
         INSERT /*+ APPEND PARALLEL(${tableName}, 6) */ INTO ${tableName} NOLOGGING (

+ 0 - 23
utic-traf-server/src/main/resources/mybatis/mapper/utic/collect/LinkCollectMOCT2.xml

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="mapper.utic.collect.MOCT2">
-
-    <select id="findAllLinkTrafMOCT4" resultType="com.utic.center.utic.traf.server.dto.LinkCollectDto" parameterType="com.utic.center.utic.traf.server.dto.LinkCollectParam" fetchSize="2000">
-        <![CDATA[
-        SELECT A.STD_LINK_ID AS linkId,
-               1             AS crtPriority,
-               'R'           AS missValueYn,
-               'S'           AS dataResType,
-               'C00'         AS centerId,
-               A.SPEED       AS speed
-        FROM CURLINKST_MOCT_PRIVATE_LOG@PTDBSDB A, LINK@PTDBSDB B
-        WHERE A.REG_DATE >= TO_CHAR(SYSDATE - 6/1440, 'YYYYMMDDHH24MISS')
-          AND A.STD_LINK_ID = B.LINKID
-          AND B.LINKLEVEL = '1'
-          AND A.SPEED BETWEEN 1 AND 149
-        ORDER BY A.STD_LINK_ID, A.REG_DATE ASC
-        ]]>
-    </select>
-<!--    WHERE A.REG_DATE >= TO_CHAR(SYSDATE - INTERVAL '6' MINUTE, 'YYYYMMDDHH24MISS')-->
-</mapper>