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

commit 5bec1c33af6c464ce75f25ade7b4bd4dba0709ea
Merge: 59897142d4 4c10226c76
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Mon Aug 28 17:38:53 2023 -0400

    Merge branch '2.1'

 .../org/apache/accumulo/core/conf/Property.java    | 11 +++++++-
 .../server/tablets/UniqueNameAllocator.java        | 33 +++++++++++++++++++++-
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --cc core/src/main/java/org/apache/accumulo/core/conf/Property.java
index e64147f02e,77df51c5d8..1261d83b35
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@@ -1438,8 -1834,13 +1445,10 @@@ public enum Property 
      return key.startsWith(Property.TABLE_PREFIX.getKey())
          || key.startsWith(Property.TSERV_PREFIX.getKey())
          || key.startsWith(Property.MANAGER_PREFIX.getKey())
 -        || key.startsWith(Property.MASTER_PREFIX.getKey())
          || key.startsWith(Property.GC_PREFIX.getKey())
-         || key.startsWith(Property.GENERAL_ARBITRARY_PROP_PREFIX.getKey());
+         || key.startsWith(Property.GENERAL_ARBITRARY_PROP_PREFIX.getKey())
+         || key.equals(Property.GENERAL_FILENAME_BASE_ALLOCATION.getKey())
 -        || key.equals(Property.GENERAL_FILENAME_JITTER_ALLOCATION.getKey())
 -        || key.startsWith(VFS_CONTEXT_CLASSPATH_PROPERTY.getKey())
 -        || key.startsWith(REPLICATION_PREFIX.getKey());
++        || key.equals(Property.GENERAL_FILENAME_JITTER_ALLOCATION.getKey());
    }
  
    /**
diff --cc 
server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
index 042cc5b3f0,7c0f29c5ea..5e4cc77a7d
--- 
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
@@@ -19,11 -19,15 +19,14 @@@
  package org.apache.accumulo.server.tablets;
  
  import static java.nio.charset.StandardCharsets.UTF_8;
 -
 -import java.security.SecureRandom;
 +import static org.apache.accumulo.core.util.LazySingletons.RANDOM;
  
  import org.apache.accumulo.core.Constants;
+ import org.apache.accumulo.core.conf.Property;
  import org.apache.accumulo.core.util.FastFormat;
  import org.apache.accumulo.server.ServerContext;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
  
  /**
   * Allocates unique names for an accumulo instance. The names are unique for 
the lifetime of the
@@@ -65,4 -75,27 +73,27 @@@ public class UniqueNameAllocator 
      return new String(FastFormat.toZeroPaddedString(next++, 7, 
Character.MAX_RADIX, new byte[0]),
          UTF_8);
    }
+ 
+   private int getAllocation() {
+     int baseAllocation =
+         
context.getConfiguration().getCount(Property.GENERAL_FILENAME_BASE_ALLOCATION);
+     int jitterAllocation =
+         
context.getConfiguration().getCount(Property.GENERAL_FILENAME_JITTER_ALLOCATION);
+ 
+     if (baseAllocation <= 0) {
+       log.warn("{} was set to {}, must be greater than 0. Using the default 
{}.",
+           Property.GENERAL_FILENAME_BASE_ALLOCATION.getKey(), baseAllocation,
+           DEFAULT_BASE_ALLOCATION);
+       baseAllocation = DEFAULT_BASE_ALLOCATION;
+     }
+ 
+     int totalAllocation = baseAllocation;
+     if (jitterAllocation > 0) {
 -      totalAllocation += random.nextInt(jitterAllocation);
++      totalAllocation += RANDOM.get().nextInt(jitterAllocation);
+     }
+ 
+     log.debug("Allocating {} filenames", totalAllocation);
+ 
+     return totalAllocation;
+   }
  }

Reply via email to