hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brfrn...@apache.org
Subject hbase git commit: HBASE-21104 client.TestRestoreSnapshotFromClientWithRegionReplicas failing on branch-1.3, branch-1.2
Date Sat, 01 Sep 2018 09:08:48 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 beb954e0d -> bd76de7e9


HBASE-21104 client.TestRestoreSnapshotFromClientWithRegionReplicas failing on branch-1.3,
branch-1.2


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

Branch: refs/heads/branch-1.2
Commit: bd76de7e910555991b17d791f9e9aae23c3a125d
Parents: beb954e
Author: Toshihiro Suzuki <brfrn169@gmail.com>
Authored: Fri Aug 31 01:05:40 2018 +0900
Committer: Toshihiro Suzuki <brfrn169@gmail.com>
Committed: Sat Sep 1 18:08:28 2018 +0900

----------------------------------------------------------------------
 .../snapshot/EnabledTableSnapshotHandler.java   |  4 ++-
 .../client/TestRestoreSnapshotFromClient.java   | 26 ++++++++++++--------
 ...oreSnapshotFromClientWithRegionReplicas.java | 26 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bd76de7e/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
index 7e047ac..f1c207d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.procedure.Procedure;
@@ -98,7 +99,8 @@ public class EnabledTableSnapshotHandler extends TakeSnapshotHandler {
       // Take the offline regions as disabled
       for (Pair<HRegionInfo, ServerName> region : regions) {
         HRegionInfo regionInfo = region.getFirst();
-        if (regionInfo.isOffline() && (regionInfo.isSplit() || regionInfo.isSplitParent()))
{
+        if (regionInfo.isOffline() && (regionInfo.isSplit() || regionInfo.isSplitParent())
&&
+          RegionReplicaUtil.isDefaultReplica(regionInfo)) {
           LOG.info("Take disabled snapshot of offline region=" + regionInfo);
           snapshotDisabledRegion(regionInfo);
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bd76de7e/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
index e70133e..524b26f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.CategoryBasedTimeout;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
@@ -64,18 +65,18 @@ public class TestRestoreSnapshotFromClient {
       .withLookingForStuckThread(true)
       .build();
 
-  private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+  protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
 
-  private final byte[] FAMILY = Bytes.toBytes("cf");
+  protected final byte[] FAMILY = Bytes.toBytes("cf");
 
-  private byte[] emptySnapshot;
-  private byte[] snapshotName0;
-  private byte[] snapshotName1;
-  private byte[] snapshotName2;
-  private int snapshot0Rows;
-  private int snapshot1Rows;
-  private TableName tableName;
-  private Admin admin;
+  protected byte[] emptySnapshot;
+  protected byte[] snapshotName0;
+  protected byte[] snapshotName1;
+  protected byte[] snapshotName2;
+  protected int snapshot0Rows;
+  protected int snapshot1Rows;
+  protected TableName tableName;
+  protected Admin admin;
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
@@ -362,4 +363,9 @@ public class TestRestoreSnapshotFromClient {
     }
     return families;
   }
+
+  protected void splitRegion(final HRegionInfo regionInfo) throws IOException {
+    byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(),
1);
+    admin.split(regionInfo.getTable(), splitPoints[1]);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bd76de7e/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
index 27ff447..876954d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClientWithRegionReplicas.java
@@ -17,7 +17,14 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(LargeTests.class)
@@ -27,4 +34,23 @@ public class TestRestoreSnapshotFromClientWithRegionReplicas extends
   protected int getNumReplicas() {
     return 3;
   }
+
+  @Test
+  public void testOnlineSnapshotAfterSplittingRegions() throws IOException, InterruptedException
{
+    List<HRegionInfo> regionInfos = admin.getTableRegions(tableName);
+    RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
+
+    // Split a region
+    splitRegion(regionInfos.get(0));
+
+    // Take a online snapshot
+    admin.snapshot(snapshotName1, tableName);
+
+    // Clone the snapshot to another table
+    TableName clonedTableName = TableName.valueOf("testOnlineSnapshotAfterSplittingRegions-"
+
+      System.currentTimeMillis());
+    admin.cloneSnapshot(snapshotName1, clonedTableName);
+
+    SnapshotTestingUtils.verifyRowCount(TEST_UTIL, clonedTableName, snapshot1Rows);
+  }
 }


Mime
View raw message