Package org.nuxeo.lib.stream.log.kafka
Class KafkaUtils
java.lang.Object
org.nuxeo.lib.stream.log.kafka.KafkaUtils
- All Implemented Interfaces:
AutoCloseable
Misc Kafka Utils
- Since:
- 9.3
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static List<List<LogPartition>>
assignments
(org.apache.kafka.clients.consumer.ConsumerPartitionAssignor assignor, int threads, Map<String, Integer> streams) void
close()
void
createTopic
(String topic) Creates a topic with partitions and replications that default to broker configuration.void
createTopic
(String topic, int partitions) Creates a topic with replication factor that defaults to broker configuration.void
createTopic
(String topic, int partitions, short replicationFactor) Creates a topic with the given partitions and replication.void
createTopicWithoutReplication
(String topic, int partitions) boolean
void
Remove all existing consumers and their committed positions.void
deleteRecords
(String topic) Delete all records of a topic by moving the first offsets to end of each partition.static String
getConsumerTopics
(String group) static Properties
int
getNumberOfPartitions
(String topic) protected static Collection<org.apache.kafka.common.PartitionInfo>
getPartsFor
(String topic, int partitions) static boolean
listConsumers
(String topic) int
partitions
(String topic) static List<List<LogPartition>>
rangeAssignments
(int threads, Map<String, Integer> streams) static List<List<LogPartition>>
roundRobinAssignments
(int threads, Map<String, Integer> streams) boolean
topicExists
(String topic) boolean
topicReady
(String topic) protected void
waitForTopicCreation
(String topic, Duration timeout)
-
Field Details
-
BOOTSTRAP_SERVERS_PROP
- See Also:
-
DEFAULT_BOOTSTRAP_SERVERS
- See Also:
-
adminClient
protected final org.apache.kafka.clients.admin.AdminClient adminClient -
allConsumers
-
allConsumersTime
protected volatile long allConsumersTime -
ALL_CONSUMERS_CACHE_TIMEOUT_MS
protected static final long ALL_CONSUMERS_CACHE_TIMEOUT_MS- See Also:
-
ADMIN_CLIENT_CLOSE_TIMEOUT_S
protected static final long ADMIN_CLIENT_CLOSE_TIMEOUT_S- See Also:
-
-
Constructor Details
-
KafkaUtils
public KafkaUtils() -
KafkaUtils
-
-
Method Details
-
getDefaultAdminProperties
-
getBootstrapServers
-
kafkaDetected
public static boolean kafkaDetected() -
rangeAssignments
-
roundRobinAssignments
-
assignments
-
getPartsFor
protected static Collection<org.apache.kafka.common.PartitionInfo> getPartsFor(String topic, int partitions) -
createTopic
Creates a topic with partitions and replications that default to broker configuration.- Since:
- 2021.33
-
createTopic
Creates a topic with replication factor that defaults to broker configuration.- Since:
- 2021.33
-
createTopicWithoutReplication
-
createTopic
Creates a topic with the given partitions and replication. Since 2021.33 partitions (or replications) below 1 defaults to broker configuration. -
waitForTopicCreation
-
topicExists
-
topicReady
-
partitions
-
listTopics
-
listConsumers
-
getConsumerTopics
-
listAllConsumers
-
getNumberOfPartitions
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
delete
-
deleteRecords
Delete all records of a topic by moving the first offsets to end of each partition.- Since:
- 2021.43
-
deleteConsumers
public void deleteConsumers()Remove all existing consumers and their committed positions. For testing purpose.- Since:
- 2021.43
-