@InterfaceAudience.Private public class ReplicationSourceManager extends Object implements ReplicationListener
Modifier and Type | Class and Description |
---|---|
(package private) class |
ReplicationSourceManager.AdoptAbandonedQueuesWorker |
(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.slf4j.Logger |
LOG |
private org.apache.hadoop.fs.Path |
logDir |
private org.apache.hadoop.fs.Path |
oldLogDir |
private List<ReplicationSourceInterface> |
oldsources |
private boolean |
replicationForBulkLoadDataEnabled |
private ReplicationPeers |
replicationPeers |
private ReplicationQueues |
replicationQueues |
private ReplicationTracker |
replicationTracker |
private Server |
server |
private long |
sleepBeforeFailover |
private List<ReplicationSourceInterface> |
sources |
private AtomicLong |
totalBufferUsed |
private WALFileLengthProvider |
walFileLengthProvider |
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,
WALFileLengthProvider walFileLengthProvider)
Creates a replication manager and sets the watch on all the other registered region servers
|
Modifier and Type | Method and Description |
---|---|
void |
addHFileRefs(TableName tableName,
byte[] family,
List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) |
(package private) 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 |
cleanUpHFileRefs(String peerId,
List<String> files) |
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
|
ReplicationPeers |
getReplicationPeers()
Get the ReplicationPeers used by this ReplicationSourceManager
|
private 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,
WALFileLengthProvider walFileLengthProvider)
Factory method to create a replication source
|
(package private) int |
getSizeOfLatestPath() |
ReplicationSourceInterface |
getSource(String peerId)
Get the normal source for a given peer
|
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
|
AtomicLong |
getTotalBufferUsed() |
(package private) Map<String,Map<String,SortedSet<String>>> |
getWALs()
Get a copy of the wals of the first source on this rs
|
(package private) Map<String,Map<String,SortedSet<String>>> |
getWalsByIdRecoveredQueues()
Get a copy of the wals of the recovered sources on this rs
|
(package private) 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 |
postLogRoll(org.apache.hadoop.fs.Path newLog) |
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.slf4j.Logger 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 Map<String,Map<String,SortedSet<String>>> walsByIdRecoveredQueues
private final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.fs.FileSystem fs
private final 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 WALFileLengthProvider walFileLengthProvider
private final long sleepBeforeFailover
private final ThreadPoolExecutor executor
private final boolean replicationForBulkLoadDataEnabled
private AtomicLong totalBufferUsed
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, WALFileLengthProvider walFileLengthProvider) throws IOException
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
- IOException
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 queueprivate void cleanOldLogs(SortedSet<String> wals, String key, String id)
void init() throws IOException, ReplicationException
IOException
ReplicationException
ReplicationSourceInterface addSource(String id) throws IOException, ReplicationException
id
- the id of the peer clusterIOException
ReplicationException
int getSizeOfLatestPath()
public void deleteSource(String peerId, boolean closeConnection)
peerId
- Id of the peer cluster queue of wals to deletepublic void join()
Map<String,Map<String,SortedSet<String>>> getWALs()
Map<String,Map<String,SortedSet<String>>> getWalsByIdRecoveredQueues()
public List<ReplicationSourceInterface> getSources()
public List<ReplicationSourceInterface> getOldSources()
public ReplicationSourceInterface getSource(String peerId)
peerId
- List<String> getAllQueues()
public 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
public void postLogRoll(org.apache.hadoop.fs.Path newLog) throws IOException
IOException
public AtomicLong getTotalBufferUsed()
private 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, WALFileLengthProvider walFileLengthProvider) 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 ReplicationPeers getReplicationPeers()
public void addHFileRefs(TableName tableName, byte[] family, List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) throws ReplicationException
ReplicationException
public void cleanUpHFileRefs(String peerId, List<String> files)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.