Package org.apache.kafka.connect.mirror
Class RemoteClusterUtils
java.lang.Object
org.apache.kafka.connect.mirror.RemoteClusterUtils
Convenience tool for multi-cluster environments. Wraps
MirrorClient
Properties passed to these methods are used to construct internal Admin
and Consumer
clients.
Sub-configs like "admin.xyz" are also supported. For example:
bootstrap.servers = host1:9092 consumer.client.id = mm2-client
-
Method Summary
Modifier and TypeMethodDescriptioncheckpointTopics
(Map<String, Object> properties) Finds all checkpoints topicsheartbeatTopics
(Map<String, Object> properties) Finds all heartbeats topicsstatic int
replicationHops
(Map<String, Object> properties, String upstreamClusterAlias) Finds the shortest number of hops from an upstream cluster.static Map<TopicPartition,
OffsetAndMetadata> translateOffsets
(Map<String, Object> properties, String remoteClusterAlias, String consumerGroupId, Duration timeout) Translates a remote consumer group's offsets into corresponding local offsets.upstreamClusters
(Map<String, Object> properties) Finds all upstream clusters
-
Method Details
-
replicationHops
public static int replicationHops(Map<String, Object> properties, String upstreamClusterAlias) throws InterruptedException, TimeoutExceptionFinds the shortest number of hops from an upstream cluster. Returns -1 if the cluster is unreachable.- Throws:
InterruptedException
TimeoutException
-
heartbeatTopics
public static Set<String> heartbeatTopics(Map<String, Object> properties) throws InterruptedException, TimeoutExceptionFinds all heartbeats topics- Throws:
InterruptedException
TimeoutException
-
checkpointTopics
public static Set<String> checkpointTopics(Map<String, Object> properties) throws InterruptedException, TimeoutExceptionFinds all checkpoints topics- Throws:
InterruptedException
TimeoutException
-
upstreamClusters
public static Set<String> upstreamClusters(Map<String, Object> properties) throws InterruptedException, TimeoutExceptionFinds all upstream clusters- Throws:
InterruptedException
TimeoutException
-
translateOffsets
public static Map<TopicPartition,OffsetAndMetadata> translateOffsets(Map<String, Object> properties, String remoteClusterAlias, String consumerGroupId, Duration timeout) throws InterruptedException, TimeoutExceptionTranslates a remote consumer group's offsets into corresponding local offsets. Topics are automatically renamed according to the configuredReplicationPolicy
.- Parameters:
properties
- Map of properties to instantiate aMirrorClient
remoteClusterAlias
- The alias of the remote clusterconsumerGroupId
- The group ID of remote consumer grouptimeout
- The maximum time to block when consuming from the checkpoints topic- Throws:
InterruptedException
TimeoutException
-