Package org.apache.kafka.connect.mirror
Class MirrorClient
java.lang.Object
org.apache.kafka.connect.mirror.MirrorClient
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionMirrorClient
(Map<String, Object> props) MirrorClient
(MirrorClientConfig config) -
Method Summary
Modifier and TypeMethodDescriptionFinds all checkpoints topics on this cluster.void
close()
Closes internal clients.Finds all heartbeats topics on this cluster.remoteConsumerOffsets
(String consumerGroupId, String remoteClusterAlias, Duration timeout) Translates a remote consumer group's offsets into corresponding local offsets.Finds all remote topics on this cluster.remoteTopics
(String source) Finds all remote topics that have been replicated directly from the given source cluster.int
replicationHops
(String upstreamClusterAlias) Computes the shortest number of hops from an upstream source cluster.Gets theReplicationPolicy
instance used to interpret remote topics.Finds upstream clusters, which may be multiple hops away, based on incoming heartbeats.
-
Constructor Details
-
MirrorClient
-
MirrorClient
-
-
Method Details
-
close
public void close()Closes internal clients.- Specified by:
close
in interfaceAutoCloseable
-
replicationPolicy
Gets theReplicationPolicy
instance used to interpret remote topics. This instance is constructed based on relevant configuration properties, includingreplication.policy.class
. -
replicationHops
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
Finds all heartbeats topics on this cluster. Heartbeats topics are replicated from other clusters.- Throws:
InterruptedException
-
checkpointTopics
Finds all checkpoints topics on this cluster.- Throws:
InterruptedException
-
upstreamClusters
Finds upstream clusters, which may be multiple hops away, based on incoming heartbeats.- Throws:
InterruptedException
-
remoteTopics
Finds all remote topics on this cluster. This does not include internal topics (heartbeats, checkpoints).- Throws:
InterruptedException
-
remoteTopics
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 groupremoteClusterAlias
- The alias of remote clustertimeout
- The maximum time to block when consuming from the checkpoints topic
-