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:22:27 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 6c70f4f7f -> e545953c3


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/e545953c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e545953c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e545953c

Branch: refs/heads/master
Commit: e545953c32584dec6488a64c3027214b9c061bed
Parents: 6c70f4f
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:20:23 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/hbase/blob/e545953c/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 b06e70a..5763cff 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
@@ -78,7 +78,6 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
@@ -119,7 +118,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;
@@ -228,6 +226,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
@@ -380,6 +379,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();
       }
@@ -1133,7 +1133,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) {
@@ -3401,7 +3401,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 {
@@ -3776,6 +3776,7 @@ public class HBaseFsck extends Configured {
    */
   public void setFixTableLocks(boolean shouldFix) {
     fixTableLocks = shouldFix;
+    fixAny |= shouldFix;
   }
 
   /**
@@ -3798,6 +3799,7 @@ public class HBaseFsck extends Configured {
    */
   public void setFixAssignments(boolean shouldFix) {
     fixAssignments = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixAssignments() {
@@ -3806,6 +3808,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixMeta(boolean shouldFix) {
     fixMeta = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixMeta() {
@@ -3814,6 +3817,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixEmptyMetaCells(boolean shouldFix) {
     fixEmptyMetaCells = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixEmptyMetaCells() {
@@ -3830,6 +3834,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsHoles(boolean shouldFix) {
     fixHdfsHoles = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsHoles() {
@@ -3838,6 +3843,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixTableOrphans(boolean shouldFix) {
     fixTableOrphans = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixTableOrphans() {
@@ -3846,6 +3852,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsOverlaps(boolean shouldFix) {
     fixHdfsOverlaps = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsOverlaps() {
@@ -3854,6 +3861,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixHdfsOrphans(boolean shouldFix) {
     fixHdfsOrphans = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixHdfsOrphans() {
@@ -3862,6 +3870,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixVersionFile(boolean shouldFix) {
     fixVersionFile = shouldFix;
+    fixAny |= shouldFix;
   }
 
   public boolean shouldFixVersionFile() {
@@ -3878,6 +3887,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixSplitParents(boolean shouldFix) {
     fixSplitParents = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixSplitParents() {
@@ -3886,6 +3896,7 @@ public class HBaseFsck extends Configured {
 
   public void setFixReferenceFiles(boolean shouldFix) {
     fixReferenceFiles = shouldFix;
+    fixAny |= shouldFix;
   }
 
   boolean shouldFixReferenceFiles() {
@@ -3893,7 +3904,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/e545953c/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 d3e62fe..2f7051e 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
@@ -110,6 +110,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;
@@ -553,6 +554,7 @@ public class TestHBaseFsck {
 
     class RunHbck implements Callable<HBaseFsck>{
       boolean fail = true;
+      @Override
       public HBaseFsck call(){
         try{
           return doFsck(conf, false);
@@ -2553,4 +2555,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