From 69d29885ed5a4b786445612703442745d4420865 Mon Sep 17 00:00:00 2001 From: bjkim Date: Tue, 14 Oct 2025 09:55:28 +0900 Subject: [PATCH] =?UTF-8?q?[REMOVE]=20JobExplorer=20=EA=B8=B0=EB=B0=98=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EC=A4=91=20=EC=B2=B4=ED=81=AC=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20runIdCache=20null?= =?UTF-8?q?=20=EC=B2=B4=ED=81=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etri/autoflow/batch/BatchScheduler.java | 38 ++++--------------- .../batch/KubeflowRunBatchConfig.java | 1 + 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/main/java/kr/re/etri/autoflow/batch/BatchScheduler.java b/src/main/java/kr/re/etri/autoflow/batch/BatchScheduler.java index 1e8e366..3133dcd 100644 --- a/src/main/java/kr/re/etri/autoflow/batch/BatchScheduler.java +++ b/src/main/java/kr/re/etri/autoflow/batch/BatchScheduler.java @@ -1,50 +1,28 @@ package kr.re.etri.autoflow.batch; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; -@Slf4j @Configuration @EnableScheduling @RequiredArgsConstructor public class BatchScheduler { private final JobLauncher jobLauncher; - private final JobExplorer jobExplorer; // 실행 중 Job 확인용 - private final Job runSyncJob; + private final Job runSyncJob; // ✅ Spring Batch의 Job 타입 - /** - * Kubeflow run 동기화 배치 Job - * - 1분마다 실행 시도 - * - 실행 중인 Job이 있으면 스킵 - */ - @Scheduled(fixedDelay = 60000) // 이전 실행이 끝난 후 1분 뒤 다시 실행 - public void runJob() { - try { - boolean running = !jobExplorer.findRunningJobExecutions("runSyncJob").isEmpty(); + @Scheduled(fixedDelay = 60000) // 1분마다 실행 + public void runJob() throws Exception { + JobParameters params = new JobParametersBuilder() + .addLong("timestamp", System.currentTimeMillis()) // 중복 실행 방지 + .toJobParameters(); - if (running) { - log.info("runSyncJob is already running. Skipping this schedule."); - return; - } - - JobParameters params = new JobParametersBuilder() - .addLong("timestamp", System.currentTimeMillis()) - .toJobParameters(); - - log.info("Launching runSyncJob..."); - jobLauncher.run(runSyncJob, params); - - } catch (Exception e) { - log.error("Error launching runSyncJob", e); - } + jobLauncher.run(runSyncJob, params); } -} \ No newline at end of file +} diff --git a/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java b/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java index 068b022..3b81fce 100644 --- a/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java +++ b/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java @@ -120,6 +120,7 @@ public class KubeflowRunBatchConfig { } // 캐시 또는 DB 중복 검사 + assert runIdCache != null; if (runIdCache.get(runId) != null || kubeflowRunRepository.existsByRunId(runId)) { runIdCache.put(runId, true); return null;