hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1125111 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java src/main/java/org/apache/hadoop/hbase/util/Bytes.java src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
Date Thu, 19 May 2011 21:16:59 GMT
Author: stack
Date: Thu May 19 21:16:58 2011
New Revision: 1125111

URL: http://svn.apache.org/viewvc?rev=1125111&view=rev
Log:
HBASE-3820 Splitlog() executed while the namenode was in safemode may cause data-loss

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1125111&r1=1125110&r2=1125111&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Thu May 19 21:16:58 2011
@@ -266,6 +266,8 @@ Release 0.90.4 - Unreleased
                region assignment
    HBASE-3902  Add Bytes.toBigDecimal and Bytes.toBytes(BigDecimal)
                (Vaibhav Puranik)
+   HBASE-3820  Splitlog() executed while the namenode was in safemode may
+               cause data-loss (Jieshan Bean)
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java?rev=1125111&r1=1125110&r2=1125111&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java Thu May
19 21:16:58 2011
@@ -147,6 +147,7 @@ public class MasterFileSystem {
     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;
@@ -235,6 +236,9 @@ public class MasterFileSystem {
         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, 1000));  
           splitter.splitLog();
         } catch (OrphanHLogAfterSplitException e) {
           LOG.warn("Retrying splitting because of:", e);

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Bytes.java?rev=1125111&r1=1125110&r2=1125111&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Bytes.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Bytes.java Thu May 19 21:16:58
2011
@@ -35,6 +35,7 @@ import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.Comparator;
 import java.util.Iterator;
+import java.math.BigDecimal;
 
 /**
  * Utility class that handles byte arrays, conversions to/from other types,

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1125111&r1=1125110&r2=1125111&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Thu May 19 21:16:58
2011
@@ -139,6 +139,26 @@ public class FSUtils {
   }
 
   /**
+   * Check whether 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 (fs instanceof DistributedFileSystem) {
+      DistributedFileSystem dfs = (DistributedFileSystem)fs;
+      // Check whether dfs is on safemode.
+      isInSafeMode = dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
+    }
+    if (isInSafeMode) {
+      throw new IOException("File system is in safemode, it can't be written now");
+    }
+  }
+  
+  /**
    * Verifies current version of file system
    *
    * @param fs filesystem object



Mime
View raw message