in hbase-hbck2/src/main/java/org/apache/hbase/hbck1/OfflineMetaRepair.java [68:122]
public static void main(String[] args) throws Exception {
// create a fsck object
Configuration conf = HBaseConfiguration.create();
// Cover both bases, the old way of setting default fs and the new.
// We're supposed to run on 0.20 and 0.21 anyways.
CommonFSUtils.setFsDefault(conf, CommonFSUtils.getRootDir(conf));
HBaseFsck fsck = new HBaseFsck(conf);
// Process command-line args.
for (int i = 0; i < args.length; i++) {
String cmd = args[i];
if (cmd.equals("-details")) {
HBaseFsck.setDisplayFullReport();
} else if (cmd.equals("-base")) {
if (i == args.length - 1) {
System.err.println("OfflineMetaRepair: -base needs an HDFS path.");
printUsageAndExit();
}
// update hbase root dir to user-specified base
i++;
CommonFSUtils.setRootDir(conf, new Path(args[i]));
CommonFSUtils.setFsDefault(conf, CommonFSUtils.getRootDir(conf));
} else if (cmd.equals("-sidelineDir")) {
if (i == args.length - 1) {
System.err.println("OfflineMetaRepair: -sidelineDir needs an HDFS path.");
printUsageAndExit();
}
// set the hbck sideline dir to user-specified one
i++;
fsck.setSidelineDir(args[i]);
} else {
String str = "Unknown command line option : " + cmd;
LOG.info(str);
System.out.println(str);
printUsageAndExit();
}
}
System.out.println("OfflineMetaRepair command line options: " + String.join(" ", args));
// Fsck doesn't shutdown and and doesn't provide a way to shutdown its
// threads cleanly, so we do a System.exit.
boolean success = false;
try {
success = fsck.rebuildMeta();
} catch (MultipleIOException mioes) {
for (IOException ioe : mioes.getExceptions()) {
LOG.error("Bailed out due to:", ioe);
}
} catch (Exception e) {
LOG.error("Bailed out due to: ", e);
} finally {
System.exit(success ? 0 : 1);
}
}