This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 4ce7511748 allow allocating zero unique names (#5681)
4ce7511748 is described below
commit 4ce75117484bab14287a032802b7d0423d823e7d
Author: Keith Turner <[email protected]>
AuthorDate: Mon Jun 30 10:42:29 2025 -0400
allow allocating zero unique names (#5681)
ImportExportIT.testImportedTableIsOnDemand was failing when its Fate
operation tried to allocate zero unique names. Allocating zero unique
names is reasonable for cases like importing a table or tablet with zero
files. Relaxed the restriction to allow zero.
---
.../org/apache/accumulo/server/tablets/UniqueNameAllocator.java | 8 +++++++-
.../main/java/org/apache/accumulo/test/UniqueNameAllocatorIT.java | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
b/server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
index a86286cce3..45f4bd16f6 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
@@ -21,6 +21,7 @@ package org.apache.accumulo.server.tablets;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.accumulo.core.util.LazySingletons.RANDOM;
+import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicLong;
@@ -67,7 +68,12 @@ public class UniqueNameAllocator {
* @return a thread safe iterator that can be called up to the number of
names requested
*/
public synchronized Iterator<String> getNextNames(int needed) {
- Preconditions.checkArgument(needed > 0, "needed=%s is <=-0", needed);
+ Preconditions.checkArgument(needed >= 0, "needed=%s is <0", needed);
+
+ if (needed == 0) {
+ return Collections.emptyIterator();
+ }
+
while ((next + needed) > maxAllocated) {
final int allocate = getAllocation(needed);
try {
diff --git
a/test/src/main/java/org/apache/accumulo/test/UniqueNameAllocatorIT.java
b/test/src/main/java/org/apache/accumulo/test/UniqueNameAllocatorIT.java
index 0f648f10af..58a56eed09 100644
--- a/test/src/main/java/org/apache/accumulo/test/UniqueNameAllocatorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/UniqueNameAllocatorIT.java
@@ -105,7 +105,7 @@ class UniqueNameAllocatorIT extends SharedMiniClusterBase {
}
assertThrows(IllegalArgumentException.class, () ->
allocators[0].getNextNames(-1));
- assertThrows(IllegalArgumentException.class, () ->
allocators[0].getNextNames(0));
+ assertFalse(allocators[0].getNextNames(0).hasNext());
assertTrue(namesSeen.size() >= 1_000_000);
assertTrue(namesSeen.stream().allMatch(name ->
name.matches("[0-9a-z]{7}")));