hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r1033736 - in /hbase/trunk: ./ bin/ src/main/java/org/apache/hadoop/hbase/client/ src/main/java/org/apache/hadoop/hbase/util/ src/test/java/org/apache/hadoop/hbase/client/ src/test/java/org/apache/hadoop/hbase/util/
Date Wed, 10 Nov 2010 21:46:14 GMT
Author: jdcryans
Date: Wed Nov 10 21:46:14 2010
New Revision: 1033736

URL: http://svn.apache.org/viewvc?rev=1033736&view=rev
Log:
HBASE-3216  Move HBaseFsck from client to util

Added:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
      - copied, changed from r1033640, hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
      - copied, changed from r1033640, hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsckRepair.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
Removed:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsckRepair.java
Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/bin/hbase
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1033736&r1=1033735&r2=1033736&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Nov 10 21:46:14 2010
@@ -673,6 +673,7 @@ Release 0.90.0 - Unreleased
                abort
    HBASE-3214  TestMasterFailover.testMasterFailoverWithMockedRITOnDeadRS is
                failing (Gary via jgray)
+   HBASE-3216  Move HBaseFsck from client to util
 
 
   IMPROVEMENTS

Modified: hbase/trunk/bin/hbase
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/hbase?rev=1033736&r1=1033735&r2=1033736&view=diff
==============================================================================
--- hbase/trunk/bin/hbase (original)
+++ hbase/trunk/bin/hbase Wed Nov 10 21:46:14 2010
@@ -255,7 +255,7 @@ elif [ "$COMMAND" = "avro" ] ; then
 elif [ "$COMMAND" = "migrate" ] ; then
   CLASS='org.apache.hadoop.hbase.util.Migrate'
 elif [ "$COMMAND" = "hbck" ] ; then
-  CLASS='org.apache.hadoop.hbase.client.HBaseFsck'
+  CLASS='org.apache.hadoop.hbase.util.HBaseFsck'
 elif [ "$COMMAND" = "zookeeper" ] ; then
   CLASS='org.apache.hadoop.hbase.zookeeper.HQuorumPeer'
   if [ "$1" != "stop" ] ; then

Copied: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (from r1033640,
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java)
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?p2=hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java&p1=hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java&r1=1033640&r2=1033736&rev=1033736&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Wed Nov 10 21:46:14
2010
@@ -17,7 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.hadoop.hbase.client;
+package org.apache.hadoop.hbase.util;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -45,6 +45,9 @@ import org.apache.hadoop.hbase.HTableDes
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HConnection;
+import org.apache.hadoop.hbase.client.MetaScanner;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;

Copied: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java (from
r1033640, hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsckRepair.java)
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java?p2=hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java&p1=hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsckRepair.java&r1=1033640&r2=1033736&rev=1033736&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseFsckRepair.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java Wed Nov 10
21:46:14 2010
@@ -17,7 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.hadoop.hbase.client;
+package org.apache.hadoop.hbase.util;
 
 import java.io.IOException;
 import java.util.List;
@@ -26,6 +26,9 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.HConnectionManager;
+import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1033736&r1=1033735&r2=1033736&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Wed Nov 10 21:46:14
2010
@@ -121,15 +121,6 @@ public class TestAdmin {
   }
 
   @Test
-  public void testHBaseFsck() throws IOException {
-    HBaseFsck fsck =
-      new HBaseFsck(TEST_UTIL.getMiniHBaseCluster().getConfiguration());
-    fsck.displayFullReport();
-    int result = fsck.doWork();
-    assertEquals(0, result);
-  }
-
-  @Test
   public void testCreateTable() throws IOException {
     HTableDescriptor [] tables = admin.listTables();
     int numTables = tables.length;

Added: hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java?rev=1033736&view=auto
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (added)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Wed Nov 10 21:46:14
2010
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2010 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HServerInfo;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestHBaseFsck {
+
+  final Log LOG = LogFactory.getLog(getClass());
+  private final static HBaseTestingUtility TEST_UTIL =
+      new HBaseTestingUtility();
+  private final static Configuration conf = TEST_UTIL.getConfiguration();
+  private final static byte[] TABLE = Bytes.toBytes("table");
+  private final static byte[] FAM = Bytes.toBytes("fam");
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    TEST_UTIL.startMiniCluster(3);
+  }
+
+  @Test
+  public void testHBaseFsck() throws IOException {
+    HBaseFsck fsck = new HBaseFsck(conf);
+    fsck.displayFullReport();
+    fsck.setTimeLag(0);
+    // Most basic check ever, 0 tables
+    int result = fsck.doWork();
+    assertEquals(0, result);
+
+    TEST_UTIL.createTable(TABLE, FAM);
+
+    // We created 1 table, should be fine
+    result = fsck.doWork();
+    assertEquals(0, result);
+
+    // Now let's mess it up and change the assignment in .META. to
+    // point to a different region server
+    HTable meta = new HTable(conf, HTableDescriptor.META_TABLEDESC.getName());
+    ResultScanner scanner = meta.getScanner(new Scan());
+    
+    resforloop : for (Result res : scanner) {
+      long startCode = Bytes.toLong(res.getValue(HConstants.CATALOG_FAMILY,
+          HConstants.STARTCODE_QUALIFIER));
+
+      for (JVMClusterUtil.RegionServerThread rs :
+          TEST_UTIL.getHBaseCluster().getRegionServerThreads()) {
+
+        HServerInfo hsi = rs.getRegionServer().getServerInfo();
+
+        // When we find a diff RS, change the assignment and break
+        if (startCode != hsi.getStartCode()) {
+          Put put = new Put(res.getRow());
+          put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
+              Bytes.toBytes(hsi.getHostnamePort()));
+          put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
+              Bytes.toBytes(hsi.getStartCode()));
+          meta.put(put);
+          break resforloop;
+        }
+      }
+    }
+
+    // We set this here, but it's really not fixing anything...
+    fsck.setFixErrors();
+    result = fsck.doWork();
+    // Fixed or not, it still reports inconsistencies
+    assertEquals(-1, result);
+
+    // Disabled, won't work because the region stays unassigned, see HBASE-3217
+    // new HTable(conf, TABLE).getScanner(new Scan());
+  }
+}



Mime
View raw message