Class MirrorClient

java.lang.Object
org.apache.kafka.connect.mirror.MirrorClient
All Implemented Interfaces:
AutoCloseable

public class MirrorClient extends Object implements AutoCloseable
Client to interact with MirrorMaker internal topics (checkpoints, heartbeats) on a given cluster. Whenever possible use the methods from RemoteClusterUtils instead of directly using MirrorClient.
  • Constructor Details

  • Method Details

    • close

      public void close()
      Closes internal clients.
      Specified by:
      close in interface AutoCloseable
    • replicationPolicy

      public ReplicationPolicy replicationPolicy()
      Gets the ReplicationPolicy instance used to interpret remote topics. This instance is constructed based on relevant configuration properties, including replication.policy.class.
    • replicationHops

      public int replicationHops(String upstreamClusterAlias) throws InterruptedException
      Computes the shortest number of hops from an upstream source cluster. For example, given replication flow A->B->C, there are two hops from A to C. Returns -1 if the upstream cluster is unreachable.
      Throws:
      InterruptedException
    • heartbeatTopics

      public Set<String> heartbeatTopics() throws InterruptedException
      Finds all heartbeats topics on this cluster. Heartbeats topics are replicated from other clusters.
      Throws:
      InterruptedException
    • checkpointTopics

      public Set<String> checkpointTopics() throws InterruptedException
      Finds all checkpoints topics on this cluster.
      Throws:
      InterruptedException
    • upstreamClusters

      public Set<String> upstreamClusters() throws InterruptedException
      Finds upstream clusters, which may be multiple hops away, based on incoming heartbeats.
      Throws:
      InterruptedException
    • remoteTopics

      public Set<String> remoteTopics() throws InterruptedException
      Finds all remote topics on this cluster. This does not include internal topics (heartbeats, checkpoints).
      Throws:
      InterruptedException
    • remoteTopics

      public Set<String> remoteTopics(String source) throws InterruptedException
      Finds all remote topics that have been replicated directly from the given source cluster.
      Throws:
      InterruptedException
    • remoteConsumerOffsets

      public Map<TopicPartition,OffsetAndMetadata> remoteConsumerOffsets(String consumerGroupId, String remoteClusterAlias, Duration timeout)
      Translates a remote consumer group's offsets into corresponding local offsets. Topics are automatically renamed according to the ReplicationPolicy.
      Parameters:
      consumerGroupId - The group ID of remote consumer group
      remoteClusterAlias - The alias of remote cluster
      timeout - The maximum time to block when consuming from the checkpoints topic