org.apache.hadoop.hbase.replication
Class ReplicationPeer

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

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

This class acts as a wrapper for all the objects used to identify and communicate with remote peers and is responsible for answering to expired sessions and re-establishing the ZK connections.


Nested Class Summary
 class ReplicationPeer.PeerStateTracker
          Tracker for state of this peer
 
Constructor Summary
ReplicationPeer(org.apache.hadoop.conf.Configuration conf, String key, String id)
          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()
           
 String getClusterKey()
          Get the cluster key of that peer
 org.apache.hadoop.conf.Configuration getConfiguration()
          Get the configuration object required to communicate with this peer
 String getId()
          Get the identifier of this peer
 AtomicBoolean getPeerEnabled()
          Get the state of this peer
 List<ServerName> getRegionServers()
          Get a list of all the addresses of all the region servers for this peer cluster
 ZooKeeperWatcher getZkw()
          Get the ZK connection to this peer
 boolean isAborted()
          Check if the server or client was aborted.
 void reloadZkWatcher()
          Closes the current ZKW (if not null) and creates a new one
 void setRegionServers(List<ServerName> regionServers)
          Set the list of region servers for that peer
 void startStateTracker(ZooKeeperWatcher zookeeper, String peerStateNode)
          start a state tracker to check whether this peer is enabled or not
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicationPeer

public ReplicationPeer(org.apache.hadoop.conf.Configuration conf,
                       String key,
                       String id)
                throws IOException
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
key - cluster key used to locate the peer
id - string representation of this peer's identifier
Throws:
IOException
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

getClusterKey

public String getClusterKey()
Get the cluster key of that peer

Returns:
string consisting of zk ensemble addresses, client port and root znode

getPeerEnabled

public AtomicBoolean getPeerEnabled()
Get the state of this peer

Returns:
atomic boolean that holds the status

getRegionServers

public List<ServerName> getRegionServers()
Get a list of all the addresses of all the region servers for this peer cluster

Returns:
list of addresses

setRegionServers

public void setRegionServers(List<ServerName> regionServers)
Set the list of region servers for that peer

Parameters:
regionServers - list of addresses for the region servers

getZkw

public ZooKeeperWatcher getZkw()
Get the ZK connection to this peer

Returns:
zk connection

getId

public String getId()
Get the identifier of this peer

Returns:
string representation of the id (short)

getConfiguration

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

Returns:
configuration object

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.

reloadZkWatcher

public void reloadZkWatcher()
                     throws IOException
Closes the current ZKW (if not null) and creates a new one

Throws:
IOException - If anything goes wrong connecting

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


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.