public int run()

in hbase-tools/src/main/java/org/apache/hbase/MissingRegionDirsRepairTool.java [58:118]


  public int run(String[] strings) throws Exception {
    Map<TableName,List<Path>> result = hbck
      .reportTablesWithMissingRegionsInMeta(new String[]{});
    Path runPath = new Path(new Path(HBCKFsUtils.getRootDir(conf),
      WORKING_DIR), "" + System.currentTimeMillis());
    FileSystem fs = runPath.getFileSystem(conf);
    LOG.info("creating temp dir at: " + runPath.getName());
    fs.mkdirs(runPath);
    try(Connection conn = ConnectionFactory.createConnection(conf)) {
      Admin admin = conn.getAdmin();
      result.forEach((t, p) -> {
        if(!p.isEmpty()) {
          Path tblPath =
            new Path(runPath, new Path(t.getNameWithNamespaceInclAsString()
              .replaceAll(":", "_")));
          try {
            fs.mkdirs(tblPath);
            Path sidelined = new Path(tblPath, "sidelined");
            fs.mkdirs(sidelined);
            Path bulkload = new Path(tblPath, "bulkload");
            fs.mkdirs(bulkload);
            p.stream().forEach(region -> {
              try {
                Path sidelinedRegionDir = new Path(sidelined, region.getName());
                fs.mkdirs(sidelinedRegionDir);
                HBCKFsUtils.copyFilesParallel(fs, region, fs, sidelinedRegionDir, conf, 3);
                admin.getDescriptor(t).getColumnFamilyNames().forEach(cf -> {
                  Path cfDir = new Path(region, Bytes.toString(cf));
                  Path tempCfDir = new Path(bulkload, cfDir.getName());
                  try {
                    if (!fs.exists(tempCfDir)) {
                      fs.mkdirs(tempCfDir);
                    }
                    FileStatus[] files = fs.listStatus(cfDir);
                    for (FileStatus file : files) {
                      fs.rename(file.getPath(),
                        new Path(tempCfDir,
                          region.getName() + "-" + file.getPath().getName()));
                    }
                  } catch (IOException e) {
                    LOG.error("Error trying to move files from inconsistent region dir: ", e);
                  }
                });
                fs.delete(region, true);
                LOG.info("region dir {} moved to {}", region.toUri().getRawPath(),
                  sidelinedRegionDir.toUri().getRawPath());
              } catch (IOException e) {
                LOG.error("Error trying to fetch table descriptor: ", e);
              }
            });
            LOG.info("Calling bulk load for: " + tblPath.toUri().getRawPath());
            bulkLoad.run(bulkload.toUri().getRawPath(), t);
          } catch (IOException e) {
            LOG.error("Error trying to create temp dir for sideline files: ", e);
          }
        }
      });
      admin.close();
    }
    return 0;
  }