HBASE-11458 NPEs if RegionServer cannot initialize

This commit is contained in:
Enis Soztutar 2014-07-07 20:35:40 -07:00
parent 36d84a1515
commit b47a3f6924
1 changed files with 27 additions and 9 deletions

View File

@ -825,7 +825,9 @@ public class HRegionServer extends HasThread implements
cacheConfig.getBlockCache().shutdown(); cacheConfig.getBlockCache().shutdown();
} }
movedRegionsCleaner.stop("Region Server stopping"); if (movedRegionsCleaner != null) {
movedRegionsCleaner.stop("Region Server stopping");
}
// Send interrupts to wake up threads if sleeping so they notice shutdown. // Send interrupts to wake up threads if sleeping so they notice shutdown.
// TODO: Should we check they are alive? If OOME could have exited already // TODO: Should we check they are alive? If OOME could have exited already
@ -845,7 +847,9 @@ public class HRegionServer extends HasThread implements
} }
// Stop the snapshot and other procedure handlers, forcefully killing all running tasks // Stop the snapshot and other procedure handlers, forcefully killing all running tasks
rspmHost.stop(this.abortRequested || this.killed); if (rspmHost != null) {
rspmHost.stop(this.abortRequested || this.killed);
}
if (this.killed) { if (this.killed) {
// Just skip out w/o closing regions. Used when testing. // Just skip out w/o closing regions. Used when testing.
@ -897,8 +901,12 @@ public class HRegionServer extends HasThread implements
if (this.rssStub != null) { if (this.rssStub != null) {
this.rssStub = null; this.rssStub = null;
} }
this.rpcClient.stop(); if (this.rpcClient != null) {
this.leases.close(); this.rpcClient.stop();
}
if (this.leases != null) {
this.leases.close();
}
if (this.pauseMonitor != null) { if (this.pauseMonitor != null) {
this.pauseMonitor.stop(); this.pauseMonitor.stop();
} }
@ -907,7 +915,9 @@ public class HRegionServer extends HasThread implements
stopServiceThreads(); stopServiceThreads();
} }
this.rpcServices.stop(); if (this.rpcServices != null) {
this.rpcServices.stop();
}
try { try {
deleteMyEphemeralNode(); deleteMyEphemeralNode();
@ -918,7 +928,9 @@ public class HRegionServer extends HasThread implements
// we delete the file anyway: a second attempt to delete the znode is likely to fail again. // we delete the file anyway: a second attempt to delete the znode is likely to fail again.
ZNodeClearer.deleteMyEphemeralNodeOnDisk(); ZNodeClearer.deleteMyEphemeralNodeOnDisk();
this.zooKeeper.close(); if (this.zooKeeper != null) {
this.zooKeeper.close();
}
LOG.info("stopping server " + this.serverName + LOG.info("stopping server " + this.serverName +
"; zookeeper connection closed."); "; zookeeper connection closed.");
@ -1852,9 +1864,15 @@ public class HRegionServer extends HasThread implements
if (this.nonceManagerChore != null) { if (this.nonceManagerChore != null) {
Threads.shutdown(this.nonceManagerChore.getThread()); Threads.shutdown(this.nonceManagerChore.getThread());
} }
Threads.shutdown(this.compactionChecker.getThread()); if (this.compactionChecker != null) {
Threads.shutdown(this.periodicFlusher.getThread()); Threads.shutdown(this.compactionChecker.getThread());
this.cacheFlusher.join(); }
if (this.periodicFlusher != null) {
Threads.shutdown(this.periodicFlusher.getThread());
}
if (this.cacheFlusher != null) {
this.cacheFlusher.join();
}
if (this.healthCheckChore != null) { if (this.healthCheckChore != null) {
Threads.shutdown(this.healthCheckChore.getThread()); Threads.shutdown(this.healthCheckChore.getThread());
} }