[REMOVE] JobExplorer 기반 실행 중 체크 로직 제거 및 runIdCache null 체크 추가

main
bjkim 8 months ago
parent e90a59ec29
commit 69d29885ed

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

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

Loading…
Cancel
Save