hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1329470 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
Date Mon, 23 Apr 2012 21:54:14 GMT
Author: stack
Date: Mon Apr 23 21:54:14 2012
New Revision: 1329470

URL: http://svn.apache.org/viewvc?rev=1329470&view=rev
Log:
HBASE-5857 RIT map in RS not getting cleared while region opening

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1329470&r1=1329469&r2=1329470&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Mon
Apr 23 21:54:14 2012
@@ -2485,9 +2485,9 @@ public class HRegionServer extends Regio
     }
     LOG.info("Received request to open region: " +
       region.getRegionNameAsString());
+    HTableDescriptor htd = this.tableDescriptors.get(region.getTableName());
     this.regionsInTransitionInRS.putIfAbsent(region.getEncodedNameAsBytes(),
         true);
-    HTableDescriptor htd = this.tableDescriptors.get(region.getTableName());
     // Need to pass the expected version in the constructor.
     if (region.isRootRegion()) {
       this.service.submit(new OpenRootHandler(this, this, region, htd,

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1329470&r1=1329469&r2=1329470&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
Mon Apr 23 21:54:14 2012
@@ -47,9 +47,13 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
 
 /**
  * Test open and close of regions using zk.
@@ -308,6 +312,30 @@ public class TestZKBasedOpenCloseRegion 
     LOG.info("Done with testCloseRegion");
   }
 
+  /**
+   * If region open fails with IOException in openRegion() while doing tableDescriptors.get()
+   * the region should not add into regionsInTransitionInRS map
+   * @throws Exception
+   */
+  @Test
+  public void testRegionOpenFailsDueToIOException() throws Exception {
+    HRegionInfo REGIONINFO = new HRegionInfo(Bytes.toBytes("t"),
+        HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW);
+    HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(0);
+    TableDescriptors htd = Mockito.mock(TableDescriptors.class);
+    Object orizinalState = Whitebox.getInternalState(regionServer,"tableDescriptors");
+    Whitebox.setInternalState(regionServer, "tableDescriptors", htd);
+    Mockito.doThrow(new IOException()).when(htd).get((byte[]) Mockito.any());
+    try {
+      regionServer.openRegion(REGIONINFO);
+      fail("It should throw IOException ");
+    } catch (IOException e) {
+    }
+    Whitebox.setInternalState(regionServer, "tableDescriptors", orizinalState);
+    assertFalse("Region should not be in RIT",
+        regionServer.getRegionsInTransitionInRS().containsKey(REGIONINFO.getEncodedNameAsBytes()));
+  }
+  
   private static void waitUntilAllRegionsAssigned()
   throws IOException {
     HTable meta = new HTable(TEST_UTIL.getConfiguration(),



Mime
View raw message