org.apache.hadoop.hbase.client.replication
Class ReplicationAdmin

java.lang.Object
  extended by org.apache.hadoop.hbase.client.replication.ReplicationAdmin
All Implemented Interfaces:
Closeable

public class ReplicationAdmin
extends Object
implements Closeable

This class provides the administrative interface to HBase cluster replication. In order to use it, the cluster and the client using ReplicationAdmin must be configured with hbase.replication set to true.

Adding a new peer results in creating new outbound connections from every region server to a subset of region servers on the slave cluster. Each new stream of replication will start replicating from the beginning of the current HLog, meaning that edits from that past will be replicated.

Removing a peer is a destructive and irreversible operation that stops all the replication streams for the given cluster and deletes the metadata used to keep track of the replication state.

Enabling and disabling peers is currently not supported.

As cluster replication is still experimental, a kill switch is provided in order to stop all replication-related operations, see setReplicating(boolean). When setting it back to true, the new state of all the replication streams will be unknown and may have holes. Use at your own risk.

To see which commands are available in the shell, type replication.


Constructor Summary
ReplicationAdmin(org.apache.hadoop.conf.Configuration conf)
          Constructor that creates a connection to the local ZooKeeper ensemble.
 
Method Summary
 void addPeer(String id, String clusterKey)
          Add a new peer cluster to replicate to.
 void close()
           
 void disablePeer(String id)
          Stop the replication stream to the specified peer.
 void enablePeer(String id)
          Restart the replication stream to the specified peer.
 int getPeersCount()
          Get the number of slave clusters the local cluster has.
 boolean getReplicating()
          Get the current status of the kill switch, if the cluster is replicating or not.
 Map<String,String> listPeers()
          Map of this cluster's peers for display.
 void removePeer(String id)
          Removes a peer cluster and stops the replication to it.
 boolean setReplicating(boolean newState)
          Kill switch for all replication-related features
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicationAdmin

public ReplicationAdmin(org.apache.hadoop.conf.Configuration conf)
                 throws IOException
Constructor that creates a connection to the local ZooKeeper ensemble.

Parameters:
conf - Configuration to use
Throws:
IOException - if the connection to ZK cannot be made
RuntimeException - if replication isn't enabled.
Method Detail

addPeer

public void addPeer(String id,
                    String clusterKey)
             throws IOException
Add a new peer cluster to replicate to.

Parameters:
id - 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:
IllegalStateException - if there's already one slave since multi-slave isn't supported yet.
IOException

removePeer

public void removePeer(String id)
                throws IOException
Removes a peer cluster and stops the replication to it.

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

enablePeer

public void enablePeer(String id)
                throws IOException
Restart the replication stream to the specified peer.

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

disablePeer

public void disablePeer(String id)
                 throws IOException
Stop the replication stream to the specified peer.

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

getPeersCount

public int getPeersCount()
Get the number of slave clusters the local cluster has.

Returns:
number of slave clusters

listPeers

public Map<String,String> listPeers()
Map of this cluster's peers for display.

Returns:
A map of peer ids to peer cluster keys

getReplicating

public boolean getReplicating()
                       throws IOException
Get the current status of the kill switch, if the cluster is replicating or not.

Returns:
true if the cluster is replicated, otherwise false
Throws:
IOException

setReplicating

public boolean setReplicating(boolean newState)
                       throws IOException
Kill switch for all replication-related features

Parameters:
newState - true to start replication, false to stop it. completely
Returns:
the previous state
Throws:
IOException

close

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


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