Skip to content

HBASE-26941 LocalHBaseCluster.waitOnRegionServer should quit while th… #4333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public Configuration getConfiguration() {
* Wait for the specified region server to stop. Removes this thread from list of running threads.
* @return Name of region server that just went down.
*/
public String waitOnRegionServer(int serverNumber) {
public String waitOnRegionServer(int serverNumber) throws InterruptedException {
JVMClusterUtil.RegionServerThread regionServerThread = this.regionThreads.get(serverNumber);
return waitOnRegionServer(regionServerThread);
}
Expand All @@ -309,15 +309,11 @@ public String waitOnRegionServer(int serverNumber) {
* Wait for the specified region server to stop. Removes this thread from list of running threads.
* @return Name of region server that just went down.
*/
public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) {
public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst)
throws InterruptedException {
while (rst.isAlive()) {
try {
LOG.info("Waiting on " + rst.getRegionServer().toString());
rst.join();
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting for {} to finish. Retrying join", rst.getName(), e);
Thread.currentThread().interrupt();
}
LOG.info("Waiting on " + rst.getRegionServer().toString());
rst.join();
}
regionThreads.remove(rst);
return rst.getName();
Expand Down Expand Up @@ -373,7 +369,7 @@ public List<JVMClusterUtil.MasterThread> getLiveMasters() {
* Wait for the specified master to stop. Removes this thread from list of running threads.
* @return Name of master that just went down.
*/
public String waitOnMaster(int serverNumber) {
public String waitOnMaster(int serverNumber) throws InterruptedException {
JVMClusterUtil.MasterThread masterThread = this.masterThreads.get(serverNumber);
return waitOnMaster(masterThread);
}
Expand All @@ -382,16 +378,10 @@ public String waitOnMaster(int serverNumber) {
* Wait for the specified master to stop. Removes this thread from list of running threads.
* @return Name of master that just went down.
*/
public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) {
public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) throws InterruptedException {
while (masterThread.isAlive()) {
try {
LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
masterThread.join();
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting for {} to finish. Retrying join",
masterThread.getName(), e);
Thread.currentThread().interrupt();
}
LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
masterThread.join();
}
masterThreads.remove(masterThread);
return masterThread.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.hbase;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -297,7 +298,11 @@ public void resumeRegionServer(ServerName serverName) throws IOException {
@Override
public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException {
// ignore timeout for now
waitOnRegionServer(getRegionServerIndex(serverName));
try {
waitOnRegionServer(getRegionServerIndex(serverName));
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
}

@Override
Expand Down Expand Up @@ -393,7 +398,11 @@ public void stopMaster(ServerName serverName) throws IOException {
@Override
public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException {
// ignore timeout for now
waitOnMaster(getMasterIndex(serverName));
try {
waitOnMaster(getMasterIndex(serverName));
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
}

/**
Expand Down Expand Up @@ -509,7 +518,7 @@ public JVMClusterUtil.RegionServerThread resumeRegionServer(int serverNumber) {
* Wait for the specified region server to stop. Removes this thread from list of running threads.
* @return Name of region server that just went down.
*/
public String waitOnRegionServer(final int serverNumber) {
public String waitOnRegionServer(final int serverNumber) throws InterruptedException {
return this.hbaseCluster.waitOnRegionServer(serverNumber);
}

Expand Down Expand Up @@ -601,7 +610,7 @@ public JVMClusterUtil.MasterThread stopMaster(int serverNumber, final boolean sh
* Wait for the specified master to stop. Removes this thread from list of running threads.
* @return Name of master that just went down.
*/
public String waitOnMaster(final int serverNumber) {
public String waitOnMaster(final int serverNumber) throws InterruptedException {
return this.hbaseCluster.waitOnMaster(serverNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static void teardown() throws Exception {
}

@Test
public void testInfo() {
public void testInfo() throws InterruptedException {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master);
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.hbase;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -310,7 +311,11 @@ public void resumeRegionServer(ServerName serverName) throws IOException {
@Override
public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException {
//ignore timeout for now
waitOnRegionServer(getRegionServerIndex(serverName));
try {
waitOnRegionServer(getRegionServerIndex(serverName));
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
}

@Override
Expand Down Expand Up @@ -406,7 +411,11 @@ public void stopMaster(ServerName serverName) throws IOException {
@Override
public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException {
//ignore timeout for now
waitOnMaster(getMasterIndex(serverName));
try {
waitOnMaster(getMasterIndex(serverName));
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
}

/**
Expand Down Expand Up @@ -535,7 +544,7 @@ public JVMClusterUtil.RegionServerThread resumeRegionServer(int serverNumber) {
* @param serverNumber
* @return Name of region server that just went down.
*/
public String waitOnRegionServer(final int serverNumber) {
public String waitOnRegionServer(final int serverNumber) throws InterruptedException {
return this.hbaseCluster.waitOnRegionServer(serverNumber);
}

Expand Down Expand Up @@ -640,7 +649,7 @@ public JVMClusterUtil.MasterThread stopMaster(int serverNumber,
* @param serverNumber
* @return Name of master that just went down.
*/
public String waitOnMaster(final int serverNumber) {
public String waitOnMaster(final int serverNumber) throws InterruptedException {
return this.hbaseCluster.waitOnMaster(serverNumber);
}

Expand Down