Repository: hbase
Updated Branches:
  refs/heads/branch-1 55645c351 -> cbdc9fcb8


Addendum HBASE-16209: Add an ExponentialBackOffPolicy so that we spread out the 
timing of open region retries in AssignmentManager.

Signed-off-by: zhangduo <zhang...@apache.org>


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

Branch: refs/heads/branch-1
Commit: cbdc9fcb8a705f4e5ee28a917a335c6f1ef5df42
Parents: 55645c3
Author: Ashu Pachauri <ashu210...@gmail.com>
Authored: Tue Nov 29 15:49:22 2016 -0800
Committer: zhangduo <zhang...@apache.org>
Committed: Fri Dec 2 10:30:28 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/master/AssignmentManager.java  | 43 +++++++++++++-------
 1 file changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cbdc9fcb/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index 72ca98c..502b63f 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -3408,23 +3408,39 @@ public class AssignmentManager extends 
ZooKeeperListener {
     return true;
   }
 
-  void invokeAssign(HRegionInfo regionInfo) {
-    invokeAssign(regionInfo, true);
+  void invokeAssignNow(HRegionInfo regionInfo, boolean forceNewPlan) {
+    threadPoolExecutorService.submit(new AssignCallable(this, regionInfo, 
forceNewPlan));
+  }
+
+  void invokeAssignLater(HRegionInfo regionInfo, boolean forceNewPlan, long 
sleepMillis) {
+    scheduledThreadPoolExecutor.schedule(new DelayedAssignCallable(new 
AssignCallable(this,
+            regionInfo, forceNewPlan)), sleepMillis, TimeUnit.MILLISECONDS);
   }
 
-  public void invokeAssign(HRegionInfo regionInfo, boolean newPlan) {
-    threadPoolExecutorService.submit(new AssignCallable(this, regionInfo, 
newPlan));
+  public void invokeAssign(HRegionInfo regionInfo) {
+    invokeAssign(regionInfo, true);
   }
 
-  public void invokeAssignLater(HRegionInfo regionInfo, long sleepMillis) {
-    scheduledThreadPoolExecutor.schedule(new DelayedAssignCallable(
-        new AssignCallable(this, regionInfo, true)), sleepMillis, 
TimeUnit.MILLISECONDS);
+  public void invokeAssign(HRegionInfo regionInfo, boolean forceNewPlan) {
+    if (failedOpenTracker.containsKey(regionInfo.getEncodedName())) {
+      // Sleep before reassigning if this region has failed to open before
+      long sleepTime = backoffPolicy.getBackoffTime(retryConfig,
+          getFailedAttempts(regionInfo.getEncodedName()));
+      invokeAssignLater(regionInfo, forceNewPlan, sleepTime);
+    } else {
+      // Immediately reassign if this region has never failed an open before
+      invokeAssignNow(regionInfo, forceNewPlan);
+    }
   }
 
-  public void invokeAssignLaterOnFailure(HRegionInfo regionInfo) {
-    long sleepTime = backoffPolicy.getBackoffTime(retryConfig,
-        failedOpenTracker.get(regionInfo.getEncodedName()).get());
-    invokeAssignLater(regionInfo, sleepTime);
+  private int getFailedAttempts(String regionName) {
+    AtomicInteger failedCount = failedOpenTracker.get(regionName);
+    if (failedCount != null) {
+      return failedCount.get();
+    } else {
+      // If we do not have a failed open tracker for a region assume it has 
never failed before
+      return 0;
+    }
   }
 
   void invokeUnAssign(HRegionInfo regionInfo) {
@@ -3738,10 +3754,7 @@ public class AssignmentManager extends ZooKeeperListener 
{
         } catch (HBaseIOException e) {
           LOG.warn("Failed to get region plan", e);
         }
-        // Have the current thread sleep a bit before resubmitting the RPC 
request
-        long sleepTime = backoffPolicy.getBackoffTime(retryConfig,
-            failedOpenTracker.get(encodedName).get());
-        invokeAssignLater(hri, sleepTime);
+        invokeAssign(hri, false);
       }
     }
   }

Reply via email to