hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1391074 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Thu, 27 Sep 2012 16:04:13 GMT
Author: ramkrishna
Date: Thu Sep 27 16:04:12 2012
New Revision: 1391074

URL: http://svn.apache.org/viewvc?rev=1391074&view=rev
Log:
HBASE-6854 Deletion of SPLITTING node on split rollback should clear the region from RIT (Ram)

Submitted by:Ram
Reviewed by:Bijieshan, Stack	

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1391074&r1=1391073&r2=1391074&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Thu Sep 27 16:04:12 2012
@@ -1125,9 +1125,13 @@ public class AssignmentManager extends Z
       if (rs != null) {
         HRegionInfo regionInfo = rs.getRegion();
         if (rs.isSplit()) {
-          LOG.debug("Ephemeral node deleted, regionserver crashed?, " +
-            "clearing from RIT; rs=" + rs);
+          LOG.debug("Ephemeral node deleted, regionserver crashed?, offlining the region"
+              + rs.getRegion() + " clearing from RIT;");
           regionOffline(rs.getRegion());
+        } else if (rs.isSplitting()) {
+          LOG.debug("Ephemeral node deleted.  Found in SPLITTING state. " + "Removing from
RIT "
+              + rs.getRegion());
+          this.regionsInTransition.remove(regionName);
         } else {
           LOG.debug("The znode of region " + regionInfo.getRegionNameAsString()
               + " has been deleted.");

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1391074&r1=1391073&r2=1391074&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
Thu Sep 27 16:04:12 2012
@@ -539,7 +539,7 @@ public class SplitTransaction {
    * to create it.
    * @see #cleanupSplitDir(FileSystem, Path)
    */
-  private static void createSplitDir(final FileSystem fs, final Path splitdir)
+  void createSplitDir(final FileSystem fs, final Path splitdir)
   throws IOException {
     if (fs.exists(splitdir)) {
       LOG.info("The " + splitdir

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java?rev=1391074&r1=1391073&r2=1391074&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
Thu Sep 27 16:04:12 2012
@@ -31,12 +31,16 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.executor.RegionTransitionData;
+import org.apache.hadoop.hbase.master.AssignmentManager;
+import org.apache.hadoop.hbase.master.AssignmentManager.RegionState;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.handler.SplitRegionHandler;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -587,6 +591,58 @@ public class TestSplitTransactionOnClust
     }
   }
   
+  @Test
+  public void testShouldClearRITWhenNodeFoundInSplittingState() throws Exception {
+    final byte[] tableName = Bytes.toBytes("testShouldClearRITWhenNodeFoundInSplittingState");
+    HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
+    try {
+      // Create table then get the single region for our new table.
+      HTableDescriptor htd = new HTableDescriptor(tableName);
+      htd.addFamily(new HColumnDescriptor("cf"));
+      admin.createTable(htd);
+
+      List<HRegion> regions = cluster.getRegions(tableName);
+      int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName());
+      HRegionServer regionServer = cluster.getRegionServer(regionServerIndex);
+      SplitTransaction st = null;
+
+      st = new MockedSplitTransaction(regions.get(0), null) {
+        @Override
+        void createSplitDir(FileSystem fs, Path splitdir) throws IOException {
+          throw new IOException("");
+        }
+      };
+
+      try {
+        st.execute(regionServer, regionServer);
+      } catch (IOException e) {
+        String node = ZKAssign.getNodeName(regionServer.getZooKeeper(), regions.get(0)
+            .getRegionInfo().getEncodedName());
+
+        assertFalse(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
+        AssignmentManager am = cluster.getMaster().getAssignmentManager();
+        while (!am.getRegionsInTransition().containsKey(regions.get(0).getRegionInfo().getEncodedName()))
{
+          Thread.sleep(200);
+        }
+        RegionState regionState = am.getRegionsInTransition().get(regions.get(0).getRegionInfo()
+            .getEncodedName());
+        assertTrue(regionState.getState() == RegionState.State.SPLITTING);
+        assertTrue(st.rollback(regionServer, regionServer));
+        assertTrue(ZKUtil.checkExists(regionServer.getZooKeeper(), node) == -1);
+        while (am.getRegionsInTransition().containsKey(regions.get(0).getRegionInfo().getEncodedName()))
{
+          // Just in case the nodeDeleted event did not get executed.
+          Thread.sleep(200);
+        }
+      }
+    } finally {
+      if (admin.isTableAvailable(tableName) && admin.isTableEnabled(tableName)) {
+        admin.disableTable(tableName);
+        admin.deleteTable(tableName);
+        admin.close();
+      }
+    }
+  }
+  
   public static class MockedSplitTransaction extends SplitTransaction {
 
     public MockedSplitTransaction(HRegion r, byte[] splitrow) {



Mime
View raw message