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

ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 81c6ae16570ae1af23a91947b28fa2c673279b80
Merge: 5bec1c33af f02d2ac500
Author: Christopher Tubbs <ctubb...@apache.org>
AuthorDate: Tue Aug 29 15:27:35 2023 -0400

    Merge branch '2.1'

 .../org/apache/accumulo/core/conf/Property.java    | 17 ++++-----
 .../server/tablets/UniqueNameAllocator.java        | 43 ++++++++++------------
 2 files changed, 28 insertions(+), 32 deletions(-)

diff --cc core/src/main/java/org/apache/accumulo/core/conf/Property.java
index 1261d83b35,0bff139725..7abc163f1f
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@@ -1445,10 -1833,13 +1444,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.equals(Property.GENERAL_FILENAME_BASE_ALLOCATION.getKey())
-         || key.equals(Property.GENERAL_FILENAME_JITTER_ALLOCATION.getKey());
+         || 
key.equals(Property.GENERAL_FILE_NAME_ALLOCATION_BATCH_SIZE_MIN.getKey())
 -        || 
key.equals(Property.GENERAL_FILE_NAME_ALLOCATION_BATCH_SIZE_MAX.getKey())
 -        || key.startsWith(VFS_CONTEXT_CLASSPATH_PROPERTY.getKey())
 -        || key.startsWith(REPLICATION_PREFIX.getKey());
++        || 
key.equals(Property.GENERAL_FILE_NAME_ALLOCATION_BATCH_SIZE_MAX.getKey());
    }
  
    /**
diff --cc 
server/base/src/main/java/org/apache/accumulo/server/tablets/UniqueNameAllocator.java
index 5e4cc77a7d,cd633137c5..14026124df
--- 
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,9 -19,11 +19,10 @@@
  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.DefaultConfiguration;
  import org.apache.accumulo.core.conf.Property;
  import org.apache.accumulo.core.util.FastFormat;
  import org.apache.accumulo.server.ServerContext;
@@@ -36,15 -38,17 +37,16 @@@ import org.slf4j.LoggerFactory
   */
  public class UniqueNameAllocator {
  
-   private static Logger log = 
LoggerFactory.getLogger(UniqueNameAllocator.class);
+   private static final Logger log = 
LoggerFactory.getLogger(UniqueNameAllocator.class);
 -  private static final SecureRandom random = new SecureRandom();
+   private static final Property MIN_PROP = 
Property.GENERAL_FILE_NAME_ALLOCATION_BATCH_SIZE_MIN;
+   private static final Property MAX_PROP = 
Property.GENERAL_FILE_NAME_ALLOCATION_BATCH_SIZE_MAX;
+   private static final int DEFAULT_MIN = 
DefaultConfiguration.getInstance().getCount(MIN_PROP);
  
-   private static final int DEFAULT_BASE_ALLOCATION =
-       
Integer.parseInt(Property.GENERAL_FILENAME_BASE_ALLOCATION.getDefaultValue());
+   private final ServerContext context;
+   private final String nextNamePath;
  
-   private ServerContext context;
    private long next = 0;
    private long maxAllocated = 0;
-   private String nextNamePath;
  
    public UniqueNameAllocator(ServerContext context) {
      this.context = context;
@@@ -75,25 -76,23 +74,23 @@@
    }
  
    private int getAllocation() {
-     int baseAllocation =
-         
context.getConfiguration().getCount(Property.GENERAL_FILENAME_BASE_ALLOCATION);
-     int jitterAllocation =
-         
context.getConfiguration().getCount(Property.GENERAL_FILENAME_JITTER_ALLOCATION);
+     int minAllocation = context.getConfiguration().getCount(MIN_PROP);
+     int maxAllocation = context.getConfiguration().getCount(MAX_PROP);
  
-     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;
+     if (minAllocation <= 0) {
+       log.warn("{} was set to {}, but must be greater than 0. Using the 
default ({}).",
+           MIN_PROP.getKey(), minAllocation, DEFAULT_MIN);
+       minAllocation = DEFAULT_MIN;
      }
  
-     int totalAllocation = baseAllocation;
-     if (jitterAllocation > 0) {
-       totalAllocation += RANDOM.get().nextInt(jitterAllocation);
+     if (maxAllocation < minAllocation) {
+       log.warn("{} was set to {}, must be greater than or equal to {} ({}). 
Using {}.",
+           MAX_PROP.getKey(), maxAllocation, MIN_PROP.getKey(), minAllocation, 
minAllocation);
+       maxAllocation = minAllocation;
      }
  
-     log.debug("Allocating {} filenames", totalAllocation);
- 
-     return totalAllocation;
 -    int actualBatchSize = minAllocation + random.nextInt((maxAllocation - 
minAllocation) + 1);
++    int actualBatchSize = minAllocation + RANDOM.get().nextInt((maxAllocation 
- minAllocation) + 1);
+     log.debug("Allocating {} filenames", actualBatchSize);
+     return actualBatchSize;
    }
  }

Reply via email to