oom처리

This commit is contained in:
dean
2026-04-15 12:02:17 +09:00
parent 0f7d794a38
commit b23c3e2689

View File

@@ -0,0 +1,64 @@
package com.kamco.makesample.batch.tasklet;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
/**
* Shapefile 생성 완료 후 실행되는 UPDATE Tasklet
*
* <p>Job Flow 상 generateShapefileStep 이후에 실행됩니다.
*
* <p>실행할 SQL은 이 클래스의 execute() 메서드 안에 작성하세요.
*/
@Component
@StepScope
public class PostShapefileUpdateTasklet implements Tasklet {
private static final Logger log = LoggerFactory.getLogger(PostShapefileUpdateTasklet.class);
private final JdbcTemplate jdbcTemplate;
@Value("#{jobParameters['inferenceId']}")
private String inferenceId;
@Value("#{jobParameters['batchIds']}")
private String batchIds;
public PostShapefileUpdateTasklet(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
throws Exception {
log.info(
"Executing post-shapefile UPDATE for inferenceId={}, batchIds={}", inferenceId, batchIds);
List<Long> batchIdList =
List.of(batchIds.split(",")).stream().map(Long::parseLong).toList();
// TODO: 실행할 UPDATE SQL을 여기에 작성하세요.
// 예시:
// int updated = jdbcTemplate.update(
// "UPDATE some_table SET status = 'EXPORTED', inference_id = ? WHERE batch_id = ANY(?)",
// ps -> {
// ps.setString(1, inferenceId);
// ps.setArray(2, ps.getConnection().createArrayOf("bigint", batchIdList.toArray()));
// });
// log.info("Updated {} rows", updated);
log.info("Post-shapefile UPDATE completed");
return RepeatStatus.FINISHED;
}
}