@InterfaceAudience.Private public class ReplicationPeerZKImpl extends Object implements ReplicationPeer, Abortable, Closeable
Modifier and Type | Class and Description |
---|---|
class |
ReplicationPeerZKImpl.PeerStateTracker
Tracker for state of this peer
|
class |
ReplicationPeerZKImpl.TableCFsTracker
Tracker for (table, cf-list) map of this peer
|
ReplicationPeer.PeerState
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private String |
id |
private static org.apache.commons.logging.Log |
LOG |
private ReplicationPeerConfig |
peerConfig |
private ReplicationPeer.PeerState |
peerState |
private ReplicationPeerZKImpl.PeerStateTracker |
peerStateTracker |
private Map<TableName,List<String>> |
tableCFs |
private ReplicationPeerZKImpl.TableCFsTracker |
tableCFsTracker |
Constructor and Description |
---|
ReplicationPeerZKImpl(org.apache.hadoop.conf.Configuration conf,
String id,
ReplicationPeerConfig peerConfig)
Constructor that takes all the objects required to communicate with the specified peer, except
for the region server addresses.
|
ReplicationPeerZKImpl(org.apache.hadoop.conf.Configuration conf,
String id,
ReplicationPeerConfig peerConfig,
Map<TableName,List<String>> tableCFs)
Constructor that takes all the objects required to communicate with the specified peer, except
for the region server addresses.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(String why,
Throwable e)
Abort the server or client.
|
void |
close() |
private static boolean |
ensurePeerEnabled(ZooKeeperWatcher zookeeper,
String path)
Utility method to ensure an ENABLED znode is in place; if not present, we create it.
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Get the configuration object required to communicate with this peer
|
String |
getId()
Get the identifier of this peer
|
ReplicationPeerConfig |
getPeerConfig()
Get the peer config object
|
ReplicationPeer.PeerState |
getPeerState()
Returns the state of the peer
|
Map<TableName,List<String>> |
getTableCFs()
Get replicable (table, cf-list) map of this peer
|
boolean |
isAborted()
Check if the server or client was aborted.
|
static boolean |
isStateEnabled(byte[] bytes)
Parse the raw data from ZK to get a peer's state
|
private static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationState.State |
parseStateFrom(byte[] bytes) |
private void |
readPeerStateZnode() |
private void |
readTableCFsZnode() |
void |
startStateTracker(ZooKeeperWatcher zookeeper,
String peerStateNode)
start a state tracker to check whether this peer is enabled or not
|
void |
startTableCFsTracker(ZooKeeperWatcher zookeeper,
String tableCFsNode)
start a table-cfs tracker to listen the (table, cf-list) map change
|
private static final org.apache.commons.logging.Log LOG
private final ReplicationPeerConfig peerConfig
private final String id
private volatile ReplicationPeer.PeerState peerState
private final org.apache.hadoop.conf.Configuration conf
private ReplicationPeerZKImpl.PeerStateTracker peerStateTracker
private ReplicationPeerZKImpl.TableCFsTracker tableCFsTracker
public ReplicationPeerZKImpl(org.apache.hadoop.conf.Configuration conf, String id, ReplicationPeerConfig peerConfig) throws ReplicationException
conf
- configuration object to this peerid
- string representation of this peer's identifierpeerConfig
- configuration for the replication peerReplicationException
public ReplicationPeerZKImpl(org.apache.hadoop.conf.Configuration conf, String id, ReplicationPeerConfig peerConfig, Map<TableName,List<String>> tableCFs) throws ReplicationException
conf
- configuration object to this peerid
- string representation of this peer's identifierpeerConfig
- configuration for the replication peertableCFs
- table-cf configuration for this peerReplicationException
public void startStateTracker(ZooKeeperWatcher zookeeper, String peerStateNode) throws org.apache.zookeeper.KeeperException
zookeeper
- zk watcher for the local clusterpeerStateNode
- path to zk node which stores peer stateorg.apache.zookeeper.KeeperException
private void readPeerStateZnode() throws DeserializationException
DeserializationException
public void startTableCFsTracker(ZooKeeperWatcher zookeeper, String tableCFsNode) throws org.apache.zookeeper.KeeperException
zookeeper
- zk watcher for the local clustertableCFsNode
- path to zk node which stores table-cfsorg.apache.zookeeper.KeeperException
private void readTableCFsZnode()
public ReplicationPeer.PeerState getPeerState()
ReplicationPeer
getPeerState
in interface ReplicationPeer
public String getId()
getId
in interface ReplicationPeer
public ReplicationPeerConfig getPeerConfig()
getPeerConfig
in interface ReplicationPeer
public org.apache.hadoop.conf.Configuration getConfiguration()
getConfiguration
in interface ReplicationPeer
public Map<TableName,List<String>> getTableCFs()
getTableCFs
in interface ReplicationPeer
public void abort(String why, Throwable e)
Abortable
public boolean isAborted()
Abortable
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public static boolean isStateEnabled(byte[] bytes) throws DeserializationException
bytes
- raw ZK databytes
are those of a pb serialized ENABLED state.DeserializationException
private static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.ReplicationState.State parseStateFrom(byte[] bytes) throws DeserializationException
bytes
- Content of a state znode.DeserializationException
private static boolean ensurePeerEnabled(ZooKeeperWatcher zookeeper, String path) throws org.apache.zookeeper.KeeperException.NodeExistsException, org.apache.zookeeper.KeeperException
zookeeper
- path
- Path to znode to checkorg.apache.zookeeper.KeeperException.NodeExistsException
org.apache.zookeeper.KeeperException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.