diff --git a/docs/services/batch.md b/docs/services/batch.md
index 47b5104946..e9a9283bcb 100644
--- a/docs/services/batch.md
+++ b/docs/services/batch.md
@@ -103,6 +103,8 @@ does not yet preempt the remaining nodes (see Limitations). `DescribeJobs`/queue
return one entry for the whole
job (with `nodeProperties`, no per-node `container`); pass `multiNodeJobId` to `ListJobs` for a
one-entry-per-node breakdown with each node's own `container` and `nodeProperties.nodeIndex`.
+Use `maxResults` and `nextToken` to page this breakdown, with up to 1,000 nodes per page.
+The final page omits `nextToken`.
`containerOverrides` and array jobs are not supported on MNP job definitions; use `nodeOverrides`
instead.
@@ -171,5 +173,3 @@ correctness, deliberately deferred):
- `ListJobs` with `arrayJobId` ignores the `filters` parameter (only `jobStatus` is honored for
children). This matches AWS's own note that filters don't apply to child jobs, but it means array
children can't be filtered by `JOB_NAME`/`JOB_DEFINITION`/etc.
-- `ListJobs` with `multiNodeJobId` has no pagination (`maxResults`/`nextToken`); it always returns
- every node in one response.
diff --git a/pom.xml b/pom.xml
index b3dbb1732e..a59b4b9818 100644
--- a/pom.xml
+++ b/pom.xml
@@ -348,6 +348,12 @@
${aws.sdk.version}
test
+
+ software.amazon.awssdk
+ batch
+ ${aws.sdk.version}
+ test
+
software.amazon.awssdk
bedrock
diff --git a/src/main/java/io/github/hectorvent/floci/services/batch/BatchService.java b/src/main/java/io/github/hectorvent/floci/services/batch/BatchService.java
index e5e6176b22..dafbaa3d80 100644
--- a/src/main/java/io/github/hectorvent/floci/services/batch/BatchService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/batch/BatchService.java
@@ -893,7 +893,7 @@ public class BatchService {
return listArrayChildren(arrayJobId, request);
}
if (multiNodeJobId != null) {
- return listMultiNodeJobNodes(multiNodeJobId);
+ return listMultiNodeJobNodes(multiNodeJobId, request);
}
BatchJobQueue queue = resolveJobQueue(jobQueueRef);
@@ -959,18 +959,26 @@ public class BatchService {
return out;
}
- // No pagination: realistic node counts are small, so every node is always returned.
- private ObjectNode listMultiNodeJobNodes(String jobId) {
+ private ObjectNode listMultiNodeJobNodes(String jobId, JsonNode request) {
+ int maxResults = request.hasNonNull("maxResults")
+ ? Math.max(1, Math.min(DEFAULT_MAX_RESULTS, request.path("maxResults").asInt()))
+ : DEFAULT_MAX_RESULTS;
+ int offset = parseNextToken(textOrNull(request, "nextToken"));
ArrayNode summaries = objectMapper.createArrayNode();
+ ObjectNode out = objectMapper.createObjectNode();
+ out.set("jobSummaryList", summaries);
getJob(jobId).ifPresent(job -> {
if (job.getNodeProperties() != null) {
- for (BatchNodeExecution execution : job.getNodeExecutions()) {
- summaries.add(nodeJobSummary(job, execution));
+ List executions = job.getNodeExecutions();
+ int end = (int) Math.min(executions.size(), (long) offset + maxResults);
+ for (int index = offset; index < end; index++) {
+ summaries.add(nodeJobSummary(job, executions.get(index)));
+ }
+ if (end < executions.size()) {
+ out.put("nextToken", String.valueOf(end));
}
}
});
- ObjectNode out = objectMapper.createObjectNode();
- out.set("jobSummaryList", summaries);
return out;
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/batch/BatchMultiNodePaginationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/batch/BatchMultiNodePaginationIntegrationTest.java
new file mode 100644
index 0000000000..af9508faf8
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/batch/BatchMultiNodePaginationIntegrationTest.java
@@ -0,0 +1,174 @@
+package io.github.hectorvent.floci.services.batch;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.batch.model.BatchJob;
+import io.github.hectorvent.floci.services.batch.model.BatchNodeExecution;
+import io.github.hectorvent.floci.services.batch.model.BatchNodeProperties;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import jakarta.inject.Inject;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.batch.BatchClient;
+import software.amazon.awssdk.services.batch.model.ClientException;
+import software.amazon.awssdk.services.batch.model.KeyValuesPair;
+import software.amazon.awssdk.services.batch.model.ListJobsResponse;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class BatchMultiNodePaginationIntegrationTest {
+
+ private static final String ACCOUNT = "741648900001";
+ private static final Region REGION = Region.US_EAST_1;
+
+ @Inject
+ StorageFactory storageFactory;
+
+ private AccountAwareStorageBackend jobs;
+ private final List seededJobs = new ArrayList<>();
+
+ @BeforeEach
+ void setUp() {
+ jobs = storageFactory.create("batch", "batch-jobs.json", new TypeReference