Interface ReplicationSourceInterface
- All Known Implementing Classes:
CatalogReplicationSource
,RecoveredReplicationSource
,ReplicationSource
Interface that defines a replication source
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addHFileRefs
(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.void
enqueueLog
(org.apache.hadoop.fs.Path log) Add a log to the list of logs to replicateorg.apache.hadoop.fs.Path
Get the current log that's replicatedGet 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.void
init
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, ReplicationSourceManager manager, ReplicationQueueStorage queueStorage, ReplicationPeer replicationPeer, Server server, String queueId, UUID clusterId, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics) Initializer for the sourceboolean
Returns peer enabled or notdefault boolean
Returns whether this is a replication source for recovery.boolean
Returns active or notdefault void
logPositionAndCleanOldLogs
(WALEntryBatch entryBatch) Log the current position to storage.void
postShipEdits
(List<WAL.Entry> entries, long batchSize) Call this after the shipper thread ship some entries to peer cluster.startup()
Start the replicationvoid
End the replicationvoid
End the replicationvoid
End the replicationvoid
tryThrottle
(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, String queueId, 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 useserver
- the server for this region server- 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
-
getStats
Get a string representation of the current statistics for this source- Returns:
- printable stats
-
isPeerEnabled
boolean isPeerEnabled()Returns peer enabled or not -
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
-