hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject git commit: HBASE-12243 HBaseFsck should auto set ignorePreCheckPermission to true if no fix option is set (Yi Deng)
Date Tue, 21 Oct 2014 20:52:22 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 89191230e -> 58e9d89c4


HBASE-12243 HBaseFsck should auto set ignorePreCheckPermission to true if no fix option is
set (Yi Deng)

Signed-off-by: Jonathan M Hsieh <jmhsieh@apache.org>


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

Branch: refs/heads/branch-1
Commit: 58e9d89c44b66b376706bf5dca523c70ee0d97a0
Parents: 8919123
Author: Yi Deng <daviddengcn@gmail.com>
Authored: Mon Oct 13 18:31:04 2014 -0700
Committer: Jonathan M Hsieh <jmhsieh@apache.org>
Committed: Tue Oct 21 13:35:49 2014 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/util/HBaseFsck.java | 20 ++++++++++++++++----
 .../apache/hadoop/hbase/util/TestHBaseFsck.java | 18 ++++++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/58e9d89c/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 cfca1f6..f9b840b 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
@@ -117,7 +117,6 @@ import org.apache.hadoop.hbase.security.AccessDeniedException;
 import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.Tool;
@@ -226,6 +225,7 @@ public class HBaseFsck extends Configured {
   private boolean fixReferenceFiles = false; // fix lingering reference store file
   private boolean fixEmptyMetaCells = false; // fix (remove) empty REGIONINFO_QUALIFIER rows
   private boolean fixTableLocks = false; // fix table locks which are expired
+  private boolean fixAny = false; // Set to true if any of the fix is required.
 
   // limit checking/fixes to listed tables, if empty attempt to check/fix all
   // hbase:meta are always checked
@@ -378,6 +378,7 @@ public class HBaseFsck extends Configured {
     // kill the hbck with a ctrl-c, we want to cleanup the lock so that
     // it is available for further calls
     Runtime.getRuntime().addShutdownHook(new Thread() {
+      @Override
       public void run() {
           unlockHbck();
       }
@@ -1131,7 +1132,7 @@ public class HBaseFsck extends Configured {
       FSTableDescriptors fstd = new FSTableDescriptors(getConf());
       while (iter.hasNext()) {
         Entry<TableName, Set<String>> entry =
-            (Entry<TableName, Set<String>>) iter.next();
+            iter.next();
         TableName tableName = entry.getKey();
         LOG.info("Trying to fix orphan table error: " + tableName);
         if (j < htds.length) {
@@ -3280,7 +3281,7 @@ public class HBaseFsck extends Configured {
   static ErrorReporter getErrorReporter(
       final Configuration conf) throws ClassNotFoundException {
     Class<? extends ErrorReporter> reporter = conf.getClass("hbasefsck.errorreporter",
PrintingErrorReporter.class, ErrorReporter.class);
-    return (ErrorReporter)ReflectionUtils.newInstance(reporter, conf);
+    return ReflectionUtils.newInstance(reporter, conf);
   }
 
   public interface ErrorReporter {
@@ -3656,6 +3657,7 @@ public class HBaseFsck extends Configured {
    */
   public void setFixTableLocks(boolean shouldFix) {
     fixTableLocks = shouldFix;
+    fixAny |= shouldFix;
   }
 
   /**
@@ -3678,6 +3680,7 @@ public class HBaseFsck extends Configured {
    */
   public void setFixAssignments(boolean shouldFix) {
     fixAssignments = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixAssignments() {
@@ -3686,6 +3689,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixMeta(boolean shouldFix) {
     fixMeta = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixMeta() {
@@ -3694,6 +3698,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixEmptyMetaCells(boolean shouldFix) {
     fixEmptyMetaCells = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixEmptyMetaCells() {
@@ -3710,6 +3715,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsHoles(boolean shouldFix) {
     fixHdfsHoles = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsHoles() {
@@ -3718,6 +3724,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixTableOrphans(boolean shouldFix) {
     fixTableOrphans = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixTableOrphans() {
@@ -3726,6 +3733,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsOverlaps(boolean shouldFix) {
     fixHdfsOverlaps = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsOverlaps() {
@@ -3734,6 +3742,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsOrphans(boolean shouldFix) {
     fixHdfsOrphans = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsOrphans() {
@@ -3742,6 +3751,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixVersionFile(boolean shouldFix) {
     fixVersionFile = shouldFix;
+    fixAny |= shouldFix;
   }
 
   public boolean shouldFixVersionFile() {
@@ -3758,6 +3768,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixSplitParents(boolean shouldFix) {
     fixSplitParents = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixSplitParents() {
@@ -3766,6 +3777,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixReferenceFiles(boolean shouldFix) {
     fixReferenceFiles = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixReferenceFiles() {
@@ -3773,7 +3785,7 @@ public class HBaseFsck extends Configured {
   }
 
   public boolean shouldIgnorePreCheckPermission() {
-    return ignorePreCheckPermission;
+    return !fixAny || ignorePreCheckPermission;
   }
 
   public void setIgnorePreCheckPermission(boolean ignorePreCheckPermission) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/58e9d89c/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
index f5d295d..e7f5898 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
@@ -104,6 +104,7 @@ import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil;
 import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
 import org.apache.zookeeper.KeeperException;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -544,6 +545,7 @@ public class TestHBaseFsck {
 
     class RunHbck implements Callable<HBaseFsck>{
       boolean fail = true;
+      @Override
       public HBaseFsck call(){
         try{
           return doFsck(conf, false);
@@ -2388,4 +2390,20 @@ public class TestHBaseFsck {
 
   @org.junit.Rule
   public TestName name = new TestName();
+
+  @Test
+  public void testReadOnlyProperty() throws Exception {
+    HBaseFsck hbck = doFsck(conf, false);
+    Assert.assertEquals("shouldIgnorePreCheckPermission", true,
+      hbck.shouldIgnorePreCheckPermission());
+
+    hbck = doFsck(conf, true);
+    Assert.assertEquals("shouldIgnorePreCheckPermission", false,
+      hbck.shouldIgnorePreCheckPermission());
+
+    hbck = doFsck(conf, true);
+    hbck.setIgnorePreCheckPermission(true);
+    Assert.assertEquals("shouldIgnorePreCheckPermission", true,
+      hbck.shouldIgnorePreCheckPermission());
+  }
 }


Mime
View raw message