Search in sources :

Example 21 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class TestAsyncReplicationAdminApi method testEnableDisablePeer.

@Test
public void testEnableDisablePeer() throws Exception {
    ReplicationPeerConfig rpc1 = ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE).build();
    admin.addReplicationPeer(ID_ONE, rpc1).join();
    List<ReplicationPeerDescription> peers = admin.listReplicationPeers().get();
    assertEquals(1, peers.size());
    assertTrue(peers.get(0).isEnabled());
    admin.disableReplicationPeer(ID_ONE).join();
    peers = admin.listReplicationPeers().get();
    assertEquals(1, peers.size());
    assertFalse(peers.get(0).isEnabled());
    admin.removeReplicationPeer(ID_ONE).join();
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription) Test(org.junit.Test)

Example 22 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class TestAsyncReplicationAdminApi method testPeerConfig.

@Test
public void testPeerConfig() throws Exception {
    ReplicationPeerConfig config = ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE).putConfiguration("key1", "value1").putConfiguration("key2", "value2").build();
    admin.addReplicationPeer(ID_ONE, config).join();
    List<ReplicationPeerDescription> peers = admin.listReplicationPeers().get();
    assertEquals(1, peers.size());
    ReplicationPeerDescription peerOne = peers.get(0);
    assertNotNull(peerOne);
    assertEquals("value1", peerOne.getPeerConfig().getConfiguration().get("key1"));
    assertEquals("value2", peerOne.getPeerConfig().getConfiguration().get("key2"));
    admin.removeReplicationPeer(ID_ONE).join();
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription) Test(org.junit.Test)

Example 23 with ReplicationPeerDescription

use of org.apache.hadoop.hbase.replication.ReplicationPeerDescription in project hbase by apache.

the class DumpReplicationQueues method dumpPeersState.

public String dumpPeersState(List<ReplicationPeerDescription> peers) throws Exception {
    Map<String, String> currentConf;
    StringBuilder sb = new StringBuilder();
    for (ReplicationPeerDescription peer : peers) {
        ReplicationPeerConfig peerConfig = peer.getPeerConfig();
        sb.append("Peer: " + peer.getPeerId() + "\n");
        sb.append("    " + "State: " + (peer.isEnabled() ? "ENABLED" : "DISABLED") + "\n");
        sb.append("    " + "Cluster Name: " + peerConfig.getClusterKey() + "\n");
        sb.append("    " + "Replication Endpoint: " + peerConfig.getReplicationEndpointImpl() + "\n");
        currentConf = peerConfig.getConfiguration();
        // Only show when we have a custom configuration for the peer
        if (currentConf.size() > 1) {
            sb.append("    " + "Peer Configuration: " + currentConf + "\n");
        }
        sb.append("    " + "Peer Table CFs: " + peerConfig.getTableCFsMap() + "\n");
        sb.append("    " + "Peer Namespaces: " + peerConfig.getNamespaces() + "\n");
    }
    return sb.toString();
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription)

Aggregations

ReplicationPeerDescription (org.apache.hadoop.hbase.replication.ReplicationPeerDescription)23 ReplicationPeerConfig (org.apache.hadoop.hbase.replication.ReplicationPeerConfig)13 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 Configuration (org.apache.hadoop.conf.Configuration)4 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 Collectors (java.util.stream.Collectors)3 Path (org.apache.hadoop.fs.Path)3 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)3 ServerName (org.apache.hadoop.hbase.ServerName)3 SyncReplicationState (org.apache.hadoop.hbase.replication.SyncReplicationState)3 ZKUtil (org.apache.hadoop.hbase.zookeeper.ZKUtil)3 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)3 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3