@InterfaceAudience.Private public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements ReplicationPeers
abortable, conf, DISABLED_ZNODE_BYTES, ENABLED_ZNODE_BYTES, hfileRefsZNode, ourClusterKey, peerStateNodeName, peersZNode, queuesZNode, replicationZNode, tableCFsNodeName, zookeeper, ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_DEFAULT, ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_KEY
Constructor and Description |
---|
ReplicationPeersZKImpl(ZooKeeperWatcher zk,
org.apache.hadoop.conf.Configuration conf,
ReplicationQueuesClient queuesClient,
Abortable abortable) |
Modifier and Type | Method and Description |
---|---|
void |
addPeer(String id,
ReplicationPeerConfig peerConfig)
Add a new remote slave cluster for replication.
|
boolean |
createAndAddPeer(String peerId)
Attempt to connect to a new remote slave cluster.
|
void |
disablePeer(String id)
Stop the replication to the specified remote slave cluster.
|
void |
enablePeer(String id)
Restart the replication to the specified remote slave cluster.
|
Map<String,ReplicationPeerConfig> |
getAllPeerConfigs()
List the cluster replication configs of all remote slave clusters (whether they are
enabled/disabled or connected/disconnected).
|
List<String> |
getAllPeerIds()
List all registered peer clusters and set a watch on their znodes.
|
ReplicationPeer |
getPeer(String peerId)
Returns the ReplicationPeer
|
Pair<ReplicationPeerConfig,org.apache.hadoop.conf.Configuration> |
getPeerConf(String peerId)
Returns the configuration needed to talk to the remote slave cluster.
|
Set<String> |
getPeerIds()
Returns the set of peerIds defined
|
Map<TableName,List<String>> |
getPeerTableCFsConfig(String id)
Get the table and column-family list of the peer from ZK.
|
ReplicationPeerConfig |
getReplicationPeerConfig(String peerId)
Returns a ReplicationPeerConfig from the znode or null for the given peerId.
|
boolean |
getStatusOfPeer(String id)
Get the replication status for the specified connected remote slave cluster.
|
boolean |
getStatusOfPeerFromBackingStore(String id)
Get the replication status for the specified remote slave cluster, which doesn't
have to be connected.
|
Map<TableName,List<String>> |
getTableCFs(String id)
Get the table and column-family-list map of the peer.
|
void |
init()
Initialize the ReplicationPeers interface.
|
boolean |
peerAdded(String peerId) |
void |
peerRemoved(String peerId) |
void |
removePeer(String id)
Removes a remote slave cluster and stops the replication to it.
|
void |
setPeerTableCFsConfig(String id,
Map<TableName,? extends Collection<String>> tableCFs)
Set the table and column-family list of the peer to ZK.
|
void |
updatePeerConfig(String id,
ReplicationPeerConfig newConfig)
Updates replication peer configuration and/or peer data
|
getListOfReplicatorsZK, getPeerNode, getPeerStateNode, getTableCFsNode, isPeerPath, peerExists, toByteArray
public ReplicationPeersZKImpl(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, ReplicationQueuesClient queuesClient, Abortable abortable)
public void init() throws ReplicationException
ReplicationPeers
init
in interface ReplicationPeers
ReplicationException
public void addPeer(String id, ReplicationPeerConfig peerConfig) throws ReplicationException
ReplicationPeers
addPeer
in interface ReplicationPeers
id
- a short that identifies the clusterpeerConfig
- configuration for the replication slave clusterReplicationException
public void removePeer(String id) throws ReplicationException
ReplicationPeers
removePeer
in interface ReplicationPeers
id
- a short that identifies the clusterReplicationException
public void enablePeer(String id) throws ReplicationException
ReplicationPeers
enablePeer
in interface ReplicationPeers
id
- a short that identifies the clusterReplicationException
public void disablePeer(String id) throws ReplicationException
ReplicationPeers
disablePeer
in interface ReplicationPeers
id
- a short that identifies the clusterReplicationException
public Map<TableName,List<String>> getPeerTableCFsConfig(String id) throws ReplicationException
ReplicationPeers
getPeerTableCFsConfig
in interface ReplicationPeers
id
- a short that identifies the clusterReplicationException
public void setPeerTableCFsConfig(String id, Map<TableName,? extends Collection<String>> tableCFs) throws ReplicationException
ReplicationPeers
setPeerTableCFsConfig
in interface ReplicationPeers
id
- a short that identifies the clustertableCFs
- the table and column-family list which will be replicated for this peerReplicationException
public Map<TableName,List<String>> getTableCFs(String id) throws IllegalArgumentException
ReplicationPeers
getTableCFs
in interface ReplicationPeers
id
- a short that identifies the clusterIllegalArgumentException
public boolean getStatusOfPeer(String id)
ReplicationPeers
ReplicationPeers.getStatusOfPeerFromBackingStore(String)
if reading the state after enabling or disabling it.getStatusOfPeer
in interface ReplicationPeers
id
- a short that identifies the clusterpublic boolean getStatusOfPeerFromBackingStore(String id) throws ReplicationException
ReplicationPeers
getStatusOfPeerFromBackingStore
in interface ReplicationPeers
id
- a short that identifies the clusterReplicationException
- thrown if there's an error contacting the storepublic Map<String,ReplicationPeerConfig> getAllPeerConfigs()
ReplicationPeers
getAllPeerConfigs
in interface ReplicationPeers
public ReplicationPeer getPeer(String peerId)
ReplicationPeers
getPeer
in interface ReplicationPeers
peerId
- id for the peerpublic Set<String> getPeerIds()
ReplicationPeers
getPeerIds
in interface ReplicationPeers
public ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws ReplicationException
getReplicationPeerConfig
in interface ReplicationPeers
peerId
- a short name that identifies the clusterReplicationException
public Pair<ReplicationPeerConfig,org.apache.hadoop.conf.Configuration> getPeerConf(String peerId) throws ReplicationException
ReplicationPeers
getPeerConf
in interface ReplicationPeers
peerId
- a short that identifies the clusterReplicationException
public void updatePeerConfig(String id, ReplicationPeerConfig newConfig) throws ReplicationException
ReplicationPeers
updatePeerConfig
in interface ReplicationPeers
id
- a short that identifies the clusternewConfig
- configuration for the replication slave clusterReplicationException
public List<String> getAllPeerIds()
getAllPeerIds
in interface ReplicationPeers
public boolean peerAdded(String peerId) throws ReplicationException
peerAdded
in interface ReplicationPeers
ReplicationException
public void peerRemoved(String peerId)
peerRemoved
in interface ReplicationPeers
public boolean createAndAddPeer(String peerId) throws ReplicationException
peerId
- a short that identifies the clusterReplicationException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.