Search in sources :

Example 1 with ReplicationPeerZKImpl

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

the class VerifyReplication method getPeerQuorumConfig.

private static Pair<ReplicationPeerConfig, Configuration> getPeerQuorumConfig(final Configuration conf) throws IOException {
    ZooKeeperWatcher localZKW = null;
    ReplicationPeerZKImpl peer = null;
    try {
        localZKW = new ZooKeeperWatcher(conf, "VerifyReplication", new Abortable() {

            @Override
            public void abort(String why, Throwable e) {
            }

            @Override
            public boolean isAborted() {
                return false;
            }
        });
        ReplicationPeers rp = ReplicationFactory.getReplicationPeers(localZKW, conf, localZKW);
        rp.init();
        Pair<ReplicationPeerConfig, Configuration> pair = rp.getPeerConf(peerId);
        if (pair == null) {
            throw new IOException("Couldn't get peer conf!");
        }
        return pair;
    } catch (ReplicationException e) {
        throw new IOException("An error occurred while trying to connect to the remove peer cluster", e);
    } finally {
        if (peer != null) {
            peer.close();
        }
        if (localZKW != null) {
            localZKW.close();
        }
    }
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) Abortable(org.apache.hadoop.hbase.Abortable) ReplicationPeerZKImpl(org.apache.hadoop.hbase.replication.ReplicationPeerZKImpl) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) IOException(java.io.IOException) ReplicationPeers(org.apache.hadoop.hbase.replication.ReplicationPeers)

Example 2 with ReplicationPeerZKImpl

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

the class ReplicationAdmin method listReplicationPeers.

/**
   * @deprecated use {@link org.apache.hadoop.hbase.client.Admin#listReplicationPeers()} instead
   */
@VisibleForTesting
@Deprecated
List<ReplicationPeer> listReplicationPeers() throws IOException {
    Map<String, ReplicationPeerConfig> peers = listPeerConfigs();
    if (peers == null || peers.size() <= 0) {
        return null;
    }
    List<ReplicationPeer> listOfPeers = new ArrayList<>(peers.size());
    for (Entry<String, ReplicationPeerConfig> peerEntry : peers.entrySet()) {
        String peerId = peerEntry.getKey();
        try {
            Pair<ReplicationPeerConfig, Configuration> pair = this.replicationPeers.getPeerConf(peerId);
            Configuration peerConf = pair.getSecond();
            ReplicationPeer peer = new ReplicationPeerZKImpl(zkw, pair.getSecond(), peerId, pair.getFirst(), this.connection);
            listOfPeers.add(peer);
        } catch (ReplicationException e) {
            LOG.warn("Failed to get valid replication peers. " + "Error connecting to peer cluster with peerId=" + peerId + ". Error message=" + e.getMessage());
            LOG.debug("Failure details to get valid replication peers.", e);
            continue;
        }
    }
    return listOfPeers;
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) Configuration(org.apache.hadoop.conf.Configuration) ArrayList(java.util.ArrayList) ReplicationPeerZKImpl(org.apache.hadoop.hbase.replication.ReplicationPeerZKImpl) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) ReplicationPeer(org.apache.hadoop.hbase.replication.ReplicationPeer) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)2 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)2 ReplicationPeerConfig (org.apache.hadoop.hbase.replication.ReplicationPeerConfig)2 ReplicationPeerZKImpl (org.apache.hadoop.hbase.replication.ReplicationPeerZKImpl)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Abortable (org.apache.hadoop.hbase.Abortable)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 ReplicationPeer (org.apache.hadoop.hbase.replication.ReplicationPeer)1 ReplicationPeers (org.apache.hadoop.hbase.replication.ReplicationPeers)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1