@InterfaceAudience.Private public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements ReplicationPeers
abortable, conf, DISABLED_ZNODE_BYTES, ENABLED_ZNODE_BYTES, hfileRefsZNode, ourClusterKey, peerStateNodeName, peersZNode, queuesZNode, replicationForBulkLoadEnabled, replicationZNode, zookeeper, ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_DEFAULT, ZOOKEEPER_ZNODE_REPLICATION_HFILE_REFS_KEY| Constructor and Description |
|---|
ReplicationPeersZKImpl(ZooKeeperWatcher zk,
Configuration conf,
Abortable abortable) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPeer(java.lang.String id,
ReplicationPeerConfig peerConfig,
java.lang.String tableCFs)
Add a new remote slave cluster for replication.
|
boolean |
createAndAddPeer(java.lang.String peerId)
Attempt to connect to a new remote slave cluster.
|
void |
disablePeer(java.lang.String id)
Stop the replication to the specified remote slave cluster.
|
void |
enablePeer(java.lang.String id)
Restart the replication to the specified remote slave cluster.
|
java.util.Map<java.lang.String,ReplicationPeerConfig> |
getAllPeerConfigs()
List the cluster replication configs of all remote slave clusters (whether they are
enabled/disabled or connected/disconnected).
|
java.util.List<java.lang.String> |
getAllPeerIds()
List all registered peer clusters and set a watch on their znodes.
|
ReplicationPeer |
getPeer(java.lang.String peerId)
Returns the ReplicationPeer
|
Pair<ReplicationPeerConfig,Configuration> |
getPeerConf(java.lang.String peerId)
Returns the configuration needed to talk to the remote slave cluster.
|
java.util.Set<java.lang.String> |
getPeerIds()
Returns the set of peerIds defined
|
java.lang.String |
getPeerTableCFsConfig(java.lang.String id)
Get the table and column-family list string of the peer from ZK.
|
ReplicationPeerConfig |
getReplicationPeerConfig(java.lang.String peerId)
Returns a ReplicationPeerConfig from the znode or null for the given peerId.
|
boolean |
getStatusOfPeer(java.lang.String id)
Get the replication status for the specified connected remote slave cluster.
|
boolean |
getStatusOfPeerFromBackingStore(java.lang.String id)
Get the replication status for the specified remote slave cluster, which doesn't
have to be connected.
|
java.util.Map<TableName,java.util.List<java.lang.String>> |
getTableCFs(java.lang.String id)
Get the table and column-family-list map of the peer.
|
void |
init()
Initialize the ReplicationPeers interface.
|
boolean |
peerAdded(java.lang.String peerId) |
void |
peerRemoved(java.lang.String peerId) |
void |
removePeer(java.lang.String id)
Removes a remote slave cluster and stops the replication to it.
|
void |
setPeerTableCFsConfig(java.lang.String id,
java.lang.String tableCFsStr)
Set the table and column-family list string of the peer to ZK.
|
getListOfReplicators, isPeerPath, peerExists, toByteArraypublic ReplicationPeersZKImpl(ZooKeeperWatcher zk, Configuration conf, Abortable abortable)
public void init()
throws ReplicationException
ReplicationPeersinit in interface ReplicationPeersReplicationExceptionpublic void addPeer(java.lang.String id,
ReplicationPeerConfig peerConfig,
java.lang.String tableCFs)
throws ReplicationException
ReplicationPeersaddPeer in interface ReplicationPeersid - a short that identifies the clusterpeerConfig - configuration for the replication slave clustertableCFs - the table and column-family list which will be replicated for this peer or null
for all table and column familiesReplicationExceptionpublic void removePeer(java.lang.String id)
throws ReplicationException
ReplicationPeersremovePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void enablePeer(java.lang.String id)
throws ReplicationException
ReplicationPeersenablePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void disablePeer(java.lang.String id)
throws ReplicationException
ReplicationPeersdisablePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic java.lang.String getPeerTableCFsConfig(java.lang.String id)
throws ReplicationException
ReplicationPeersgetPeerTableCFsConfig in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void setPeerTableCFsConfig(java.lang.String id,
java.lang.String tableCFsStr)
throws ReplicationException
ReplicationPeerssetPeerTableCFsConfig in interface ReplicationPeersid - a short that identifies the clustertableCFsStr - the table and column-family list which will be replicated for this peerReplicationExceptionpublic java.util.Map<TableName,java.util.List<java.lang.String>> getTableCFs(java.lang.String id) throws java.lang.IllegalArgumentException
ReplicationPeersgetTableCFs in interface ReplicationPeersid - a short that identifies the clusterjava.lang.IllegalArgumentExceptionpublic boolean getStatusOfPeer(java.lang.String id)
ReplicationPeersReplicationPeers.getStatusOfPeerFromBackingStore(String)
if reading the state after enabling or disabling it.getStatusOfPeer in interface ReplicationPeersid - a short that identifies the clusterpublic boolean getStatusOfPeerFromBackingStore(java.lang.String id)
throws ReplicationException
ReplicationPeersgetStatusOfPeerFromBackingStore in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic java.util.Map<java.lang.String,ReplicationPeerConfig> getAllPeerConfigs()
ReplicationPeersgetAllPeerConfigs in interface ReplicationPeerspublic ReplicationPeer getPeer(java.lang.String peerId)
ReplicationPeersgetPeer in interface ReplicationPeerspeerId - id for the peerpublic java.util.Set<java.lang.String> getPeerIds()
ReplicationPeersgetPeerIds in interface ReplicationPeerspublic ReplicationPeerConfig getReplicationPeerConfig(java.lang.String peerId) throws ReplicationException
getReplicationPeerConfig in interface ReplicationPeerspeerId - a short name that identifies the clusterReplicationExceptionpublic Pair<ReplicationPeerConfig,Configuration> getPeerConf(java.lang.String peerId) throws ReplicationException
ReplicationPeersgetPeerConf in interface ReplicationPeerspeerId - a short that identifies the clusterReplicationExceptionpublic java.util.List<java.lang.String> getAllPeerIds()
getAllPeerIds in interface ReplicationPeerspublic boolean peerAdded(java.lang.String peerId)
throws ReplicationException
peerAdded in interface ReplicationPeersReplicationExceptionpublic void peerRemoved(java.lang.String peerId)
peerRemoved in interface ReplicationPeerspublic boolean createAndAddPeer(java.lang.String peerId)
throws ReplicationException
peerId - a short that identifies the clusterReplicationException