Index: src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (revision 1100866) +++ src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (working copy) @@ -132,6 +132,7 @@ if (this.fsOk) { try { FSUtils.checkFileSystemAvailable(this.fs); + FSUtils.checkDfsSafeMode(this.conf); } catch (IOException e) { master.abort("Shutting down HBase cluster: file system not available", e); this.fsOk = false; @@ -194,6 +195,9 @@ HLogSplitter splitter = HLogSplitter.createLogSplitter( conf, rootdir, logDir, oldLogDir, this.fs); try { + // If FS is in safe mode, just wait till out of it. + FSUtils.waitOnSafeMode(conf, conf.getInt(HConstants.THREAD_WAKE_FREQUENCY, + 10 * 1000)); splitter.splitLog(); } catch (OrphanHLogAfterSplitException e) { LOG.warn("Retrying splitting because of:", e); Index: src/main/java/org/apache/hadoop/hbase/util/FSUtils.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (revision 1100866) +++ src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (working copy) @@ -138,6 +138,27 @@ } /** + * Check whether dfs is on safemode. + * @param conf + * @return true if dfs is on safemode. + * @throws IOException + */ + public static void checkDfsSafeMode(final Configuration conf) + throws IOException { + boolean isOnSafeMode = false; + FileSystem fs = FileSystem.get(conf); + + if (fs instanceof DistributedFileSystem) { + DistributedFileSystem dfs = (DistributedFileSystem)fs; + // Check whether dfs is on safemode. + isOnSafeMode = dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET); + } + if (isOnSafeMode) { + throw new IOException("File system is in safemode, it can't be written now"); + } + } + + /** * Verifies current version of file system * * @param fs filesystem object