You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2015/07/17 20:02:01 UTC

hbase git commit: HBASE-14092 Add -noLock and -noBalanceSwitch options to hbck

Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 229965646 -> e10585bec


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


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e10585be
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e10585be
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e10585be

Branch: refs/heads/branch-1.2
Commit: e10585bec7240fa47dc0c9bf53822ac73340cbed
Parents: 2299656
Author: Elliott Clark <ec...@apache.org>
Authored: Wed Jul 15 12:03:59 2015 -0700
Committer: Elliott Clark <ec...@apache.org>
Committed: Fri Jul 17 10:57:56 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/util/HBaseFsck.java | 50 +++++++++++++++-----
 1 file changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e10585be/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 406848f..7b54371 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -235,6 +235,8 @@ public class HBaseFsck extends Configured implements Closeable {
    * Options
    ***********/
   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 boolean fixAssignments = false; // fix assignment errors?
   private boolean fixMeta = false; // fix meta errors?
@@ -486,18 +488,21 @@ public class HBaseFsck extends Configured implements Closeable {
    */
   public void connect() throws IOException {
 
-    // Check if another instance of balancer is running
-    hbckOutFd = checkAndMarkRunningHbck();
-    if (hbckOutFd == null) {
-      setRetCode(-1);
-      LOG.error("Another instance of hbck is running, exiting this instance.[If you are sure" +
-          " no other instance is running, delete the lock file " +
-          HBCK_LOCK_PATH + " and rerun the tool]");
-      throw new IOException("Duplicate hbck - Abort");
+    if (useLock) {
+      // Check if another instance of balancer is running
+      hbckOutFd = checkAndMarkRunningHbck();
+      if (hbckOutFd == null) {
+        setRetCode(-1);
+        LOG.error("Another instance of hbck is running, exiting this instance.[If you are sure" +
+            " no other instance is running, delete the lock file " +
+            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
     // kill the hbck with a ctrl-c, we want to cleanup the lock so that
@@ -676,7 +681,6 @@ public class HBaseFsck extends Configured implements Closeable {
     fixOrphanTables();
 
     LOG.info("Checking and fixing region consistency");
-
     // Check and fix consistency
     checkAndFixConsistency();
 
@@ -694,13 +698,19 @@ public class HBaseFsck extends Configured implements Closeable {
     errors.print("Version: " + status.getHBaseVersion());
     offlineHdfsIntegrityRepair();
 
+    boolean oldBalancer = true;
     // turn the balancer off
-    boolean oldBalancer = admin.setBalancerRunning(false, true);
+    if (switchBalancer) {
+      oldBalancer = admin.setBalancerRunning(false, true);
+    }
+
     try {
       onlineConsistencyRepair();
     }
     finally {
-      admin.setBalancerRunning(oldBalancer, false);
+      if (switchBalancer) {
+        admin.setBalancerRunning(oldBalancer, false);
+      }
     }
 
     if (checkRegionBoundaries) {
@@ -4156,6 +4166,14 @@ public class HBaseFsck extends Configured implements Closeable {
     details = true;
   }
 
+  public static void setNoLock() {
+    useLock = false;
+  }
+
+  public static void setNoBalacerSwitch() {
+    switchBalancer = false;
+  }
+
   /**
    * Set summary mode.
    * Print only summary of the tables and status (OK or INCONSISTENT)
@@ -4417,6 +4435,8 @@ public class HBaseFsck extends Configured implements Closeable {
     out.println("   -metaonly Only check the state of the hbase:meta table.");
     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("   -noLock Turn off using the hdfs lock file.");
+    out.println("   -noBalancerSwitch Don't switch the balancer off.");
 
     out.println("");
     out.println("  Metadata Repair options: (expert features, use with caution!)");
@@ -4511,6 +4531,10 @@ public class HBaseFsck extends Configured implements Closeable {
         return printUsageAndExit();
       } else if (cmd.equals("-details")) {
         setDisplayFullReport();
+      } else if (cmd.equals("-noLock")) {
+        setNoLock();
+      } else if (cmd.equals("-noBalancerSwitch")) {
+        setNoBalacerSwitch();
       } else if (cmd.equals("-timelag")) {
         if (i == args.length - 1) {
           errors.reportError(ERROR_CODE.WRONG_USAGE, "HBaseFsck: -timelag needs a value.");