Author: tedyu
Date: Sat Jun 25 15:21:20 2011
New Revision: 1139552

URL: http://svn.apache.org/viewvc?rev=1139552&view=rev
Log:
HBASE-4025  Server startup fails during startup due to failure in loading
            all table descriptors. (Subbu Iyer via Ted Yu)


Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/HConstants.java
    
hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.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=1139552&r1=1139551&r2=1139552&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Jun 25 15:21:20 2011
@@ -292,6 +292,8 @@ Release 0.91.0 - Unreleased
    HBASE-3970  Address HMaster crash/failure half way through meta migration
                (Subbu M Iyer)
    HBASE-4013  Make ZooKeeperListener Abstract (Akash Ashok via Ted Yu)
+   HBASE-4025  Server startup fails during startup due to failure in loading
+               all table descriptors. (Subbu Iyer via Ted Yu)
 
   NEW FEATURES
    HBASE-2001  Coprocessors: Colocate user code with regions (Mingjie Lai via

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1139552&r1=1139551&r2=1139552&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HConstants.java Sat Jun 
25 15:21:20 2011
@@ -22,6 +22,10 @@ package org.apache.hadoop.hbase;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.util.Bytes;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * HConstants holds a bunch of HBase-related constants
  */
@@ -142,7 +146,7 @@ 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 a region should should perform a major 
compaction */
   public static final String MAJOR_COMPACTION_PERIOD = 
"hbase.hregion.majorcompaction";
 
@@ -456,7 +460,7 @@ public final class HConstants {
    * timeout for each RPC
    */
   public static String HBASE_RPC_TIMEOUT_KEY = "hbase.rpc.timeout";
-  
+
   /**
    * Default value of {@link #HBASE_RPC_TIMEOUT_KEY}
    */
@@ -482,6 +486,10 @@ public final class HConstants {
     */
   public static final float HBASE_CLUSTER_MINIMUM_MEMORY_THRESHOLD = 0.2f;
 
+  public static final List<String> HBASE_NON_USER_TABLE_DIRS = new 
ArrayList<String>(
+      Arrays.asList(new String[]{".logs", ".oldlogs",
+          ".corrupt", ".META.", "-ROOT-"}));
+
   private HConstants() {
     // Can't be instantiated with this ctor.
   }

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java?rev=1139552&r1=1139551&r2=1139552&view=diff
==============================================================================
--- 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java 
(original)
+++ 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java 
Sat Jun 25 15:21:20 2011
@@ -114,6 +114,11 @@ public class FSTableDescriptors implemen
       cachehits++;
       return HTableDescriptor.META_TABLEDESC;
     }
+    // .META. and -ROOT- is already handled. If some one tries to get the 
descriptor for
+    // .logs, .oldlogs or .corrupt throw an exception.
+    if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tablename)) {
+       throw new IOException("No descriptor found for table = " + tablename);
+    }
 
     // Look in cache of descriptors.
     TableDescriptorModtime tdm = this.cache.get(tablename);
@@ -161,6 +166,9 @@ public class FSTableDescriptors implemen
     if (Bytes.equals(HConstants.META_TABLE_NAME, htd.getName())) {
       throw new NotImplementedException();
     }
+    if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(htd.getNameAsString())) {
+      throw new NotImplementedException();
+    }
     if (!this.fsreadonly) FSUtils.updateHTableDescriptor(this.fs, 
this.rootdir, htd);
     long modtime =
       FSUtils.getTableInfoModtime(this.fs, this.rootdir, 
htd.getNameAsString());
@@ -181,4 +189,4 @@ public class FSTableDescriptors implemen
     TableDescriptorModtime tdm = this.cache.remove(tablename);
     return tdm == null? null: tdm.getTableDescriptor();
   }
-}
\ No newline at end of file
+}

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=1139552&r1=1139551&r2=1139552&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 Sat Jun 
25 15:21:20 2011
@@ -840,7 +840,8 @@ public class FSUtils {
   /**
    * @param fs
    * @param rootdir
-   * @return All the table directories under <code>rootdir</code>
+   * @return All the table directories under <code>rootdir</code>. Ignore non 
table hbase folders such as
+   * .logs, .oldlogs, .corrupt, .META., and -ROOT- folders.
    * @throws IOException
    */
   public static List<Path> getTableDirs(final FileSystem fs, final Path 
rootdir)
@@ -851,13 +852,9 @@ public class FSUtils {
     for (FileStatus dir: dirs) {
       Path p = dir.getPath();
       String tableName = p.getName();
-      if (tableName.equals(HConstants.HREGION_LOGDIR_NAME) ||
-          tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME)) ||
-          tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME)) ||
-          tableName.equals(HConstants.HREGION_OLDLOGDIR_NAME) ) {
-        continue;
+      if (!HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tableName)) {
+        tabledirs.add(p);
       }
-      tabledirs.add(p);
     }
     return tabledirs;
   }
@@ -1056,4 +1053,4 @@ public class FSUtils {
       out.close();
     }
   }
-}
\ No newline at end of file
+}


Reply via email to