accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject accumulo git commit: ACCUMULO-3683 add exponential back-off and jitter
Date Thu, 19 Mar 2015 14:42:40 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master bddb007a1 -> ed7d962ac


ACCUMULO-3683 add exponential back-off and jitter


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ed7d962a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ed7d962a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ed7d962a

Branch: refs/heads/master
Commit: ed7d962ac61ffb53bb6279b72faa6af3eb21aee1
Parents: bddb007
Author: Eric Newton <Eric Newton>
Authored: Thu Mar 19 10:42:20 2015 -0400
Committer: Eric Newton <Eric Newton>
Committed: Thu Mar 19 10:42:20 2015 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/impl/ThriftScanner.java   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ed7d962a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
index 1963532..abe91d9 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java
@@ -196,6 +196,12 @@ public class ThriftScanner {
 
   }
 
+  private static long pause(long millis) throws InterruptedException {
+    Thread.sleep(millis);
+    // wait 2 * last time, with +-10% random jitter
+    return (long)(Math.max(millis * 2, 3000) * (.9 + Math.random() / 5));
+  }
+
   public static List<KeyValue> scan(ClientContext context, ScanState scanState, int
timeOut) throws ScanTimedOutException, AccumuloException,
       AccumuloSecurityException, TableNotFoundException {
     TabletLocation loc = null;
@@ -204,6 +210,7 @@ public class ThriftScanner {
     String lastError = null;
     String error = null;
     int tooManyFilesCount = 0;
+    long sleepMillis = 100;
 
     List<KeyValue> results = null;
 
@@ -238,7 +245,7 @@ public class ThriftScanner {
               else if (log.isTraceEnabled())
                 log.trace(error);
               lastError = error;
-              Thread.sleep(100);
+              sleepMillis = pause(sleepMillis);
             } else {
               // when a tablet splits we do want to continue scanning the low child
               // of the split if we are already passed it
@@ -266,7 +273,7 @@ public class ThriftScanner {
               log.trace(error);
 
             lastError = error;
-            Thread.sleep(100);
+            sleepMillis = pause(sleepMillis);
           } finally {
             locateSpan.stop();
           }
@@ -301,7 +308,7 @@ public class ThriftScanner {
           if (scanState.isolated)
             throw new IsolationException();
 
-          Thread.sleep(100);
+          sleepMillis = pause(sleepMillis);
         } catch (NoSuchScanIDException e) {
           error = "Scan failed, no such scan id " + scanState.scanID + " " + loc;
           if (!error.equals(lastError))
@@ -336,7 +343,7 @@ public class ThriftScanner {
           if (scanState.isolated)
             throw new IsolationException();
 
-          Thread.sleep(100);
+          sleepMillis = pause(sleepMillis);
         } catch (TException e) {
           TabletLocator.getLocator(context, scanState.tableId).invalidateCache(context.getInstance(),
loc.tablet_location);
           error = "Scan failed, thrift error " + e.getClass().getName() + "  " + e.getMessage()
+ " " + loc;
@@ -354,7 +361,7 @@ public class ThriftScanner {
           if (scanState.isolated)
             throw new IsolationException();
 
-          Thread.sleep(100);
+          sleepMillis = pause(sleepMillis);
         } finally {
           scanLocation.stop();
         }


Mime
View raw message