HBASE-19117 Avoid NPE occurring while active master dies

This commit is contained in:
Chia-Ping Tsai 2017-10-30 06:15:48 +08:00
parent ac6b998afe
commit 22b07e91d7

View File

@ -543,14 +543,17 @@ public class HMaster extends HRegionServer implements MasterServices {
try { try {
super.run(); super.run();
} finally { } finally {
if (this.clusterSchemaService != null) {
// If on way out, then we are no longer active master. // If on way out, then we are no longer active master.
this.clusterSchemaService.stopAsync(); this.clusterSchemaService.stopAsync();
try { try {
this.clusterSchemaService.awaitTerminated(getConfiguration().getInt(HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS, this.clusterSchemaService.awaitTerminated(
getConfiguration().getInt(HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS,
DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS), TimeUnit.SECONDS); DEFAULT_HBASE_MASTER_WAIT_ON_SERVICE_IN_SECONDS), TimeUnit.SECONDS);
} catch (TimeoutException te) { } catch (TimeoutException te) {
LOG.warn("Failed shutdown of clusterSchemaService", te); LOG.warn("Failed shutdown of clusterSchemaService", te);
} }
}
this.activeMaster = false; this.activeMaster = false;
} }
} }