diff --git a/CHANGES.txt b/CHANGES.txt index a0bb505ec22..c258514f580 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -702,6 +702,9 @@ Release 0.90.0 - Unreleased HBASE-3252 TestZooKeeperNodeTracker sometimes fails due to a race condition in test notification (Gary Helmling via Andrew Purtell) HBASE-3253 Thrift's missing from all the repositories in pom.xml + HBASE-3258 EOF when version file is empty + HBASE-3259 Can't kill the region servers when they wait on the master or + the cluster state znode IMPROVEMENTS 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 3b27df23d43..03c02a9f2dc 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -557,7 +557,7 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server { } if (this.rpcServer != null) this.rpcServer.stop(); // Clean up and close up shop - this.logCleaner.interrupt(); + if (this.logCleaner!= null) this.logCleaner.interrupt(); if (this.infoServer != null) { LOG.info("Stopping infoServer"); try { diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index ca5382d35fc..dd861d9286c 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -119,6 +119,7 @@ import org.apache.hadoop.hbase.util.Sleeper; import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker; import org.apache.hadoop.hbase.zookeeper.ZKUtil; +import org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.hadoop.io.MapWritable; import org.apache.hadoop.io.Writable; @@ -456,15 +457,15 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, // Create the master address manager, register with zk, and start it. Then // block until a master is available. No point in starting up if no master // running. - this.masterAddressManager = new MasterAddressTracker(zooKeeper, this); + this.masterAddressManager = new MasterAddressTracker(this.zooKeeper, this); this.masterAddressManager.start(); - this.masterAddressManager.blockUntilAvailable(); + blockAndCheckIfStopped(this.masterAddressManager); // Wait on cluster being up. Master will set this flag up in zookeeper // when ready. this.clusterStatusTracker = new ClusterStatusTracker(this.zooKeeper, this); this.clusterStatusTracker.start(); - this.clusterStatusTracker.blockUntilAvailable(); + blockAndCheckIfStopped(this.clusterStatusTracker); // Create the catalog tracker and start it; this.catalogTracker = new CatalogTracker(this.zooKeeper, this.connection, @@ -472,6 +473,22 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, catalogTracker.start(); } + /** + * Utilty method to wait indefinitely on a znode availability while checking + * if the region server is shut down + * @param tracker znode tracker to use + * @throws IOException any IO exception, plus if the RS is stopped + * @throws InterruptedException + */ + private void blockAndCheckIfStopped(ZooKeeperNodeTracker tracker) + throws IOException, InterruptedException { + while (tracker.blockUntilAvailable(this.msgInterval) == null) { + if (this.stopped) { + throw new IOException("Received the shutdown message while waiting."); + } + } + } + /** * @return False if cluster shutdown in progress */ diff --git a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 7412e7de060..c88b320bc61 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.protocol.FSConstants; import org.apache.hadoop.io.SequenceFile; import java.io.DataInputStream; +import java.io.EOFException; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -149,6 +150,8 @@ public class FSUtils { fs.open(versionFile); try { version = DataInputStream.readUTF(s); + } catch (EOFException eof) { + LOG.warn("Version file was empty, odd, will try to set it."); } finally { s.close(); }