hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1196318 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
Date Tue, 01 Nov 2011 22:08:37 GMT
Author: stack
Date: Tue Nov  1 22:08:36 2011
New Revision: 1196318

URL: http://svn.apache.org/viewvc?rev=1196318&view=rev
Log:
HBASE-4708 Revert safemode related pieces of hbase-4510

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1196318&r1=1196317&r2=1196318&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Tue Nov  1 22:08:36 2011
@@ -399,6 +399,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-4492  TestRollingRestart fails intermittently

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1196318&r1=1196317&r2=1196318&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Tue Nov  1
22:08:36 2011
@@ -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.RemoteExc
 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;
@@ -152,36 +150,21 @@ public abstract class FSUtils {
   }
 
   /**
-   * 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);



Mime
View raw message