@InterfaceAudience.Private public class ZKReplicationPeerStorage extends ZKReplicationStorageBase implements ReplicationPeerStorage
Modifier and Type | Field and Description |
---|---|
static byte[] |
DISABLED_ZNODE_BYTES |
static byte[] |
ENABLED_ZNODE_BYTES |
static String |
NEW_SYNC_REPLICATION_STATE_ZNODE |
static byte[] |
NONE_STATE_ZNODE_BYTES |
static String |
PEERS_STATE_ZNODE |
static String |
PEERS_STATE_ZNODE_DEFAULT |
static String |
PEERS_ZNODE |
static String |
PEERS_ZNODE_DEFAULT |
private String |
peerStateNodeName
The name of the znode that contains the replication status of a remote slave (i.e.
|
private String |
peersZNode
The name of the znode that contains a list of all remote slave (i.e.
|
static String |
SYNC_REPLICATION_STATE_ZNODE |
conf, REPLICATION_ZNODE, REPLICATION_ZNODE_DEFAULT, replicationZNode, zookeeper
Constructor and Description |
---|
ZKReplicationPeerStorage(ZKWatcher zookeeper,
org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
void |
addPeer(String peerId,
ReplicationPeerConfig peerConfig,
boolean enabled,
SyncReplicationState syncReplicationState)
Add a replication peer.
|
String |
getNewSyncReplicationStateNode(String peerId) |
ReplicationPeerConfig |
getPeerConfig(String peerId)
Get the peer config of a replication peer.
|
SyncReplicationState |
getPeerNewSyncReplicationState(String peerId)
Get the new sync replication state.
|
String |
getPeerNode(String peerId) |
String |
getPeerStateNode(String peerId) |
SyncReplicationState |
getPeerSyncReplicationState(String peerId)
Get the sync replication state.
|
private SyncReplicationState |
getSyncReplicationState(String peerId,
String path) |
String |
getSyncReplicationStateNode(String peerId) |
boolean |
isPeerEnabled(String peerId)
Test whether a replication peer is enabled.
|
List<String> |
listPeerIds()
Return the peer ids of all replication peers.
|
void |
removePeer(String peerId)
Remove a replication peer.
|
void |
setPeerNewSyncReplicationState(String peerId,
SyncReplicationState state)
Set the new sync replication state that we are going to transit to.
|
void |
setPeerState(String peerId,
boolean enabled)
Set the state of peer,
true to ENABLED , otherwise to DISABLED . |
void |
transitPeerSyncReplicationState(String peerId)
Overwrite the sync replication state with the new sync replication state which is set with the
ReplicationPeerStorage.setPeerNewSyncReplicationState(String, SyncReplicationState) method above, and clear
the new sync replication state. |
void |
updatePeerConfig(String peerId,
ReplicationPeerConfig peerConfig)
Update the config a replication peer.
|
toByteArray
public static final String PEERS_ZNODE
public static final String PEERS_ZNODE_DEFAULT
public static final String PEERS_STATE_ZNODE
public static final String PEERS_STATE_ZNODE_DEFAULT
public static final byte[] ENABLED_ZNODE_BYTES
public static final byte[] DISABLED_ZNODE_BYTES
public static final String SYNC_REPLICATION_STATE_ZNODE
public static final String NEW_SYNC_REPLICATION_STATE_ZNODE
public static final byte[] NONE_STATE_ZNODE_BYTES
private final String peerStateNodeName
private final String peersZNode
public ZKReplicationPeerStorage(ZKWatcher zookeeper, org.apache.hadoop.conf.Configuration conf)
public String getPeerStateNode(String peerId)
public String getPeerNode(String peerId)
public String getSyncReplicationStateNode(String peerId)
public String getNewSyncReplicationStateNode(String peerId)
public void addPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled, SyncReplicationState syncReplicationState) throws ReplicationException
ReplicationPeerStorage
addPeer
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public void removePeer(String peerId) throws ReplicationException
ReplicationPeerStorage
removePeer
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public void setPeerState(String peerId, boolean enabled) throws ReplicationException
ReplicationPeerStorage
true
to ENABLED
, otherwise to DISABLED
.setPeerState
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig) throws ReplicationException
ReplicationPeerStorage
updatePeerConfig
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public List<String> listPeerIds() throws ReplicationException
ReplicationPeerStorage
listPeerIds
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public boolean isPeerEnabled(String peerId) throws ReplicationException
ReplicationPeerStorage
isPeerEnabled
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public ReplicationPeerConfig getPeerConfig(String peerId) throws ReplicationException
ReplicationPeerStorage
getPeerConfig
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state) throws ReplicationException
ReplicationPeerStorage
setPeerNewSyncReplicationState
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public void transitPeerSyncReplicationState(String peerId) throws ReplicationException
ReplicationPeerStorage
ReplicationPeerStorage.setPeerNewSyncReplicationState(String, SyncReplicationState)
method above, and clear
the new sync replication state.transitPeerSyncReplicationState
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.private SyncReplicationState getSyncReplicationState(String peerId, String path) throws ReplicationException
ReplicationException
public SyncReplicationState getPeerNewSyncReplicationState(String peerId) throws ReplicationException
ReplicationPeerStorage
SyncReplicationState.NONE
if we are not
in a transition.getPeerNewSyncReplicationState
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.public SyncReplicationState getPeerSyncReplicationState(String peerId) throws ReplicationException
ReplicationPeerStorage
getPeerSyncReplicationState
in interface ReplicationPeerStorage
ReplicationException
- if there are errors accessing the storage service.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.