HBASE-4153 Ramkrishna's fix for TestZKBasedOpenCloseRegion#testRSAlreadyProcessingRegion

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1174105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-09-22 13:03:27 +00:00
parent 2fd0a26de9
commit 083d104243
2 changed files with 14 additions and 7 deletions

View File

@ -20,13 +20,12 @@
package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.hbase.catalog.CatalogTracker;
import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
import org.apache.zookeeper.KeeperException;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap;
/**
* Services provided by {@link HRegionServer}
@ -77,6 +76,6 @@ public interface RegionServerServices extends OnlineRegions {
* Get the regions that are currently being opened or closed in the RS
* @return map of regions in transition in this RS
*/
public ConcurrentSkipListMap<byte[], Boolean> getRegionsInTransitionInRS();
public Map<byte[], Boolean> getRegionsInTransitionInRS();
}

View File

@ -257,21 +257,29 @@ public class TestZKBasedOpenCloseRegion {
// make sure the region came back
assertEquals(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()), null);
// remove the block and reset the boolean
hr1.getRegionsInTransitionInRS().remove(hri.getEncodedNameAsBytes());
reopenEventProcessed.set(false);
// now try moving a region when there is no region in transition.
hri = getNonMetaRegion(hr1.getOnlineRegions());
// move the region again, but this time it will work
openListener =
new ReopenEventListener(hri.getRegionNameAsString(),
reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
cluster.getMaster().executorService.
registerListener(EventType.RS_ZK_REGION_OPENED, openListener);
TEST_UTIL.getHBaseAdmin().move(hri.getEncodedNameAsBytes(),
Bytes.toBytes(hr1.getServerName().toString()));
Bytes.toBytes(hr0.getServerName().toString()));
while (!reopenEventProcessed.get()) {
Threads.sleep(100);
}
// make sure the region has moved from the original RS
assertTrue(hr0.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
assertTrue(hr1.getOnlineRegion(hri.getEncodedNameAsBytes()) == null);
}