hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1290884 - in /hbase/branches/0.92: ./ src/main/java/org/apache/hadoop/hbase/ src/main/java/org/apache/hadoop/hbase/master/ src/main/java/org/apache/hadoop/hbase/util/ src/main/resources/
Date Sat, 18 Feb 2012 21:33:32 GMT
Author: stack
Date: Sat Feb 18 21:33:31 2012
New Revision: 1290884

URL: http://svn.apache.org/viewvc?rev=1290884&view=rev
Log:
HBASE-5003 If the master is started with a wrong root dir, it gets stuck and can't be killed

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/HConstants.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
    hbase/branches/0.92/src/main/resources/hbase-default.xml

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1290884&r1=1290883&r2=1290884&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Sat Feb 18 21:33:31 2012
@@ -34,6 +34,8 @@ Release 0.92.1 - Unreleased
                leaving the region assignment inconsistent
    HBASE-5432  Hunk missed applying 'hbase-5255 Use singletons for
                OperationStatus to save memory'
+   HBASE-5003  If the master is started with a wrong root dir, it gets stuck
+               and can't be killed (Shaneal Manek)
 
  
   IMPROVEMENTS

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1290884&r1=1290883&r2=1290884&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/HConstants.java Sat Feb 18 21:33:31
2012
@@ -151,7 +151,13 @@ public final class HConstants {
 
   /** Default value for thread wake frequency */
   public static final int DEFAULT_THREAD_WAKE_FREQUENCY = 10 * 1000;
-
+  
+  /** Parameter name for how often we should try to write a version file, before failing
*/
+  public static final String VERSION_FILE_WRITE_ATTEMPTS = "hbase.server.versionfile.writeattempts";
+
+  /** Parameter name for how often we should try to write a version file, before failing
*/
+  public static final int DEFAULT_VERSION_FILE_WRITE_ATTEMPTS = 3;
+  
   /** Parameter name for how often a region should should perform a major compaction */
   public static final String MAJOR_COMPACTION_PERIOD = "hbase.hregion.majorcompaction";
 

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java?rev=1290884&r1=1290883&r2=1290884&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
Sat Feb 18 21:33:31 2012
@@ -337,14 +337,16 @@ public class MasterFileSystem {
         // there is one datanode it will succeed. Permission problems should have
         // already been caught by mkdirs above.
         FSUtils.setVersion(fs, rd, c.getInt(HConstants.THREAD_WAKE_FREQUENCY,
-          10 * 1000));
+          10 * 1000), c.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS, 
+        		  HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
       } else {
         if (!fs.isDirectory(rd)) {
           throw new IllegalArgumentException(rd.toString() + " is not a directory");
         }
         // as above
         FSUtils.checkVersion(fs, rd, true, c.getInt(HConstants.THREAD_WAKE_FREQUENCY,
-          10 * 1000));
+          10 * 1000), c.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS, 
+        		  HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
       }
     } catch (IllegalArgumentException iae) {
       LOG.fatal("Please fix invalid configuration for "

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=1290884&r1=1290883&r2=1290884&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 Sat Feb 18
21:33:31 2012
@@ -204,7 +204,8 @@ public abstract class FSUtils {
    */
   public static void checkVersion(FileSystem fs, Path rootdir,
       boolean message) throws IOException {
-    checkVersion(fs, rootdir, message, 0);
+    checkVersion(fs, rootdir, message, 0, 
+    		HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS);
   }
 
   /**
@@ -213,19 +214,20 @@ public abstract class FSUtils {
    * @param fs file system
    * @param rootdir root directory of HBase installation
    * @param message if true, issues a message on System.out
-   * @param wait wait interval for retry if > 0
+   * @param wait wait interval
+   * @param retries number of times to retry
    *
    * @throws IOException e
    */
   public static void checkVersion(FileSystem fs, Path rootdir,
-      boolean message, int wait) throws IOException {
+      boolean message, int wait, int retries) throws IOException {
     String version = getVersion(fs, rootdir);
 
     if (version == null) {
       if (!rootRegionExists(fs, rootdir)) {
         // rootDir is empty (no version file and no root region)
         // just create new version file (HBASE-1195)
-        FSUtils.setVersion(fs, rootdir, wait);
+        FSUtils.setVersion(fs, rootdir, wait, retries);
         return;
       }
     } else if (version.compareTo(HConstants.FILE_SYSTEM_VERSION) == 0)
@@ -252,7 +254,8 @@ public abstract class FSUtils {
    */
   public static void setVersion(FileSystem fs, Path rootdir)
   throws IOException {
-    setVersion(fs, rootdir, HConstants.FILE_SYSTEM_VERSION, 0);
+    setVersion(fs, rootdir, HConstants.FILE_SYSTEM_VERSION, 0, 
+    		HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS);
   }
 
   /**
@@ -261,13 +264,15 @@ public abstract class FSUtils {
    * @param fs filesystem object
    * @param rootdir hbase root
    * @param wait time to wait for retry
+   * @param retries number of times to retry before failing
    * @throws IOException e
    */
-  public static void setVersion(FileSystem fs, Path rootdir, int wait)
+  public static void setVersion(FileSystem fs, Path rootdir, int wait, int retries)
   throws IOException {
-    setVersion(fs, rootdir, HConstants.FILE_SYSTEM_VERSION, wait);
+    setVersion(fs, rootdir, HConstants.FILE_SYSTEM_VERSION, wait, retries);
   }
 
+
   /**
    * Sets version of file system
    *
@@ -275,10 +280,11 @@ public abstract class FSUtils {
    * @param rootdir hbase root directory
    * @param version version to set
    * @param wait time to wait for retry
+   * @param retries number of times to retry before throwing an IOException
    * @throws IOException e
    */
   public static void setVersion(FileSystem fs, Path rootdir, String version,
-      int wait) throws IOException {
+      int wait, int retries) throws IOException {
     Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME);
     while (true) {
       try {
@@ -289,15 +295,20 @@ public abstract class FSUtils {
         s.close();
         return;
       } catch (IOException e) {
-        if (wait > 0) {
+        if (retries > 0) {
           LOG.warn("Unable to create version file at " + rootdir.toString() +
               ", retrying: " + e.getMessage());
           fs.delete(versionFile, false);
           try {
-            Thread.sleep(wait);
+            if (wait > 0) {
+              Thread.sleep(wait);  						
+            }
           } catch (InterruptedException ex) {
             // ignore
           }
+          retries--;
+        } else {
+          throw e;
         }
       }
     }

Modified: hbase/branches/0.92/src/main/resources/hbase-default.xml
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/resources/hbase-default.xml?rev=1290884&r1=1290883&r2=1290884&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/resources/hbase-default.xml (original)
+++ hbase/branches/0.92/src/main/resources/hbase-default.xml Sat Feb 18 21:33:31 2012
@@ -333,6 +333,15 @@
     </description>
   </property>
   <property>
+    <name>hbase.server.versionfile.writeattempts</name>
+    <value>3</value>
+    <description>
+    How many time to retry attempting to write a version file
+    before just aborting. Each attempt is seperated by the
+    hbase.server.thread.wakefrequency milliseconds.
+    </description>
+  </property>
+  <property>
     <name>hbase.hregion.memstore.flush.size</name>
     <value>134217728</value>
     <description>



Mime
View raw message