|
@@ -6,9 +6,11 @@ import com.evps.comm.server.dao.mapper.EvpsServiceMapper;
|
|
|
import com.evps.comm.server.dao.mapper.ProcessMapper;
|
|
|
import com.evps.comm.server.dao.mapper.batch.EvpCommServerDao;
|
|
|
import com.evps.comm.server.entity.TbRegionCenterComm;
|
|
|
+import com.evps.comm.server.repository.ApplicationRepository;
|
|
|
import com.evps.common.dto.EvpsCenter;
|
|
|
import com.evps.common.kafka.dto.KafkaEvpsEventDto;
|
|
|
import com.evps.common.kafka.dto.KafkaEvpsServiceDto;
|
|
|
+import com.evps.common.protocol.eEvpsOpCode;
|
|
|
import com.its.common.spring.SpringUtils;
|
|
|
import com.its.common.utils.Elapsed;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -37,13 +39,8 @@ public class DbmsDataProcess {
|
|
|
private final EvpCommServerDao evpCommServerDao;
|
|
|
private final EvpsCenterMapper evpsCenterMapper;
|
|
|
|
|
|
- private int maxCore = Runtime.getRuntime().availableProcessors();
|
|
|
-
|
|
|
public void run() {
|
|
|
log.info("DbmsDataProcess.run: Start.");
|
|
|
- if (this.maxCore < 8) {
|
|
|
- this.maxCore = 8;
|
|
|
- }
|
|
|
ThreadPoolInitializer poolInitializer = SpringUtils.getBean(ThreadPoolInitializer.class);
|
|
|
int executePool = poolInitializer.getDbms();
|
|
|
for (int ii = 0; ii < executePool; ii++) {
|
|
@@ -103,8 +100,7 @@ public class DbmsDataProcess {
|
|
|
KafkaEvpsServiceDto updService = (KafkaEvpsServiceDto)data.getData();
|
|
|
try {
|
|
|
result = this.serviceMapper.updateEvpService(updService);
|
|
|
- }
|
|
|
- catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("DBMS_DATA_UPD_SERVICE: [{}]. {}", center.getLogKey(), updService);
|
|
|
log.error("DBMS_DATA_UPD_SERVICE: [{}]. Exception: {}\r\n", center.getLogKey(), e.toString());
|
|
|
}
|
|
@@ -112,15 +108,32 @@ public class DbmsDataProcess {
|
|
|
|
|
|
case DbmsData.DBMS_DATA_INS_EVENT:
|
|
|
typeDesc = "DBMS_DATA_INS_EVENT";
|
|
|
+ // TODO:
|
|
|
+ // 종료 이벤트가 아닌경우 서비스가 메모리에 존재하는지를 확인하고 데이터를 저장하자.
|
|
|
+ // 지역센터에서 종료이벤트를 중복으로 전송하는 경우가 는 경우, 또는 멀티스레드 처리 중에 시간의 역전.
|
|
|
+ // 종료 이벤트 인 경우 메모리에서 삭제 한 후에 이벤트(종료) 이벤트를 저장한다.
|
|
|
+ boolean insData = true;
|
|
|
KafkaEvpsEventDto event = (KafkaEvpsEventDto)data.getData();
|
|
|
- try {
|
|
|
- result = this.serviceMapper.insertEvpEventCurr(event);
|
|
|
+ if (event.getEventCd() < KafkaEvpsEventDto.EVPS_EVENT_SERVICE_END) {
|
|
|
+ KafkaEvpsServiceDto service = ApplicationRepository.getService(event.getServiceId());
|
|
|
+ if (service == null) {
|
|
|
+ insData = false;
|
|
|
+ result = 0;
|
|
|
+ log.warn("DBMS_DATA_INS_EVENT: [{}]. EVPS service has already ended. {}", center.getLogKey(), event);
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception e) {
|
|
|
- log.error("DBMS_DATA_INS_EVENT_CURR: [{}]. {}", center.getLogKey(), event);
|
|
|
- log.error("DBMS_DATA_INS_EVENT_CURR: [{}]. Exception: {}\r\n", center.getLogKey(), e.toString());
|
|
|
+ if (insData) {
|
|
|
+ try {
|
|
|
+ // 현재 서비스 이벤트 정보에서 종료 후 다른 이벤트가 처리되지 않도록 한다.
|
|
|
+ result = this.serviceMapper.insertEvpEventCurr(event);
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ log.error("DBMS_DATA_INS_EVENT_CURR: [{}]. {}", center.getLogKey(), event);
|
|
|
+ log.error("DBMS_DATA_INS_EVENT_CURR: [{}]. Exception: {}\r\n", center.getLogKey(), e.toString());
|
|
|
+ }
|
|
|
}
|
|
|
try {
|
|
|
+ // 이벤트 이력은 모두 입력 되도록 한다.
|
|
|
result = this.serviceMapper.insertEvpEvent(event);
|
|
|
}
|
|
|
catch (Exception e) {
|
|
@@ -198,14 +211,19 @@ public class DbmsDataProcess {
|
|
|
case TbRegionCenterComm.CENTER_COMM_START:
|
|
|
typeDesc = "CENTER_COMM_START";
|
|
|
result = this.evpsCenterMapper.updateCommStateConnect(stts.getCenterId());
|
|
|
+ result = this.evpsCenterMapper.insertEvpCommHs(stts.getCenterId(), "1", "");
|
|
|
break;
|
|
|
case TbRegionCenterComm.CENTER_COMM_STOP:
|
|
|
typeDesc = "CENTER_COMM_STOP";
|
|
|
result = this.evpsCenterMapper.updateCommStateDisconnect(stts.getCenterId());
|
|
|
+ result = this.evpsCenterMapper.insertEvpCommHs(stts.getCenterId(), "0", "");
|
|
|
break;
|
|
|
case TbRegionCenterComm.CENTER_COMM_LAST:
|
|
|
typeDesc = "CENTER_COMM_LAST";
|
|
|
result = this.evpsCenterMapper.updateCommLastComm(stts.getCenterId());
|
|
|
+ if (stts.getOpCode() != eEvpsOpCode.EVPS_NET_PING.getValue()) {
|
|
|
+ result = this.evpsCenterMapper.insertEvpCommHs(stts.getCenterId(), "0", stts.getOpCodeDesc());
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
typeDesc = "UNKNOWN DBMS_DATA_CENTER_STTS";
|
|
@@ -247,3 +265,6 @@ public class DbmsDataProcess {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+//select SYSDATE(), now(), STR_TO_DATE('2024-10-17 10:42:13.899','%Y-%m-%d %H:%i:%s.%f'),
|
|
|
+//STR_TO_DATE('2024-10-17 10:42:13.899','%Y-%m-%d %H:%i:%s'),
|
|
|
+//current_timestamp(6), current_timestamp(3), current_timestamp(), to_days('2024-02-01 00:00:00');
|