diff --git a/CHANGES.txt b/CHANGES.txt index 763ddbc5389..7bbea33b69a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -203,6 +203,7 @@ Release 0.91.0 - Unreleased HBASE-4211 Do init-sizing of the StringBuilder making a ServerName (BenoƮt Sigoure) HBASE-4175 Fix FSUtils.createTableDescriptor() (Ramkrishna) + HBASE-4008 Problem while stopping HBase (Akash Ashok) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index a00b93de847..97841953b27 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -1336,6 +1336,11 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server { return this.stopped; } + boolean isAborted() { + return this.abort; + } + + /** * Report whether this master is currently the active master or not. * If not active master, we are parked on ZK waiting to become active. diff --git a/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java b/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java index 72720631ed8..44d28dff8cc 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java +++ b/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java @@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.MasterNotRunningException; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.apache.hadoop.hbase.util.ServerCommandLine; import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; import org.apache.zookeeper.KeeperException; @@ -138,6 +139,7 @@ public class HMasterCommandLine extends ServerCommandLine { LocalHMaster.class, HRegionServer.class); ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster); cluster.startup(); + waitOnMasterThreads(cluster); } else { HMaster master = HMaster.constructMaster(masterClass, conf); if (master.isStopped()) { @@ -146,6 +148,8 @@ public class HMasterCommandLine extends ServerCommandLine { } master.start(); master.join(); + if(master.isAborted()) + throw new RuntimeException("HMaster Aborted"); } } catch (Throwable t) { LOG.error("Failed to start master", t); @@ -177,6 +181,27 @@ public class HMasterCommandLine extends ServerCommandLine { return 0; } + private void waitOnMasterThreads(LocalHBaseCluster cluster) throws InterruptedException{ + List masters = cluster.getMasters(); + List regionservers = cluster.getRegionServers(); + + if (masters != null) { + for (JVMClusterUtil.MasterThread t : masters) { + t.join(); + if(t.getMaster().isAborted()) { + closeAllRegionServerThreads(regionservers); + throw new RuntimeException("HMaster Aborted"); + } + } + } + } + + private static void closeAllRegionServerThreads(List regionservers) { + for(JVMClusterUtil.RegionServerThread t : regionservers){ + t.getRegionServer().stop("HMaster Aborted; Bringing down regions servers"); + } + } + /* * Version of master that will shutdown the passed zk cluster on its way out. */ @@ -204,4 +229,4 @@ public class HMasterCommandLine extends ServerCommandLine { this.zkcluster = zkcluster; } } -} \ No newline at end of file +}