You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2014/09/24 20:50:33 UTC

[1/3] git commit: HBASE-12054 bad state after NamespaceUpgrade with reserved table names

Repository: hbase
Updated Branches:
  refs/heads/0.98 4ab989c81 -> b291f7e1e
  refs/heads/branch-1 8ff5f2548 -> 5e096c5de
  refs/heads/master bcee3609d -> 9152d8677


HBASE-12054 bad state after NamespaceUpgrade with reserved table names


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9152d867
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9152d867
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9152d867

Branch: refs/heads/master
Commit: 9152d8677eb631e708aca1f10d9586e4133078c5
Parents: bcee360
Author: Matteo Bertozzi <ma...@cloudera.com>
Authored: Wed Sep 24 19:39:52 2014 +0100
Committer: Matteo Bertozzi <ma...@cloudera.com>
Committed: Wed Sep 24 19:39:52 2014 +0100

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/HConstants.java     |   7 +-
 .../hbase/migration/NamespaceUpgrade.java       |   1 +
 .../hadoop/hbase/util/FSRegionScanner.java      |   8 +-
 .../org/apache/hadoop/hbase/util/FSUtils.java   | 132 +++++--------------
 .../hbase/util/TestFSTableDescriptors.java      |   5 +-
 5 files changed, 41 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9152d867/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
index 6945eb0..ba152c0 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
@@ -925,10 +925,9 @@ public final class HConstants {
   public static final long DEFAULT_REGIONSERVER_METRICS_PERIOD = 5000;
   /** Directories that are not HBase table directories */
   public static final List<String> HBASE_NON_TABLE_DIRS =
-    Collections.unmodifiableList(Arrays.asList(new String[] { HREGION_LOGDIR_NAME,
-      HREGION_OLDLOGDIR_NAME, CORRUPT_DIR_NAME, SPLIT_LOGDIR_NAME,
-      HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY, SNAPSHOT_DIR_NAME, HBASE_TEMP_DIRECTORY,
-      OLD_SNAPSHOT_DIR_NAME, BASE_NAMESPACE_DIR, MIGRATION_NAME, LIB_DIR}));
+    Collections.unmodifiableList(Arrays.asList(new String[] {
+      HBCK_SIDELINEDIR_NAME, HBASE_TEMP_DIRECTORY, MIGRATION_NAME
+    }));
 
   /** Directories that are not HBase user table directories */
   public static final List<String> HBASE_NON_USER_TABLE_DIRS =

http://git-wip-us.apache.org/repos/asf/hbase/blob/9152d867/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
index 1649c4e..59d847f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
@@ -253,6 +253,7 @@ public class NamespaceUpgrade implements Tool {
         // Make the new directory under the ns to which we will move the table.
         Path nsDir = new Path(this.defNsDir,
           TableName.valueOf(oldTableDir.getName()).getQualifierAsString());
+        LOG.info("Moving " + oldTableDir + " to " + nsDir);
         if (!fs.exists(nsDir.getParent())) {
           if (!fs.mkdirs(nsDir.getParent())) {
             throw new IOException("Failed to create namespace dir "+nsDir.getParent());

http://git-wip-us.apache.org/repos/asf/hbase/blob/9152d867/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
index c7aa406..02dfc5f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.util.FSUtils;
 
 /**
  * Thread that walks over the filesystem, and computes the mappings
@@ -79,7 +80,7 @@ class FSRegionScanner implements Runnable {
       int totalBlkCount = 0;
 
       // ignore null
-      FileStatus[] cfList = fs.listStatus(regionPath);
+      FileStatus[] cfList = fs.listStatus(regionPath, new FSUtils.FamilyDirFilter(fs));
       if (null == cfList) {
         return;
       }
@@ -90,10 +91,7 @@ class FSRegionScanner implements Runnable {
           // skip because this is not a CF directory
           continue;
         }
-        if (cfStatus.getPath().getName().startsWith(".") ||
-            HConstants.HBASE_NON_USER_TABLE_DIRS.contains(cfStatus.getPath().getName())) {
-          continue;
-        }
+
         FileStatus[] storeFileLists = fs.listStatus(cfStatus.getPath());
         if (null == storeFileLists) {
           continue;

http://git-wip-us.apache.org/repos/asf/hbase/blob/9152d867/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 7e740cf..62a40df 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -976,15 +976,14 @@ public abstract class FSUtils {
       final Path hbaseRootDir)
   throws IOException {
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     for (Path d : tableDirs) {
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           Path family = familyDir.getPath();
           // Now in family make sure only one file.
@@ -1050,19 +1049,17 @@ public abstract class FSUtils {
     Map<String, Integer> frags = new HashMap<String, Integer>();
     int cfCountTotal = 0;
     int cfFragTotal = 0;
-    DirFilter df = new DirFilter(fs);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
     for (Path d : tableDirs) {
       int cfCount = 0;
       int cfFrag = 0;
-      FileStatus[] regionDirs = fs.listStatus(d, df);
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // else its a region name, now look in region for families
-        FileStatus[] familyDirs = fs.listStatus(dd, df);
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           cfCount++;
           cfCountTotal++;
@@ -1085,86 +1082,6 @@ public abstract class FSUtils {
   }
 
   /**
-   * Expects to find -ROOT- directory.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this a pre020 layout.
-   * @throws IOException e
-   */
-  public static boolean isPre020FileLayout(final FileSystem fs,
-    final Path hbaseRootDir)
-  throws IOException {
-    Path mapfiles = new Path(new Path(new Path(new Path(hbaseRootDir, "-ROOT-"),
-      "70236052"), "info"), "mapfiles");
-    return fs.exists(mapfiles);
-  }
-
-  /**
-   * Runs through the hbase rootdir and checks all stores have only
-   * one file in them -- that is, they've been major compacted.  Looks
-   * at root and meta tables too.  This version differs from
-   * {@link #isMajorCompacted(FileSystem, Path)} in that it expects a
-   * pre-0.20.0 hbase layout on the filesystem.  Used migrating.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this hbase install is major compacted.
-   * @throws IOException e
-   */
-  public static boolean isMajorCompactedPre020(final FileSystem fs,
-      final Path hbaseRootDir)
-  throws IOException {
-    // Presumes any directory under hbase.rootdir is a table.
-    List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
-    for (Path d: tableDirs) {
-      // Inside a table, there are compaction.dir directories to skip.
-      // Otherwise, all else should be regions.  Then in each region, should
-      // only be family directories.  Under each of these, should be a mapfile
-      // and info directory and in these only one file.
-      if (d.getName().equals(HConstants.HREGION_LOGDIR_NAME)) {
-        continue;
-      }
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
-      for (FileStatus regionDir : regionDirs) {
-        Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
-        // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
-        for (FileStatus familyDir : familyDirs) {
-          Path family = familyDir.getPath();
-          FileStatus[] infoAndMapfile = fs.listStatus(family);
-          // Assert that only info and mapfile in family dir.
-          if (infoAndMapfile.length != 0 && infoAndMapfile.length != 2) {
-            LOG.debug(family.toString() +
-                " has more than just info and mapfile: " + infoAndMapfile.length);
-            return false;
-          }
-          // Make sure directory named info or mapfile.
-          for (int ll = 0; ll < 2; ll++) {
-            if (infoAndMapfile[ll].getPath().getName().equals("info") ||
-                infoAndMapfile[ll].getPath().getName().equals("mapfiles"))
-              continue;
-            LOG.debug("Unexpected directory name: " +
-                infoAndMapfile[ll].getPath());
-            return false;
-          }
-          // Now in family, there are 'mapfile' and 'info' subdirs.  Just
-          // look in the 'mapfile' subdir.
-          FileStatus[] familyStatus =
-              fs.listStatus(new Path(family, "mapfiles"));
-          if (familyStatus.length > 1) {
-            LOG.debug(family.toString() + " has " + familyStatus.length +
-                " files.");
-            return false;
-          }
-        }
-      }
-    }
-    return true;
-  }
-
-  /**
    * Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
    * path rootdir
    *
@@ -1248,10 +1165,10 @@ public abstract class FSUtils {
     public boolean accept(Path p) {
       boolean isValid = false;
       try {
-        if (blacklist.contains(p.getName().toString())) {
-          isValid = false;
-        } else {
+        if (isValidName(p.getName())) {
           isValid = fs.getFileStatus(p).isDirectory();
+        } else {
+          isValid = false;
         }
       } catch (IOException e) {
         LOG.warn("An error occurred while verifying if [" + p.toString()
@@ -1259,6 +1176,10 @@ public abstract class FSUtils {
       }
       return isValid;
     }
+
+    protected boolean isValidName(final String name) {
+      return !blacklist.contains(name);
+    }
   }
 
   /**
@@ -1276,10 +1197,22 @@ public abstract class FSUtils {
    * {@link BlackListDirFilter} with a <tt>null</tt> blacklist
    */
   public static class UserTableDirFilter extends BlackListDirFilter {
-
     public UserTableDirFilter(FileSystem fs) {
       super(fs, HConstants.HBASE_NON_TABLE_DIRS);
     }
+
+    protected boolean isValidName(final String name) {
+      if (!super.isValidName(name))
+        return false;
+
+      try {
+        TableName.isLegalTableQualifierName(Bytes.toBytes(name));
+      } catch (IllegalArgumentException e) {
+        LOG.info("INVALID NAME " + name);
+        return false;
+      }
+      return true;
+    }
   }
 
   /**
@@ -1540,15 +1473,12 @@ public abstract class FSUtils {
     Path tableDir = FSUtils.getTableDir(hbaseRootDir, tableName);
     // Inside a table, there are compaction.dir directories to skip.  Otherwise, all else
     // should be regions.
-    PathFilter df = new BlackListDirFilter(fs, HConstants.HBASE_NON_TABLE_DIRS);
-    FileStatus[] regionDirs = fs.listStatus(tableDir);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
+    FileStatus[] regionDirs = fs.listStatus(tableDir, new RegionDirFilter(fs));
     for (FileStatus regionDir : regionDirs) {
       Path dd = regionDir.getPath();
-      if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-        continue;
-      }
       // else its a region name, now look in region for families
-      FileStatus[] familyDirs = fs.listStatus(dd, df);
+      FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
       for (FileStatus familyDir : familyDirs) {
         Path family = familyDir.getPath();
         // now in family, iterate over the StoreFiles and

http://git-wip-us.apache.org/repos/asf/hbase/blob/9152d867/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
index 23b1310..5ba3e45 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
@@ -301,11 +301,12 @@ public class TestFSTableDescriptors {
   }
 
   @Test
-  public void testReadingArchiveDirectoryFromFS() throws IOException {
+  public void testReadingInvalidDirectoryFromFS() throws IOException {
     FileSystem fs = FileSystem.get(UTIL.getConfiguration());
     try {
+      // .tmp dir is an invalid table name
       new FSTableDescriptors(fs, FSUtils.getRootDir(UTIL.getConfiguration()))
-          .get(TableName.valueOf(HConstants.HFILE_ARCHIVE_DIRECTORY));
+          .get(TableName.valueOf(HConstants.HBASE_TEMP_DIRECTORY));
       fail("Shouldn't be able to read a table descriptor for the archive directory.");
     } catch (Exception e) {
       LOG.debug("Correctly got error when reading a table descriptor from the archive directory: "


[2/3] git commit: HBASE-12054 bad state after NamespaceUpgrade with reserved table names

Posted by mb...@apache.org.
HBASE-12054 bad state after NamespaceUpgrade with reserved table names


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5e096c5d
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5e096c5d
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5e096c5d

Branch: refs/heads/branch-1
Commit: 5e096c5deab9ef1d3003ccbc5cb7168dcfc56a40
Parents: 8ff5f25
Author: Matteo Bertozzi <ma...@cloudera.com>
Authored: Wed Sep 24 19:42:13 2014 +0100
Committer: Matteo Bertozzi <ma...@cloudera.com>
Committed: Wed Sep 24 19:42:13 2014 +0100

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/HConstants.java     |   7 +-
 .../hbase/migration/NamespaceUpgrade.java       |   1 +
 .../hadoop/hbase/util/FSRegionScanner.java      |   8 +-
 .../org/apache/hadoop/hbase/util/FSUtils.java   | 132 +++++--------------
 .../src/test/data/TestNamespaceUpgrade.tgz      | Bin 10449 -> 13572 bytes
 .../hbase/migration/TestNamespaceUpgrade.java   |   3 +-
 .../hbase/util/TestFSTableDescriptors.java      |   5 +-
 7 files changed, 43 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
index 6945eb0..ba152c0 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
@@ -925,10 +925,9 @@ public final class HConstants {
   public static final long DEFAULT_REGIONSERVER_METRICS_PERIOD = 5000;
   /** Directories that are not HBase table directories */
   public static final List<String> HBASE_NON_TABLE_DIRS =
-    Collections.unmodifiableList(Arrays.asList(new String[] { HREGION_LOGDIR_NAME,
-      HREGION_OLDLOGDIR_NAME, CORRUPT_DIR_NAME, SPLIT_LOGDIR_NAME,
-      HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY, SNAPSHOT_DIR_NAME, HBASE_TEMP_DIRECTORY,
-      OLD_SNAPSHOT_DIR_NAME, BASE_NAMESPACE_DIR, MIGRATION_NAME, LIB_DIR}));
+    Collections.unmodifiableList(Arrays.asList(new String[] {
+      HBCK_SIDELINEDIR_NAME, HBASE_TEMP_DIRECTORY, MIGRATION_NAME
+    }));
 
   /** Directories that are not HBase user table directories */
   public static final List<String> HBASE_NON_USER_TABLE_DIRS =

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
index b11d74c..e34420d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
@@ -251,6 +251,7 @@ public class NamespaceUpgrade implements Tool {
         // Make the new directory under the ns to which we will move the table.
         Path nsDir = new Path(this.defNsDir,
           TableName.valueOf(oldTableDir.getName()).getQualifierAsString());
+        LOG.info("Moving " + oldTableDir + " to " + nsDir);
         if (!fs.exists(nsDir.getParent())) {
           if (!fs.mkdirs(nsDir.getParent())) {
             throw new IOException("Failed to create namespace dir "+nsDir.getParent());

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
index c7aa406..02dfc5f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.util.FSUtils;
 
 /**
  * Thread that walks over the filesystem, and computes the mappings
@@ -79,7 +80,7 @@ class FSRegionScanner implements Runnable {
       int totalBlkCount = 0;
 
       // ignore null
-      FileStatus[] cfList = fs.listStatus(regionPath);
+      FileStatus[] cfList = fs.listStatus(regionPath, new FSUtils.FamilyDirFilter(fs));
       if (null == cfList) {
         return;
       }
@@ -90,10 +91,7 @@ class FSRegionScanner implements Runnable {
           // skip because this is not a CF directory
           continue;
         }
-        if (cfStatus.getPath().getName().startsWith(".") ||
-            HConstants.HBASE_NON_USER_TABLE_DIRS.contains(cfStatus.getPath().getName())) {
-          continue;
-        }
+
         FileStatus[] storeFileLists = fs.listStatus(cfStatus.getPath());
         if (null == storeFileLists) {
           continue;

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 3f43094..ed1a4e6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -975,15 +975,14 @@ public abstract class FSUtils {
       final Path hbaseRootDir)
   throws IOException {
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     for (Path d : tableDirs) {
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           Path family = familyDir.getPath();
           // Now in family make sure only one file.
@@ -1049,19 +1048,17 @@ public abstract class FSUtils {
     Map<String, Integer> frags = new HashMap<String, Integer>();
     int cfCountTotal = 0;
     int cfFragTotal = 0;
-    DirFilter df = new DirFilter(fs);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
     for (Path d : tableDirs) {
       int cfCount = 0;
       int cfFrag = 0;
-      FileStatus[] regionDirs = fs.listStatus(d, df);
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // else its a region name, now look in region for families
-        FileStatus[] familyDirs = fs.listStatus(dd, df);
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           cfCount++;
           cfCountTotal++;
@@ -1084,86 +1081,6 @@ public abstract class FSUtils {
   }
 
   /**
-   * Expects to find -ROOT- directory.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this a pre020 layout.
-   * @throws IOException e
-   */
-  public static boolean isPre020FileLayout(final FileSystem fs,
-    final Path hbaseRootDir)
-  throws IOException {
-    Path mapfiles = new Path(new Path(new Path(new Path(hbaseRootDir, "-ROOT-"),
-      "70236052"), "info"), "mapfiles");
-    return fs.exists(mapfiles);
-  }
-
-  /**
-   * Runs through the hbase rootdir and checks all stores have only
-   * one file in them -- that is, they've been major compacted.  Looks
-   * at root and meta tables too.  This version differs from
-   * {@link #isMajorCompacted(FileSystem, Path)} in that it expects a
-   * pre-0.20.0 hbase layout on the filesystem.  Used migrating.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this hbase install is major compacted.
-   * @throws IOException e
-   */
-  public static boolean isMajorCompactedPre020(final FileSystem fs,
-      final Path hbaseRootDir)
-  throws IOException {
-    // Presumes any directory under hbase.rootdir is a table.
-    List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
-    for (Path d: tableDirs) {
-      // Inside a table, there are compaction.dir directories to skip.
-      // Otherwise, all else should be regions.  Then in each region, should
-      // only be family directories.  Under each of these, should be a mapfile
-      // and info directory and in these only one file.
-      if (d.getName().equals(HConstants.HREGION_LOGDIR_NAME)) {
-        continue;
-      }
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
-      for (FileStatus regionDir : regionDirs) {
-        Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
-        // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
-        for (FileStatus familyDir : familyDirs) {
-          Path family = familyDir.getPath();
-          FileStatus[] infoAndMapfile = fs.listStatus(family);
-          // Assert that only info and mapfile in family dir.
-          if (infoAndMapfile.length != 0 && infoAndMapfile.length != 2) {
-            LOG.debug(family.toString() +
-                " has more than just info and mapfile: " + infoAndMapfile.length);
-            return false;
-          }
-          // Make sure directory named info or mapfile.
-          for (int ll = 0; ll < 2; ll++) {
-            if (infoAndMapfile[ll].getPath().getName().equals("info") ||
-                infoAndMapfile[ll].getPath().getName().equals("mapfiles"))
-              continue;
-            LOG.debug("Unexpected directory name: " +
-                infoAndMapfile[ll].getPath());
-            return false;
-          }
-          // Now in family, there are 'mapfile' and 'info' subdirs.  Just
-          // look in the 'mapfile' subdir.
-          FileStatus[] familyStatus =
-              fs.listStatus(new Path(family, "mapfiles"));
-          if (familyStatus.length > 1) {
-            LOG.debug(family.toString() + " has " + familyStatus.length +
-                " files.");
-            return false;
-          }
-        }
-      }
-    }
-    return true;
-  }
-
-  /**
    * Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
    * path rootdir
    *
@@ -1247,10 +1164,10 @@ public abstract class FSUtils {
     public boolean accept(Path p) {
       boolean isValid = false;
       try {
-        if (blacklist.contains(p.getName().toString())) {
-          isValid = false;
-        } else {
+        if (isValidName(p.getName())) {
           isValid = fs.getFileStatus(p).isDirectory();
+        } else {
+          isValid = false;
         }
       } catch (IOException e) {
         LOG.warn("An error occurred while verifying if [" + p.toString()
@@ -1258,6 +1175,10 @@ public abstract class FSUtils {
       }
       return isValid;
     }
+
+    protected boolean isValidName(final String name) {
+      return !blacklist.contains(name);
+    }
   }
 
   /**
@@ -1275,10 +1196,22 @@ public abstract class FSUtils {
    * {@link BlackListDirFilter} with a <tt>null</tt> blacklist
    */
   public static class UserTableDirFilter extends BlackListDirFilter {
-
     public UserTableDirFilter(FileSystem fs) {
       super(fs, HConstants.HBASE_NON_TABLE_DIRS);
     }
+
+    protected boolean isValidName(final String name) {
+      if (!super.isValidName(name))
+        return false;
+
+      try {
+        TableName.isLegalTableQualifierName(Bytes.toBytes(name));
+      } catch (IllegalArgumentException e) {
+        LOG.info("INVALID NAME " + name);
+        return false;
+      }
+      return true;
+    }
   }
 
   /**
@@ -1539,15 +1472,12 @@ public abstract class FSUtils {
     Path tableDir = FSUtils.getTableDir(hbaseRootDir, tableName);
     // Inside a table, there are compaction.dir directories to skip.  Otherwise, all else
     // should be regions.
-    PathFilter df = new BlackListDirFilter(fs, HConstants.HBASE_NON_TABLE_DIRS);
-    FileStatus[] regionDirs = fs.listStatus(tableDir);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
+    FileStatus[] regionDirs = fs.listStatus(tableDir, new RegionDirFilter(fs));
     for (FileStatus regionDir : regionDirs) {
       Path dd = regionDir.getPath();
-      if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-        continue;
-      }
       // else its a region name, now look in region for families
-      FileStatus[] familyDirs = fs.listStatus(dd, df);
+      FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
       for (FileStatus familyDir : familyDirs) {
         Path family = familyDir.getPath();
         // now in family, iterate over the StoreFiles and

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/test/data/TestNamespaceUpgrade.tgz
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/data/TestNamespaceUpgrade.tgz b/hbase-server/src/test/data/TestNamespaceUpgrade.tgz
index db6e9c3..bd91ba2 100644
Binary files a/hbase-server/src/test/data/TestNamespaceUpgrade.tgz and b/hbase-server/src/test/data/TestNamespaceUpgrade.tgz differ

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
index d0b2188..046290d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
@@ -94,7 +94,8 @@ public class TestNamespaceUpgrade {
   private final static String currentKeys[] =
       {"1","2","3","4","5","6","7","8","9","A"};
   private final static TableName tables[] =
-    {TableName.valueOf("foo"), TableName.valueOf("ns1.foo"), TableName.valueOf("ns.two.foo")};
+    {TableName.valueOf("data"), TableName.valueOf("foo"),
+     TableName.valueOf("ns1.foo"), TableName.valueOf("ns.two.foo")};
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/hbase/blob/5e096c5d/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
index aa16177..cbe8016 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
@@ -260,11 +260,12 @@ public class TestFSTableDescriptors {
   }
 
   @Test
-  public void testReadingArchiveDirectoryFromFS() throws IOException {
+  public void testReadingInvalidDirectoryFromFS() throws IOException {
     FileSystem fs = FileSystem.get(UTIL.getConfiguration());
     try {
+      // .tmp dir is an invalid table name
       new FSTableDescriptors(fs, FSUtils.getRootDir(UTIL.getConfiguration()))
-          .get(TableName.valueOf(HConstants.HFILE_ARCHIVE_DIRECTORY));
+          .get(TableName.valueOf(HConstants.HBASE_TEMP_DIRECTORY));
       fail("Shouldn't be able to read a table descriptor for the archive directory.");
     } catch (Exception e) {
       LOG.debug("Correctly got error when reading a table descriptor from the archive directory: "


[3/3] git commit: HBASE-12054 bad state after NamespaceUpgrade with reserved table names

Posted by mb...@apache.org.
HBASE-12054 bad state after NamespaceUpgrade with reserved table names


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b291f7e1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b291f7e1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b291f7e1

Branch: refs/heads/0.98
Commit: b291f7e1e76b907cd87ee447278c05f978bc7ec1
Parents: 4ab989c
Author: Matteo Bertozzi <ma...@cloudera.com>
Authored: Wed Sep 24 19:42:13 2014 +0100
Committer: Matteo Bertozzi <ma...@cloudera.com>
Committed: Wed Sep 24 19:49:45 2014 +0100

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/HConstants.java     |   7 +-
 .../hbase/migration/NamespaceUpgrade.java       |   1 +
 .../hadoop/hbase/util/FSRegionScanner.java      |   8 +-
 .../org/apache/hadoop/hbase/util/FSUtils.java   | 132 +++++--------------
 .../src/test/data/TestNamespaceUpgrade.tgz      | Bin 10449 -> 13572 bytes
 .../hbase/migration/TestNamespaceUpgrade.java   |   2 +-
 .../hbase/util/TestFSTableDescriptors.java      |   5 +-
 7 files changed, 42 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
index 956fae3..5eddd7f 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
@@ -918,10 +918,9 @@ public final class HConstants {
   public static final long DEFAULT_REGIONSERVER_METRICS_PERIOD = 5000;
   /** Directories that are not HBase table directories */
   public static final List<String> HBASE_NON_TABLE_DIRS =
-    Collections.unmodifiableList(Arrays.asList(new String[] { HREGION_LOGDIR_NAME,
-      HREGION_OLDLOGDIR_NAME, CORRUPT_DIR_NAME, SPLIT_LOGDIR_NAME,
-      HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY, SNAPSHOT_DIR_NAME, HBASE_TEMP_DIRECTORY,
-      OLD_SNAPSHOT_DIR_NAME, BASE_NAMESPACE_DIR, MIGRATION_NAME, LIB_DIR}));
+    Collections.unmodifiableList(Arrays.asList(new String[] {
+      HBCK_SIDELINEDIR_NAME, HBASE_TEMP_DIRECTORY, MIGRATION_NAME
+    }));
 
   /** Directories that are not HBase user table directories */
   public static final List<String> HBASE_NON_USER_TABLE_DIRS =

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
index daef083..748f1a8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
@@ -251,6 +251,7 @@ public class NamespaceUpgrade implements Tool {
         // Make the new directory under the ns to which we will move the table.
         Path nsDir = new Path(this.defNsDir,
           TableName.valueOf(oldTableDir.getName()).getQualifierAsString());
+        LOG.info("Moving " + oldTableDir + " to " + nsDir);
         if (!fs.exists(nsDir.getParent())) {
           if (!fs.mkdirs(nsDir.getParent())) {
             throw new IOException("Failed to create namespace dir "+nsDir.getParent());

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
index 70cf768..21003b6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSRegionScanner.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.util.FSUtils;
 
 /**
  * Thread that walks over the filesystem, and computes the mappings
@@ -79,7 +80,7 @@ class FSRegionScanner implements Runnable {
       int totalBlkCount = 0;
 
       // ignore null
-      FileStatus[] cfList = fs.listStatus(regionPath);
+      FileStatus[] cfList = fs.listStatus(regionPath, new FSUtils.FamilyDirFilter(fs));
       if (null == cfList) {
         return;
       }
@@ -90,10 +91,7 @@ class FSRegionScanner implements Runnable {
           // skip because this is not a CF directory
           continue;
         }
-        if (cfStatus.getPath().getName().startsWith(".") ||
-            HConstants.HBASE_NON_USER_TABLE_DIRS.contains(cfStatus.getPath().getName())) {
-          continue;
-        }
+
         FileStatus[] storeFileLists = fs.listStatus(cfStatus.getPath());
         if (null == storeFileLists) {
           continue;

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 9e0c63e..112eb5f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -990,15 +990,14 @@ public abstract class FSUtils {
       final Path hbaseRootDir)
   throws IOException {
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     for (Path d : tableDirs) {
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           Path family = familyDir.getPath();
           // Now in family make sure only one file.
@@ -1064,19 +1063,17 @@ public abstract class FSUtils {
     Map<String, Integer> frags = new HashMap<String, Integer>();
     int cfCountTotal = 0;
     int cfFragTotal = 0;
-    DirFilter df = new DirFilter(fs);
+    PathFilter regionFilter = new RegionDirFilter(fs);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
     List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
     for (Path d : tableDirs) {
       int cfCount = 0;
       int cfFrag = 0;
-      FileStatus[] regionDirs = fs.listStatus(d, df);
+      FileStatus[] regionDirs = fs.listStatus(d, regionFilter);
       for (FileStatus regionDir : regionDirs) {
         Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
         // else its a region name, now look in region for families
-        FileStatus[] familyDirs = fs.listStatus(dd, df);
+        FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
         for (FileStatus familyDir : familyDirs) {
           cfCount++;
           cfCountTotal++;
@@ -1099,86 +1096,6 @@ public abstract class FSUtils {
   }
 
   /**
-   * Expects to find -ROOT- directory.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this a pre020 layout.
-   * @throws IOException e
-   */
-  public static boolean isPre020FileLayout(final FileSystem fs,
-    final Path hbaseRootDir)
-  throws IOException {
-    Path mapfiles = new Path(new Path(new Path(new Path(hbaseRootDir, "-ROOT-"),
-      "70236052"), "info"), "mapfiles");
-    return fs.exists(mapfiles);
-  }
-
-  /**
-   * Runs through the hbase rootdir and checks all stores have only
-   * one file in them -- that is, they've been major compacted.  Looks
-   * at root and meta tables too.  This version differs from
-   * {@link #isMajorCompacted(FileSystem, Path)} in that it expects a
-   * pre-0.20.0 hbase layout on the filesystem.  Used migrating.
-   * @param fs filesystem
-   * @param hbaseRootDir hbase root directory
-   * @return True if this hbase install is major compacted.
-   * @throws IOException e
-   */
-  public static boolean isMajorCompactedPre020(final FileSystem fs,
-      final Path hbaseRootDir)
-  throws IOException {
-    // Presumes any directory under hbase.rootdir is a table.
-    List<Path> tableDirs = getTableDirs(fs, hbaseRootDir);
-    for (Path d: tableDirs) {
-      // Inside a table, there are compaction.dir directories to skip.
-      // Otherwise, all else should be regions.  Then in each region, should
-      // only be family directories.  Under each of these, should be a mapfile
-      // and info directory and in these only one file.
-      if (d.getName().equals(HConstants.HREGION_LOGDIR_NAME)) {
-        continue;
-      }
-      FileStatus[] regionDirs = fs.listStatus(d, new DirFilter(fs));
-      for (FileStatus regionDir : regionDirs) {
-        Path dd = regionDir.getPath();
-        if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-          continue;
-        }
-        // Else its a region name.  Now look in region for families.
-        FileStatus[] familyDirs = fs.listStatus(dd, new DirFilter(fs));
-        for (FileStatus familyDir : familyDirs) {
-          Path family = familyDir.getPath();
-          FileStatus[] infoAndMapfile = fs.listStatus(family);
-          // Assert that only info and mapfile in family dir.
-          if (infoAndMapfile.length != 0 && infoAndMapfile.length != 2) {
-            LOG.debug(family.toString() +
-                " has more than just info and mapfile: " + infoAndMapfile.length);
-            return false;
-          }
-          // Make sure directory named info or mapfile.
-          for (int ll = 0; ll < 2; ll++) {
-            if (infoAndMapfile[ll].getPath().getName().equals("info") ||
-                infoAndMapfile[ll].getPath().getName().equals("mapfiles"))
-              continue;
-            LOG.debug("Unexpected directory name: " +
-                infoAndMapfile[ll].getPath());
-            return false;
-          }
-          // Now in family, there are 'mapfile' and 'info' subdirs.  Just
-          // look in the 'mapfile' subdir.
-          FileStatus[] familyStatus =
-              fs.listStatus(new Path(family, "mapfiles"));
-          if (familyStatus.length > 1) {
-            LOG.debug(family.toString() + " has " + familyStatus.length +
-                " files.");
-            return false;
-          }
-        }
-      }
-    }
-    return true;
-  }
-
-  /**
    * Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
    * path rootdir
    *
@@ -1262,10 +1179,10 @@ public abstract class FSUtils {
     public boolean accept(Path p) {
       boolean isValid = false;
       try {
-        if (blacklist.contains(p.getName().toString())) {
-          isValid = false;
-        } else {
+        if (isValidName(p.getName())) {
           isValid = fs.getFileStatus(p).isDir();
+        } else {
+          isValid = false;
         }
       } catch (IOException e) {
         LOG.warn("An error occurred while verifying if [" + p.toString()
@@ -1273,6 +1190,10 @@ public abstract class FSUtils {
       }
       return isValid;
     }
+
+    protected boolean isValidName(final String name) {
+      return !blacklist.contains(name);
+    }
   }
 
   /**
@@ -1290,10 +1211,22 @@ public abstract class FSUtils {
    * {@link BlackListDirFilter} with a <tt>null</tt> blacklist
    */
   public static class UserTableDirFilter extends BlackListDirFilter {
-
     public UserTableDirFilter(FileSystem fs) {
       super(fs, HConstants.HBASE_NON_TABLE_DIRS);
     }
+
+    protected boolean isValidName(final String name) {
+      if (!super.isValidName(name))
+        return false;
+
+      try {
+        TableName.isLegalTableQualifierName(Bytes.toBytes(name));
+      } catch (IllegalArgumentException e) {
+        LOG.info("INVALID NAME " + name);
+        return false;
+      }
+      return true;
+    }
   }
 
   /**
@@ -1554,15 +1487,12 @@ public abstract class FSUtils {
     Path tableDir = FSUtils.getTableDir(hbaseRootDir, tableName);
     // Inside a table, there are compaction.dir directories to skip.  Otherwise, all else
     // should be regions.
-    PathFilter df = new BlackListDirFilter(fs, HConstants.HBASE_NON_TABLE_DIRS);
-    FileStatus[] regionDirs = fs.listStatus(tableDir);
+    PathFilter familyFilter = new FamilyDirFilter(fs);
+    FileStatus[] regionDirs = fs.listStatus(tableDir, new RegionDirFilter(fs));
     for (FileStatus regionDir : regionDirs) {
       Path dd = regionDir.getPath();
-      if (dd.getName().equals(HConstants.HREGION_COMPACTIONDIR_NAME)) {
-        continue;
-      }
       // else its a region name, now look in region for families
-      FileStatus[] familyDirs = fs.listStatus(dd, df);
+      FileStatus[] familyDirs = fs.listStatus(dd, familyFilter);
       for (FileStatus familyDir : familyDirs) {
         Path family = familyDir.getPath();
         // now in family, iterate over the StoreFiles and

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/test/data/TestNamespaceUpgrade.tgz
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/data/TestNamespaceUpgrade.tgz b/hbase-server/src/test/data/TestNamespaceUpgrade.tgz
index db6e9c3..bd91ba2 100644
Binary files a/hbase-server/src/test/data/TestNamespaceUpgrade.tgz and b/hbase-server/src/test/data/TestNamespaceUpgrade.tgz differ

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
index 0744361..4dcd3ab 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
@@ -93,7 +93,7 @@ public class TestNamespaceUpgrade {
       {"1","2","3","4","5","6","7","8","9"};
   private final static String currentKeys[] =
       {"1","2","3","4","5","6","7","8","9","A"};
-  private final static String tables[] = {"foo", "ns1.foo","ns.two.foo"};
+  private final static String tables[] = {"data", "foo", "ns1.foo","ns.two.foo"};
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/hbase/blob/b291f7e1/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
index aa16177..cbe8016 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
@@ -260,11 +260,12 @@ public class TestFSTableDescriptors {
   }
 
   @Test
-  public void testReadingArchiveDirectoryFromFS() throws IOException {
+  public void testReadingInvalidDirectoryFromFS() throws IOException {
     FileSystem fs = FileSystem.get(UTIL.getConfiguration());
     try {
+      // .tmp dir is an invalid table name
       new FSTableDescriptors(fs, FSUtils.getRootDir(UTIL.getConfiguration()))
-          .get(TableName.valueOf(HConstants.HFILE_ARCHIVE_DIRECTORY));
+          .get(TableName.valueOf(HConstants.HBASE_TEMP_DIRECTORY));
       fail("Shouldn't be able to read a table descriptor for the archive directory.");
     } catch (Exception e) {
       LOG.debug("Correctly got error when reading a table descriptor from the archive directory: "