hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1509385 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/master/
Date Thu, 01 Aug 2013 18:56:02 GMT
Author: jxiang
Date: Thu Aug  1 18:56:02 2013
New Revision: 1509385

URL: http://svn.apache.org/r1509385
Log:
HBASE-9092 OpenRegion could be ignored by mistake

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1509385&r1=1509384&r2=1509385&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Thu Aug  1 18:56:02 2013
@@ -71,9 +71,7 @@ import org.apache.hadoop.hbase.master.ha
 import org.apache.hadoop.hbase.master.handler.MergedRegionHandler;
 import org.apache.hadoop.hbase.master.handler.OpenedRegionHandler;
 import org.apache.hadoop.hbase.master.handler.SplitRegionHandler;
-import org.apache.hadoop.hbase.regionserver.RegionAlreadyInTransitionException;
 import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
-import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.KeyLocker;
 import org.apache.hadoop.hbase.util.Pair;
@@ -923,26 +921,25 @@ public class AssignmentManager extends Z
               + " or not on the expected server");
             return;
           }
-          // Handle this the same as if it were opened and then closed.
-          regionState = regionStates.updateRegionState(rt, RegionState.State.CLOSED);
-          // When there are more than one region server a new RS is selected as the
-          // destination and the same is updated in the regionplan. (HBASE-5546)
-          if (regionState != null) {
-            AtomicInteger failedOpenCount = failedOpenTracker.get(encodedName);
-            if (failedOpenCount == null) {
-              failedOpenCount = new AtomicInteger();
-              // No need to use putIfAbsent, or extra synchronization since
-              // this whole handleRegion block is locked on the encoded region
-              // name, and failedOpenTracker is updated only in this block
-              failedOpenTracker.put(encodedName, failedOpenCount);
-            }
-            if (failedOpenCount.incrementAndGet() >= maximumAttempts) {
-              regionStates.updateRegionState(
-                regionState.getRegion(), RegionState.State.FAILED_OPEN);
-              // remove the tracking info to save memory, also reset
-              // the count for next open initiative
-              failedOpenTracker.remove(encodedName);
-            } else {
+          AtomicInteger failedOpenCount = failedOpenTracker.get(encodedName);
+          if (failedOpenCount == null) {
+            failedOpenCount = new AtomicInteger();
+            // No need to use putIfAbsent, or extra synchronization since
+            // this whole handleRegion block is locked on the encoded region
+            // name, and failedOpenTracker is updated only in this block
+            failedOpenTracker.put(encodedName, failedOpenCount);
+          }
+          if (failedOpenCount.incrementAndGet() >= maximumAttempts) {
+            regionStates.updateRegionState(rt, RegionState.State.FAILED_OPEN);
+            // remove the tracking info to save memory, also reset
+            // the count for next open initiative
+            failedOpenTracker.remove(encodedName);
+          } else {
+            // Handle this the same as if it were opened and then closed.
+            regionState = regionStates.updateRegionState(rt, RegionState.State.CLOSED);
+            if (regionState != null) {
+              // When there are more than one region server a new RS is selected as the
+              // destination and the same is updated in the regionplan. (HBASE-5546)
               getRegionPlan(regionState.getRegion(), sn, true);
               this.executorService.submit(new ClosedRegionHandler(server,
                 this, regionState.getRegion()));
@@ -1757,10 +1754,10 @@ public class AssignmentManager extends Z
       case CLOSING:
       case PENDING_CLOSE:
       case FAILED_CLOSE:
+      case FAILED_OPEN:
         unassign(region, state, -1, null, false, null);
         state = regionStates.getRegionState(region);
         if (state.isOffline()) break;
-      case FAILED_OPEN:
       case CLOSED:
         LOG.debug("Forcing OFFLINE; was=" + state);
         state = regionStates.updateRegionState(

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java?rev=1509385&r1=1509384&r2=1509385&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
Thu Aug  1 18:56:02 2013
@@ -248,7 +248,7 @@ public class RegionStates {
 
     if (state == State.FAILED_CLOSE || state == State.FAILED_OPEN) {
       LOG.warn("Failed to transition " + hri.getShortNameToLog()
-        + " on " + serverName + ": " + state);
+        + " on " + serverName + ", set to " + state);
     }
 
     String regionName = hri.getEncodedName();

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java?rev=1509385&r1=1509384&r2=1509385&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
Thu Aug  1 18:56:02 2013
@@ -19,6 +19,8 @@ package org.apache.hadoop.hbase.master;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -392,6 +394,8 @@ public class TestAssignmentManagerOnClus
 
       RegionState state = am.getRegionStates().getRegionState(hri);
       assertEquals(RegionState.State.FAILED_OPEN, state.getState());
+      // Failed to open since no plan, so it's on no server
+      assertNull(state.getServerName());
 
       MockLoadBalancer.controledRegion = null;
       master.assignRegion(hri);
@@ -436,6 +440,10 @@ public class TestAssignmentManagerOnClus
 
       RegionState state = am.getRegionStates().getRegionState(hri);
       assertEquals(RegionState.State.FAILED_OPEN, state.getState());
+      // Failed to open due to file system issue. Region state should
+      // carry the opening region server so that we can force close it
+      // later on before opening it again. See HBASE-9092.
+      assertNotNull(state.getServerName());
 
       // remove the blocking file, so that region can be opened
       fs.delete(regionDir, true);



Mime
View raw message