From 6a6fff103e0fcadfd539fbbae5157a99643a033b Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Thu, 16 Mar 2017 16:55:18 +0800 Subject: [PATCH] HBASE-17790 Mark ReplicationAdmin's peerAdded and listReplicationPeers as Deprecated --- .../client/replication/ReplicationAdmin.java | 5 ++++ .../replication/TestReplicationAdmin.java | 25 ++++++++++--------- .../TestReplicationAdminWithClusters.java | 3 +-- .../replication/TestNamespaceReplication.java | 1 - .../replication/TestReplicationBase.java | 4 ++- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java index c7f040e345e..0eae10b97dc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java @@ -521,11 +521,16 @@ public class ReplicationAdmin implements Closeable { } @VisibleForTesting + @Deprecated public void peerAdded(String id) throws ReplicationException { this.replicationPeers.peerConnected(id); } + /** + * @deprecated use {@link org.apache.hadoop.hbase.client.Admin#listReplicationPeers()} instead + */ @VisibleForTesting + @Deprecated List listReplicationPeers() throws IOException { Map peers = listPeerConfigs(); if (peers == null || peers.size() <= 0) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java index f092a48afbc..a23b76ae0fc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java @@ -33,11 +33,13 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.ReplicationPeerNotFoundException; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.RetriesExhaustedException; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationFactory; import org.apache.hadoop.hbase.replication.ReplicationPeer; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; +import org.apache.hadoop.hbase.replication.ReplicationPeerDescription; import org.apache.hadoop.hbase.replication.ReplicationQueues; import org.apache.hadoop.hbase.replication.ReplicationQueuesArguments; import org.apache.hadoop.hbase.testclassification.ClientTests; @@ -74,6 +76,7 @@ public class TestReplicationAdmin { private final String KEY_SECOND = "127.0.0.1:2181:/hbase2"; private static ReplicationAdmin admin; + private static Admin hbaseAdmin; @Rule public TestName name = new TestName(); @@ -87,6 +90,7 @@ public class TestReplicationAdmin { Configuration conf = TEST_UTIL.getConfiguration(); conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1); admin = new ReplicationAdmin(conf); + hbaseAdmin = TEST_UTIL.getAdmin(); } @AfterClass @@ -149,16 +153,16 @@ public class TestReplicationAdmin { config.setClusterKey(KEY_ONE); config.getConfiguration().put("key1", "value1"); config.getConfiguration().put("key2", "value2"); - admin.addPeer(ID_ONE, config, null); + hbaseAdmin.addReplicationPeer(ID_ONE, config); - List peers = admin.listReplicationPeers(); + List peers = hbaseAdmin.listReplicationPeers(); assertEquals(1, peers.size()); - ReplicationPeer peerOne = peers.get(0); + ReplicationPeerDescription peerOne = peers.get(0); assertNotNull(peerOne); - assertEquals("value1", peerOne.getConfiguration().get("key1")); - assertEquals("value2", peerOne.getConfiguration().get("key2")); + assertEquals("value1", peerOne.getPeerConfig().getConfiguration().get("key1")); + assertEquals("value2", peerOne.getPeerConfig().getConfiguration().get("key2")); - admin.removePeer(ID_ONE); + hbaseAdmin.removeReplicationPeer(ID_ONE); } @Test @@ -403,8 +407,7 @@ public class TestReplicationAdmin { ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(KEY_ONE); - admin.addPeer(ID_ONE, rpc); - admin.peerAdded(ID_ONE); + hbaseAdmin.addReplicationPeer(ID_ONE, rpc); rpc = admin.getPeerConfig(ID_ONE); Set namespaces = new HashSet<>(); @@ -438,8 +441,7 @@ public class TestReplicationAdmin { ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(KEY_ONE); - admin.addPeer(ID_ONE, rpc); - admin.peerAdded(ID_ONE); + hbaseAdmin.addReplicationPeer(ID_ONE, rpc); rpc = admin.getPeerConfig(ID_ONE); Set namespaces = new HashSet(); @@ -482,8 +484,7 @@ public class TestReplicationAdmin { public void testPeerBandwidth() throws Exception { ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(KEY_ONE); - admin.addPeer(ID_ONE, rpc); - admin.peerAdded(ID_ONE); + hbaseAdmin.addReplicationPeer(ID_ONE, rpc); rpc = admin.getPeerConfig(ID_ONE); assertEquals(0, rpc.getBandwidth()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java index 312a90acb43..56f4141b05d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java @@ -229,8 +229,7 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase { rpc.setReplicationEndpointImpl(TestUpdatableReplicationEndpoint.class.getName()); rpc.getConfiguration().put("key1", "value1"); - admin.addPeer(peerId, rpc); - admin.peerAdded(peerId); + admin1.addReplicationPeer(peerId, rpc); rpc.getConfiguration().put("key1", "value2"); admin.updatePeerConfig(peerId, rpc); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java index e296f8704d4..433a3450c34 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java @@ -140,7 +140,6 @@ public class TestNamespaceReplication extends TestReplicationBase { Table htab1B = connection1.getTable(tabBName); Table htab2B = connection2.getTable(tabBName); - admin.peerAdded("2"); // add ns1 to peer config which replicate to cluster2 ReplicationPeerConfig rpc = admin.getPeerConfig("2"); Set namespaces = new HashSet<>(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java index caad544d8ce..81fe6297802 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java @@ -63,6 +63,7 @@ public class TestReplicationBase { protected static ZooKeeperWatcher zkw2; protected static ReplicationAdmin admin; + private static Admin hbaseAdmin; protected static Table htable1; protected static Table htable2; @@ -133,7 +134,8 @@ public class TestReplicationBase { ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(utility2.getClusterKey()); - admin.addPeer("2", rpc, null); + hbaseAdmin = ConnectionFactory.createConnection(conf1).getAdmin(); + hbaseAdmin.addReplicationPeer("2", rpc); HTableDescriptor table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName);