@InterfaceAudience.Private public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements ReplicationPeers
| Modifier and Type | Field and Description | 
|---|---|
private static org.apache.commons.logging.Log | 
LOG  | 
private Map<String,ReplicationPeerZKImpl> | 
peerClusters  | 
private String | 
tableCFsNodeName  | 
abortable, conf, DISABLED_ZNODE_BYTES, ENABLED_ZNODE_BYTES, ourClusterKey, peerStateNodeName, peersZNode, queuesZNode, replicationZNode, zookeeper| Constructor and Description | 
|---|
ReplicationPeersZKImpl(ZooKeeperWatcher zk,
                      org.apache.hadoop.conf.Configuration conf,
                      Abortable abortable)  | 
| Modifier and Type | Method and Description | 
|---|---|
private void | 
addExistingPeers()
A private method used during initialization. 
 | 
void | 
addPeer(String id,
       ReplicationPeerConfig peerConfig,
       String tableCFs)
Add a new remote slave cluster for replication. 
 | 
private void | 
changePeerState(String id,
               org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationState.State state)
Update the state znode of a peer cluster. 
 | 
private static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationPeer | 
convert(ReplicationPeerConfig peerConfig)  | 
private static ReplicationPeerConfig | 
convert(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationPeer peer)  | 
boolean | 
createAndAddPeer(String peerId)
Attempt to connect to a new remote slave cluster. 
 | 
private ReplicationPeerZKImpl | 
createPeer(String peerId)
Helper method to connect to a peer 
 | 
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 
 | 
private String | 
getPeerStateNode(String id)  | 
String | 
getPeerTableCFsConfig(String id)
Get the table and column-family list string 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. 
 | 
private String | 
getTableCFsNode(String id)  | 
void | 
init()
Initialize the ReplicationPeers interface. 
 | 
private static ReplicationPeerConfig | 
parsePeerFrom(byte[] bytes)  | 
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,
                     String tableCFsStr)
Set the table and column-family list string of the peer to ZK. 
 | 
private static byte[] | 
toByteArray(ReplicationPeerConfig peerConfig)  | 
getListOfReplicatorsZK, isPeerPath, peerExists, toByteArrayprivate Map<String,ReplicationPeerZKImpl> peerClusters
private final String tableCFsNodeName
private static final org.apache.commons.logging.Log LOG
public ReplicationPeersZKImpl(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, Abortable abortable)
public void init()
          throws ReplicationException
ReplicationPeersinit in interface ReplicationPeersReplicationExceptionpublic void addPeer(String id, ReplicationPeerConfig peerConfig, 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(String id) throws ReplicationException
ReplicationPeersremovePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void enablePeer(String id) throws ReplicationException
ReplicationPeersenablePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void disablePeer(String id) throws ReplicationException
ReplicationPeersdisablePeer in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic String getPeerTableCFsConfig(String id) throws ReplicationException
ReplicationPeersgetPeerTableCFsConfig in interface ReplicationPeersid - a short that identifies the clusterReplicationExceptionpublic void setPeerTableCFsConfig(String id, 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 Map<TableName,List<String>> getTableCFs(String id) throws IllegalArgumentException
ReplicationPeersgetTableCFs in interface ReplicationPeersid - a short that identifies the clusterIllegalArgumentExceptionpublic boolean getStatusOfPeer(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(String id) throws ReplicationException
ReplicationPeersgetStatusOfPeerFromBackingStore in interface ReplicationPeersid - a short that identifies the clusterReplicationException - thrown if there's an error contacting the storepublic Map<String,ReplicationPeerConfig> getAllPeerConfigs()
ReplicationPeersgetAllPeerConfigs in interface ReplicationPeerspublic ReplicationPeer getPeer(String peerId)
ReplicationPeersgetPeer in interface ReplicationPeerspeerId - id for the peerpublic Set<String> getPeerIds()
ReplicationPeersgetPeerIds in interface ReplicationPeerspublic ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws ReplicationException
getReplicationPeerConfig in interface ReplicationPeerspeerId - a short name that identifies the clusterReplicationExceptionpublic Pair<ReplicationPeerConfig,org.apache.hadoop.conf.Configuration> getPeerConf(String peerId) throws ReplicationException
ReplicationPeersgetPeerConf in interface ReplicationPeerspeerId - a short that identifies the clusterReplicationExceptionpublic List<String> getAllPeerIds()
getAllPeerIds in interface ReplicationPeersprivate void addExistingPeers()
                       throws ReplicationException
ReplicationExceptionpublic boolean peerAdded(String peerId) throws ReplicationException
peerAdded in interface ReplicationPeersReplicationExceptionpublic void peerRemoved(String peerId)
peerRemoved in interface ReplicationPeerspublic boolean createAndAddPeer(String peerId) throws ReplicationException
peerId - a short that identifies the clusterReplicationExceptionprivate void changePeerState(String id, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationState.State state) throws ReplicationException
id - state - ReplicationExceptionprivate ReplicationPeerZKImpl createPeer(String peerId) throws ReplicationException
peerId - peer's identifierReplicationExceptionprivate static ReplicationPeerConfig parsePeerFrom(byte[] bytes) throws DeserializationException
bytes - Content of a peer znode.DeserializationExceptionprivate static ReplicationPeerConfig convert(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationPeer peer)
private static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationPeer convert(ReplicationPeerConfig peerConfig)
private static byte[] toByteArray(ReplicationPeerConfig peerConfig)
peerConfig - peerConfig with pb magic prefix prepended suitable
         for use as content of a this.peersZNode; i.e. the content of PEER_ID znode under
         /hbase/replication/peers/PEER_IDCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.