org.apache.hadoop.hbase.replication
Class ReplicationQueuesZKImpl

java.lang.Object
  extended by org.apache.hadoop.hbase.replication.ReplicationStateZKBase
      extended by org.apache.hadoop.hbase.replication.ReplicationQueuesZKImpl
All Implemented Interfaces:
ReplicationQueues

@InterfaceAudience.Private
public class ReplicationQueuesZKImpl
extends ReplicationStateZKBase
implements ReplicationQueues

This class provides an implementation of the ReplicationQueues interface using Zookeeper. The base znode that this class works at is the myQueuesZnode. The myQueuesZnode contains a list of all outstanding HLog files on this region server that need to be replicated. The myQueuesZnode is the regionserver name (a concatenation of the region server’s hostname, client port and start code). For example: /hbase/replication/rs/hostname.example.org,6020,1234 Within this znode, the region server maintains a set of HLog replication queues. These queues are represented by child znodes named using there give queue id. For example: /hbase/replication/rs/hostname.example.org,6020,1234/1 /hbase/replication/rs/hostname.example.org,6020,1234/2 Each queue has one child znode for every HLog that still needs to be replicated. The value of these HLog child znodes is the latest position that has been replicated. This position is updated every time a HLog entry is replicated. For example: /hbase/replication/rs/hostname.example.org,6020,1234/1/23522342.23422 [VALUE: 254]


Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.replication.ReplicationStateZKBase
abortable, conf, DISABLED_ZNODE_BYTES, ENABLED_ZNODE_BYTES, ourClusterKey, peerStateNodeName, peersZNode, queuesZNode, replicationZNode, zookeeper
 
Constructor Summary
ReplicationQueuesZKImpl(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, Abortable abortable)
           
 
Method Summary
 void addLog(String queueId, String filename)
          Add a new HLog file to the given queue.
 SortedMap<String,SortedSet<String>> claimQueues(String regionserverZnode)
          Take ownership for the set of queues belonging to a dead region server.
 List<String> getAllQueues()
          Get a list of all queues for this region server.
 long getLogPosition(String queueId, String filename)
          Get the current position for a specific HLog in a given queue.
 List<String> getLogsInQueue(String queueId)
          Get a list of all HLogs 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
 void removeAllQueues()
          Remove all replication queues for this region server.
 void removeLog(String queueId, String filename)
          Remove an HLog 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 HLog in a given queue.
 
Methods inherited from class org.apache.hadoop.hbase.replication.ReplicationStateZKBase
getListOfReplicators, isPeerPath, peerExists, toByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hbase.replication.ReplicationQueues
getListOfReplicators
 

Constructor Detail

ReplicationQueuesZKImpl

public ReplicationQueuesZKImpl(ZooKeeperWatcher zk,
                               org.apache.hadoop.conf.Configuration conf,
                               Abortable abortable)
Method Detail

init

public void init(String serverName)
          throws ReplicationException
Description copied from interface: ReplicationQueues
Initialize the region server replication queue interface.

Specified by:
init in interface ReplicationQueues
Parameters:
serverName - The server name of the region server that owns the replication queues this interface manages.
Throws:
ReplicationException

removeQueue

public void removeQueue(String queueId)
Description copied from interface: ReplicationQueues
Remove a replication queue.

Specified by:
removeQueue in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue.

addLog

public void addLog(String queueId,
                   String filename)
            throws ReplicationException
Description copied from interface: ReplicationQueues
Add a new HLog file to the given queue. If the queue does not exist it is created.

Specified by:
addLog in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue.
filename - name of the HLog
Throws:
ReplicationException

removeLog

public void removeLog(String queueId,
                      String filename)
Description copied from interface: ReplicationQueues
Remove an HLog file from the given queue.

Specified by:
removeLog in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue.
filename - name of the HLog

setLogPosition

public void setLogPosition(String queueId,
                           String filename,
                           long position)
Description copied from interface: ReplicationQueues
Set the current position for a specific HLog in a given queue.

Specified by:
setLogPosition in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue
filename - name of the HLog
position - the current position in the file

getLogPosition

public long getLogPosition(String queueId,
                           String filename)
                    throws ReplicationException
Description copied from interface: ReplicationQueues
Get the current position for a specific HLog in a given queue.

Specified by:
getLogPosition in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue
filename - name of the HLog
Returns:
the current position in the file
Throws:
ReplicationException

isThisOurZnode

public boolean isThisOurZnode(String znode)
Description copied from interface: ReplicationQueues
Checks if the provided znode is the same as this region server's

Specified by:
isThisOurZnode in interface ReplicationQueues
Parameters:
znode - to check
Returns:
if this is this rs's znode

claimQueues

public SortedMap<String,SortedSet<String>> claimQueues(String regionserverZnode)
Description copied from interface: ReplicationQueues
Take ownership for the set of queues belonging to a dead region server.

Specified by:
claimQueues in interface ReplicationQueues
Parameters:
regionserverZnode - the id of the dead region server
Returns:
A SortedMap of the queues that have been claimed, including a SortedSet of HLogs in each queue. Returns an empty map if no queues were failed-over.

removeAllQueues

public void removeAllQueues()
Description copied from interface: ReplicationQueues
Remove all replication queues for this region server.

Specified by:
removeAllQueues in interface ReplicationQueues

getLogsInQueue

public List<String> getLogsInQueue(String queueId)
Description copied from interface: ReplicationQueues
Get a list of all HLogs in the given queue.

Specified by:
getLogsInQueue in interface ReplicationQueues
Parameters:
queueId - a String that identifies the queue
Returns:
a list of HLogs, null if this region server is dead and has no outstanding queues

getAllQueues

public List<String> getAllQueues()
Description copied from interface: ReplicationQueues
Get a list of all queues for this region server.

Specified by:
getAllQueues in interface ReplicationQueues
Returns:
a list of queueIds, null if this region server is dead and has no outstanding queues


Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.