hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hbase git commit: HBASE-13169 ModifyTable increasing the region replica count should also auto-setup RRRE
Date Thu, 12 Mar 2015 20:40:06 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 5316214d4 -> d45efa720


HBASE-13169 ModifyTable increasing the region replica count should also auto-setup RRRE


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

Branch: refs/heads/master
Commit: d45efa72080e9b7ce77c69d1bd8e812e7ef1b698
Parents: 5316214
Author: Enis Soztutar <enis@apache.org>
Authored: Thu Mar 12 13:39:55 2015 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Thu Mar 12 13:39:55 2015 -0700

----------------------------------------------------------------------
 .../master/handler/ModifyTableHandler.java      |  5 +++
 .../TestRegionReplicaReplicationEndpoint.java   | 32 ++++++++++++++++++++
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d45efa72/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
index 1cb0643..9b82701 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
@@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
 import org.apache.hadoop.hbase.master.MasterFileSystem;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
 
 @InterfaceAudience.Private
 public class ModifyTableHandler extends TableEventHandler {
@@ -88,6 +89,10 @@ public class ModifyTableHandler extends TableEventHandler {
         this.htd.getRegionReplication(),
         oldDescriptor.getRegionReplication(),
         this.htd.getTableName());
+    // Setup replication for region replicas if needed
+    if (htd.getRegionReplication() > 1 && oldDescriptor.getRegionReplication()
<= 1) {
+      ServerRegionReplicaUtil.setupRegionReplicaReplication(server.getConfiguration());
+    }
     if (cpHost != null) {
       cpHost.postModifyTableHandler(this.tableName, this.htd);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/d45efa72/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
index 1da2897..2226fcb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java
@@ -135,6 +135,38 @@ public class TestRegionReplicaReplicationEndpoint {
     admin.close();
   }
 
+  @Test (timeout=240000)
+  public void testRegionReplicaReplicationPeerIsCreatedForModifyTable() throws Exception
{
+    // modify a table by adding region replicas. Check whether the replication peer is created
+    // and replication started.
+    ReplicationAdmin admin = new ReplicationAdmin(HTU.getConfiguration());
+    String peerId = "region_replica_replication";
+
+    if (admin.getPeerConfig(peerId) != null) {
+      admin.removePeer(peerId);
+    }
+
+    HTableDescriptor htd
+      = HTU.createTableDescriptor("testRegionReplicaReplicationPeerIsCreatedForModifyTable");
+    HTU.getHBaseAdmin().createTable(htd);
+
+    // assert that replication peer is not created yet
+    ReplicationPeerConfig peerConfig = admin.getPeerConfig(peerId);
+    assertNull(peerConfig);
+
+    HTU.getHBaseAdmin().disableTable(htd.getTableName());
+    htd.setRegionReplication(2);
+    HTU.getHBaseAdmin().modifyTable(htd.getTableName(), htd);
+    HTU.getHBaseAdmin().enableTable(htd.getTableName());
+
+    // assert peer configuration is correct
+    peerConfig = admin.getPeerConfig(peerId);
+    assertNotNull(peerConfig);
+    assertEquals(peerConfig.getClusterKey(), ZKUtil.getZooKeeperClusterKey(HTU.getConfiguration()));
+    assertEquals(peerConfig.getReplicationEndpointImpl(),
+      RegionReplicaReplicationEndpoint.class.getName());
+    admin.close();
+  }
 
   public void testRegionReplicaReplication(int regionReplication) throws Exception {
     // test region replica replication. Create a table with single region, write some data


Mime
View raw message