You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/07/13 07:17:13 UTC
svn commit: r1145866 - in /hbase/branches/0.90: CHANGES.txt
src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
Author: stack
Date: Wed Jul 13 05:17:13 2011
New Revision: 1145866
URL: http://svn.apache.org/viewvc?rev=1145866&view=rev
Log:
HBASE-4075 A bug in TestZKBasedOpenCloseRegion
Modified:
hbase/branches/0.90/CHANGES.txt
hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1145866&r1=1145865&r2=1145866&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Wed Jul 13 05:17:13 2011
@@ -67,6 +67,7 @@ Release 0.90.4 - Unreleased
(Adam Warrington via Ted Yu)
HBASE-3893 HRegion.internalObtainRowLock shouldn't wait forever
HBASE-4088 npes in server shutdown
+ HBASE-4075 A bug in TestZKBasedOpenCloseRegion (Jieshan Bean)
IMPROVEMENT
HBASE-3882 hbase-config.sh needs to be updated so it can auto-detects the
Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1145866&r1=1145865&r2=1145866&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java Wed Jul 13 05:17:13 2011
@@ -188,6 +188,59 @@ public class TestZKBasedOpenCloseRegion
}
}
+ /**
+ * This test shows how a region won't be able to be assigned to a RS
+ * if it's already "processing" it.
+ * @throws Exception
+ */
+ @Test
+ public void testRSAlreadyProcessingRegion() throws Exception {
+ MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+
+ HRegionServer hr0 =
+ cluster.getLiveRegionServerThreads().get(0).getRegionServer();
+ HRegionServer hr1 =
+ cluster.getLiveRegionServerThreads().get(1).getRegionServer();
+ HRegionInfo hri = getNonMetaRegion(hr0.getOnlineRegions());
+
+ // fake that hr1 is processing the region
+ hr1.getRegionsInTransitionInRS().add(hri.getEncodedNameAsBytes());
+
+ AtomicBoolean reopenEventProcessed = new AtomicBoolean(false);
+ EventHandlerListener openListener =
+ new ReopenEventListener(hri.getRegionNameAsString(),
+ reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
+ cluster.getMaster().executorService.
+ registerListener(EventType.RS_ZK_REGION_OPENED, openListener);
+
+ // now ask the master to move the region to hr1, will fail
+ TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
+ Bytes.toBytes(hr1.getServerName()));
+
+ while (!reopenEventProcessed.get()) {
+ Threads.sleep(100);
+ }
+
+ // make sure the region came back
+ assertTrue(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
+
+ // remove the block and reset the boolean
+ hr1.getRegionsInTransitionInRS().remove(hri.getEncodedNameAsBytes());
+ reopenEventProcessed.set(false);
+
+ // move the region again, but this time it will work
+ TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
+ Bytes.toBytes(hr1.getServerName()));
+
+ while (!reopenEventProcessed.get()) {
+ Threads.sleep(100);
+ }
+
+ // make sure the region has moved from the original RS
+ assertTrue(hr0.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
+
+ }
+
@Test (timeout=300000) public void testCloseRegion()
throws Exception {
LOG.info("Running testCloseRegion");
@@ -247,58 +300,6 @@ public class TestZKBasedOpenCloseRegion
}
}
- /**
- * This test shows how a region won't be able to be assigned to a RS
- * if it's already "processing" it.
- * @throws Exception
- */
- @Test
- public void testRSAlreadyProcessingRegion() throws Exception {
- MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
-
- HRegionServer hr0 =
- cluster.getLiveRegionServerThreads().get(0).getRegionServer();
- HRegionServer hr1 =
- cluster.getLiveRegionServerThreads().get(1).getRegionServer();
- HRegionInfo hri = getNonMetaRegion(hr0.getOnlineRegions());
-
- // fake that hr1 is processing the region
- hr1.getRegionsInTransitionInRS().add(hri.getEncodedNameAsBytes());
-
- AtomicBoolean reopenEventProcessed = new AtomicBoolean(false);
- EventHandlerListener openListener =
- new ReopenEventListener(hri.getRegionNameAsString(),
- reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
- cluster.getMaster().executorService.
- registerListener(EventType.RS_ZK_REGION_OPENED, openListener);
-
- // now ask the master to move the region to hr1, will fail
- TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
- Bytes.toBytes(hr1.getServerName()));
-
- while (!reopenEventProcessed.get()) {
- Threads.sleep(100);
- }
-
- // make sure the region came back
- assertTrue(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
-
- // remove the block and reset the boolean
- hr1.getRegionsInTransitionInRS().remove(hri.getEncodedNameAsBytes());
- reopenEventProcessed.set(false);
-
- // move the region again, but this time it will work
- TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
- Bytes.toBytes(hr1.getServerName()));
-
- while (!reopenEventProcessed.get()) {
- Threads.sleep(100);
- }
-
- // make sure the region has moved from the original RS
- assertTrue(hr0.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
-
- }
private static void waitUntilAllRegionsAssigned()
throws IOException {