You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2010/11/23 22:31:19 UTC

svn commit: r1038346 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/HMaster.java src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Author: jdcryans
Date: Tue Nov 23 21:31:18 2010
New Revision: 1038346

URL: http://svn.apache.org/viewvc?rev=1038346&view=rev
Log:
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


Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1038346&r1=1038345&r2=1038346&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Nov 23 21:31:18 2010
@@ -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

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1038346&r1=1038345&r2=1038346&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Tue Nov 23 21:31:18 2010
@@ -557,7 +557,7 @@ implements HMasterInterface, HMasterRegi
     }
     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 {

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1038346&r1=1038345&r2=1038346&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Tue Nov 23 21:31:18 2010
@@ -119,6 +119,7 @@ import org.apache.hadoop.hbase.util.Slee
 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 HR
     // 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,
@@ -473,6 +474,22 @@ public class HRegionServer implements HR
   }
 
   /**
+   * 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
    */
   private boolean isClusterUp() {

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1038346&r1=1038345&r2=1038346&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Tue Nov 23 21:31:18 2010
@@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.protocol.F
 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();
       }