在HConnectionImplementation中的listTables()中直接调用HMaster的getHTableDescriptors()
而在方法里直接调用FSTableDescriptors的Map<String, HTableDescriptor> getAll()
其中使用List<Path> tableDirs = FSUtils.getTableDirs(fs, rootdir);
public static List<Path> getTableDirs(final FileSystem fs, final Path rootdir) throws IOException { // presumes any directory under hbase.rootdir is a table FileStatus [] dirs = fs.listStatus(rootdir, new DirFilter(fs)); List<Path> tabledirs = new ArrayList<Path>(dirs.length); for (FileStatus dir: dirs) { Path p = dir.getPath(); String tableName = p.getName(); if (!HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tableName)) { tabledirs.add(p); } } return tabledirs; }
rootdir是HBase的根目录,总体来listTables就是list Hbase根目录下的目录,排除特殊文件(".logs",".oldlogs",".corrupt",".META.","-ROOT-","splitlog")就是结果