Interface ReplicationSourceInterface
- All Known Implementing Classes:
RecoveredReplicationSource,ReplicationSource
Interface that defines a replication source
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddHFileRefs(TableName tableName, byte[] family, List<Pair<org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path>> pairs) Add hfile names to the queue to be replicated.voidenqueueLog(org.apache.hadoop.fs.Path log) Add a log to the list of logs to replicateorg.apache.hadoop.fs.PathGet the current log that's replicatedgetPeer()Get the replication peer instance.default StringGet the id that the source is replicating to.Get the queue id that the source is replicating toReturns the replication endpoint used by this replication sourceReturns The instance of queueStorage used by this ReplicationSource.The queue of WALs only belong to one region server.Returns the replication source managerReturns metrics of this replication sourcegetStats()Get a string representation of the current statistics for this sourceReturns the wal file length providerdefault Map<String,ReplicationStatus> get the stat of replication for each wal group.voidinit(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, ReplicationSourceManager manager, ReplicationQueueStorage queueStorage, ReplicationPeer replicationPeer, Server server, ReplicationQueueData queueData, UUID clusterId, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics) Initializer for the sourcedefault booleanReturns peer enabled or notdefault booleanReturns whether this is a replication source for recovery.booleanReturns active or notdefault booleanReturns whether this is sync replication peer.default voidlogPositionAndCleanOldLogs(WALEntryBatch entryBatch) Log the current position to storage.voidpostShipEdits(List<WAL.Entry> entries, long batchSize) Call this after the shipper thread ship some entries to peer cluster.startup()Start the replicationvoidEnd the replicationvoidEnd the replicationvoidEnd the replicationvoidtryThrottle(int batchSize) Try to throttle when the peer config with a bandwidth
-
Method Details
-
init
void init(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, ReplicationSourceManager manager, ReplicationQueueStorage queueStorage, ReplicationPeer replicationPeer, Server server, ReplicationQueueData queueData, UUID clusterId, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics) throws IOException Initializer for the source- Parameters:
conf- the configuration to usefs- the file system to usemanager- the manager to usequeueStorage- the replication queue storagereplicationPeer- the replication peerserver- the server for this region serverqueueData- the existing replication queue data, contains the queue id and replication start offsetsclusterId- the cluster idwalFileLengthProvider- for getting the length of the WAL file which is currently being writtenmetrics- the replication metrics- Throws:
IOException
-
enqueueLog
Add a log to the list of logs to replicate- Parameters:
log- path to the log to replicate
-
addHFileRefs
void addHFileRefs(TableName tableName, byte[] family, List<Pair<org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path>> pairs) throws ReplicationExceptionAdd hfile names to the queue to be replicated.- Parameters:
tableName- 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}- Throws:
ReplicationException- If failed to add hfile references
-
startup
Start the replication -
terminate
End the replication- Parameters:
reason- why it's terminating
-
terminate
End the replication- Parameters:
reason- why it's terminatingcause- the error that's causing it
-
terminate
End the replication- Parameters:
reason- why it's terminatingcause- the error that's causing itclearMetrics- removes all metrics about this Source
-
getCurrentPath
org.apache.hadoop.fs.Path getCurrentPath()Get the current log that's replicated- Returns:
- the current log
-
getQueueId
Get the queue id that the source is replicating to- Returns:
- queue id
-
getPeerId
Get the id that the source is replicating to.- Returns:
- peer id
-
getPeer
Get the replication peer instance.- Returns:
- the replication peer instance
-
getStats
Get a string representation of the current statistics for this source- Returns:
- printable stats
-
isPeerEnabled
Returns peer enabled or not -
isSyncReplication
Returns whether this is sync replication peer. -
isSourceActive
boolean isSourceActive()Returns active or not -
getSourceMetrics
Returns metrics of this replication source -
getReplicationEndpoint
Returns the replication endpoint used by this replication source -
getSourceManager
Returns the replication source manager -
getWALFileLengthProvider
Returns the wal file length provider -
tryThrottle
Try to throttle when the peer config with a bandwidth- Parameters:
batchSize- entries size will be pushed- Throws:
InterruptedException
-
postShipEdits
Call this after the shipper thread ship some entries to peer cluster.- Parameters:
entries- pushedbatchSize- entries size pushed
-
getServerWALsBelongTo
The queue of WALs only belong to one region server. This will return the server name which all WALs belong to.- Returns:
- the server name which all WALs belong to
-
getWalGroupStatus
get the stat of replication for each wal group.- Returns:
- stat of replication
-
isRecovered
Returns whether this is a replication source for recovery. -
getReplicationQueueStorage
Returns The instance of queueStorage used by this ReplicationSource. -
logPositionAndCleanOldLogs
Log the current position to storage. Also clean old logs from the replication queue. Use to bypass the default call toReplicationSourceManager.logPositionAndCleanOldLogs(ReplicationSourceInterface, WALEntryBatch)whem implementation does not need to persist state to backing storage.- Parameters:
entryBatch- the wal entry batch we just shipped
-