This is an automated email from the ASF dual-hosted git repository.

smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a7d0c7475d HDDS-16996. Extract limits and sizing from 
ContainerExportManager (#11537)
2a7d0c7475d is described below

commit 2a7d0c7475deba2d87cf0a57ea50fc0d95d01349
Author: Sarveksha Yeshavantha Raju 
<[email protected]>
AuthorDate: Sun Oct 18 07:04:20 2026 +0530

    HDDS-16996. Extract limits and sizing from ContainerExportManager (#11537)
---
 .../hdds/scm/container/export/ExportLimits.java    | 45 ++++++++++++++
 .../hdds/scm/container/export/package-info.java    | 21 +++++++
 .../container/export/ContainerExportManager.java   | 51 +++++++++-------
 .../scm/container/export/ExportFileManager.java    |  3 +-
 .../hdds/scm/container/export/ExportJob.java       | 16 ++---
 .../hdds/scm/container/export/ExportSizing.java    | 70 ++++++++++++++++++++++
 .../export/TestContainerExportManager.java         | 59 +++++++++---------
 7 files changed, 203 insertions(+), 62 deletions(-)

diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportLimits.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportLimits.java
new file mode 100644
index 00000000000..060c7375426
--- /dev/null
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportLimits.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.container.export;
+
+/**
+ * Shared limits and defaults for container ID export.
+ *
+ * <p>A <b>batch</b> is the container IDs returned by one {@code 
ContainerManager} listing
+ * call during export. A <b>part</b> is one text file in the export archive; 
export rotates to a
+ * new part after {@code partSize} container IDs have been written.
+ *
+ * <p>{@code DEFAULT_*} values apply when a submit request passes {@code 0} 
for that setting.
+ * {@code MAX_*} values bound per-job overrides.
+ */
+public final class ExportLimits {
+
+  public static final String EXPORT_SUBDIR = "exports";
+
+  /** Default container IDs fetched per listing call. */
+  public static final int DEFAULT_BATCH_SIZE = 100_000;
+  /** Default container IDs written into each part text file. */
+  public static final int DEFAULT_PART_SIZE = 500_000;
+  /** Maximum allowed {@code batchSize} override for a single export job. */
+  public static final int MAX_BATCH_SIZE = 1_000_000;
+  /** Maximum allowed {@code partSize} override for a single export job. */
+  public static final int MAX_PART_SIZE = 5_000_000;
+
+  private ExportLimits() {
+  }
+}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/package-info.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/package-info.java
new file mode 100644
index 00000000000..103c9519fca
--- /dev/null
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/export/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This package contains classes related to container export.
+ */
+package org.apache.hadoop.hdds.scm.container.export;
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ContainerExportManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ContainerExportManager.java
index 3cfd1d25ce6..a02b59fe48f 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ContainerExportManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ContainerExportManager.java
@@ -17,6 +17,9 @@
 
 package org.apache.hadoop.hdds.scm.container.export;
 
+import static 
org.apache.hadoop.hdds.scm.container.export.ExportLimits.DEFAULT_BATCH_SIZE;
+import static 
org.apache.hadoop.hdds.scm.container.export.ExportLimits.DEFAULT_PART_SIZE;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
@@ -58,8 +61,6 @@ public class ContainerExportManager {
 
   private static final Logger LOG = 
LoggerFactory.getLogger(ContainerExportManager.class);
 
-  private static final int DEFAULT_BATCH_SIZE = 100_000;
-  private static final int DEFAULT_PART_SIZE = 500_000;
   private static final long SHUTDOWN_TIMEOUT_MS = 5_000;
 
   private final Map<ExportJob.Id, ExportJob> jobMap = new 
ConcurrentHashMap<>();
@@ -68,8 +69,7 @@ public class ContainerExportManager {
   private final ContainerManager containerManager;
   private final ExportFileManager fileManager;
   private final BooleanSupplier isLeaderReady;
-  private final int partSize;
-  private final int batchSize;
+  private final ExportSizing defaultSizing;
 
   public ContainerExportManager(String scmId, ContainerManager 
containerManager, BooleanSupplier isLeaderReady,
       OzoneConfiguration conf) {
@@ -79,15 +79,10 @@ public ContainerExportManager(String scmId, 
ContainerManager containerManager, B
 
   ContainerExportManager(String scmId, ContainerManager containerManager, 
BooleanSupplier isLeaderReady,
       String exportDirectory, int partSize, int batchSize) {
-    if (partSize <= 0 || batchSize <= 0) {
-      throw new IllegalArgumentException("partSize and batchSize must be 
positive: partSize=" + partSize
-          + ", batchSize=" + batchSize);
-    }
+    this.defaultSizing = new ExportSizing(0, 0, 0, batchSize, partSize);
     this.containerManager = Objects.requireNonNull(containerManager, 
"containerManager == null");
     this.isLeaderReady = Objects.requireNonNull(isLeaderReady, "isLeaderReady 
== null");
     this.fileManager = new ExportFileManager(exportDirectory);
-    this.partSize = partSize;
-    this.batchSize = batchSize;
     this.workerPool = newWorkerPool(scmId);
   }
 
@@ -110,25 +105,32 @@ protected void terminated() {
   public void start() throws IOException {
     fileManager.start();
     LOG.info("ContainerExportManager started (dir={}, partSize={}, 
batchSize={})",
-        fileManager.getExportDirectory(), partSize, batchSize);
+        fileManager.getExportDirectory(), defaultSizing.getPartSize(), 
defaultSizing.getBatchSize());
   }
 
   /**
    * Submit a container ID export job on the SCM leader.
    *
+   * @param maxRows upper bound on exported container IDs; {@code 0} means no 
limit
+   * @param requestBatchSize container IDs per listing query; {@code 0} means 
the manager default
+   * @param requestPartSize container IDs per part file; {@code 0} means the 
manager default
    * @return the submitted job
+   * @throws IllegalArgumentException if a size is negative or above its 
{@link ExportLimits} maximum
    * @throws SCMException with {@link SCMException.ResultCodes#SCM_NOT_LEADER} 
if this SCM is not the ready leader
    * @throws IOException if another export is already running or the export 
worker is shut down
    */
-  public ExportJob submitJob(ContainerID start, LifeCycleState lifeCycleState, 
ContainerHealthState healthState)
-      throws IOException {
+  public ExportJob submitJob(ContainerID start, LifeCycleState lifeCycleState, 
ContainerHealthState healthState,
+      long maxRows, int requestBatchSize, int requestPartSize) throws 
IOException {
+    final ExportSizing sizing = new ExportSizing(maxRows, requestBatchSize, 
requestPartSize,
+        defaultSizing.getBatchSize(), defaultSizing.getPartSize());
+
     if (!isLeaderReady.getAsBoolean()) {
       throw new SCMException("Container ID export can only be submitted on the 
SCM leader",
           SCMException.ResultCodes.SCM_NOT_LEADER);
     }
 
     final ExportScope scope = ExportScope.of(lifeCycleState, healthState);
-    final ExportJob job = new ExportJob(scope, start, batchSize, partSize);
+    final ExportJob job = new ExportJob(scope, start, sizing);
     if (!runningJob.compareAndSet(null, job)) {
       throw new IOException("Another container ID export is already running");
     }
@@ -141,8 +143,8 @@ public ExportJob submitJob(ContainerID start, 
LifeCycleState lifeCycleState, Con
       runningJob.compareAndSet(job, null);
       throw new IOException("Container ID export worker is shut down", e);
     }
-    LOG.info("Submitted container ID export job {} (scope={}, start={}, 
batchSize={}, partSize={})",
-        job, scope, start, batchSize, partSize);
+    LOG.info("Submitted container ID export job {} (scope={}, start={}, 
maxRows={}, batchSize={}, partSize={})",
+        job, scope, start, job.getMaxRows(), job.getBatchSize(), 
job.getPartSize());
     return job;
   }
 
@@ -237,7 +239,7 @@ private Long writeContainerIDs(ExportJob job) throws 
IOException {
       }
 
       if (batchIndex >= batch.size()) {
-        batch = fetchContainerIds(job, cursor);
+        batch = fetchContainerIds(job, cursor, idsWritten);
         batchIndex = 0;
         if (batch.isEmpty()) {
           break;
@@ -255,7 +257,7 @@ private Long writeContainerIDs(ExportJob job) throws 
IOException {
         while (idsInCurrentPart < job.getPartSize()
             && (batchIndex < batch.size() || cursor != null)) {
           if (batchIndex >= batch.size()) {
-            batch = fetchContainerIds(job, cursor);
+            batch = fetchContainerIds(job, cursor, idsWritten);
             batchIndex = 0;
             if (batch.isEmpty()) {
               cursor = null;
@@ -289,11 +291,18 @@ private static ContainerID nextCursor(List<ContainerID> 
batch) {
     return ContainerID.valueOf(batch.get(batch.size() - 
1).getProtobuf().getId() + 1);
   }
 
-  private List<ContainerID> fetchContainerIds(ExportJob job, ContainerID 
cursor) throws IOException {
+  private List<ContainerID> fetchContainerIds(ExportJob job, ContainerID 
cursor, long idsWritten) throws IOException {
     if (!isLeaderReady.getAsBoolean()) {
       throw new IOException("SCM lost leadership during " + job);
     }
-    return containerManager.getContainerIDs(
-        cursor, job.getBatchSize(), job.getLifeCycleState(), 
job.getHealthState());
+    int count = job.getBatchSize();
+    if (job.getMaxRows() > 0) {
+      final long remaining = job.getMaxRows() - idsWritten;
+      if (remaining <= 0) {
+        return Collections.emptyList();
+      }
+      count = (int) Math.min(count, remaining);
+    }
+    return containerManager.getContainerIDs(cursor, count, 
job.getLifeCycleState(), job.getHealthState());
   }
 }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportFileManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportFileManager.java
index 7dc37847cc8..46f66d942b5 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportFileManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportFileManager.java
@@ -78,7 +78,6 @@ final class ExportFileManager {
 
   private static final Logger LOG = 
LoggerFactory.getLogger(ExportFileManager.class);
 
-  static final String EXPORT_SUBDIR = "exports";
   static final String EXPORT_JOB_DIR_PREFIX = "export_";
   static final String EXPORT_ARCHIVE_JOB_INFIX = "_job";
   static final String EXPORT_ARCHIVE_SUFFIX = ".tar.gz";
@@ -96,7 +95,7 @@ final class ExportFileManager {
 
   static String resolveExportDirectory(OzoneConfiguration conf) {
     File scmDbDir = ServerUtils.getScmDbDir(conf);
-    return new File(scmDbDir, EXPORT_SUBDIR).getAbsolutePath();
+    return new File(scmDbDir, ExportLimits.EXPORT_SUBDIR).getAbsolutePath();
   }
 
   String getExportDirectory() {
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportJob.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportJob.java
index 1d7a1e79353..3b6a7f2cfeb 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportJob.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportJob.java
@@ -40,8 +40,7 @@ public final class ExportJob {
   private final ExportScope scope;
   private final String jobStartTime = 
ExportFileManager.formatJobStartTime(Instant.now());
   private final ContainerID startContainerId;
-  private final int batchSize;
-  private final int partSize;
+  private final ExportSizing sizing;
   /** The .tar.gz output path, fixed at job creation; used by the worker to 
write the archive. */
   private final String fileName;
 
@@ -134,13 +133,12 @@ public Throwable getException() {
     }
   }
 
-  ExportJob(ExportScope scope, ContainerID startContainerId, int batchSize, 
int partSize) {
+  ExportJob(ExportScope scope, ContainerID startContainerId, ExportSizing 
sizing) {
     this.id = Id.newId();
     this.scope = scope;
     this.startContainerId = startContainerId != null ? startContainerId : 
ContainerID.valueOf(0);
     this.fileName = ExportFileManager.archiveFileName(scope, jobStartTime, id);
-    this.batchSize = batchSize;
-    this.partSize = partSize;
+    this.sizing = sizing;
   }
 
   Id getId() {
@@ -163,12 +161,16 @@ ContainerID getStartContainerId() {
     return startContainerId;
   }
 
+  long getMaxRows() {
+    return sizing.getMaxRows();
+  }
+
   int getBatchSize() {
-    return batchSize;
+    return sizing.getBatchSize();
   }
 
   int getPartSize() {
-    return partSize;
+    return sizing.getPartSize();
   }
 
   CompletableFuture<Long> getFuture() {
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportSizing.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportSizing.java
new file mode 100644
index 00000000000..c73c107e2e6
--- /dev/null
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/export/ExportSizing.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.container.export;
+
+import static 
org.apache.hadoop.hdds.scm.container.export.ExportLimits.MAX_BATCH_SIZE;
+import static 
org.apache.hadoop.hdds.scm.container.export.ExportLimits.MAX_PART_SIZE;
+
+/**
+ * Per-job batch sizing for container ID export.
+ * These values are always used together when reading container IDs from SCM 
and writing them into the export TAR:
+ * {@code batchSize} container IDs returned per {@code ContainerManager} 
listing query.
+ * {@code partSize} - container IDs written into each part text file before 
that file is appended to the TAR.
+ * {@code maxRows} - upper bound on total exported container IDs for the job; 
{@code 0} means no limit.
+ * <p>
+ * A {@code batchSize} or {@code partSize} of {@code 0} in a submit request 
means use the
+ * manager defaults. The {@code MAX_*} values in {@link ExportLimits} bound 
the request values.
+ */
+final class ExportSizing {
+
+  private final long maxRows;
+  private final int batchSize;
+  private final int partSize;
+
+  ExportSizing(long maxRows, int batchSize, int partSize, int 
defaultBatchSize, int defaultPartSize) {
+    if (maxRows < 0) {
+      throw new IllegalArgumentException("maxRows must be non-negative: " + 
maxRows);
+    }
+    this.maxRows = maxRows;
+    this.batchSize = resolve("batchSize", batchSize, defaultBatchSize, 
MAX_BATCH_SIZE);
+    this.partSize = resolve("partSize", partSize, defaultPartSize, 
MAX_PART_SIZE);
+  }
+
+  /** Checks the default and the requested value ({@code 0} selects the 
default), and returns the one to use. */
+  private static int resolve(String name, int requested, int defaultValue, int 
max) {
+    if (defaultValue <= 0 || defaultValue > max) {
+      throw new IllegalArgumentException("default " + name + " must be between 
1 and " + max + ": " + defaultValue);
+    }
+    if (requested < 0 || requested > max) {
+      throw new IllegalArgumentException(name + " must be between 0 and " + 
max + ": " + requested);
+    }
+    return requested > 0 ? requested : defaultValue;
+  }
+
+  long getMaxRows() {
+    return maxRows;
+  }
+
+  int getBatchSize() {
+    return batchSize;
+  }
+
+  int getPartSize() {
+    return partSize;
+  }
+}
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/export/TestContainerExportManager.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/export/TestContainerExportManager.java
index 9c60af26672..62533ea3fe6 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/export/TestContainerExportManager.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/export/TestContainerExportManager.java
@@ -95,7 +95,7 @@ public void teardown() {
   @Test
   public void testRejectMissingFilters() {
     assertThrows(IllegalArgumentException.class, () ->
-        exportManager.submitJob(ContainerID.valueOf(0), null, null));
+        submit(ContainerID.valueOf(0), null, null));
   }
 
   @Test
@@ -103,7 +103,7 @@ public void testRejectSubmitWhenNotLeader() throws 
Exception {
     exportManager.shutdown();
     exportManager = newExportManager(TEST_PART_SIZE, TEST_BATCH_SIZE, () -> 
false);
     SCMException e = assertThrows(SCMException.class, () ->
-        exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING));
+        submit(ContainerID.valueOf(0), null, ContainerHealthState.MISSING));
     assertEquals(SCMException.ResultCodes.SCM_NOT_LEADER, e.getResult());
   }
 
@@ -111,7 +111,7 @@ public void testRejectSubmitWhenNotLeader() throws 
Exception {
   public void testRejectSubmitAfterShutdown() {
     exportManager.shutdown();
     IOException e = assertThrows(IOException.class, () ->
-        exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING));
+        submit(ContainerID.valueOf(0), null, ContainerHealthState.MISSING));
     assertTrue(e.getMessage().contains("shut down"));
   }
 
@@ -140,11 +140,10 @@ public void testRejectConcurrentExport() throws Exception 
{
           return Collections.emptyList();
         });
 
-    ExportJob first = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob first = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(first);
     IOException e = assertThrows(IOException.class, () ->
-        exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.EMPTY));
+        submit(ContainerID.valueOf(0), null, ContainerHealthState.EMPTY));
     assertTrue(e.getMessage().contains("already running"));
   }
 
@@ -177,19 +176,19 @@ public void 
testRejectSubmitWhileArchivingThenAcceptAfterDone() throws Exception
           return Collections.emptyList();
         });
 
-    ExportJob first = exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
+    ExportJob first = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertTrue(archivingStarted.await(30, TimeUnit.SECONDS));
     assertFalse(exportManager.getExportStatus(first.getId()).isDone());
 
     IOException e = assertThrows(IOException.class, () ->
-        exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.EMPTY));
+        submit(ContainerID.valueOf(0), null, ContainerHealthState.EMPTY));
     assertTrue(e.getMessage().contains("already running"));
 
     releaseArchiving.countDown();
     ExportJob.Status status = waitForDone(first.getId());
     assertNull(status.getException());
     assertTrue(archiveFile(first).exists());
-    assertNotNull(exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.EMPTY));
+    assertNotNull(submit(ContainerID.valueOf(0), null, 
ContainerHealthState.EMPTY));
   }
 
   @Test
@@ -198,7 +197,7 @@ public void testNullStartDefaultsToZeroCursor() throws 
Exception {
         eq(ContainerID.valueOf(0)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(null, null, 
ContainerHealthState.MISSING);
+    ExportJob job = submit(null, null, ContainerHealthState.MISSING);
     assertNotNull(job);
     waitForDone(job.getId());
 
@@ -215,8 +214,7 @@ public void testExportStartsFromRequestedCursor() throws 
Exception {
         eq(ContainerID.valueOf(7)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(5), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(5), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -236,7 +234,7 @@ public void testExportWithLifeCycleFilter() throws 
Exception {
         eq(ContainerID.valueOf(2)), anyInt(), eq(LifeCycleState.OPEN), 
isNull()))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), 
LifeCycleState.OPEN, null);
+    ExportJob job = submit(ContainerID.valueOf(0), LifeCycleState.OPEN, null);
     assertNotNull(job);
     waitForDone(job.getId());
 
@@ -250,8 +248,7 @@ public void testZeroMatchesSucceedsWithoutArchive() throws 
Exception {
         eq(ContainerID.valueOf(0)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -272,8 +269,7 @@ public void testSinglePartExportCreatesTar() throws 
Exception {
         eq(ContainerID.valueOf(5)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -302,8 +298,7 @@ public void testMultiPartExportCreatesTar() throws 
Exception {
         eq(ContainerID.valueOf(8)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -319,7 +314,7 @@ public void testMultiPartExportCreatesTar() throws 
Exception {
       extractGzTar(archive, extractDir);
       List<Path> parts;
       try (Stream<Path> stream = Files.list(extractDir)) {
-        parts = stream.sorted().collect(Collectors.toList());
+        parts = stream.sorted().toList();
       }
       assertEquals(3, parts.size());
       
assertTrue(parts.get(0).getFileName().toString().endsWith("part001.txt"));
@@ -345,7 +340,7 @@ public void testMultiPartExportCreatesTar() throws 
Exception {
   public void testLeadershipLostWhileArchivingLeavesNoArchive() throws 
Exception {
     ExportFileManager fileManager = new 
ExportFileManager(tempDir.getAbsolutePath());
     ExportJob job = new ExportJob(ExportScope.of(null, 
ContainerHealthState.MISSING),
-        ContainerID.valueOf(0), TEST_BATCH_SIZE, TEST_PART_SIZE);
+        ContainerID.valueOf(0), new ExportSizing(0, TEST_BATCH_SIZE, 
TEST_PART_SIZE, TEST_BATCH_SIZE, TEST_PART_SIZE));
     fileManager.createJobDirectory(job.getId());
     try (OutputStream out = fileManager.newPartOutputStream(job.getId(), 
job.partFileName(1))) {
       job.writeMetadataHeader(out, 1, ContainerID.valueOf(1));
@@ -382,7 +377,7 @@ public void testLockReleasedOnlyAfterWorkerStops() throws 
Exception {
           return Collections.emptyList();
         });
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertTrue(workerBusy.await(30, TimeUnit.SECONDS));
 
     // Returns after the 5s timeout while the worker is still running.
@@ -418,12 +413,10 @@ public void testSubmitAfterPreviousJobCompletes() throws 
Exception {
         eq(ContainerID.valueOf(11)), anyInt(), isNull(), 
eq(ContainerHealthState.EMPTY)))
         .thenReturn(Collections.emptyList());
 
-    ExportJob first = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob first = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     waitForDone(first.getId());
 
-    ExportJob second = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.EMPTY);
+    ExportJob second = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.EMPTY);
     assertNotNull(second);
     ExportJob.Status status = waitForDone(second.getId());
     assertNull(status.getException());
@@ -443,8 +436,7 @@ public void testFailsWhenLeadershipLostDuringExport() 
throws Exception {
           return ids(1);
         });
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -458,8 +450,7 @@ public void testFailsWhenContainerManagerThrows() throws 
Exception {
         eq(ContainerID.valueOf(0)), anyInt(), isNull(), 
eq(ContainerHealthState.MISSING)))
         .thenThrow(new RuntimeException("container listing failed"));
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     ExportJob.Status status = waitForDone(job.getId());
@@ -477,8 +468,7 @@ public void testShutdownCancelsRunningExport() throws 
Exception {
           return Collections.emptyList();
         });
 
-    ExportJob job = exportManager.submitJob(ContainerID.valueOf(0), null,
-        ContainerHealthState.MISSING);
+    ExportJob job = submit(ContainerID.valueOf(0), null, 
ContainerHealthState.MISSING);
     assertNotNull(job);
 
     exportManager.shutdown();
@@ -486,6 +476,11 @@ public void testShutdownCancelsRunningExport() throws 
Exception {
     assertNotNull(status.getException());
     exportManager = null;
   }
+  
+  private ExportJob submit(ContainerID start, LifeCycleState lifeCycle, 
ContainerHealthState health)
+      throws IOException {
+    return exportManager.submitJob(start, lifeCycle, health, 0, 0, 0);
+  }
 
   private File archiveFile(ExportJob job) {
     return new File(tempDir, job.getFileName());


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to