hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1125109 - in /hbase/branches/0.90: 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:13:42 GMT
Author: stack
Date: Thu May 19 21:13:41 2011
New Revision: 1125109

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

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

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1125109&r1=1125108&r2=1125109&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Thu May 19 21:13:41 2011
@@ -10,6 +10,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/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java?rev=1125109&r1=1125108&r2=1125109&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
Thu May 19 21:13:41 2011
@@ -132,6 +132,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;
@@ -194,6 +195,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/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/Bytes.java?rev=1125109&r1=1125108&r2=1125109&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/Bytes.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/Bytes.java Thu May 19 21:13:41
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/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1125109&r1=1125108&r2=1125109&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Thu May 19
21:13:41 2011
@@ -138,6 +138,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