|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.replication.ReplicationZookeeper
public class ReplicationZookeeper
This class serves as a helper for all things related to zookeeper in replication.
The layout looks something like this under zookeeper.znode.parent for the master cluster:
replication/
state {contains true or false}
clusterId {contains a byte}
peers/
1/ {contains a full cluster address}
2/
...
rs/ {lists all RS that replicate}
startcode1/ {lists all peer clusters}
1/ {lists hlogs to process}
10.10.1.76%3A53488.123456789 {contains nothing or a position}
10.10.1.76%3A53488.123456790
...
2/
...
startcode2/
...
| Nested Class Summary | |
|---|---|
class |
ReplicationZookeeper.ReplicationStatusTracker
Tracker for status of the replication |
| Constructor Summary | |
|---|---|
ReplicationZookeeper(Abortable abortable,
org.apache.hadoop.conf.Configuration conf,
ZooKeeperWatcher zk)
Constructor used by clients of replication (like master and HBase clients) |
|
ReplicationZookeeper(Server server,
java.util.concurrent.atomic.AtomicBoolean replicating)
Constructor used by region servers, connects to the peer cluster right away. |
|
| Method Summary | |
|---|---|
void |
addLogToList(java.lang.String filename,
java.lang.String clusterId)
Add a new log to the list of hlogs in zookeeper |
void |
addPeer(java.lang.String id,
java.lang.String clusterKey)
Add a new peer to this cluster |
boolean |
connectToPeer(java.lang.String peerId)
This method connects this cluster to another one and registers it in this region server's replication znode |
java.util.SortedMap<java.lang.String,java.util.SortedSet<java.lang.String>> |
copyQueuesFromRS(java.lang.String znode)
This methods copies all the hlogs queues from another region server and returns them all sorted per peer cluster (appended with the dead server's znode) |
void |
deleteOwnRSZNode()
Delete this cluster's queues |
void |
deleteRsQueues(java.lang.String znode)
Recursive deletion of all znodes in specified rs' znode |
void |
deleteSource(java.lang.String peerZnode,
boolean closeConnection)
Delete a complete queue of hlogs |
java.lang.String |
getClusterId()
Get the identification of the cluster |
long |
getHLogRepPosition(java.lang.String peerId,
java.lang.String hlog)
Get the position of the specified hlog in the specified peer znode |
java.util.List<java.lang.String> |
getListHLogsForPeerForRS(java.lang.String rs,
java.lang.String id)
Get the list of hlogs for the specified region server and peer cluster |
java.util.List<java.lang.String> |
getListOfReplicators()
Get the list of the replicators that have queues, they can be alive, dead or simply from a previous run |
java.util.List<java.lang.String> |
getListPeersForRS(java.lang.String rs)
Get the list of peer clusters for the specified server names |
ReplicationPeer |
getPeer(java.lang.String peerId)
Helper method to connect to a peer |
java.util.Map<java.lang.String,ReplicationPeer> |
getPeerClusters()
Get a map of all peer clusters |
java.lang.String |
getPeersZNode()
Get the full path to the peers' znode |
java.util.List<java.lang.String> |
getRegisteredRegionServers()
Get a list of all the other region servers in this cluster and set a watch |
boolean |
getReplication()
Get the replication status of this cluster. |
java.util.List<HServerAddress> |
getSlavesAddresses(java.lang.String peerClusterId)
Returns all region servers from given peer |
static java.lang.String |
getZNodeName(java.lang.String fullPath)
Extracts the znode name of a peer cluster from a ZK path |
ZooKeeperWatcher |
getZookeeperWatcher()
Get this cluster's zk connection |
java.util.List<java.lang.String> |
listPeersIdsAndWatch()
List this cluster's peers' IDs |
boolean |
lockOtherRS(java.lang.String znode)
Try to set a lock in another server's znode. |
void |
registerRegionServerListener(ZooKeeperListener listener)
|
void |
removeLogFromList(java.lang.String filename,
java.lang.String clusterId)
Remove a log from the list of hlogs in zookeeper |
void |
removePeer(java.lang.String id)
Remove the peer from zookeeper. |
void |
setReplicating(boolean newState)
Set the new replication state for this cluster |
void |
writeReplicationStatus(java.lang.String filename,
java.lang.String clusterId,
long position)
Set the current position of the specified cluster in the current hlog |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReplicationZookeeper(Abortable abortable,
org.apache.hadoop.conf.Configuration conf,
ZooKeeperWatcher zk)
throws org.apache.zookeeper.KeeperException
conf - conf to usezk - zk connection to use
java.io.IOException
org.apache.zookeeper.KeeperException
public ReplicationZookeeper(Server server,
java.util.concurrent.atomic.AtomicBoolean replicating)
throws java.io.IOException,
org.apache.zookeeper.KeeperException
server - replicating - atomic boolean to start/stop replication
java.io.IOException
org.apache.zookeeper.KeeperException| Method Detail |
|---|
public java.util.List<java.lang.String> listPeersIdsAndWatch()
public java.util.List<HServerAddress> getSlavesAddresses(java.lang.String peerClusterId)
throws org.apache.zookeeper.KeeperException
peerClusterId - (byte) the cluster to interrogate
org.apache.zookeeper.KeeperException
public boolean connectToPeer(java.lang.String peerId)
throws java.io.IOException,
org.apache.zookeeper.KeeperException
peerId - id of the peer cluster
org.apache.zookeeper.KeeperException
java.io.IOException
public ReplicationPeer getPeer(java.lang.String peerId)
throws java.io.IOException,
org.apache.zookeeper.KeeperException
peerId - peer's identifier
java.io.IOException
org.apache.zookeeper.KeeperException
public void setReplicating(boolean newState)
throws org.apache.zookeeper.KeeperException
newState -
org.apache.zookeeper.KeeperException
public void removePeer(java.lang.String id)
throws java.io.IOException
id -
java.lang.IllegalArgumentException - Thrown when the peer doesn't exist
java.io.IOException
public void addPeer(java.lang.String id,
java.lang.String clusterKey)
throws java.io.IOException
id - peer's identifierclusterKey - ZK ensemble's addresses, client port and root znode
java.lang.IllegalArgumentException - Thrown when the peer doesn't exist
java.lang.IllegalStateException - Thrown when a peer already exists, since
multi-slave isn't supported yet.
java.io.IOException
public boolean getReplication()
throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public void addLogToList(java.lang.String filename,
java.lang.String clusterId)
filename - name of the hlog's znodeclusterId - name of the cluster's znode
public void removeLogFromList(java.lang.String filename,
java.lang.String clusterId)
filename - name of the hlog's znodeclusterId - name of the cluster's znode
public void writeReplicationStatus(java.lang.String filename,
java.lang.String clusterId,
long position)
filename - filename name of the hlog's znodeclusterId - clusterId name of the cluster's znodeposition - the position in the file
java.io.IOExceptionpublic java.util.List<java.lang.String> getRegisteredRegionServers()
public java.util.List<java.lang.String> getListOfReplicators()
public java.util.List<java.lang.String> getListPeersForRS(java.lang.String rs)
rs - server names of the rs
public java.util.List<java.lang.String> getListHLogsForPeerForRS(java.lang.String rs,
java.lang.String id)
rs - server names of the rsid - peer cluster
public boolean lockOtherRS(java.lang.String znode)
znode - the server names of the other server
public java.util.SortedMap<java.lang.String,java.util.SortedSet<java.lang.String>> copyQueuesFromRS(java.lang.String znode)
znode - server names to copy
public void deleteSource(java.lang.String peerZnode,
boolean closeConnection)
peerZnode - znode of the peer cluster queue of hlogs to deletepublic void deleteRsQueues(java.lang.String znode)
znode - public void deleteOwnRSZNode()
public long getHLogRepPosition(java.lang.String peerId,
java.lang.String hlog)
throws org.apache.zookeeper.KeeperException
peerId - znode of the peer clusterhlog - name of the hlog
org.apache.zookeeper.KeeperExceptionpublic void registerRegionServerListener(ZooKeeperListener listener)
public java.lang.String getClusterId()
public java.util.Map<java.lang.String,ReplicationPeer> getPeerClusters()
public static java.lang.String getZNodeName(java.lang.String fullPath)
fullPath - Path to extract the id from
public ZooKeeperWatcher getZookeeperWatcher()
public java.lang.String getPeersZNode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||