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 dfa6feb3ba5..7cc6a360ef2 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 @@ -18,12 +18,13 @@ package org.apache.hadoop.hbase; import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.regex.Pattern; +import org.apache.commons.lang.ArrayUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -737,10 +738,18 @@ public final class HConstants { /** Directory under /hbase where archived hfiles are stored */ public static final String HFILE_ARCHIVE_DIRECTORY = ".archive"; - public static final List HBASE_NON_USER_TABLE_DIRS = new ArrayList( - Arrays.asList(new String[] { HREGION_LOGDIR_NAME, HREGION_OLDLOGDIR_NAME, CORRUPT_DIR_NAME, - toString(META_TABLE_NAME), toString(ROOT_TABLE_NAME), SPLIT_LOGDIR_NAME, - HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY })); + /** Directories that are not HBase table directories */ + public static final List 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 })); + + /** Directories that are not HBase user table directories */ + public static final List HBASE_NON_USER_TABLE_DIRS = + Collections.unmodifiableList(Arrays.asList((String[])ArrayUtils.addAll( + new String[] { toString(META_TABLE_NAME), toString(ROOT_TABLE_NAME) }, + HBASE_NON_TABLE_DIRS.toArray()))); + /** Health script related settings. */ public static final String HEALTH_SCRIPT_LOC = "hbase.node.health.script.location"; public static final String HEALTH_SCRIPT_TIMEOUT = "hbase.node.health.script.timeout"; 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 03c3295d8d5..cc233465328 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 @@ -1194,11 +1194,11 @@ public abstract class FSUtils { // presumes any directory under hbase.rootdir is a table FileStatus [] tableDirs = fs.listStatus(hbaseRootDir, df); for (FileStatus tableDir : tableDirs) { - // Skip the .log directory. All others should be tables. Inside a table, - // there are compaction.dir directories to skip. Otherwise, all else + // Skip the .log and other non-table directories. All others should be tables. + // Inside a table, there are compaction.dir directories to skip. Otherwise, all else // should be regions. Path d = tableDir.getPath(); - if (d.getName().equals(HConstants.HREGION_LOGDIR_NAME)) { + if (HConstants.HBASE_NON_TABLE_DIRS.contains(d.getName())) { continue; } FileStatus[] regionDirs = fs.listStatus(d, df);