hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject [4/4] hbase git commit: HBASE-12694 testTableExistsIfTheSpecifiedTableRegionIsSplitParent in TestSplitTransactionOnCluster class leaves regions in transition (Vandana Ayyalasomayajula)
Date Wed, 07 Jan 2015 19:08:00 GMT
HBASE-12694 testTableExistsIfTheSpecifiedTableRegionIsSplitParent in TestSplitTransactionOnCluster
class leaves regions in transition (Vandana Ayyalasomayajula)


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

Branch: refs/heads/0.98
Commit: 3a71fc93e77c7a306db70e195b4e98c1688e73f7
Parents: 7890d27
Author: Virag Kothari <virag@yahoo-inc.com>
Authored: Wed Jan 7 11:00:54 2015 -0800
Committer: Virag Kothari <virag@yahoo-inc.com>
Committed: Wed Jan 7 11:00:54 2015 -0800

----------------------------------------------------------------------
 .../hbase/regionserver/SplitTransaction.java    |  1 +
 .../TestSplitTransactionOnCluster.java          | 41 +++++++++++++++++---
 2 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3a71fc93/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
index f4d0473..4bfc092 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
@@ -217,6 +217,7 @@ public class SplitTransaction {
     this.parent = r;
     this.splitrow = splitrow;
     this.journal.add(new JournalEntry(JournalEntryType.STARTED));
+    this.useZKForAssignment = ConfigUtil.useZKForAssignment(r.getBaseConf());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a71fc93/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
index b6744e0..2f463a1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.CoprocessorEnvironment;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.RegionTransition;
@@ -293,7 +294,10 @@ public class TestSplitTransactionOnCluster {
       this.admin.split(region.getRegionName(), new byte[] {42});
 
       // we have to wait until the SPLITTING state is seen by the master
-      FailingSplitRegionObserver.latch.await();
+      FailingSplitRegionObserver observer = (FailingSplitRegionObserver) region
+          .getCoprocessorHost().findCoprocessor(FailingSplitRegionObserver.class.getName());
+      assertNotNull(observer);
+      observer.latch.await();
 
       LOG.info("Waiting for region to come out of RIT");
       TESTING_UTIL.waitFor(60000, 1000, new Waiter.Predicate<Exception>() {
@@ -312,13 +316,26 @@ public class TestSplitTransactionOnCluster {
   }
 
   public static class FailingSplitRegionObserver extends BaseRegionObserver {
-    static volatile CountDownLatch latch = new CountDownLatch(1);
+    volatile CountDownLatch latch;
+    volatile CountDownLatch postSplit;
+    @Override
+    public void start(CoprocessorEnvironment e) throws IOException {
+      latch = new CountDownLatch(1);
+      postSplit = new CountDownLatch(1);
+    }
     @Override
     public void preSplitBeforePONR(ObserverContext<RegionCoprocessorEnvironment> ctx,
         byte[] splitKey, List<Mutation> metaEntries) throws IOException {
       latch.countDown();
+      LOG.info("Causing rollback of region split");
       throw new IOException("Causing rollback of region split");
     }
+    @Override
+    public void postCompleteSplit(ObserverContext<RegionCoprocessorEnvironment> ctx)
+        throws IOException {
+      postSplit.countDown();
+      LOG.info("postCompleteSplit called");
+    }
   }
 
  /**
@@ -855,6 +872,14 @@ public class TestSplitTransactionOnCluster {
       tableExists = MetaReader.tableExists(regionServer.getCatalogTracker(),
           tableName);
       assertEquals("The specified table should present.", true, tableExists);
+      Map<String, RegionState> rit = cluster.getMaster().getAssignmentManager().getRegionStates()
+          .getRegionsInTransition();
+      assertTrue(rit.size() == 3);
+      cluster.getMaster().getAssignmentManager().regionOffline(st.getFirstDaughter());
+      cluster.getMaster().getAssignmentManager().regionOffline(st.getSecondDaughter());
+      cluster.getMaster().getAssignmentManager().regionOffline(region.getRegionInfo());
+      rit = cluster.getMaster().getAssignmentManager().getRegionStates().getRegionsInTransition();
+      assertTrue(rit.size() == 0);
     } finally {
       if (regions != null) {
         String node = ZKAssign.getNodeName(zkw, regions.get(0).getRegionInfo()
@@ -864,6 +889,7 @@ public class TestSplitTransactionOnCluster {
       admin.setBalancerRunning(true, false);
       cluster.getMaster().setCatalogJanitorEnabled(true);
       t.close();
+      TESTING_UTIL.deleteTable(tableName);
     }
   }
 
@@ -1162,7 +1188,7 @@ public class TestSplitTransactionOnCluster {
     return(null);
   }
 
-  @Test
+  @Test(timeout = 120000)
   public void testFailedSplit() throws Exception {
     TableName tableName = TableName.valueOf("testFailedSplit");
     byte[] colFamily = Bytes.toBytes("info");
@@ -1178,18 +1204,23 @@ public class TestSplitTransactionOnCluster {
 
       // The following split would fail.
       admin.split(tableName.getNameAsString());
-      FailingSplitRegionObserver.latch.await();
+      FailingSplitRegionObserver observer = (FailingSplitRegionObserver) actualRegion
+          .getCoprocessorHost().findCoprocessor(FailingSplitRegionObserver.class.getName());
+      assertNotNull(observer);
+      observer.latch.await();
+      observer.postSplit.await();
       LOG.info("Waiting for region to come out of RIT");
       TESTING_UTIL.waitFor(60000, 1000, new Waiter.Predicate<Exception>() {
         @Override
         public boolean evaluate() throws Exception {
           RegionStates regionStates = cluster.getMaster().getAssignmentManager().getRegionStates();
           Map<String, RegionState> rit = regionStates.getRegionsInTransition();
-          return !rit.containsKey(actualRegion.getRegionInfo().getEncodedName());
+          return (rit.size() == 0);
         }
       });
       regions = TESTING_UTIL.getHBaseAdmin().getTableRegions(tableName);
       assertTrue(regions.size() == 1);
+      assertTrue(admin.balancer());
     } finally {
       table.close();
       TESTING_UTIL.deleteTable(tableName);


Mime
View raw message