Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9F38C10E1A for ; Tue, 10 Mar 2015 01:49:50 +0000 (UTC) Received: (qmail 71992 invoked by uid 500); 10 Mar 2015 01:49:50 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 71946 invoked by uid 500); 10 Mar 2015 01:49:50 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 71937 invoked by uid 99); 10 Mar 2015 01:49:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2015 01:49:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5DB23E1831; Tue, 10 Mar 2015 01:49:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: enis@apache.org To: commits@hbase.apache.org Message-Id: <48b10a6e5f2344038f2603cfd7b16ad3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-13169 ModifyTable increasing the region replica count should also auto-setup RRRE Date: Tue, 10 Mar 2015 01:49:50 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/master 9aa8f0672 -> be25b0d59 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/be25b0d5 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/be25b0d5 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/be25b0d5 Branch: refs/heads/master Commit: be25b0d595371e221da93a1b734dc696d044c9c8 Parents: 9aa8f06 Author: Enis Soztutar Authored: Mon Mar 9 18:49:40 2015 -0700 Committer: Enis Soztutar Committed: Mon Mar 9 18:49:40 2015 -0700 ---------------------------------------------------------------------- .../master/handler/ModifyTableHandler.java | 6 +++ .../TestRegionReplicaReplicationEndpoint.java | 39 ++++++++++++++++++++ 2 files changed, 45 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/be25b0d5/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..2896354 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,11 @@ 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/be25b0d5/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 886bd6e..9306b15 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,45 @@ public class TestRegionReplicaReplicationEndpoint { admin.close(); } + @Test + 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(); + + // verify it is working + try(Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration()); + Table table = connection.getTable(htd.getTableName());){ + HTU.loadNumericRows(table, HBaseTestingUtility.fam1, 0, 1000); + verifyReplication(htd.getTableName(), 2, 0, 1000); + } + } public void testRegionReplicaReplication(int regionReplication) throws Exception { // test region replica replication. Create a table with single region, write some data