@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 |
---|---|
void |
addHFileRefs(TableName tableName,
byte[] family,
List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) |
protected ReplicationSourceInterface |
addSource(String id)
Add sources for the given peer cluster on this region server.
|
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
|
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
|
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
|
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
|
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.
|
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).
|
void |
setPendingShipment(boolean pendingShipment) |
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 setPendingShipment(boolean pendingShipment)
public 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()
public ReplicationSourceInterface getSource(String peerId)
peerId
- 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
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 String getStats()
public void addHFileRefs(TableName tableName, byte[] family, List<Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path>> pairs) throws ReplicationException
ReplicationException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.