public class ReplicationSource extends java.lang.Thread implements ReplicationSourceInterface
A stream is considered down when we cannot contact a region server on the peer cluster for more than 55 seconds by default.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplicationSource.LogsComparator
Comparator used to compare logs together based on their start time
|
| Modifier and Type | Field and Description |
|---|---|
protected Configuration |
conf |
static int |
DEFAULT_WAIT_ON_ENDPOINT_SECONDS |
protected FileSystem |
fs |
protected ReplicationSourceManager |
manager |
protected java.lang.String |
peerClusterZnode |
protected int |
queueSizePerGroup |
protected ReplicationQueueInfo |
replicationQueueInfo |
protected ReplicationQueues |
replicationQueues |
protected Server |
server |
static java.lang.String |
WAIT_ON_ENDPOINT_SECONDS |
protected WALEntryFilter |
walEntryFilter |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,ReplicationSourceShipper> |
workerThreads |
| Constructor and Description |
|---|
ReplicationSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
addHFileRefs(TableName tableName,
byte[] family,
java.util.List<<any>> pairs)
Add hfile names to the queue to be replicated.
|
void |
enqueueLog(Path log)
Add a log to the list of logs to replicate
|
Path |
getCurrentPath()
Get the current log that's replicated
|
java.lang.String |
getPeerClusterZnode()
Get the id that the source is replicating to
|
java.lang.String |
getPeerId()
Get the id that the source is replicating to.
|
ReplicationEndpoint |
getReplicationEndpoint() |
ServerName |
getServerWALsBelongTo()
The queue of WALs only belong to one region server.
|
ReplicationSourceManager |
getSourceManager() |
MetricsSource |
getSourceMetrics() |
java.lang.String |
getStats()
Get a string representation of the current statistics
for this source
|
java.lang.Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
WALFileLengthProvider |
getWALFileLengthProvider() |
void |
init(Configuration conf,
FileSystem fs,
ReplicationSourceManager manager,
ReplicationQueues replicationQueues,
ReplicationPeers replicationPeers,
Server server,
java.lang.String peerClusterZnode,
java.util.UUID clusterId,
ReplicationEndpoint replicationEndpoint,
WALFileLengthProvider walFileLengthProvider,
MetricsSource metrics)
Instantiation method used by region servers
|
boolean |
isPeerEnabled()
check whether the peer is enabled or not
|
boolean |
isSourceActive() |
void |
postShipEdits(java.util.List<Entry> entries,
int batchSize)
Call this after the shipper thread ship some entries to peer cluster.
|
void |
run() |
protected boolean |
sleepForRetries(java.lang.String msg,
int sleepMultiplier)
Do the sleeping logic
|
protected ReplicationSourceWALReader |
startNewWALReader(java.lang.String threadName,
java.lang.String walGroupId,
java.util.concurrent.PriorityBlockingQueue<Path> queue,
long startPosition) |
void |
startup()
Start the replication
|
void |
terminate(java.lang.String reason)
End the replication
|
void |
terminate(java.lang.String reason,
java.lang.Exception cause)
End the replication
|
void |
terminate(java.lang.String reason,
java.lang.Exception cause,
boolean join) |
protected void |
tryStartNewShipper(java.lang.String walGroupId,
java.util.concurrent.PriorityBlockingQueue<Path> queue) |
void |
tryThrottle(int batchSize)
Try to throttle when the peer config with a bandwidth
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected int queueSizePerGroup
protected ReplicationQueues replicationQueues
protected Configuration conf
protected ReplicationQueueInfo replicationQueueInfo
protected ReplicationSourceManager manager
protected Server server
protected FileSystem fs
protected java.lang.String peerClusterZnode
protected WALEntryFilter walEntryFilter
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,ReplicationSourceShipper> workerThreads
public static final java.lang.String WAIT_ON_ENDPOINT_SECONDS
public static final int DEFAULT_WAIT_ON_ENDPOINT_SECONDS
public void init(Configuration conf,
FileSystem fs,
ReplicationSourceManager manager,
ReplicationQueues replicationQueues,
ReplicationPeers replicationPeers,
Server server,
java.lang.String peerClusterZnode,
java.util.UUID clusterId,
ReplicationEndpoint replicationEndpoint,
WALFileLengthProvider walFileLengthProvider,
MetricsSource metrics)
throws java.io.IOException
init in interface ReplicationSourceInterfaceconf - configuration to usefs - file system to usemanager - replication manager to ping toserver - the server for this region serverpeerClusterZnode - the name of our znodeclusterId - unique UUID for the clusterreplicationEndpoint - the replication endpoint implementationmetrics - metrics for replication sourcejava.io.IOExceptionpublic void enqueueLog(Path log)
ReplicationSourceInterfaceenqueueLog in interface ReplicationSourceInterfacelog - path to the log to replicatepublic void addHFileRefs(TableName tableName,
byte[] family,
java.util.List<<any>> pairs)
throws ReplicationException
ReplicationSourceInterfaceaddHFileRefs in interface ReplicationSourceInterfacetableName - Name of the table these files belongs tofamily - Name of the family these files belong topairs - list of pairs of { HFile location in staging dir, HFile path in region dir which
will be added in the queue for replication}ReplicationException - If failed to add hfile referencespublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprotected void tryStartNewShipper(java.lang.String walGroupId,
java.util.concurrent.PriorityBlockingQueue<Path> queue)
protected ReplicationSourceWALReader startNewWALReader(java.lang.String threadName, java.lang.String walGroupId, java.util.concurrent.PriorityBlockingQueue<Path> queue, long startPosition)
public java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler in class java.lang.Threadpublic ReplicationEndpoint getReplicationEndpoint()
getReplicationEndpoint in interface ReplicationSourceInterfacepublic ReplicationSourceManager getSourceManager()
getSourceManager in interface ReplicationSourceInterfacepublic void tryThrottle(int batchSize)
throws java.lang.InterruptedException
ReplicationSourceInterfacetryThrottle in interface ReplicationSourceInterfacebatchSize - entries size will be pushedjava.lang.InterruptedExceptionprotected boolean sleepForRetries(java.lang.String msg,
int sleepMultiplier)
msg - Why we sleepsleepMultiplier - by how many times the default sleeping time is augmentedsleepMultiplier is < maxRetriesMultiplierpublic boolean isPeerEnabled()
isPeerEnabled in interface ReplicationSourceInterfacepublic void startup()
ReplicationSourceInterfacestartup in interface ReplicationSourceInterfacepublic void terminate(java.lang.String reason)
ReplicationSourceInterfaceterminate in interface ReplicationSourceInterfacereason - why it's terminatingpublic void terminate(java.lang.String reason,
java.lang.Exception cause)
ReplicationSourceInterfaceterminate in interface ReplicationSourceInterfacereason - why it's terminatingcause - the error that's causing itpublic void terminate(java.lang.String reason,
java.lang.Exception cause,
boolean join)
public java.lang.String getPeerClusterZnode()
ReplicationSourceInterfacegetPeerClusterZnode in interface ReplicationSourceInterfacepublic java.lang.String getPeerId()
ReplicationSourceInterfacegetPeerId in interface ReplicationSourceInterfacepublic Path getCurrentPath()
ReplicationSourceInterfacegetCurrentPath in interface ReplicationSourceInterfacepublic boolean isSourceActive()
isSourceActive in interface ReplicationSourceInterfacepublic java.lang.String getStats()
ReplicationSourceInterfacegetStats in interface ReplicationSourceInterfacepublic MetricsSource getSourceMetrics()
getSourceMetrics in interface ReplicationSourceInterfacepublic void postShipEdits(java.util.List<Entry> entries,
int batchSize)
ReplicationSourceInterfacepostShipEdits in interface ReplicationSourceInterfaceentries - pushedbatchSize - entries size pushedpublic WALFileLengthProvider getWALFileLengthProvider()
getWALFileLengthProvider in interface ReplicationSourceInterfacepublic ServerName getServerWALsBelongTo()
ReplicationSourceInterfacegetServerWALsBelongTo in interface ReplicationSourceInterface