`
yinhudongtian
  • 浏览: 11646 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

HBaseAdmin中的listTables源代码解读

阅读更多
方法中直接调用HConnectionImplementation中的listTables()
在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")就是结果
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics