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

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


The following commit(s) were added to refs/heads/elasticity by this push:
     new 12166db314 Changed enableTabletServerFallback to 
timeToWaitForScanServers (#4638)
12166db314 is described below

commit 12166db314f50d9e748e7680b37bb0a020dec591
Author: Arbaaz Khan <bazzy...@yahoo.com>
AuthorDate: Tue Jun 18 10:24:04 2024 -0400

    Changed enableTabletServerFallback to timeToWaitForScanServers (#4638)
    
    Changed ConfigurableScanServerSelector configuration property
    enableTabletServerFallback to timeToWaitForScanServers and
    changed it from a boolean value to a duration with a default
    value of 0s.
---
 .../spi/scan/ConfigurableScanServerSelector.java   | 54 +++++++++++++++-------
 .../scan/ConfigurableScanServerSelectorTest.java   |  2 +-
 .../accumulo/test/ScanServerIT_NoServers.java      |  4 +-
 .../test/functional/OnDemandTabletUnloadingIT.java |  4 +-
 4 files changed, 42 insertions(+), 22 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
 
b/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
index 5cfc87e306..27b7a255ff 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
@@ -83,13 +83,25 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
  * certain scans. Second groups can be used to have different hardware/VM 
types for scans, for
  * example could have some scans use expensive high memory VMs and others use 
cheaper burstable
  * VMs.</li>
- * <li><b>enableTabletServerFallback : </b> When there are no scans servers, 
this setting determines
- * if fallback to tablet servers is desired. Falling back to tablet servers 
may cause tablets to be
- * loaded that are not currently loaded. When this setting is false and there 
are no scan servers,
- * it will wait for scan servers to be available. This setting avoids loading 
tablets on tablet
- * servers when scans servers are temporarily unavailable which could be 
caused by normal cluster
- * activity. If not specified this setting defaults to true. Set to false to 
avoid tablet server
- * fallback. Waiting for scan servers is done via
+ * <li><b>timeToWaitForScanServers : </b> When there are no scans servers, 
this setting determines
+ * how long to wait for scan servers to become available before falling back 
to tablet servers.
+ * Falling back to tablet servers may cause tablets to be loaded that are not 
currently loaded. When
+ * this setting is given a wait time and there are no scan servers, it will 
wait for scan servers to
+ * be available. This setting avoids loading tablets on tablet servers when 
scans servers are
+ * temporarily unavailable which could be caused by normal cluster activity. 
You can specify the
+ * wait time using different units to precisely control the wait duration. The 
supported units are:
+ * <ul>
+ * <li>"d" for days</li>
+ * <li>"h" for hours</li>
+ * <li>"m" for minutes</li>
+ * <li>"s" for seconds</li>
+ * <li>"ms" for milliseconds</li>
+ * </ul>
+ * If duration is not specified this setting defaults to 0s, and will disable 
the wait for scan
+ * servers and will fall back to tablet servers immediately. When set to a 
large value, the selector
+ * will effectively wait for scan servers to become available before falling 
back to tablet servers.
+ * To ensure the selector never falls back to scanning tablet servers an 
unrealistic wait time can
+ * be set. For instance 10000d should be sufficient. Setting Waiting for scan 
servers is done via
  * {@link 
org.apache.accumulo.core.spi.scan.ScanServerSelector.SelectorParameters#waitUntil(Supplier,
 Duration, String)}</li>
  * <li><b>attemptPlans : </b> A list of configuration to use for each scan 
attempt. Each list object
  * has the following fields:
@@ -124,7 +136,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
  *       "maxBusyTimeout":"20m",
  *       "busyTimeoutMultiplier":8,
  *       "group":"lowcost",
- *       "enableTabletServerFallback":false,
+ *       "timeToWaitForScanServers": "120s",
  *       "attemptPlans":[
  *         {"servers":"1", "busyTimeout":"10s"},
  *         {"servers":"3", "busyTimeout":"30s","salt":"42"},
@@ -226,6 +238,7 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
       parse();
       return parsedBusyTimeout;
     }
+
   }
 
   @SuppressFBWarnings(value = {"NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", 
"UWF_UNWRITTEN_FIELD"},
@@ -237,11 +250,13 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
     int busyTimeoutMultiplier;
     String maxBusyTimeout;
     String group = ScanServerSelector.DEFAULT_SCAN_SERVER_GROUP_NAME;
-    boolean enableTabletServerFallback = true;
+    String timeToWaitForScanServers = "0s";
 
     transient boolean parsed = false;
     transient long parsedMaxBusyTimeout;
 
+    transient Duration parsedTimeToWaitForScanServers;
+
     int getNumServers(int attempt, int totalServers) {
       int index = Math.min(attempt, attemptPlans.size() - 1);
       return attemptPlans.get(index).getNumServers(totalServers);
@@ -252,6 +267,8 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
         return;
       }
       parsedMaxBusyTimeout = 
ConfigurationTypeHelper.getTimeInMillis(maxBusyTimeout);
+      parsedTimeToWaitForScanServers =
+          
Duration.ofMillis(ConfigurationTypeHelper.getTimeInMillis(timeToWaitForScanServers));
       parsed = true;
     }
 
@@ -272,6 +289,11 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
       int index = Math.min(attempts, attemptPlans.size() - 1);
       return attemptPlans.get(index).salt;
     }
+
+    Duration getTimeToWaitForScanServers() {
+      parse();
+      return parsedTimeToWaitForScanServers;
+    }
   }
 
   private void parseProfiles(Map<String,String> options) {
@@ -344,16 +366,14 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
     List<String> orderedScanServers =
         orderedScanServersSupplier.get().getOrDefault(profile.group, 
List.of());
 
+    Duration scanServerWaitTime = profile.getTimeToWaitForScanServers();
+
     var finalProfile = profile;
-    if (orderedScanServers.isEmpty() && !profile.enableTabletServerFallback) {
+    if (orderedScanServers.isEmpty() && !scanServerWaitTime.isZero()) {
       // Wait for scan servers in the configured group to be present.
-      orderedScanServers =
-          params
-              .waitUntil(
-                  () -> Optional
-                      
.ofNullable(orderedScanServersSupplier.get().get(finalProfile.group)),
-                  Duration.ofMillis(Long.MAX_VALUE), "scan servers in group : 
" + profile.group)
-              .orElseThrow();
+      orderedScanServers = params.waitUntil(
+          () -> 
Optional.ofNullable(orderedScanServersSupplier.get().get(finalProfile.group)),
+          scanServerWaitTime, "scan servers in group : " + 
profile.group).orElseThrow();
       // at this point the list should be non empty unless there is a bug
       Preconditions.checkState(!orderedScanServers.isEmpty());
     }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
index 64fe25bb43..54de138520 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
@@ -490,7 +490,7 @@ public class ConfigurableScanServerSelectorTest {
     // will wait for scan servers
 
     String defaultProfile =
-        
"{'isDefault':true,'maxBusyTimeout':'5m','busyTimeoutMultiplier':4,'enableTabletServerFallback':false,"
+        
"{'isDefault':true,'maxBusyTimeout':'5m','busyTimeoutMultiplier':4,'timeToWaitForScanServers':'120s',"
             + "'attemptPlans':[{'servers':'100%', 'busyTimeout':'60s'}]}";
 
     var opts = Map.of("profiles", "[" + defaultProfile + "]".replace('\'', 
'"'));
diff --git 
a/test/src/main/java/org/apache/accumulo/test/ScanServerIT_NoServers.java 
b/test/src/main/java/org/apache/accumulo/test/ScanServerIT_NoServers.java
index a3129f6343..aa00b40f90 100644
--- a/test/src/main/java/org/apache/accumulo/test/ScanServerIT_NoServers.java
+++ b/test/src/main/java/org/apache/accumulo/test/ScanServerIT_NoServers.java
@@ -139,7 +139,7 @@ public class ScanServerIT_NoServers extends 
SharedMiniClusterBase {
     var clientProps = new Properties();
     clientProps.putAll(getClientProps());
     String scanServerSelectorProfiles = 
"[{'isDefault':true,'maxBusyTimeout':'5m',"
-        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'enableTabletServerFallback':false,"
+        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'timeToWaitForScanServers':'120s',"
         + "'attemptPlans':[{'servers':'3', 'busyTimeout':'1s'}]}]";
     clientProps.put("scan.server.selector.impl", 
ConfigurableScanServerSelector.class.getName());
     clientProps.put("scan.server.selector.opts.profiles",
@@ -167,7 +167,7 @@ public class ScanServerIT_NoServers extends 
SharedMiniClusterBase {
     var clientProps = new Properties();
     clientProps.putAll(getClientProps());
     String scanServerSelectorProfiles = 
"[{'isDefault':true,'maxBusyTimeout':'5m',"
-        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'enableTabletServerFallback':false,"
+        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'timeToWaitForScanServers':'120s',"
         + "'attemptPlans':[{'servers':'3', 'busyTimeout':'1s'}]}]";
     clientProps.put("scan.server.selector.impl", 
ConfigurableScanServerSelector.class.getName());
     clientProps.put("scan.server.selector.opts.profiles",
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
index 27bf68a5d6..b950c6b120 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
@@ -190,7 +190,7 @@ public class OnDemandTabletUnloadingIT extends 
SharedMiniClusterBase {
 
   public static final String SCAN_SERVER_SELECTOR_CONFIG =
       "[{'isDefault':true,'maxBusyTimeout':'5m',"
-          + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'enableTabletServerFallback':false"
+          + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'timeToWaitForScanServers':'120s',"
           + "'attemptPlans':[{'servers':'3', 'busyTimeout':'33ms', 
'salt':'one'},"
           + "{'servers':'13', 'busyTimeout':'33ms', 'salt':'two'},"
           + "{'servers':'100%', 'busyTimeout':'33ms'}]}]";
@@ -204,7 +204,7 @@ public class OnDemandTabletUnloadingIT extends 
SharedMiniClusterBase {
     var clientProps = new Properties();
     clientProps.putAll(getClientProps());
     String scanServerSelectorProfiles = 
"[{'isDefault':true,'maxBusyTimeout':'5m',"
-        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'enableTabletServerFallback':false,"
+        + "'busyTimeoutMultiplier':8, 'scanTypeActivations':[], 
'timeToWaitForScanServers':'120s',"
         + "'attemptPlans':[{'servers':'3', 'busyTimeout':'1s'}]}]";
     clientProps.put("scan.server.selector.impl", 
ConfigurableScanServerSelector.class.getName());
     clientProps.put("scan.server.selector.opts.profiles",

Reply via email to