diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 2cdd136..d9f2add 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -826,7 +826,9 @@ public class HRegionServer extends HasThread implements 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. // TODO: Should we check they are alive? If OOME could have exited already @@ -846,7 +848,9 @@ public class HRegionServer extends HasThread implements } // 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) { // Just skip out w/o closing regions. Used when testing. @@ -889,8 +893,12 @@ public class HRegionServer extends HasThread implements if (this.rssStub != null) { this.rssStub = null; } - this.rpcClient.stop(); - this.leases.close(); + if (this.rpcClient != null) { + this.rpcClient.stop(); + } + if (this.leases != null) { + this.leases.close(); + } if (this.pauseMonitor != null) { this.pauseMonitor.stop(); } @@ -899,7 +907,9 @@ public class HRegionServer extends HasThread implements stopServiceThreads(); } - this.rpcServices.stop(); + if (this.rpcServices != null) { + this.rpcServices.stop(); + } try { deleteMyEphemeralNode(); @@ -910,7 +920,9 @@ public class HRegionServer extends HasThread implements // we delete the file anyway: a second attempt to delete the znode is likely to fail again. ZNodeClearer.deleteMyEphemeralNodeOnDisk(); - this.zooKeeper.close(); + if (this.zooKeeper != null) { + this.zooKeeper.close(); + } LOG.info("stopping server " + this.serverName + "; zookeeper connection closed."); @@ -1839,9 +1851,15 @@ public class HRegionServer extends HasThread implements if (this.nonceManagerChore != null) { Threads.shutdown(this.nonceManagerChore.getThread()); } - Threads.shutdown(this.compactionChecker.getThread()); - Threads.shutdown(this.periodicFlusher.getThread()); - this.cacheFlusher.join(); + if (this.compactionChecker != null) { + Threads.shutdown(this.compactionChecker.getThread()); + } + if (this.periodicFlusher != null) { + Threads.shutdown(this.periodicFlusher.getThread()); + } + if (this.cacheFlusher != null) { + this.cacheFlusher.join(); + } if (this.healthCheckChore != null) { Threads.shutdown(this.healthCheckChore.getThread()); }