@InterfaceAudience.Private public class ReplicationSourceManager extends Object implements ReplicationListener
| Constructor and Description |
|---|
ReplicationSourceManager(ReplicationQueues replicationQueues,
ReplicationPeers replicationPeers,
ReplicationTracker replicationTracker,
org.apache.hadoop.conf.Configuration conf,
Server server,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path logDir,
org.apache.hadoop.fs.Path oldLogDir,
UUID clusterId)
Creates a replication manager and sets the watch on all the other registered region servers
|
| Modifier and Type | Method and Description |
|---|---|
protected ReplicationSourceInterface |
addSource(String id)
Add a new normal source to this region server
|
void |
cleanOldLogs(String key,
String id,
boolean queueRecovered)
Cleans a log file and all older files from ZK.
|
void |
closeRecoveredQueue(ReplicationSourceInterface src)
Clear the references to the specified old source
|
void |
deleteSource(String peerId,
boolean closeConnection)
Delete a complete queue of wals associated with a peer cluster
|
org.apache.hadoop.fs.FileSystem |
getFs()
Get the handle on the local file system
|
org.apache.hadoop.fs.Path |
getLogDir()
Get the directory where wals are stored by their RSs
|
org.apache.hadoop.fs.Path |
getOldLogDir()
Get the directory where wals are archived
|
List<ReplicationSourceInterface> |
getOldSources()
Get a list of all the old sources of this rs
|
protected ReplicationSourceInterface |
getReplicationSource(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
ReplicationSourceManager manager,
ReplicationQueues replicationQueues,
ReplicationPeers replicationPeers,
Server server,
String peerId,
UUID clusterId,
ReplicationPeerConfig peerConfig,
ReplicationPeer replicationPeer)
Factory method to create a replication source
|
List<ReplicationSourceInterface> |
getSources()
Get a list of all the normal sources of this rs
|
String |
getStats()
Get a string representation of all the sources' metrics
|
protected Map<String,SortedSet<String>> |
getWALs()
Get a copy of the wals of the first source on this rs
|
protected Map<String,SortedSet<String>> |
getWalsByIdRecoveredQueues()
Get a copy of the wals of the recovered sources on this rs
|
protected void |
init()
Adds a normal source per registered peer cluster and tries to process all
old region server wal queues
|
void |
join()
Terminate the replication on this region server
|
void |
logPositionAndCleanOldLogs(org.apache.hadoop.fs.Path log,
String id,
long position,
boolean queueRecovered,
boolean holdLogInZK)
Provide the id of the peer and a log key and this method will figure which
wal it belongs to and will log, for this region server, the current
position.
|
void |
peerListChanged(List<String> peerIds)
The list of registered peer clusters has changed.
|
void |
peerRemoved(String peerId)
A peer cluster has been removed (i.e.
|
void |
regionServerRemoved(String regionserver)
A region server has been removed from the local cluster
|
void |
removePeer(String id)
Thie method first deletes all the recovered sources for the specified
id, then deletes the normal source (deleting all related data in ZK).
|
public ReplicationSourceManager(ReplicationQueues replicationQueues, ReplicationPeers replicationPeers, ReplicationTracker replicationTracker, org.apache.hadoop.conf.Configuration conf, Server server, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path logDir, org.apache.hadoop.fs.Path oldLogDir, UUID clusterId)
replicationQueues - the interface for manipulating replication queuesreplicationPeers - replicationTracker - conf - the configuration to useserver - the server for this region serverfs - the file system to uselogDir - the directory that contains all wal directories of live RSsoldLogDir - the directory where old logs are archivedclusterId - public void logPositionAndCleanOldLogs(org.apache.hadoop.fs.Path log,
String id,
long position,
boolean queueRecovered,
boolean holdLogInZK)
log - Path to the log currently being replicated from
replication status in zookeeper. It will also delete older entries.id - id of the peer clusterposition - current location in the logqueueRecovered - indicates if this queue comes from another region serverholdLogInZK - if true then the log is retained in ZKpublic void cleanOldLogs(String key, String id, boolean queueRecovered)
key - Path to the logid - id of the peer clusterqueueRecovered - Whether this is a recovered queueprotected void init()
throws IOException,
ReplicationException
IOExceptionReplicationExceptionprotected ReplicationSourceInterface addSource(String id) throws IOException, ReplicationException
id - the id of the peer clusterIOExceptionReplicationExceptionpublic void deleteSource(String peerId, boolean closeConnection)
peerId - Id of the peer cluster queue of wals to deletepublic void join()
protected Map<String,SortedSet<String>> getWALs()
protected Map<String,SortedSet<String>> getWalsByIdRecoveredQueues()
public List<ReplicationSourceInterface> getSources()
public List<ReplicationSourceInterface> getOldSources()
protected ReplicationSourceInterface getReplicationSource(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, ReplicationSourceManager manager, ReplicationQueues replicationQueues, ReplicationPeers replicationPeers, Server server, String peerId, UUID clusterId, ReplicationPeerConfig peerConfig, ReplicationPeer replicationPeer) throws IOException
conf - the configuration to usefs - the file system to usemanager - the manager to useserver - the server object for this region serverpeerId - the id of the peer clusterIOExceptionpublic void closeRecoveredQueue(ReplicationSourceInterface src)
src - source to clearpublic void removePeer(String id)
id - The id of the peer clusterpublic void regionServerRemoved(String regionserver)
ReplicationListenerregionServerRemoved in interface ReplicationListenerregionserver - the removed region serverpublic void peerRemoved(String peerId)
ReplicationListenerpeerRemoved in interface ReplicationListenerpeerId - The peer id of the cluster that has been removedpublic void peerListChanged(List<String> peerIds)
ReplicationListenerpeerListChanged in interface ReplicationListenerpeerIds - A list of all currently registered peer clusterspublic org.apache.hadoop.fs.Path getOldLogDir()
public org.apache.hadoop.fs.Path getLogDir()
public org.apache.hadoop.fs.FileSystem getFs()
public String getStats()
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.