hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjus...@apache.org
Subject svn commit: r1552239 - in /hbase/branches/0.98: hbase-client/src/main/java/org/apache/hadoop/hbase/ hbase-server/src/main/java/org/apache/hadoop/hbase/util/ hbase-server/src/test/java/org/apache/hadoop/hbase/util/
Date Thu, 19 Dec 2013 06:27:17 GMT
Author: zjushch
Date: Thu Dec 19 06:27:16 2013
New Revision: 1552239

URL: http://svn.apache.org/r1552239
Log:
HBASE-10196 Enhance HBCK to understand the case after online region merge

Modified:
    hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
    hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java

Modified: hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=1552239&r1=1552238&r2=1552239&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
(original)
+++ hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
Thu Dec 19 06:27:16 2013
@@ -1012,6 +1012,20 @@ public class HRegionInfo implements Comp
 
     return new PairOfSameType<HRegionInfo>(splitA, splitB);
   }
+  
+  /**
+   * Returns the merge regions by reading the corresponding columns of the catalog table
+   * Result.
+   * @param data a Result object from the catalog table scan
+   * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split
+   * parent
+   */
+  public static PairOfSameType<HRegionInfo> getMergeRegions(Result data) throws IOException
{
+    HRegionInfo mergeA = getHRegionInfo(data, HConstants.MERGEA_QUALIFIER);
+    HRegionInfo mergeB = getHRegionInfo(data, HConstants.MERGEB_QUALIFIER);
+
+    return new PairOfSameType<HRegionInfo>(mergeA, mergeB);
+  }
 
   /**
    * Returns the HRegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and

Modified: hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1552239&r1=1552238&r2=1552239&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
(original)
+++ hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
Thu Dec 19 06:27:16 2013
@@ -1668,6 +1668,14 @@ public class HBaseFsck extends Configure
       }
 
     } else if (!inMeta && inHdfs && !isDeployed) {
+      if (hbi.isMerged()) {
+        // This region has already been merged, the remaining hdfs file will be
+        // cleaned by CatalogJanitor later
+        hbi.setSkipChecks(true);
+        LOG.info("Region " + descriptiveName
+            + " got merge recently, its file(s) will be cleaned by CatalogJanitor later");
+        return;
+      }
       errors.reportError(ERROR_CODE.NOT_IN_META_OR_DEPLOYED, "Region "
           + descriptiveName + " on HDFS, but not listed in hbase:meta " +
           "or deployed on any region server");
@@ -2646,6 +2654,16 @@ public class HBaseFsck extends Configure
           } else {
             throw new IOException("Two entries in hbase:meta are same " + previous);
           }
+          
+          PairOfSameType<HRegionInfo> mergeRegions = HRegionInfo.getMergeRegions(result);
+          for (HRegionInfo mergeRegion : new HRegionInfo[] {
+              mergeRegions.getFirst(), mergeRegions.getSecond() }) {
+            if (mergeRegion != null) {
+              // This region is already been merged
+              HbckInfo hbInfo = getOrCreateInfo(mergeRegion.getEncodedName());
+              hbInfo.setMerged(true);
+            }
+          }
 
           // show proof of progress to the user, once for every 100 records.
           if (countRecord % 100 == 0) {
@@ -2753,6 +2771,7 @@ public class HBaseFsck extends Configure
     private List<OnlineEntry> deployedEntries = Lists.newArrayList(); // on Region
Server
     private List<ServerName> deployedOn = Lists.newArrayList(); // info on RS's
     private boolean skipChecks = false; // whether to skip further checks to this region
info.
+    private boolean isMerged = false;// whether this region has already been merged into
another one
 
     HbckInfo(MetaEntry metaEntry) {
       this.metaEntry = metaEntry;
@@ -2879,6 +2898,14 @@ public class HBaseFsck extends Configure
     public boolean isSkipChecks() {
       return skipChecks;
     }
+
+    public void setMerged(boolean isMerged) {
+      this.isMerged = isMerged;
+    }
+
+    public boolean isMerged() {
+      return this.isMerged;
+    }
   }
 
   final static Comparator<HbckInfo> cmp = new Comparator<HbckInfo>() {

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java?rev=1552239&r1=1552238&r2=1552239&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
Thu Dec 19 06:27:16 2013
@@ -23,6 +23,7 @@ import static org.apache.hadoop.hbase.ut
 import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.doFsck;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -2177,6 +2178,54 @@ public class TestHBaseFsck {
 
   }
 
+  @Test
+  public void testHbckAfterRegionMerge() throws Exception {
+    TableName table = TableName.valueOf("testMergeRegionFilesInHdfs");
+    HTable meta = null;
+    try {
+      // disable CatalogJanitor
+      TEST_UTIL.getHBaseCluster().getMaster().setCatalogJanitorEnabled(false);
+      setupTable(table);
+      assertEquals(ROWKEYS.length, countRows());
+
+      // make sure data in regions, if in hlog only there is no data loss
+      TEST_UTIL.getHBaseAdmin().flush(table.getName());
+      HRegionInfo region1 = tbl.getRegionLocation("A").getRegionInfo();
+      HRegionInfo region2 = tbl.getRegionLocation("B").getRegionInfo();
+
+      int regionCountBeforeMerge = tbl.getRegionLocations().size();
+
+      assertNotEquals(region1, region2);
+
+      // do a region merge
+      HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+      admin.mergeRegions(region1.getEncodedNameAsBytes(),
+          region2.getEncodedNameAsBytes(), false);
+
+      // wait until region merged
+      long timeout = System.currentTimeMillis() + 30 * 1000;
+      while (true) {
+        if (tbl.getRegionLocations().size() < regionCountBeforeMerge) {
+          break;
+        } else if (System.currentTimeMillis() > timeout) {
+          fail("Time out waiting on region " + region1.getEncodedName()
+              + " and " + region2.getEncodedName() + " be merged");
+        }
+        Thread.sleep(10);
+      }
+
+      assertEquals(ROWKEYS.length, countRows());
+
+      HBaseFsck hbck = doFsck(conf, false);
+      assertNoErrors(hbck); // no errors
+
+    } finally {
+      TEST_UTIL.getHBaseCluster().getMaster().setCatalogJanitorEnabled(true);
+      deleteTable(table);
+      IOUtils.closeQuietly(meta);
+    }
+  }
+
   @org.junit.Rule
   public TestName name = new TestName();
 }



Mime
View raw message