@InterfaceAudience.Private public class TableBasedReplicationQueuesImpl extends Object implements ReplicationQueues
| Modifier and Type | Field and Description |
|---|---|
protected Abortable |
abortable |
static byte[] |
CF_QUEUE |
static byte[] |
COL_QUEUE_OWNER |
static byte[] |
COL_QUEUE_OWNER_HISTORY |
protected org.apache.hadoop.conf.Configuration |
conf |
static String |
QUEUE_HISTORY_DELIMITER |
static TableName |
REPLICATION_TABLE_NAME
Name of the HBase Table used for tracking replication
|
static String |
ROW_KEY_DELIMITER |
| Constructor and Description |
|---|
TableBasedReplicationQueuesImpl(org.apache.hadoop.conf.Configuration conf,
Abortable abort,
ZooKeeperWatcher zkw) |
TableBasedReplicationQueuesImpl(ReplicationQueuesArguments args) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHFileRefs(String peerId,
List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs)
Add new hfile references to the queue.
|
void |
addLog(String queueId,
String filename)
Add a new WAL file to the given queue.
|
void |
addPeerToHFileRefs(String peerId)
Add a peer to hfile reference queue if peer does not exist.
|
protected String |
buildClaimedQueueHistory(String originalHistory,
String oldServer)
Creates a "|" delimited record of the queue's past region server owners.
|
protected String |
buildQueueRowKey(String serverName,
String queueId)
Build the row key for the given queueId.
|
Pair<String,SortedSet<String>> |
claimQueue(String regionserver,
String queueId)
Take ownership for the queue identified by queueId and belongs to a dead region server.
|
List<String> |
getAllQueues()
Get a list of all queues for this region server.
|
protected List<String> |
getAllQueues(String serverName) |
boolean |
getInitializationStatus()
Get whether the Replication Table has been successfully initialized yet
|
List<String> |
getListOfReplicators()
Get a list of all region servers that have outstanding replication queues.
|
long |
getLogPosition(String queueId,
String filename)
Get the current position for a specific WAL in a given queue.
|
protected List<String> |
getLogsInQueue(byte[] rowKey) |
List<String> |
getLogsInQueue(String queueId)
Get a list of all WALs in the given queue.
|
protected List<String> |
getLogsInQueue(String serverName,
String queueId) |
protected Table |
getOrBlockOnReplicationTable()
Attempts to acquire the Replication Table.
|
protected ResultScanner |
getQueuesBelongingToServer(String server)
Get the queue id's and meta data (Owner and History) for the queues belonging to the named
server
|
protected String |
getRawQueueIdFromRowKey(String rowKey)
Parse the original queueId from a row key
|
List<String> |
getUnClaimedQueueIds(String regionserver)
Get queueIds from a dead region server, whose queues has not been claimed by other region
servers.
|
void |
init(String serverName)
Initialize the region server replication queue interface.
|
boolean |
isThisOurRegionServer(String regionserver)
Checks if the provided znode is the same as this region server's
|
protected byte[] |
queueIdToRowKey(String serverName,
String queueId)
Returns a queue's row key given either its raw or reclaimed queueId
|
protected List<String> |
readWALsFromResult(Result queue)
Read all of the WAL's from a queue into a list
|
void |
removeAllQueues()
Remove all replication queues for this region server.
|
void |
removeHFileRefs(String peerId,
List<String> files)
Remove hfile references from the queue.
|
void |
removeLog(String queueId,
String filename)
Remove an WAL file from the given queue.
|
void |
removePeerFromHFileRefs(String peerId)
Remove a peer from hfile reference queue.
|
void |
removeQueue(String queueId)
Remove a replication queue.
|
void |
removeReplicatorIfQueueIsEmpty(String regionserver)
Remove the znode of region server if the queue is empty.
|
void |
setLogPosition(String queueId,
String filename,
long position)
Set the current position for a specific WAL in a given queue.
|
public static final TableName REPLICATION_TABLE_NAME
public static final byte[] CF_QUEUE
public static final byte[] COL_QUEUE_OWNER
public static final byte[] COL_QUEUE_OWNER_HISTORY
public static final String ROW_KEY_DELIMITER
public static final String QUEUE_HISTORY_DELIMITER
protected final org.apache.hadoop.conf.Configuration conf
protected final Abortable abortable
public TableBasedReplicationQueuesImpl(ReplicationQueuesArguments args) throws IOException
IOExceptionpublic TableBasedReplicationQueuesImpl(org.apache.hadoop.conf.Configuration conf,
Abortable abort,
ZooKeeperWatcher zkw)
throws IOException
IOExceptionpublic void init(String serverName) throws ReplicationException
ReplicationQueuesinit in interface ReplicationQueuesserverName - The server name of the region server that owns the replication queues this
interface manages.ReplicationExceptionpublic List<String> getListOfReplicators()
getListOfReplicators in interface ReplicationQueuespublic void removeQueue(String queueId)
ReplicationQueuesremoveQueue in interface ReplicationQueuesqueueId - a String that identifies the queue.public void addLog(String queueId, String filename) throws ReplicationException
ReplicationQueuesaddLog in interface ReplicationQueuesqueueId - a String that identifies the queue.filename - name of the WALReplicationExceptionpublic void removeLog(String queueId, String filename)
ReplicationQueuesremoveLog in interface ReplicationQueuesqueueId - a String that identifies the queue.filename - name of the WALpublic void setLogPosition(String queueId, String filename, long position)
ReplicationQueuessetLogPosition in interface ReplicationQueuesqueueId - a String that identifies the queuefilename - name of the WALposition - the current position in the filepublic long getLogPosition(String queueId, String filename) throws ReplicationException
ReplicationQueuesgetLogPosition in interface ReplicationQueuesqueueId - a String that identifies the queuefilename - name of the WALReplicationExceptionpublic void removeAllQueues()
ReplicationQueuesremoveAllQueues in interface ReplicationQueuespublic List<String> getLogsInQueue(String queueId)
ReplicationQueuesgetLogsInQueue in interface ReplicationQueuesqueueId - a String that identifies the queuepublic List<String> getAllQueues()
ReplicationQueuesgetAllQueues in interface ReplicationQueuespublic List<String> getUnClaimedQueueIds(String regionserver)
ReplicationQueuesgetUnClaimedQueueIds in interface ReplicationQueuespublic void removeReplicatorIfQueueIsEmpty(String regionserver)
ReplicationQueuesremoveReplicatorIfQueueIsEmpty in interface ReplicationQueuespublic Pair<String,SortedSet<String>> claimQueue(String regionserver, String queueId)
ReplicationQueuesclaimQueue in interface ReplicationQueuesregionserver - the id of the dead region serverqueueId - the id of the queuepublic boolean isThisOurRegionServer(String regionserver)
ReplicationQueuesisThisOurRegionServer in interface ReplicationQueuesregionserver - the id of the region serverpublic void addPeerToHFileRefs(String peerId) throws ReplicationException
ReplicationQueuesaddPeerToHFileRefs in interface ReplicationQueuespeerId - peer cluster id to be addedReplicationException - if fails to add a peer id to hfile reference queuepublic void removePeerFromHFileRefs(String peerId)
ReplicationQueuesremovePeerFromHFileRefs in interface ReplicationQueuespeerId - peer cluster id to be removedpublic void addHFileRefs(String peerId, List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) throws ReplicationException
ReplicationQueuesaddHFileRefs in interface ReplicationQueuespeerId - peer cluster id to which the hfiles need to be replicatedpairs - list of pairs of { HFile location in staging dir, HFile path in region dir which
will be added in the queue }ReplicationException - if fails to add a hfile referencepublic void removeHFileRefs(String peerId, List<String> files)
ReplicationQueuesremoveHFileRefs in interface ReplicationQueuespeerId - peer cluster id from which this hfile references needs to be removedfiles - list of hfile references to be removedpublic boolean getInitializationStatus()
protected String buildQueueRowKey(String serverName, String queueId)
serverName - The owner of the queuequeueId - String identifier of the queueprotected String getRawQueueIdFromRowKey(String rowKey)
rowKey - String representation of a queue's row keyprotected byte[] queueIdToRowKey(String serverName, String queueId)
queueId - queueId of the queueprotected String buildClaimedQueueHistory(String originalHistory, String oldServer)
originalHistory - the queue's original owner historyoldServer - the name of the server that used to own the queueprotected List<String> readWALsFromResult(Result queue)
queue - HBase query result containing the queueprotected ResultScanner getQueuesBelongingToServer(String server) throws IOException
server - name of the serverIOExceptionprotected Table getOrBlockOnReplicationTable() throws IOException
IOExceptionCopyright © 2007–2017 The Apache Software Foundation. All rights reserved.