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
.
Modifier and Type | Field and Description |
---|---|
static String |
CFNAME |
static String |
REPLICATIONGLOBAL |
static String |
REPLICATIONTYPE |
static String |
TNAME |
Constructor and Description |
---|
ReplicationAdmin(org.apache.hadoop.conf.Configuration conf)
Constructor that creates a connection to the local ZooKeeper ensemble.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
getPeerState(String id)
Get state of the peer
|
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.
|
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.
|
boolean |
setReplicating(boolean newState)
Kill switch for all replication-related features
|
public static final String TNAME
public static final String CFNAME
public static final String REPLICATIONTYPE
public static final String REPLICATIONGLOBAL
public ReplicationAdmin(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
- Configuration to useIOException
- if the connection to ZK cannot be madeRuntimeException
- if replication isn't enabled.public void addPeer(String id, String clusterKey) throws IOException
id
- a short that identifies the clusterclusterKey
- the concatenation of the slave cluster's
hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent
IllegalStateException
- if there's already one slave since
multi-slave isn't supported yet.IOException
public void removePeer(String id) throws IOException
id
- a short that identifies the clusterIOException
public void enablePeer(String id) throws IOException
id
- a short that identifies the clusterIOException
public void disablePeer(String id) throws IOException
id
- a short that identifies the clusterIOException
public int getPeersCount()
public Map<String,String> listPeers()
public String getPeerState(String id) throws IOException
id
- peer's identifierIOException
public boolean getReplicating() throws IOException
IOException
public boolean setReplicating(boolean newState) throws IOException
newState
- true to start replication, false to stop it.
completelyIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public List<HashMap<String,String>> listReplicated() throws IOException
IOException
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.