@InterfaceAudience.Private public class ReplicationSourceManager extends Object implements ReplicationListener
Modifier and Type | Class and Description |
---|---|
(package private) class |
ReplicationSourceManager.NodeFailoverWorker
Class responsible to setup new ReplicationSources to take care of the
queues from dead region servers.
|
Modifier and Type | Field and Description |
---|---|
private UUID |
clusterId |
private org.apache.hadoop.conf.Configuration |
conf |
private ThreadPoolExecutor |
executor |
private org.apache.hadoop.fs.FileSystem |
fs |
private Set<org.apache.hadoop.fs.Path> |
latestPaths |
private static org.apache.commons.logging.Log |
LOG |
private org.apache.hadoop.fs.Path |
logDir |
private org.apache.hadoop.fs.Path |
oldLogDir |
private List<ReplicationSourceInterface> |
oldsources |
private Random |
rand |
private ReplicationPeers |
replicationPeers |
private ReplicationQueues |
replicationQueues |
private ReplicationTracker |
replicationTracker |
private Server |
server |
private long |
sleepBeforeFailover |
private List<ReplicationSourceInterface> |
sources |
private Map<String,Map<String,SortedSet<String>>> |
walsById |
private Map<String,Map<String,SortedSet<String>>> |
walsByIdRecoveredQueues |
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 sources for the given peer cluster on this region server.
|
private void |
cleanOldLogs(SortedSet<String> wals,
String key,
String id) |
void |
cleanOldLogs(String key,
String id,
boolean queueRecovered)
Cleans a log file and all older files from ZK.
|
void |
closeQueue(ReplicationSourceInterface src)
Clear the references to the specified old source
|
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
|
(package private) List<String> |
getAllQueues() |
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,Map<String,SortedSet<String>>> |
getWALs()
Get a copy of the wals of the first source on this rs
|
protected Map<String,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.
|
(package private) void |
postLogRoll(org.apache.hadoop.fs.Path newLog) |
(package private) void |
preLogRoll(org.apache.hadoop.fs.Path newLog) |
private void |
recordLog(org.apache.hadoop.fs.Path logPath)
Check and enqueue the given log to the correct source.
|
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).
|
private void |
transferQueues(String rsZnode)
Transfer all the queues of the specified to this region server.
|
private static final org.apache.commons.logging.Log LOG
private final List<ReplicationSourceInterface> sources
private final List<ReplicationSourceInterface> oldsources
private final ReplicationQueues replicationQueues
private final ReplicationTracker replicationTracker
private final ReplicationPeers replicationPeers
private final UUID clusterId
private final Server server
private final Map<String,Map<String,SortedSet<String>>> walsByIdRecoveredQueues
private final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.fs.FileSystem fs
private Set<org.apache.hadoop.fs.Path> latestPaths
private final org.apache.hadoop.fs.Path logDir
private final org.apache.hadoop.fs.Path oldLogDir
private final long sleepBeforeFailover
private final ThreadPoolExecutor executor
private final Random rand
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
IOException
ReplicationException
protected ReplicationSourceInterface addSource(String id) throws IOException, ReplicationException
id
- the id of the peer clusterIOException
ReplicationException
public void deleteSource(String peerId, boolean closeConnection)
peerId
- Id of the peer cluster queue of wals to deletepublic void join()
protected Map<String,Map<String,SortedSet<String>>> getWALs()
protected Map<String,Map<String,SortedSet<String>>> getWalsByIdRecoveredQueues()
public List<ReplicationSourceInterface> getSources()
public List<ReplicationSourceInterface> getOldSources()
void preLogRoll(org.apache.hadoop.fs.Path newLog) throws IOException
IOException
private void recordLog(org.apache.hadoop.fs.Path logPath) throws IOException
logPath
- the log path to check and enqueueIOException
void postLogRoll(org.apache.hadoop.fs.Path newLog) throws IOException
IOException
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 clusterIOException
private void transferQueues(String rsZnode)
rsZnode
- public void closeRecoveredQueue(ReplicationSourceInterface src)
src
- source to clearpublic void closeQueue(ReplicationSourceInterface src)
src
- source to clearpublic void removePeer(String id)
id
- The id of the peer clusterpublic void regionServerRemoved(String regionserver)
ReplicationListener
regionServerRemoved
in interface ReplicationListener
regionserver
- the removed region serverpublic void peerRemoved(String peerId)
ReplicationListener
peerRemoved
in interface ReplicationListener
peerId
- The peer id of the cluster that has been removedpublic void peerListChanged(List<String> peerIds)
ReplicationListener
peerListChanged
in interface ReplicationListener
peerIds
- 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–2019 The Apache Software Foundation. All rights reserved.