|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.replication.ReplicationStateZKBase
org.apache.hadoop.hbase.replication.ReplicationZookeeper
@InterfaceAudience.Private 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}
peer-state {contains ENABLED or DISABLED}
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/
...
| Field Summary | |
|---|---|
static byte[] |
ENABLED_ZNODE_BYTES
ZNode content if enabled state. |
| Fields inherited from class org.apache.hadoop.hbase.replication.ReplicationStateZKBase |
|---|
queuesZNode, stateZNode |
| 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,
AtomicBoolean replicating)
Constructor used by region servers, connects to the peer cluster right away. |
|
| Method Summary | |
|---|---|
void |
addLogToList(String filename,
String peerId)
Add a new log to the list of hlogs in zookeeper |
void |
addPeer(String id,
String clusterKey)
Add a new peer to this cluster |
SortedMap<String,SortedSet<String>> |
claimQueues(String regionserver)
Take ownership for the set of queues belonging to a dead region server. |
void |
close()
|
boolean |
connectToPeer(String peerId)
This method connects this cluster to another one and registers it in this region server's replication znode |
void |
deleteOwnRSZNode()
Delete this cluster's queues |
void |
deleteSource(String peerZnode,
boolean closeConnection)
Delete a complete queue of hlogs |
void |
disablePeer(String id)
Disable replication to the peer |
void |
enablePeer(String id)
Enable replication to the peer |
long |
getHLogRepPosition(String peerId,
String hlog)
Get the position of the specified hlog in the specified peer znode |
ReplicationPeer |
getPeer(String peerId)
Helper method to connect to a peer |
Map<String,ReplicationPeer> |
getPeerClusters()
Get a map of all peer clusters |
boolean |
getPeerEnabled(String id)
Check whether the peer is enabled or not. |
String |
getPeersZNode()
Get the full path to the peers' znode |
UUID |
getPeerUUID(String peerId)
Returns the UUID of the provided peer id. |
List<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. |
List<ServerName> |
getSlavesAddresses(String peerClusterId)
Returns all region servers from given peer |
UUID |
getUUIDForCluster(ZooKeeperWatcher zkw)
Get the UUID for the provided ZK watcher. |
static String |
getZNodeName(String fullPath)
Extracts the znode name of a peer cluster from a ZK path |
ZooKeeperWatcher |
getZookeeperWatcher()
Get this cluster's zk connection |
boolean |
isPeerPath(String path)
Determine if a ZK path points to a peer node. |
static List<ServerName> |
listChildrenAndGetAsServerNames(ZooKeeperWatcher zkw,
String znode)
Lists the children of the specified znode, retrieving the data of each child as a server address. |
Map<String,String> |
listPeers()
Map of this cluster's peers for display. |
List<String> |
listPeersIdsAndWatch()
List this cluster's peers' IDs |
static long |
parseHLogPositionFrom(byte[] bytes)
|
static byte[] |
positionToByteArray(long position)
|
void |
registerRegionServerListener(ZooKeeperListener listener)
|
void |
removeLogFromList(String filename,
String clusterId)
Remove a log from the list of hlogs in zookeeper |
void |
removePeer(String id)
Remove the peer from zookeeper. |
void |
setReplication(boolean newState)
Set the new replication state for this cluster |
void |
writeReplicationStatus(String filename,
String clusterId,
long position)
Set the current position of the specified cluster in the current hlog |
| Methods inherited from class org.apache.hadoop.hbase.replication.ReplicationStateZKBase |
|---|
getListOfReplicators, peerExists |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte[] ENABLED_ZNODE_BYTES
| 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
IOException
org.apache.zookeeper.KeeperException
public ReplicationZookeeper(Server server,
AtomicBoolean replicating)
throws IOException,
org.apache.zookeeper.KeeperException
server - replicating - atomic boolean to start/stop replication
IOException
org.apache.zookeeper.KeeperException| Method Detail |
|---|
public List<String> listPeersIdsAndWatch()
public Map<String,String> listPeers()
public List<ServerName> getSlavesAddresses(String peerClusterId)
peerClusterId - (byte) the cluster to interrogate
public static List<ServerName> listChildrenAndGetAsServerNames(ZooKeeperWatcher zkw,
String znode)
throws org.apache.zookeeper.KeeperException
zkw - zookeeper referenceznode - node to get children of as addresses
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
public boolean connectToPeer(String peerId)
throws IOException,
org.apache.zookeeper.KeeperException
peerId - id of the peer cluster
org.apache.zookeeper.KeeperException
IOException
public ReplicationPeer getPeer(String peerId)
throws IOException,
org.apache.zookeeper.KeeperException
peerId - peer's identifier
IOException
org.apache.zookeeper.KeeperException
public void removePeer(String id)
throws IOException
id -
IllegalArgumentException - Thrown when the peer doesn't exist
IOException
public void addPeer(String id,
String clusterKey)
throws IOException
id - peer's identifierclusterKey - ZK ensemble's addresses, client port and root znode
IllegalArgumentException - Thrown when the peer doesn't exist
IllegalStateException - Thrown when a peer already exists, since
multi-slave isn't supported yet.
IOExceptionpublic static byte[] positionToByteArray(long position)
position -
position with pb magic prefix
prepended suitable for use as content of an hlog position in a
replication queue.
public static long parseHLogPositionFrom(byte[] bytes)
throws DeserializationException
bytes - - Content of a HLog position znode.
DeserializationException
public void enablePeer(String id)
throws IOException
id - peer's identifier
IllegalArgumentException - Thrown when the peer doesn't exist
IOException
public void disablePeer(String id)
throws IOException
id - peer's identifier
IllegalArgumentException - Thrown when the peer doesn't exist
IOExceptionpublic boolean getPeerEnabled(String id)
id - peer identifier
IllegalArgumentException - Thrown when the peer doesn't exist
public boolean getReplication()
throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public void setReplication(boolean newState)
throws org.apache.zookeeper.KeeperException
newState -
org.apache.zookeeper.KeeperException
public void addLogToList(String filename,
String peerId)
throws org.apache.zookeeper.KeeperException
filename - name of the hlog's znodepeerId - name of the cluster's znode
org.apache.zookeeper.KeeperException
public void removeLogFromList(String filename,
String clusterId)
filename - name of the hlog's znodeclusterId - name of the cluster's znode
public void writeReplicationStatus(String filename,
String clusterId,
long position)
filename - filename name of the hlog's znodeclusterId - clusterId name of the cluster's znodeposition - the position in the filepublic List<String> getRegisteredRegionServers()
public SortedMap<String,SortedSet<String>> claimQueues(String regionserver)
regionserver - the id of the dead region server
public void deleteSource(String peerZnode,
boolean closeConnection)
peerZnode - znode of the peer cluster queue of hlogs to deletepublic void deleteOwnRSZNode()
public long getHLogRepPosition(String peerId,
String hlog)
throws org.apache.zookeeper.KeeperException
peerId - znode of the peer clusterhlog - name of the hlog
org.apache.zookeeper.KeeperExceptionpublic UUID getPeerUUID(String peerId)
peerId - the peer's ID that will be converted into a UUID
public UUID getUUIDForCluster(ZooKeeperWatcher zkw)
throws org.apache.zookeeper.KeeperException
zkw - watcher connected to an ensemble
org.apache.zookeeper.KeeperExceptionpublic void registerRegionServerListener(ZooKeeperListener listener)
public Map<String,ReplicationPeer> getPeerClusters()
public boolean isPeerPath(String path)
path - path to be checked
public static String getZNodeName(String fullPath)
fullPath - Path to extract the id from
public ZooKeeperWatcher getZookeeperWatcher()
public String getPeersZNode()
public void close()
throws IOException
close in interface CloseableIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||