From 6a1b724e6d9ca1df26809c2df4803d38305633c9 Mon Sep 17 00:00:00 2001 From: jxiang Date: Thu, 18 Jul 2013 22:07:11 +0000 Subject: [PATCH] HBASE-8991 TestMasterFailover.testMasterFailoverWithMockedRITOnDeadRS failed again git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504683 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/regionserver/HRegionServer.java | 1 - .../hbase/master/TestMasterFailover.java | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 5c7a260229d..0e7900ff89c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2196,7 +2196,6 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa return this.rsHost; } - @Override public ConcurrentMap getRegionsInTransitionInRS() { return this.regionsInTransitionInRS; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java index 37cac60cd12..ac8fc6b932b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java @@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -41,7 +40,6 @@ import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.LargeTests; @@ -789,7 +787,7 @@ public class TestMasterFailover { ZKAssign.blockUntilNoRIT(zkw); log("No more RIT in ZK"); long now = System.currentTimeMillis(); - final long maxTime = 120000; + long maxTime = 120000; boolean done = master.assignmentManager.waitUntilNoRegionsInTransition(maxTime); if (!done) { LOG.info("rit=" + master.getAssignmentManager().getRegionStates().getRegionsInTransition()); @@ -801,10 +799,22 @@ public class TestMasterFailover { // Grab all the regions that are online across RSs Set onlineRegions = new TreeSet(); + now = System.currentTimeMillis(); + maxTime = 30000; for (JVMClusterUtil.RegionServerThread rst : cluster.getRegionServerThreads()) { try { - onlineRegions.addAll(ProtobufUtil.getOnlineRegions(rst.getRegionServer())); + HRegionServer rs = rst.getRegionServer(); + while (!rs.getRegionsInTransitionInRS().isEmpty()) { + elapsed = System.currentTimeMillis() - now; + assertTrue("Test timed out in getting online regions", elapsed < maxTime); + if (rs.isAborted() || rs.isStopped()) { + // This region server is stopped, skip it. + break; + } + Thread.sleep(100); + } + onlineRegions.addAll(ProtobufUtil.getOnlineRegions(rs)); } catch (RegionServerStoppedException e) { LOG.info("Got RegionServerStoppedException", e); }