org.apache.hadoop.hbase.replication
Interface ReplicationPeers

All Known Implementing Classes:
ReplicationPeersZKImpl

@InterfaceAudience.Private
public interface ReplicationPeers

This provides an interface for maintaining a set of peer clusters. These peers are remote slave clusters that data is replicated to. A peer cluster can be in three different states: 1. Not-Registered - There is no notion of the peer cluster. 2. Registered - The peer has an id and is being tracked but there is no connection. 3. Connected - There is an active connection to the remote peer. In the registered or connected state, a peer cluster can either be enabled or disabled.


Method Summary
 void addPeer(String peerId, String clusterKey)
          Add a new remote slave cluster for replication.
 boolean connectToPeer(String peerId)
          Attempt to connect to a new remote slave cluster.
 void disablePeer(String peerId)
          Stop the replication to the specified remote slave cluster.
 void disconnectFromPeer(String peerId)
          Disconnect from a remote slave cluster.
 void enablePeer(String peerId)
          Restart the replication to the specified remote slave cluster.
 Map<String,String> getAllPeerClusterKeys()
          List the cluster keys of all remote slave clusters (whether they are enabled/disabled or connected/disconnected).
 List<String> getAllPeerIds()
          List the peer ids of all remote slave clusters (whether they are enabled/disabled or connected/disconnected).
 Set<String> getConnectedPeers()
          Get a set of all connected remote slave clusters.
 org.apache.hadoop.conf.Configuration getPeerConf(String peerId)
          Returns the configuration needed to talk to the remote slave cluster.
 UUID getPeerUUID(String peerId)
          Returns the UUID of the provided peer id.
 List<ServerName> getRegionServersOfConnectedPeer(String peerId)
          Returns all region servers from given connected remote slave cluster.
 boolean getStatusOfConnectedPeer(String peerId)
          Get the replication status for the specified connected remote slave cluster.
 boolean getStatusOfPeerFromBackingStore(String peerId)
          Get the replication status for the specified remote slave cluster, which doesn't have to be connected.
 long getTimestampOfLastChangeToPeer(String peerId)
          Get the timestamp of the last change in composition of a given peer cluster.
 void init()
          Initialize the ReplicationPeers interface.
 void removePeer(String peerId)
          Removes a remote slave cluster and stops the replication to it.
 

Method Detail

init

void init()
          throws IOException,
                 org.apache.zookeeper.KeeperException
Initialize the ReplicationPeers interface.

Throws:
org.apache.zookeeper.KeeperException
IOException

addPeer

void addPeer(String peerId,
             String clusterKey)
             throws IOException
Add a new remote slave cluster for replication.

Parameters:
peerId - a short that identifies the cluster
clusterKey - the concatenation of the slave cluster's: hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
Throws:
IOException

removePeer

void removePeer(String peerId)
                throws IOException
Removes a remote slave cluster and stops the replication to it.

Parameters:
peerId - a short that identifies the cluster
Throws:
IOException

enablePeer

void enablePeer(String peerId)
                throws IOException
Restart the replication to the specified remote slave cluster.

Parameters:
peerId - a short that identifies the cluster
Throws:
IOException

disablePeer

void disablePeer(String peerId)
                 throws IOException
Stop the replication to the specified remote slave cluster.

Parameters:
peerId - a short that identifies the cluster
Throws:
IOException

getStatusOfConnectedPeer

boolean getStatusOfConnectedPeer(String peerId)
Get the replication status for the specified connected remote slave cluster. The value might be read from cache, so it is recommended to use getStatusOfPeerFromBackingStore(String) if reading the state after enabling or disabling it.

Parameters:
peerId - a short that identifies the cluster
Returns:
true if replication is enabled, false otherwise.

getStatusOfPeerFromBackingStore

boolean getStatusOfPeerFromBackingStore(String peerId)
                                        throws IOException
Get the replication status for the specified remote slave cluster, which doesn't have to be connected. The state is read directly from the backing store.

Parameters:
peerId - a short that identifies the cluster
Returns:
true if replication is enabled, false otherwise.
Throws:
IOException - Throws if there's an error contacting the store

getConnectedPeers

Set<String> getConnectedPeers()
Get a set of all connected remote slave clusters.

Returns:
set of peer ids

getAllPeerClusterKeys

Map<String,String> getAllPeerClusterKeys()
List the cluster keys of all remote slave clusters (whether they are enabled/disabled or connected/disconnected).

Returns:
A map of peer ids to peer cluster keys

getAllPeerIds

List<String> getAllPeerIds()
List the peer ids of all remote slave clusters (whether they are enabled/disabled or connected/disconnected).

Returns:
A list of peer ids

connectToPeer

boolean connectToPeer(String peerId)
                      throws IOException,
                             org.apache.zookeeper.KeeperException
Attempt to connect to a new remote slave cluster.

Parameters:
peerId - a short that identifies the cluster
Returns:
true if a new connection was made, false if no new connection was made.
Throws:
IOException
org.apache.zookeeper.KeeperException

disconnectFromPeer

void disconnectFromPeer(String peerId)
Disconnect from a remote slave cluster.

Parameters:
peerId - a short that identifies the cluster

getRegionServersOfConnectedPeer

List<ServerName> getRegionServersOfConnectedPeer(String peerId)
Returns all region servers from given connected remote slave cluster.

Parameters:
peerId - a short that identifies the cluster
Returns:
addresses of all region servers in the peer cluster. Returns an empty list if the peer cluster is unavailable or there are no region servers in the cluster.

getTimestampOfLastChangeToPeer

long getTimestampOfLastChangeToPeer(String peerId)
Get the timestamp of the last change in composition of a given peer cluster.

Parameters:
peerId - identifier of the peer cluster for which the timestamp is requested
Returns:
the timestamp (in milliseconds) of the last change to the composition of the peer cluster

getPeerUUID

UUID getPeerUUID(String peerId)
Returns the UUID of the provided peer id.

Parameters:
peerId - the peer's ID that will be converted into a UUID
Returns:
a UUID or null if the peer cluster does not exist or is not connected.

getPeerConf

org.apache.hadoop.conf.Configuration getPeerConf(String peerId)
                                                 throws org.apache.zookeeper.KeeperException
Returns the configuration needed to talk to the remote slave cluster.

Parameters:
peerId - a short that identifies the cluster
Returns:
the configuration for the peer cluster, null if it was unable to get the configuration
Throws:
org.apache.zookeeper.KeeperException


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