From e44d373842da7d16747e1eb13b6ede8f3e63ee18 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 1 Nov 2011 22:10:10 +0000 Subject: [PATCH] HBASE-4708 Revert safemode related pieces of hbase-4510 git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1196321 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../org/apache/hadoop/hbase/util/FSUtils.java | 41 ++++++------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3bffc8b02b1..4dcefebb3bb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -437,6 +437,7 @@ Release 0.92.0 - Unreleased HBASE-4710 UnknownProtocolException should abort client retries HBASE-4695 WAL logs get deleted before region server can fully flush (gaojinchao) + HBASE-4708 Revert safemode related pieces of hbase-4510 (Harsh J) TESTS HBASE-4450 test for number of blocks read: to serve as baseline for expected diff --git a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 36d90c3c9fa..922e89521ff 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -40,7 +40,6 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathFilter; -import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HDFSBlocksDistribution; import org.apache.hadoop.hbase.HRegionInfo; @@ -49,7 +48,6 @@ import org.apache.hadoop.hbase.RemoteExceptionHandler; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hdfs.DistributedFileSystem; -import org.apache.hadoop.hdfs.server.namenode.SafeModeException; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.StringUtils; @@ -151,37 +149,22 @@ public abstract class FSUtils { throw io; } - /** - * Utility to check if provided FS is in safemode. - * @return true if dfs is in safemode, false otherwise. - * - */ - private static boolean isInSafeMode(FileSystem fs) throws IOException { - // Refactored safe-mode check for HBASE-4510 - if (fs instanceof DistributedFileSystem) { - Path rootPath = new Path("/"); - FsPermission rootPerm = fs.getFileStatus(rootPath).getPermission(); - try { - // Should be harmless to set back the path we retrieved. - // The first check server-side is the safemode, so if - // other exceptions are spewed out, we're not interested. - fs.setPermission(rootPath, rootPerm); - } catch (SafeModeException e) { - return true; - } - } - return false; - } - /** * Check whether dfs is in safemode. - * @param conf Configuration to use - * @throws IOException if dfs is in safemode + * @param conf + * @return true if dfs is in safemode. + * @throws IOException */ public static void checkDfsSafeMode(final Configuration conf) throws IOException { + boolean isInSafeMode = false; FileSystem fs = FileSystem.get(conf); - if (isInSafeMode(fs)) { + if (fs instanceof DistributedFileSystem) { + DistributedFileSystem dfs = (DistributedFileSystem)fs; + // Check whether dfs is on safemode. + isInSafeMode = dfs.setSafeMode(org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction.SAFEMODE_GET); + } + if (isInSafeMode) { throw new IOException("File system is in safemode, it can't be written now"); } } @@ -452,8 +435,10 @@ public abstract class FSUtils { final long wait) throws IOException { FileSystem fs = FileSystem.get(conf); + if (!(fs instanceof DistributedFileSystem)) return; + DistributedFileSystem dfs = (DistributedFileSystem)fs; // Make sure dfs is not in safe mode - while (isInSafeMode(fs)) { + while (dfs.setSafeMode(org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction.SAFEMODE_GET)) { LOG.info("Waiting for dfs to exit safe mode..."); try { Thread.sleep(wait);