HBASE-17790 Mark ReplicationAdmin's peerAdded and listReplicationPeers as Deprecated
This commit is contained in:
parent
53e9a1c43a
commit
6a6fff103e
|
@ -521,11 +521,16 @@ public class ReplicationAdmin implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@Deprecated
|
||||||
public void peerAdded(String id) throws ReplicationException {
|
public void peerAdded(String id) throws ReplicationException {
|
||||||
this.replicationPeers.peerConnected(id);
|
this.replicationPeers.peerConnected(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link org.apache.hadoop.hbase.client.Admin#listReplicationPeers()} instead
|
||||||
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@Deprecated
|
||||||
List<ReplicationPeer> listReplicationPeers() throws IOException {
|
List<ReplicationPeer> listReplicationPeers() throws IOException {
|
||||||
Map<String, ReplicationPeerConfig> peers = listPeerConfigs();
|
Map<String, ReplicationPeerConfig> peers = listPeerConfigs();
|
||||||
if (peers == null || peers.size() <= 0) {
|
if (peers == null || peers.size() <= 0) {
|
||||||
|
|
|
@ -33,11 +33,13 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
|
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
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.client.RetriesExhaustedException;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationException;
|
import org.apache.hadoop.hbase.replication.ReplicationException;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationFactory;
|
import org.apache.hadoop.hbase.replication.ReplicationFactory;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationPeer;
|
import org.apache.hadoop.hbase.replication.ReplicationPeer;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
|
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.ReplicationQueues;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationQueuesArguments;
|
import org.apache.hadoop.hbase.replication.ReplicationQueuesArguments;
|
||||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
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 final String KEY_SECOND = "127.0.0.1:2181:/hbase2";
|
||||||
|
|
||||||
private static ReplicationAdmin admin;
|
private static ReplicationAdmin admin;
|
||||||
|
private static Admin hbaseAdmin;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TestName name = new TestName();
|
public TestName name = new TestName();
|
||||||
|
@ -87,6 +90,7 @@ public class TestReplicationAdmin {
|
||||||
Configuration conf = TEST_UTIL.getConfiguration();
|
Configuration conf = TEST_UTIL.getConfiguration();
|
||||||
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
||||||
admin = new ReplicationAdmin(conf);
|
admin = new ReplicationAdmin(conf);
|
||||||
|
hbaseAdmin = TEST_UTIL.getAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -149,16 +153,16 @@ public class TestReplicationAdmin {
|
||||||
config.setClusterKey(KEY_ONE);
|
config.setClusterKey(KEY_ONE);
|
||||||
config.getConfiguration().put("key1", "value1");
|
config.getConfiguration().put("key1", "value1");
|
||||||
config.getConfiguration().put("key2", "value2");
|
config.getConfiguration().put("key2", "value2");
|
||||||
admin.addPeer(ID_ONE, config, null);
|
hbaseAdmin.addReplicationPeer(ID_ONE, config);
|
||||||
|
|
||||||
List<ReplicationPeer> peers = admin.listReplicationPeers();
|
List<ReplicationPeerDescription> peers = hbaseAdmin.listReplicationPeers();
|
||||||
assertEquals(1, peers.size());
|
assertEquals(1, peers.size());
|
||||||
ReplicationPeer peerOne = peers.get(0);
|
ReplicationPeerDescription peerOne = peers.get(0);
|
||||||
assertNotNull(peerOne);
|
assertNotNull(peerOne);
|
||||||
assertEquals("value1", peerOne.getConfiguration().get("key1"));
|
assertEquals("value1", peerOne.getPeerConfig().getConfiguration().get("key1"));
|
||||||
assertEquals("value2", peerOne.getConfiguration().get("key2"));
|
assertEquals("value2", peerOne.getPeerConfig().getConfiguration().get("key2"));
|
||||||
|
|
||||||
admin.removePeer(ID_ONE);
|
hbaseAdmin.removeReplicationPeer(ID_ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -403,8 +407,7 @@ public class TestReplicationAdmin {
|
||||||
|
|
||||||
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
||||||
rpc.setClusterKey(KEY_ONE);
|
rpc.setClusterKey(KEY_ONE);
|
||||||
admin.addPeer(ID_ONE, rpc);
|
hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
|
||||||
admin.peerAdded(ID_ONE);
|
|
||||||
|
|
||||||
rpc = admin.getPeerConfig(ID_ONE);
|
rpc = admin.getPeerConfig(ID_ONE);
|
||||||
Set<String> namespaces = new HashSet<>();
|
Set<String> namespaces = new HashSet<>();
|
||||||
|
@ -438,8 +441,7 @@ public class TestReplicationAdmin {
|
||||||
|
|
||||||
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
||||||
rpc.setClusterKey(KEY_ONE);
|
rpc.setClusterKey(KEY_ONE);
|
||||||
admin.addPeer(ID_ONE, rpc);
|
hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
|
||||||
admin.peerAdded(ID_ONE);
|
|
||||||
|
|
||||||
rpc = admin.getPeerConfig(ID_ONE);
|
rpc = admin.getPeerConfig(ID_ONE);
|
||||||
Set<String> namespaces = new HashSet<String>();
|
Set<String> namespaces = new HashSet<String>();
|
||||||
|
@ -482,8 +484,7 @@ public class TestReplicationAdmin {
|
||||||
public void testPeerBandwidth() throws Exception {
|
public void testPeerBandwidth() throws Exception {
|
||||||
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
||||||
rpc.setClusterKey(KEY_ONE);
|
rpc.setClusterKey(KEY_ONE);
|
||||||
admin.addPeer(ID_ONE, rpc);
|
hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
|
||||||
admin.peerAdded(ID_ONE);
|
|
||||||
|
|
||||||
rpc = admin.getPeerConfig(ID_ONE);
|
rpc = admin.getPeerConfig(ID_ONE);
|
||||||
assertEquals(0, rpc.getBandwidth());
|
assertEquals(0, rpc.getBandwidth());
|
||||||
|
|
|
@ -229,8 +229,7 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase {
|
||||||
rpc.setReplicationEndpointImpl(TestUpdatableReplicationEndpoint.class.getName());
|
rpc.setReplicationEndpointImpl(TestUpdatableReplicationEndpoint.class.getName());
|
||||||
rpc.getConfiguration().put("key1", "value1");
|
rpc.getConfiguration().put("key1", "value1");
|
||||||
|
|
||||||
admin.addPeer(peerId, rpc);
|
admin1.addReplicationPeer(peerId, rpc);
|
||||||
admin.peerAdded(peerId);
|
|
||||||
|
|
||||||
rpc.getConfiguration().put("key1", "value2");
|
rpc.getConfiguration().put("key1", "value2");
|
||||||
admin.updatePeerConfig(peerId, rpc);
|
admin.updatePeerConfig(peerId, rpc);
|
||||||
|
|
|
@ -140,7 +140,6 @@ public class TestNamespaceReplication extends TestReplicationBase {
|
||||||
Table htab1B = connection1.getTable(tabBName);
|
Table htab1B = connection1.getTable(tabBName);
|
||||||
Table htab2B = connection2.getTable(tabBName);
|
Table htab2B = connection2.getTable(tabBName);
|
||||||
|
|
||||||
admin.peerAdded("2");
|
|
||||||
// add ns1 to peer config which replicate to cluster2
|
// add ns1 to peer config which replicate to cluster2
|
||||||
ReplicationPeerConfig rpc = admin.getPeerConfig("2");
|
ReplicationPeerConfig rpc = admin.getPeerConfig("2");
|
||||||
Set<String> namespaces = new HashSet<>();
|
Set<String> namespaces = new HashSet<>();
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class TestReplicationBase {
|
||||||
protected static ZooKeeperWatcher zkw2;
|
protected static ZooKeeperWatcher zkw2;
|
||||||
|
|
||||||
protected static ReplicationAdmin admin;
|
protected static ReplicationAdmin admin;
|
||||||
|
private static Admin hbaseAdmin;
|
||||||
|
|
||||||
protected static Table htable1;
|
protected static Table htable1;
|
||||||
protected static Table htable2;
|
protected static Table htable2;
|
||||||
|
@ -133,7 +134,8 @@ public class TestReplicationBase {
|
||||||
|
|
||||||
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
|
||||||
rpc.setClusterKey(utility2.getClusterKey());
|
rpc.setClusterKey(utility2.getClusterKey());
|
||||||
admin.addPeer("2", rpc, null);
|
hbaseAdmin = ConnectionFactory.createConnection(conf1).getAdmin();
|
||||||
|
hbaseAdmin.addReplicationPeer("2", rpc);
|
||||||
|
|
||||||
HTableDescriptor table = new HTableDescriptor(tableName);
|
HTableDescriptor table = new HTableDescriptor(tableName);
|
||||||
HColumnDescriptor fam = new HColumnDescriptor(famName);
|
HColumnDescriptor fam = new HColumnDescriptor(famName);
|
||||||
|
|
Loading…
Reference in New Issue