diff --git a/CHANGES.txt b/CHANGES.txt index 922b4caed06..c50b0fda96f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -49,7 +49,8 @@ Hbase Change Log HBASE-528 table 'does not exist' when it does HBASE-531 Merge tool won't merge two overlapping regions (port HBASE-483 to trunk) - + HBASE-537 Wait for hdfs to exit safe mode + IMPROVEMENTS HBASE-415 Rewrite leases to use DelayedBlockingQueue instead of polling HBASE-35 Make BatchUpdate public in the API diff --git a/src/java/org/apache/hadoop/hbase/master/HMaster.java b/src/java/org/apache/hadoop/hbase/master/HMaster.java index 4e8ec54119d..fabcc70320f 100644 --- a/src/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/src/java/org/apache/hadoop/hbase/master/HMaster.java @@ -36,6 +36,8 @@ import java.util.concurrent.atomic.AtomicInteger; 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.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.io.Cell; @@ -171,10 +173,25 @@ public class HMaster extends Thread implements HConstants, HMasterInterface, 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 = @@ -215,7 +232,6 @@ public class HMaster extends Thread implements HConstants, HMasterInterface, 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);