hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1040360 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Date Tue, 30 Nov 2010 00:42:03 GMT
Author: stack
Date: Tue Nov 30 00:42:03 2010
New Revision: 1040360

URL: http://svn.apache.org/viewvc?rev=1040360&view=rev
Log:
HBASE-3263 Stack overflow in AssignmentManager

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1040360&r1=1040359&r2=1040360&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Tue Nov
30 00:42:03 2010
@@ -96,7 +96,7 @@ public class AssignmentManager extends Z
   /*
    * Maximum times we recurse an assignment.  See below in {@link #assign()}.
    */
-  private final int maximumAssignmentRecursions;
+  private final int maximumAssignmentAttempts;
 
   /**
    * Regions currently in transition.  Map of encoded region names to the master
@@ -163,8 +163,8 @@ public class AssignmentManager extends Z
     Threads.setDaemonThreadRunning(timeoutMonitor,
       master.getServerName() + ".timeoutMonitor");
     this.zkTable = new ZKTable(this.master.getZooKeeper());
-    this.maximumAssignmentRecursions =
-      this.master.getConfiguration().getInt("hbase.assignment.maximum.recursions", 10);
+    this.maximumAssignmentAttempts =
+      this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
   }
 
   /**
@@ -823,51 +823,37 @@ public class AssignmentManager extends Z
    */
   private void assign(final RegionState state, final boolean setOfflineInZK,
       final boolean forceNewPlan) {
-    assign(state, setOfflineInZK, forceNewPlan, new AtomicInteger(0));
-  }
-
-  /**
-   * Caller must hold lock on the passed <code>state</code> object.
-   * @param state
-   * @param setOfflineInZK
-   * @param forceNewPlan
-   * @param recursions Keep a count so can have upper bound on recursions.
-   */
-  private void assign(final RegionState state, final boolean setOfflineInZK,
-      final boolean forceNewPlan, final int recursions) {
-    if (setOfflineInZK && !setOfflineInZooKeeper(state)) return;
-    if (this.master.isStopped()) {
-      LOG.debug("Server stopped; skipping assign of " + state);
-      return;
-    }
-    RegionPlan plan = getRegionPlan(state, forceNewPlan);
-    if (plan == null) return; // Should get reassigned later when RIT times out.
-    try {
-      LOG.debug("Assigning region " + state.getRegion().getRegionNameAsString() +
-        " to " + plan.getDestination().getServerName());
-      // Transition RegionState to PENDING_OPEN
-      state.update(RegionState.State.PENDING_OPEN);
-      // Send OPEN RPC. This can fail if the server on other end is is not up.
-      serverManager.sendRegionOpen(plan.getDestination(), state.getRegion());
-    } catch (Throwable t) {
-      LOG.warn("Failed assignment of " +
-        state.getRegion().getRegionNameAsString() + " to " +
-        plan.getDestination() + ", trying to assign elsewhere instead; retry=" +
-        recursions, t);
-      // Clean out plan we failed execute and one that doesn't look like it'll
-      // succeed anyways; we need a new plan!
-      // Transition back to OFFLINE
-      state.update(RegionState.State.OFFLINE);
-      // Force a new plan and reassign.  Will return null if no servers.
-      if (getRegionPlan(state, plan.getDestination(), true) == null) {
-        LOG.warn("Unable to find a viable location to assign region " +
-          state.getRegion().getRegionNameAsString());
+    for (int i = 0; i < this.maximumAssignmentAttempts; i++) {
+      if (setOfflineInZK && !setOfflineInZooKeeper(state)) return;
+      if (this.master.isStopped()) {
+        LOG.debug("Server stopped; skipping assign of " + state);
         return;
       }
-      if (recursions < this.maximumAssignmentRecursions) {
-        assign(state, false, false, recursions + 1);
+      RegionPlan plan = getRegionPlan(state, forceNewPlan);
+      if (plan == null) return; // Should get reassigned later when RIT times out.
+      try {
+        LOG.debug("Assigning region " + state.getRegion().getRegionNameAsString() +
+          " to " + plan.getDestination().getServerName());
+        // Transition RegionState to PENDING_OPEN
+        state.update(RegionState.State.PENDING_OPEN);
+        // Send OPEN RPC. This can fail if the server on other end is is not up.
+        serverManager.sendRegionOpen(plan.getDestination(), state.getRegion());
+      } catch (Throwable t) {
+        LOG.warn("Failed assignment of " +
+          state.getRegion().getRegionNameAsString() + " to " +
+          plan.getDestination() + ", trying to assign elsewhere instead; " +
+          "retry=" + i, t);
+        // Clean out plan we failed execute and one that doesn't look like it'll
+        // succeed anyways; we need a new plan!
+        // Transition back to OFFLINE
+        state.update(RegionState.State.OFFLINE);
+        // Force a new plan and reassign.  Will return null if no servers.
+        if (getRegionPlan(state, plan.getDestination(), true) == null) {
+          LOG.warn("Unable to find a viable location to assign region " +
+            state.getRegion().getRegionNameAsString());
+          return;
+        }
       }
-      // Else Just leave the region in RIT.  On timeout, we'll retry later.
     }
   }
 



Mime
View raw message