@InterfaceAudience.Private public class ReplicationQueuesZKImpl extends ReplicationStateZKBase implements ReplicationQueues
Modifier and Type | Field and Description |
---|---|
private static org.apache.commons.logging.Log |
LOG |
private String |
myQueuesZnode
Znode containing all replication queues for this region server.
|
static String |
RS_LOCK_ZNODE
Name of znode we use to lock during failover
|
abortable, conf, DISABLED_ZNODE_BYTES, ENABLED_ZNODE_BYTES, ourClusterKey, peerStateNodeName, peersZNode, queuesZNode, replicationZNode, zookeeper
Constructor and Description |
---|
ReplicationQueuesZKImpl(ZooKeeperWatcher zk,
org.apache.hadoop.conf.Configuration conf,
Abortable abortable) |
Modifier and Type | Method and Description |
---|---|
void |
addLog(String queueId,
String filename)
Add a new WAL file to the given queue.
|
boolean |
checkLockExists(String znode) |
SortedMap<String,SortedSet<String>> |
claimQueues(String regionserverZnode)
Take ownership for the set of queues belonging to a dead region server.
|
private SortedMap<String,SortedSet<String>> |
copyQueuesFromRS(String znode)
This methods copies all the wals queues from another region server and returns them all sorted
per peer cluster (appended with the dead server's znode)
|
private SortedMap<String,SortedSet<String>> |
copyQueuesFromRSUsingMulti(String znode)
It "atomically" copies all the wals queues from another region server and returns them all
sorted per peer cluster (appended with the dead server's znode).
|
private void |
deleteAnotherRSQueues(String regionserverZnode)
Delete all the replication queues for a given region server.
|
List<String> |
getAllQueues()
Get a list of all queues for this region server.
|
List<String> |
getListOfReplicators()
Get a list of all region servers that have outstanding replication queues.
|
String |
getLockZNode(String znode) |
long |
getLogPosition(String queueId,
String filename)
Get the current position for a specific WAL in a given queue.
|
List<String> |
getLogsInQueue(String queueId)
Get a list of all WALs in the given queue.
|
void |
init(String serverName)
Initialize the region server replication queue interface.
|
boolean |
isThisOurZnode(String znode)
Checks if the provided znode is the same as this region server's
|
boolean |
lockOtherRS(String znode)
Try to set a lock in another region server's znode.
|
(package private) static byte[] |
lockToByteArray(String lockOwner) |
void |
removeAllQueues()
Remove all replication queues for this region server.
|
void |
removeLog(String queueId,
String filename)
Remove an WAL file from the given queue.
|
void |
removeQueue(String queueId)
Remove a replication queue.
|
void |
setLogPosition(String queueId,
String filename,
long position)
Set the current position for a specific WAL in a given queue.
|
getListOfReplicatorsZK, isPeerPath, peerExists, toByteArray
private String myQueuesZnode
public static final String RS_LOCK_ZNODE
private static final org.apache.commons.logging.Log LOG
public ReplicationQueuesZKImpl(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, Abortable abortable)
public void init(String serverName) throws ReplicationException
ReplicationQueues
init
in interface ReplicationQueues
serverName
- The server name of the region server that owns the replication queues this
interface manages.ReplicationException
public List<String> getListOfReplicators() throws ReplicationException
ReplicationQueues
getListOfReplicators
in interface ReplicationQueues
ReplicationException
public void removeQueue(String queueId)
ReplicationQueues
removeQueue
in interface ReplicationQueues
queueId
- a String that identifies the queue.public void addLog(String queueId, String filename) throws ReplicationException
ReplicationQueues
addLog
in interface ReplicationQueues
queueId
- a String that identifies the queue.filename
- name of the WALReplicationException
public void removeLog(String queueId, String filename)
ReplicationQueues
removeLog
in interface ReplicationQueues
queueId
- a String that identifies the queue.filename
- name of the WALpublic void setLogPosition(String queueId, String filename, long position)
ReplicationQueues
setLogPosition
in interface ReplicationQueues
queueId
- a String that identifies the queuefilename
- name of the WALposition
- the current position in the filepublic long getLogPosition(String queueId, String filename) throws ReplicationException
ReplicationQueues
getLogPosition
in interface ReplicationQueues
queueId
- a String that identifies the queuefilename
- name of the WALReplicationException
public boolean isThisOurZnode(String znode)
ReplicationQueues
isThisOurZnode
in interface ReplicationQueues
znode
- to checkpublic SortedMap<String,SortedSet<String>> claimQueues(String regionserverZnode)
ReplicationQueues
claimQueues
in interface ReplicationQueues
regionserverZnode
- the id of the dead region serverpublic void removeAllQueues()
ReplicationQueues
removeAllQueues
in interface ReplicationQueues
public List<String> getLogsInQueue(String queueId)
ReplicationQueues
getLogsInQueue
in interface ReplicationQueues
queueId
- a String that identifies the queuepublic List<String> getAllQueues()
ReplicationQueues
getAllQueues
in interface ReplicationQueues
public boolean lockOtherRS(String znode)
znode
- the server names of the other serverpublic boolean checkLockExists(String znode) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
private void deleteAnotherRSQueues(String regionserverZnode)
regionserverZnode
- The znode of the region server to delete.private SortedMap<String,SortedSet<String>> copyQueuesFromRSUsingMulti(String znode)
znode
- pertaining to the region server to copy the queues fromprivate SortedMap<String,SortedSet<String>> copyQueuesFromRS(String znode)
znode
- server names to copystatic byte[] lockToByteArray(String lockOwner)
lockOwner
- lockOwner
with pb magic prefix prepended suitable
for use as content of an replication lock during region server fail over.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.