From c134b6a361fd56cbd00abbe8dbc2063337235ec5 Mon Sep 17 00:00:00 2001 From: bjkim Date: Mon, 29 Sep 2025 14:58:28 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20KubeflowRunResponse=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EB=AA=85=EC=B9=AD=20=ED=91=9C=EC=A4=80?= =?UTF-8?q?=ED=99=94=20=EB=B0=8F=20=EB=B0=B0=EC=B9=98=20=EA=B5=AC=EC=84=B1?= =?UTF-8?q?=EC=9D=98=20runReader=20=EB=A1=9C=EC=A7=81=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8:=20=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EC=85=98=EA=B3=BC=20=EC=A0=95=EB=A0=AC=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=84=EC=86=8C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/KubeflowRunBatchConfig.java | 25 ++++++++++++------- .../payload/response/KubeflowRunResponse.java | 3 +-- 2 files changed, 17 insertions(+), 11 deletions(-) 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 485a4b5..acd0697 100644 --- a/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java +++ b/src/main/java/kr/re/etri/autoflow/batch/KubeflowRunBatchConfig.java @@ -22,6 +22,7 @@ import org.springframework.web.reactive.function.client.WebClient; import java.time.Instant; import java.util.List; +import java.util.Optional; @Configuration @EnableBatchProcessing @@ -33,7 +34,9 @@ public class KubeflowRunBatchConfig { private final KubeflowRunRepository kubeflowRunRepository; // 최신 데이터 몇 개만 가져올지 - private static final int PAGE_SIZE = 50; + private static final int PAGE_SIZE = 10; + + private static final String SORT_BY = "created_at DESC"; @Bean public WebClient.Builder webClientBuilder() { @@ -65,35 +68,39 @@ public class KubeflowRunBatchConfig { @Bean public ItemReader runReader() { return new ItemReader<>() { - private boolean read = false; - private List runs; + private List runs = List.of(); private int index = 0; @Override public KubeflowRunRequest read() { - if (!read) { + // 페이지 끝나면 항상 최신 10개 fetch + if (index >= runs.size()) { WebClient client = webClientBuilder().build(); KubeflowRunResponse response = client.get() .uri(uriBuilder -> uriBuilder .path("/apis/v2beta1/runs") .queryParam("page_size", PAGE_SIZE) + .queryParam("sort_by", "created_at desc") .build()) .retrieve() .bodyToMono(KubeflowRunResponse.class) .block(); runs = response != null ? response.getRuns() : List.of(); - read = true; - } + index = 0; - if (runs != null && index < runs.size()) { - return runs.get(index++); + // 데이터가 없으면 Step 종료 + if (runs.isEmpty()) { + return null; + } } - return null; + + return runs.get(index++); } }; } + @Bean public ItemProcessor runProcessor() { return dto -> { diff --git a/src/main/java/kr/re/etri/autoflow/payload/response/KubeflowRunResponse.java b/src/main/java/kr/re/etri/autoflow/payload/response/KubeflowRunResponse.java index 13513a4..a86dd05 100644 --- a/src/main/java/kr/re/etri/autoflow/payload/response/KubeflowRunResponse.java +++ b/src/main/java/kr/re/etri/autoflow/payload/response/KubeflowRunResponse.java @@ -8,6 +8,5 @@ import java.util.List; @Data public class KubeflowRunResponse { private List runs; - private int total_size; - private String next_page_token; + private int totalSize; } \ No newline at end of file