org.apache.hadoop.hbase.replication
Class ReplicationPeerZKImpl

java.lang.Object
  extended by org.apache.hadoop.hbase.replication.ReplicationPeerZKImpl
All Implemented Interfaces:
Closeable, Abortable, ReplicationPeer

@InterfaceAudience.Private
public class ReplicationPeerZKImpl
extends Object
implements ReplicationPeer, Abortable, Closeable


Nested Class Summary
 class ReplicationPeerZKImpl.PeerStateTracker
          Tracker for state of this peer
 class ReplicationPeerZKImpl.TableCFsTracker
          Tracker for (table, cf-list) map of this peer
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.replication.ReplicationPeer
ReplicationPeer.PeerState
 
Constructor Summary
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.
 
Method Summary
 void abort(String why, Throwable e)
          Abort the server or client.
 void close()
           
 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<String,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
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicationPeerZKImpl

public ReplicationPeerZKImpl(org.apache.hadoop.conf.Configuration conf,
                             String id,
                             ReplicationPeerConfig peerConfig)
                      throws ReplicationException
Constructor that takes all the objects required to communicate with the specified peer, except for the region server addresses.

Parameters:
conf - configuration object to this peer
id - string representation of this peer's identifier
peerConfig - configuration for the replication peer
Throws:
ReplicationException
Method Detail

startStateTracker

public void startStateTracker(ZooKeeperWatcher zookeeper,
                              String peerStateNode)
                       throws org.apache.zookeeper.KeeperException
start a state tracker to check whether this peer is enabled or not

Parameters:
zookeeper - zk watcher for the local cluster
peerStateNode - path to zk node which stores peer state
Throws:
org.apache.zookeeper.KeeperException

startTableCFsTracker

public void startTableCFsTracker(ZooKeeperWatcher zookeeper,
                                 String tableCFsNode)
                          throws org.apache.zookeeper.KeeperException
start a table-cfs tracker to listen the (table, cf-list) map change

Parameters:
zookeeper - zk watcher for the local cluster
tableCFsNode - path to zk node which stores table-cfs
Throws:
org.apache.zookeeper.KeeperException

getPeerState

public ReplicationPeer.PeerState getPeerState()
Description copied from interface: ReplicationPeer
Returns the state of the peer

Specified by:
getPeerState in interface ReplicationPeer
Returns:
the enabled state

getId

public String getId()
Get the identifier of this peer

Specified by:
getId in interface ReplicationPeer
Returns:
string representation of the id (short)

getPeerConfig

public ReplicationPeerConfig getPeerConfig()
Get the peer config object

Specified by:
getPeerConfig in interface ReplicationPeer
Returns:
the ReplicationPeerConfig for this peer

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Get the configuration object required to communicate with this peer

Specified by:
getConfiguration in interface ReplicationPeer
Returns:
configuration object

getTableCFs

public Map<String,List<String>> getTableCFs()
Get replicable (table, cf-list) map of this peer

Specified by:
getTableCFs in interface ReplicationPeer
Returns:
the replicable (table, cf-list) map

abort

public void abort(String why,
                  Throwable e)
Description copied from interface: Abortable
Abort the server or client.

Specified by:
abort in interface Abortable
Parameters:
why - Why we're aborting.
e - Throwable that caused abort. Can be null.

isAborted

public boolean isAborted()
Description copied from interface: Abortable
Check if the server or client was aborted.

Specified by:
isAborted in interface Abortable
Returns:
true if the server or client was aborted, false otherwise

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

isStateEnabled

public static boolean isStateEnabled(byte[] bytes)
                              throws DeserializationException
Parse the raw data from ZK to get a peer's state

Parameters:
bytes - raw ZK data
Returns:
True if the passed in bytes are those of a pb serialized ENABLED state.
Throws:
DeserializationException


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