hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r892073 - in /hadoop/hbase/branches/0.20_on_hadoop-0.18.3: 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:27 GMT
Author: apurtell
Date: Fri Dec 18 01:33:26 2009
New Revision: 892073

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

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

Modified: hadoop/hbase/branches/0.20_on_hadoop-0.18.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_on_hadoop-0.18.3/CHANGES.txt?rev=892073&r1=892072&r2=892073&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20_on_hadoop-0.18.3/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20_on_hadoop-0.18.3/CHANGES.txt Fri Dec 18 01:33:26 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_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=892073&r1=892072&r2=892073&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++ hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/master/HMaster.java
Fri Dec 18 01:33:26 2009
@@ -192,22 +192,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_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=892073&r1=892072&r2=892073&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/util/FSUtils.java
(original)
+++ hadoop/hbase/branches/0.20_on_hadoop-0.18.3/src/java/org/apache/hadoop/hbase/util/FSUtils.java
Fri Dec 18 01:33:26 2009
@@ -28,6 +28,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.dfs.DistributedFileSystem;
+import org.apache.hadoop.dfs.FSConstants;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
@@ -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