Index: src/java/org/apache/hadoop/hbase/HMaster.java =================================================================== --- src/java/org/apache/hadoop/hbase/HMaster.java (revision 639779) +++ src/java/org/apache/hadoop/hbase/HMaster.java (working copy) @@ -46,6 +46,8 @@ 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.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -876,10 +878,25 @@ throws IOException { this.conf = conf; this.rootdir = rd; + this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000); // The filesystem hbase wants to use is probably not what is set into // 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)) { + System.out.println(message); + 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(); Path rootRegionDir = @@ -920,7 +937,6 @@ throw e; } - this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000); this.numRetries = conf.getInt("hbase.client.retries.number", 2); this.maxRegionOpenTime = conf.getLong("hbase.hbasemaster.maxregionopen", 60 * 1000);