@InterfaceAudience.Private public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements ReplicationPeers
Modifier and Type | Field and Description |
---|---|
private Abortable |
abortable |
private static org.slf4j.Logger |
LOG |
private Map<String,ReplicationPeerZKImpl> |
peerClusters |
private ReplicationQueuesClient |
queuesClient |
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(ZKWatcher zk,
org.apache.hadoop.conf.Configuration conf,
ReplicationQueuesClient queuesClient,
Abortable abortable) |
Modifier and Type | Method and Description |
---|---|
private void |
addExistingPeers()
A private method used during initialization.
|
private void |
changePeerState(String id,
org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.ReplicationState.State state)
Update the state znode of a peer cluster.
|
private void |
checkQueuesDeleted(String peerId) |
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 |
getConnectedPeer(String peerId)
Returns the ReplicationPeer for the specified connected peer.
|
Set<String> |
getConnectedPeerIds()
Returns the set of peerIds of the clusters that have been connected and have an underlying
ReplicationPeer.
|
Pair<ReplicationPeerConfig,org.apache.hadoop.conf.Configuration> |
getPeerConf(String peerId)
Returns the configuration needed to talk to the remote slave cluster.
|
Map<TableName,List<String>> |
getPeerTableCFsConfig(String id)
Get the table and column-family list string of the peer from the underlying storage.
|
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.
|
void |
init()
Initialize the ReplicationPeers interface.
|
private boolean |
isStringEquals(String s1,
String s2)
For replication peer cluster key or endpoint class, null and empty string is same.
|
boolean |
peerConnected(String peerId)
Method called after a peer has been connected.
|
void |
peerDisconnected(String peerId)
Method called after a peer has been disconnected.
|
void |
registerPeer(String id,
ReplicationPeerConfig peerConfig,
boolean enabled)
Add a new remote slave cluster for replication.
|
void |
setPeerTableCFsConfig(String id,
Map<TableName,? extends Collection<String>> tableCFs)
Set the table and column-family list string of the peer to the underlying storage.
|
void |
unregisterPeer(String id)
Removes a remote slave cluster and stops the replication to it.
|
void |
updatePeerConfig(String id,
ReplicationPeerConfig newConfig)
Update the peerConfig for the a given peer cluster
|
getListOfReplicatorsZK, getPeerNode, getPeerStateNode, getTableCFsNode, isPeerPath, peerExists, toByteArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
registerPeer
private Map<String,ReplicationPeerZKImpl> peerClusters
private final ReplicationQueuesClient queuesClient
private static final org.slf4j.Logger LOG
public ReplicationPeersZKImpl(ZKWatcher zk, org.apache.hadoop.conf.Configuration conf, ReplicationQueuesClient queuesClient, Abortable abortable)
public void init() throws ReplicationException
ReplicationPeers
init
in interface ReplicationPeers
ReplicationException
public void registerPeer(String id, ReplicationPeerConfig peerConfig, boolean enabled) throws ReplicationException
ReplicationPeers
registerPeer
in interface ReplicationPeers
id
- a short that identifies the clusterpeerConfig
- configuration for the replication slave clusterenabled
- peer state, true if ENABLED and false if DISABLEDReplicationException
public void unregisterPeer(String id) throws ReplicationException
ReplicationPeers
unregisterPeer
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 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 getConnectedPeer(String peerId)
ReplicationPeers
getConnectedPeer
in interface ReplicationPeers
peerId
- id for the peerpublic Set<String> getConnectedPeerIds()
ReplicationPeers
getConnectedPeerIds
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
- new config for the peer clusterReplicationException
public List<String> getAllPeerIds()
getAllPeerIds
in interface ReplicationPeers
private void addExistingPeers() throws ReplicationException
ReplicationException
public boolean peerConnected(String peerId) throws ReplicationException
ReplicationPeers
peerConnected
in interface ReplicationPeers
peerId
- a short that identifies the clusterReplicationException
public void peerDisconnected(String peerId)
ReplicationPeers
peerDisconnected
in interface ReplicationPeers
peerId
- a short that identifies the clusterpublic boolean createAndAddPeer(String peerId) throws ReplicationException
peerId
- a short that identifies the clusterReplicationException
private void changePeerState(String id, org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.ReplicationState.State state) throws ReplicationException
id
- state
- ReplicationException
private ReplicationPeerZKImpl createPeer(String peerId) throws ReplicationException
peerId
- peer's identifierReplicationException
private void checkQueuesDeleted(String peerId) throws ReplicationException
ReplicationException
private boolean isStringEquals(String s1, String s2)
StringUtils.equals(CharSequence, CharSequence)
directly.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.