HBASE-4780 Lower mini cluster shutdown time in HRegionServer#waitOnAllRegionsToClose and ServerManager#letRegionServersShutdown

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1201954 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-11-14 22:50:10 +00:00
parent 6ebf318735
commit 1c9f356fca
2 changed files with 26 additions and 12 deletions

View File

@ -308,19 +308,25 @@ public class ServerManager {
}
void letRegionServersShutdown() {
synchronized (onlineServers) {
while (!onlineServers.isEmpty()) {
long previousLogTime = 0;
while (!onlineServers.isEmpty()) {
if (System.currentTimeMillis() > (previousLogTime + 1000)) {
StringBuilder sb = new StringBuilder();
for (ServerName key: this.onlineServers.keySet()) {
for (ServerName key : this.onlineServers.keySet()) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(key);
}
LOG.info("Waiting on regionserver(s) to go down " + sb.toString());
previousLogTime = System.currentTimeMillis();
}
synchronized (onlineServers) {
try {
this.onlineServers.wait(1000);
} catch (InterruptedException e) {
onlineServers.wait(100);
} catch (InterruptedException ignored) {
// continue
}
}
@ -348,6 +354,9 @@ public class ServerManager {
// not in online servers list.
this.deadservers.add(serverName);
this.onlineServers.remove(serverName);
synchronized (onlineServers) {
onlineServers.notifyAll();
}
this.serverConnections.remove(serverName);
// If cluster is going down, yes, servers are going to be expiring; don't
// process as a dead server

View File

@ -831,16 +831,21 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
private void waitOnAllRegionsToClose(final boolean abort) {
// Wait till all regions are closed before going out.
int lastCount = -1;
long previousLogTime = 0;
while (!isOnlineRegionsEmpty()) {
int count = getNumberOfOnlineRegions();
// Only print a message if the count of regions has changed.
if (count != lastCount) {
lastCount = count;
LOG.info("Waiting on " + count + " regions to close");
// Only print out regions still closing if a small number else will
// swamp the log.
if (count < 10 && LOG.isDebugEnabled()) {
LOG.debug(this.onlineRegions);
// Log every second at most
if (System.currentTimeMillis() > (previousLogTime + 1000)) {
previousLogTime = System.currentTimeMillis();
lastCount = count;
LOG.info("Waiting on " + count + " regions to close");
// Only print out regions still closing if a small number else will
// swamp the log.
if (count < 10 && LOG.isDebugEnabled()) {
LOG.debug(this.onlineRegions);
}
}
}
// Ensure all user regions have been sent a close. Use this to
@ -853,7 +858,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
closeRegion(hri, abort, false);
}
}
Threads.sleep(1000);
Threads.sleep(200);
}
}