public class ReplicationSourceManager extends Object
Modifier and Type | Class and Description |
---|---|
class |
ReplicationSourceManager.OtherRegionServerWatcher
Watcher used to be notified of the other region server's death
in the local cluster.
|
class |
ReplicationSourceManager.PeersWatcher
Watcher used to follow the creation and deletion of peer clusters.
|
Constructor and Description |
---|
ReplicationSourceManager(ReplicationZookeeper zkHelper,
org.apache.hadoop.conf.Configuration conf,
Stoppable stopper,
org.apache.hadoop.fs.FileSystem fs,
AtomicBoolean replicating,
org.apache.hadoop.fs.Path logDir,
org.apache.hadoop.fs.Path oldLogDir)
Creates a replication manager and sets the watch on all the other
registered region servers
|
Modifier and Type | Method and Description |
---|---|
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
|
org.apache.hadoop.fs.FileSystem |
getFs()
Get the handle on the local file system
|
protected Map<String,SortedSet<String>> |
getHLogs()
Get a copy of the hlogs of the first source on this rs
|
org.apache.hadoop.fs.Path |
getLogDir()
Get the directory where hlogs are stored by their RSs
|
org.apache.hadoop.fs.Path |
getOldLogDir()
Get the directory where hlogs are archived
|
List<ReplicationSourceInterface> |
getOldSources()
Get a list of all the old sources of this rs
|
ReplicationSourceInterface |
getReplicationSource(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
ReplicationSourceManager manager,
Stoppable stopper,
AtomicBoolean replicating,
String peerId)
Factory method to create a replication source
|
ReplicationZookeeper |
getRepZkWrapper()
Get the ZK help of this manager
|
List<ReplicationSourceInterface> |
getSources()
Get a list of all the normal sources of this rs
|
void |
init()
Adds a normal source per registered peer cluster and tries to process all
old region server hlog 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
hlog it belongs to and will log, for this region server, the current
position.
|
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).
|
void |
transferQueues(String rsZnode)
Transfer all the queues of the specified to this region server.
|
public ReplicationSourceManager(ReplicationZookeeper zkHelper, org.apache.hadoop.conf.Configuration conf, Stoppable stopper, org.apache.hadoop.fs.FileSystem fs, AtomicBoolean replicating, org.apache.hadoop.fs.Path logDir, org.apache.hadoop.fs.Path oldLogDir)
zkHelper
- the zk helper for replicationconf
- the configuration to usestopper
- the stopper object for this region serverfs
- the file system to usereplicating
- the status of the replication on this clusterlogDir
- the directory that contains all hlog directories of live RSsoldLogDir
- the directory where old logs are archivedpublic 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 queuepublic void init() throws IOException
IOException
public ReplicationSourceInterface addSource(String id) throws IOException
id
- the id of the peer clusterIOException
public void join()
protected Map<String,SortedSet<String>> getHLogs()
public List<ReplicationSourceInterface> getSources()
public List<ReplicationSourceInterface> getOldSources()
public ReplicationZookeeper getRepZkWrapper()
public ReplicationSourceInterface getReplicationSource(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, ReplicationSourceManager manager, Stoppable stopper, AtomicBoolean replicating, String peerId) throws IOException
conf
- the configuration to usefs
- the file system to usemanager
- the manager to usestopper
- the stopper object for this region serverreplicating
- the status of the replication on this clusterpeerId
- the id of the peer clusterIOException
public void transferQueues(String rsZnode)
rsZnode
- public void closeRecoveredQueue(ReplicationSourceInterface src)
src
- source to clearpublic void removePeer(String id)
id
- The id of the peer clusterpublic org.apache.hadoop.fs.Path getOldLogDir()
public org.apache.hadoop.fs.Path getLogDir()
public org.apache.hadoop.fs.FileSystem getFs()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.