HBASE-14092 Add -noLock and -noBalanceSwitch options to hbck

This commit is contained in:
Elliott Clark 2015-07-15 12:03:59 -07:00
parent a6e91903ec
commit 1446d01e98
1 changed files with 37 additions and 13 deletions

View File

@ -231,6 +231,8 @@ public class HBaseFsck extends Configured implements Closeable {
* Options * Options
***********/ ***********/
private static boolean details = false; // do we display the full report private static boolean details = false; // do we display the full report
private static boolean useLock = true; // do we use the hbck exclusivity lock
private static boolean switchBalancer = true; // do we turn the balancer off while running
private long timelag = DEFAULT_TIME_LAG; // tables whose modtime is older private long timelag = DEFAULT_TIME_LAG; // tables whose modtime is older
private boolean fixAssignments = false; // fix assignment errors? private boolean fixAssignments = false; // fix assignment errors?
private boolean fixMeta = false; // fix meta errors? private boolean fixMeta = false; // fix meta errors?
@ -476,18 +478,21 @@ public class HBaseFsck extends Configured implements Closeable {
*/ */
public void connect() throws IOException { public void connect() throws IOException {
// Check if another instance of balancer is running if (useLock) {
hbckOutFd = checkAndMarkRunningHbck(); // Check if another instance of balancer is running
if (hbckOutFd == null) { hbckOutFd = checkAndMarkRunningHbck();
setRetCode(-1); if (hbckOutFd == null) {
LOG.error("Another instance of hbck is running, exiting this instance.[If you are sure" + setRetCode(-1);
" no other instance is running, delete the lock file " + LOG.error("Another instance of hbck is running, exiting this instance.[If you are sure" +
HBCK_LOCK_PATH + " and rerun the tool]"); " no other instance is running, delete the lock file " +
throw new IOException("Duplicate hbck - Abort"); HBCK_LOCK_PATH + " and rerun the tool]");
throw new IOException("Duplicate hbck - Abort");
}
// Make sure to cleanup the lock
hbckLockCleanup.set(true);
} }
// Make sure to cleanup the lock
hbckLockCleanup.set(true);
// Add a shutdown hook to this thread, in case user tries to // Add a shutdown hook to this thread, in case user tries to
// kill the hbck with a ctrl-c, we want to cleanup the lock so that // kill the hbck with a ctrl-c, we want to cleanup the lock so that
@ -666,7 +671,6 @@ public class HBaseFsck extends Configured implements Closeable {
fixOrphanTables(); fixOrphanTables();
LOG.info("Checking and fixing region consistency"); LOG.info("Checking and fixing region consistency");
// Check and fix consistency // Check and fix consistency
checkAndFixConsistency(); checkAndFixConsistency();
@ -684,13 +688,19 @@ public class HBaseFsck extends Configured implements Closeable {
errors.print("Version: " + status.getHBaseVersion()); errors.print("Version: " + status.getHBaseVersion());
offlineHdfsIntegrityRepair(); offlineHdfsIntegrityRepair();
boolean oldBalancer = true;
// turn the balancer off // turn the balancer off
boolean oldBalancer = admin.setBalancerRunning(false, true); if (switchBalancer) {
oldBalancer = admin.setBalancerRunning(false, true);
}
try { try {
onlineConsistencyRepair(); onlineConsistencyRepair();
} }
finally { finally {
admin.setBalancerRunning(oldBalancer, false); if (switchBalancer) {
admin.setBalancerRunning(oldBalancer, false);
}
} }
if (checkRegionBoundaries) { if (checkRegionBoundaries) {
@ -4140,6 +4150,14 @@ public class HBaseFsck extends Configured implements Closeable {
details = true; details = true;
} }
public static void setNoLock() {
useLock = false;
}
public static void setNoBalacerSwitch() {
switchBalancer = false;
}
/** /**
* Set summary mode. * Set summary mode.
* Print only summary of the tables and status (OK or INCONSISTENT) * Print only summary of the tables and status (OK or INCONSISTENT)
@ -4392,6 +4410,8 @@ public class HBaseFsck extends Configured implements Closeable {
out.println(" -metaonly Only check the state of the hbase:meta table."); out.println(" -metaonly Only check the state of the hbase:meta table.");
out.println(" -sidelineDir <hdfs://> HDFS path to backup existing meta."); out.println(" -sidelineDir <hdfs://> HDFS path to backup existing meta.");
out.println(" -boundaries Verify that regions boundaries are the same between META and store files."); out.println(" -boundaries Verify that regions boundaries are the same between META and store files.");
out.println(" -noLock Turn off using the hdfs lock file.");
out.println(" -noBalancerSwitch Don't switch the balancer off.");
out.println(""); out.println("");
out.println(" Metadata Repair options: (expert features, use with caution!)"); out.println(" Metadata Repair options: (expert features, use with caution!)");
@ -4481,6 +4501,10 @@ public class HBaseFsck extends Configured implements Closeable {
return printUsageAndExit(); return printUsageAndExit();
} else if (cmd.equals("-details")) { } else if (cmd.equals("-details")) {
setDisplayFullReport(); setDisplayFullReport();
} else if (cmd.equals("-noLock")) {
setNoLock();
} else if (cmd.equals("-noBalancerSwitch")) {
setNoBalacerSwitch();
} else if (cmd.equals("-timelag")) { } else if (cmd.equals("-timelag")) {
if (i == args.length - 1) { if (i == args.length - 1) {
errors.reportError(ERROR_CODE.WRONG_USAGE, "HBaseFsck: -timelag needs a value."); errors.reportError(ERROR_CODE.WRONG_USAGE, "HBaseFsck: -timelag needs a value.");