HBASE-13526 TestRegionServerReportForDuty can be flaky: hang or timeout
This commit is contained in:
parent
afd7a8f474
commit
6c427175b8
|
@ -92,6 +92,8 @@ public class TestRegionServerReportForDuty {
|
||||||
master.start();
|
master.start();
|
||||||
rs.start();
|
rs.start();
|
||||||
|
|
||||||
|
waitForClusterOnline(master);
|
||||||
|
|
||||||
// Add a 2nd region server
|
// Add a 2nd region server
|
||||||
cluster.getConfiguration().set(HConstants.REGION_SERVER_IMPL, MyRegionServer.class.getName());
|
cluster.getConfiguration().set(HConstants.REGION_SERVER_IMPL, MyRegionServer.class.getName());
|
||||||
rs2 = cluster.addRegionServer();
|
rs2 = cluster.addRegionServer();
|
||||||
|
@ -101,7 +103,7 @@ public class TestRegionServerReportForDuty {
|
||||||
LOG.debug("Starting 2nd region server: " + rs2.getRegionServer().getServerName());
|
LOG.debug("Starting 2nd region server: " + rs2.getRegionServer().getServerName());
|
||||||
rs2.start();
|
rs2.start();
|
||||||
|
|
||||||
waitForClusterOnline(master);
|
waitForSecondRsStarted();
|
||||||
|
|
||||||
// Stop the current master.
|
// Stop the current master.
|
||||||
master.getMaster().stop("Stopping master");
|
master.getMaster().stop("Stopping master");
|
||||||
|
@ -126,8 +128,7 @@ public class TestRegionServerReportForDuty {
|
||||||
|
|
||||||
private void waitForClusterOnline(MasterThread master) throws InterruptedException {
|
private void waitForClusterOnline(MasterThread master) throws InterruptedException {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (master.getMaster().isInitialized()
|
if (master.getMaster().isInitialized()) {
|
||||||
&& ((MyRegionServer) rs2.getRegionServer()).getRpcStubCreatedFlag() == true) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Thread.sleep(SLEEP_INTERVAL);
|
Thread.sleep(SLEEP_INTERVAL);
|
||||||
|
@ -136,6 +137,16 @@ public class TestRegionServerReportForDuty {
|
||||||
rs.waitForServerOnline();
|
rs.waitForServerOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void waitForSecondRsStarted() throws InterruptedException {
|
||||||
|
while (true) {
|
||||||
|
if (((MyRegionServer) rs2.getRegionServer()).getRpcStubCreatedFlag() == true) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(SLEEP_INTERVAL);
|
||||||
|
LOG.debug("Waiting 2nd RS to be started ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a Region Server that provide a hook so that we can wait for the master switch over
|
// Create a Region Server that provide a hook so that we can wait for the master switch over
|
||||||
// before continuing reportForDuty to the mater.
|
// before continuing reportForDuty to the mater.
|
||||||
// The idea is that we get a RPC connection to the first active master, then we wait.
|
// The idea is that we get a RPC connection to the first active master, then we wait.
|
||||||
|
@ -170,6 +181,7 @@ public class TestRegionServerReportForDuty {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(SLEEP_INTERVAL);
|
Thread.sleep(SLEEP_INTERVAL);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
LOG.debug("Waiting for master switch over ... ");
|
LOG.debug("Waiting for master switch over ... ");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue