From 3314b87804e2bbf0e69bf38874937a09a4d467ff Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 13 Jul 2011 09:23:56 +0000 Subject: [PATCH] HBASE-4075 A bug in TestZKBasedOpenCloseRegion git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1145927 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../master/TestZKBasedOpenCloseRegion.java | 50 +++++++++---------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0b9ba405e28..ae6bbd45ae3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -159,6 +159,7 @@ Release 0.91.0 - Unreleased HBASE-4077 Deadlock if WrongRegionException is thrown from getLock in HRegion.delete (Adam Warrington via Ted Yu) HBASE-3893 HRegion.internalObtainRowLock shouldn't wait forever + HBASE-4075 A bug in TestZKBasedOpenCloseRegion (Jieshan Bean via Ted Yu) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java b/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java index 308fc9e4ff9..a9cf2a55e2c 100644 --- a/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java +++ b/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java @@ -188,31 +188,6 @@ public class TestZKBasedOpenCloseRegion { } } - @Test (timeout=300000) public void testCloseRegion() - throws Exception { - LOG.info("Running testCloseRegion"); - MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); - LOG.info("Number of region servers = " + cluster.getLiveRegionServerThreads().size()); - - int rsIdx = 0; - HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(rsIdx); - HRegionInfo hri = getNonMetaRegion(regionServer.getOnlineRegions()); - LOG.debug("Asking RS to close region " + hri.getRegionNameAsString()); - - AtomicBoolean closeEventProcessed = new AtomicBoolean(false); - EventHandlerListener listener = - new CloseRegionEventListener(hri.getRegionNameAsString(), - closeEventProcessed); - cluster.getMaster().executorService.registerListener(EventType.RS_ZK_REGION_CLOSED, listener); - - cluster.getMaster().assignmentManager.unassign(hri); - - while (!closeEventProcessed.get()) { - Threads.sleep(100); - } - LOG.info("Done with testCloseRegion"); - } - public static class CloseRegionEventListener implements EventHandlerListener { private static final Log LOG = LogFactory.getLog(CloseRegionEventListener.class); String regionToClose; @@ -301,6 +276,31 @@ public class TestZKBasedOpenCloseRegion { } + @Test (timeout=300000) public void testCloseRegion() + throws Exception { + LOG.info("Running testCloseRegion"); + MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); + LOG.info("Number of region servers = " + cluster.getLiveRegionServerThreads().size()); + + int rsIdx = 0; + HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(rsIdx); + HRegionInfo hri = getNonMetaRegion(regionServer.getOnlineRegions()); + LOG.debug("Asking RS to close region " + hri.getRegionNameAsString()); + + AtomicBoolean closeEventProcessed = new AtomicBoolean(false); + EventHandlerListener listener = + new CloseRegionEventListener(hri.getRegionNameAsString(), + closeEventProcessed); + cluster.getMaster().executorService.registerListener(EventType.RS_ZK_REGION_CLOSED, listener); + + cluster.getMaster().assignmentManager.unassign(hri); + + while (!closeEventProcessed.get()) { + Threads.sleep(100); + } + LOG.info("Done with testCloseRegion"); + } + private static void waitUntilAllRegionsAssigned() throws IOException { HTable meta = new HTable(TEST_UTIL.getConfiguration(),