hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r892074 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/master/HMaster.java src/java/org/apache/hadoop/hbase/util/FSUtils.java
Date Fri, 18 Dec 2009 01:33:28 GMT
Author: apurtell
Date: Fri Dec 18 01:33:27 2009
New Revision: 892074

URL: http://svn.apache.org/viewvc?rev=892074&view=rev
Log:
HBASE-1960 Master should wait for DFS to come up when creating hbase.version

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=892074&r1=892073&r2=892074&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Fri Dec 18 01:33:27 2009
@@ -20,6 +20,8 @@
                documentation doesn't work (Benoit Sigoure via JD)
    HBASE-2048  Small inconsistency in the "Example API Usage"
                (Benoit Sigoure via JD)
+   HBASE-1960  Master should wait for DFS to come up when creating 
+               hbase.version
 
   IMPROVEMENTS
    HBASE-1961  HBase EC2 scripts

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=892074&r1=892073&r2=892074&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java Fri Dec
18 01:33:27 2009
@@ -81,8 +81,6 @@
 import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
-import org.apache.hadoop.hdfs.protocol.FSConstants;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
@@ -192,22 +190,12 @@
     // fs.default.name; its value is probably the default.
     this.conf.set("fs.default.name", this.rootdir.toString());
     this.fs = FileSystem.get(conf);
-    if (this.fs instanceof DistributedFileSystem) {
-      // Make sure dfs is not in safe mode
-      String message = "Waiting for dfs to exit safe mode...";
-      while (((DistributedFileSystem) fs).setSafeMode(
-          FSConstants.SafeModeAction.SAFEMODE_GET)) {
-        LOG.info(message);
-        try {
-          Thread.sleep(this.threadWakeFrequency);
-        } catch (InterruptedException e) {
-          //continue
-        }
-      }
-    }
     this.conf.set(HConstants.HBASE_DIR, this.rootdir.toString());
     this.rand = new Random();
 
+    // If FS is in safe mode wait till out of it.
+    FSUtils.waitOnSafeMode(this.conf, this.threadWakeFrequency);
+
     try {
       // Make sure the hbase root directory exists!
       if (!fs.exists(rootdir)) {

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=892074&r1=892073&r2=892074&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/util/FSUtils.java Fri Dec
18 01:33:27 2009
@@ -39,6 +39,7 @@
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.protocol.FSConstants;
 
 /**
  * Utility methods for interacting with the underlying file system.
@@ -128,6 +129,40 @@
   }
   
   /**
+   * If DFS, check safe mode and if so, wait until we clear it.
+   * @param conf
+   * @param wait Sleep between retries
+   * @throws IOException
+   */
+  public static void waitOnSafeMode(final HBaseConfiguration conf,
+    final long wait)
+  throws IOException {
+    FileSystem fs = FileSystem.get(conf);
+    if (!(fs instanceof DistributedFileSystem)) return;
+    DistributedFileSystem dfs = (DistributedFileSystem)fs;
+    // Are there any data nodes up yet?
+    // Currently the safe mode check falls through if the namenode is up but no
+    // datanodes have reported in yet.
+    while (dfs.getDataNodeStats().length == 0) {
+      LOG.info("Waiting for dfs to come up...");
+      try {
+        Thread.sleep(wait);
+      } catch (InterruptedException e) {
+        //continue
+      }
+    }
+    // Make sure dfs is not in safe mode
+    while (dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET)) {
+      LOG.info("Waiting for dfs to exit safe mode...");
+      try {
+        Thread.sleep(wait);
+      } catch (InterruptedException e) {
+        //continue
+      }
+    }
+  }
+
+  /**
    * Verifies current version of file system
    * 
    * @param fs



Mime
View raw message