|
|
@@ -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();
|