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

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

@InterfaceAudience.Public
@InterfaceStability.Evolving
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.

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


Field Summary
static String CFNAME
           
static String REPLICATIONGLOBAL
           
static String REPLICATIONTYPE
           
static String TNAME
           
 
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, ReplicationPeerConfig peerConfig, Map<TableName,? extends Collection<String>> tableCfs)
          Add a new remote slave cluster for replication.
 void addPeer(String id, String clusterKey)
          Deprecated. Use addPeer(String, ReplicationPeerConfig, Map) instead.
 void addPeer(String id, String clusterKey, String tableCFs)
          Deprecated. 
 void close()
           
 void disablePeer(String id)
          Stop the replication stream to the specified peer.
 void disableTableRep(TableName tableName)
          Disable a table's replication switch.
 void enablePeer(String id)
          Restart the replication stream to the specified peer.
 void enableTableRep(TableName tableName)
          Enable a table's replication switch.
 ReplicationPeerConfig getPeerConfig(String id)
           
 int getPeersCount()
          Get the number of slave clusters the local cluster has.
 boolean getPeerState(String id)
          Get the state of the specified peer cluster
 String getPeerTableCFs(String id)
          Get the replicable table-cf config of the specified peer.
 Map<String,ReplicationPeerConfig> listPeerConfigs()
           
 Map<String,String> listPeers()
          Deprecated. use listPeerConfigs()
 List<HashMap<String,String>> listReplicated()
          Find all column families that are replicated from this cluster
 void removePeer(String id)
          Removes a peer cluster and stops the replication to it.
 void setPeerTableCFs(String id, Map<TableName,? extends Collection<String>> tableCfs)
          Set the replicable table-cf config of the specified peer
 void setPeerTableCFs(String id, String tableCFs)
          Deprecated. use setPeerTableCFs(String, Map)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TNAME

public static final String TNAME
See Also:
Constant Field Values

CFNAME

public static final String CFNAME
See Also:
Constant Field Values

REPLICATIONTYPE

public static final String REPLICATIONTYPE
See Also:
Constant Field Values

REPLICATIONGLOBAL

public static final String REPLICATIONGLOBAL
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 an internal replication error occurs
RuntimeException - if replication isn't enabled.
Method Detail

addPeer

@Deprecated
public void addPeer(String id,
                               String clusterKey)
             throws ReplicationException
Deprecated. Use addPeer(String, ReplicationPeerConfig, Map) instead.

Add a new peer cluster to replicate to.

Parameters:
id - a short name 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.
ReplicationException

addPeer

@Deprecated
public void addPeer(String id,
                               String clusterKey,
                               String tableCFs)
             throws ReplicationException
Deprecated. 

Throws:
ReplicationException

addPeer

public void addPeer(String id,
                    ReplicationPeerConfig peerConfig,
                    Map<TableName,? extends Collection<String>> tableCfs)
             throws ReplicationException
Add a new remote slave cluster for replication.

Parameters:
id - a short name that identifies the cluster
peerConfig - configuration for the replication slave cluster
tableCfs - the table and column-family list which will be replicated for this peer. A map from tableName to column family names. An empty collection can be passed to indicate replicating all column families. Pass null for replicating all table and column families
Throws:
ReplicationException

removePeer

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

Parameters:
id - a short name that identifies the cluster
Throws:
ReplicationException

enablePeer

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

Parameters:
id - a short name that identifies the cluster
Throws:
ReplicationException

disablePeer

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

Parameters:
id - a short name that identifies the cluster
Throws:
ReplicationException

getPeersCount

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

Returns:
number of slave clusters

listPeers

@Deprecated
public Map<String,String> listPeers()
Deprecated. use listPeerConfigs()

Map of this cluster's peers for display.

Returns:
A map of peer ids to peer cluster keys

listPeerConfigs

public Map<String,ReplicationPeerConfig> listPeerConfigs()

getPeerConfig

public ReplicationPeerConfig getPeerConfig(String id)
                                    throws ReplicationException
Throws:
ReplicationException

getPeerTableCFs

public String getPeerTableCFs(String id)
                       throws ReplicationException
Get the replicable table-cf config of the specified peer.

Parameters:
id - a short name that identifies the cluster
Throws:
ReplicationException

setPeerTableCFs

@Deprecated
public void setPeerTableCFs(String id,
                                       String tableCFs)
                     throws ReplicationException
Deprecated. use setPeerTableCFs(String, Map)

Set the replicable table-cf config of the specified peer

Parameters:
id - a short name that identifies the cluster
Throws:
ReplicationException

setPeerTableCFs

public void setPeerTableCFs(String id,
                            Map<TableName,? extends Collection<String>> tableCfs)
                     throws ReplicationException
Set the replicable table-cf config of the specified peer

Parameters:
id - a short name that identifies the cluster
tableCfs - the table and column-family list which will be replicated for this peer. A map from tableName to column family names. An empty collection can be passed to indicate replicating all column families. Pass null for replicating all table and column families
Throws:
ReplicationException

getPeerState

public boolean getPeerState(String id)
                     throws ReplicationException
Get the state of the specified peer cluster

Parameters:
id - String format of the Short name that identifies the peer, an IllegalArgumentException is thrown if it doesn't exist
Returns:
true if replication is enabled to that peer, false if it isn't
Throws:
ReplicationException

close

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

listReplicated

public List<HashMap<String,String>> listReplicated()
                                            throws IOException
Find all column families that are replicated from this cluster

Returns:
the full list of the replicated column families of this cluster as: tableName, family name, replicationType Currently replicationType is Global. In the future, more replication types may be extended here. For example 1) the replication may only apply to selected peers instead of all peers 2) the replicationType may indicate the host Cluster servers as Slave for the table:columnFam.
Throws:
IOException

enableTableRep

public void enableTableRep(TableName tableName)
                    throws IOException
Enable a table's replication switch.

Parameters:
tableName - name of the table
Throws:
IOException - if a remote or network exception occurs

disableTableRep

public void disableTableRep(TableName tableName)
                     throws IOException
Disable a table's replication switch.

Parameters:
tableName - name of the table
Throws:
IOException - if a remote or network exception occurs


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