Interface ReplicationSourceInterface

All Known Implementing Classes:
RecoveredReplicationSource, ReplicationSource

@Private public interface ReplicationSourceInterface
Interface that defines a replication source
  • 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 use
      fs - the file system to use
      manager - the manager to use
      queueStorage - the replication queue storage
      replicationPeer - the replication peer
      server - the server for this region server
      queueData - the existing replication queue data, contains the queue id and replication start offsets
      clusterId - the cluster id
      walFileLengthProvider - for getting the length of the WAL file which is currently being written
      metrics - the replication metrics
      Throws:
      IOException
    • enqueueLog

      void enqueueLog(org.apache.hadoop.fs.Path log)
      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 ReplicationException
      Add hfile names to the queue to be replicated.
      Parameters:
      tableName - Name of the table these files belongs to
      family - Name of the family these files belong to
      pairs - 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

      void terminate(String reason)
      End the replication
      Parameters:
      reason - why it's terminating
    • terminate

      void terminate(String reason, Exception cause)
      End the replication
      Parameters:
      reason - why it's terminating
      cause - the error that's causing it
    • terminate

      void terminate(String reason, Exception cause, boolean clearMetrics)
      End the replication
      Parameters:
      reason - why it's terminating
      cause - the error that's causing it
      clearMetrics - 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

      default String 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

      default boolean isPeerEnabled()
      Returns peer enabled or not
    • isSyncReplication

      default boolean 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

      void tryThrottle(int batchSize) throws InterruptedException
      Try to throttle when the peer config with a bandwidth
      Parameters:
      batchSize - entries size will be pushed
      Throws:
      InterruptedException
    • postShipEdits

      void postShipEdits(List<WAL.Entry> entries, long batchSize)
      Call this after the shipper thread ship some entries to peer cluster.
      Parameters:
      entries - pushed
      batchSize - 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

      default boolean isRecovered()
      Returns whether this is a replication source for recovery.
    • getReplicationQueueStorage

      Returns The instance of queueStorage used by this ReplicationSource.
    • logPositionAndCleanOldLogs

      default void logPositionAndCleanOldLogs(WALEntryBatch entryBatch)
      Log the current position to storage. Also clean old logs from the replication queue. Use to bypass the default call to ReplicationSourceManager.logPositionAndCleanOldLogs(ReplicationSourceInterface, WALEntryBatch) whem implementation does not need to persist state to backing storage.
      Parameters:
      entryBatch - the wal entry batch we just shipped