public class KafkaUtils
extends java.lang.Object
Constructor and Description |
---|
KafkaUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
waitForTopic(java.lang.String topic,
int numPartitions,
org.apache.kafka.common.utils.Time time,
java.time.Duration timeout,
java.util.function.Function<java.lang.String,java.util.Set<java.lang.Integer>> describeTopic,
java.util.function.Consumer<java.lang.String> createTopic)
Waits for full partition metadata for topic with `numPartitions` partitions to be available.
|
public static void waitForTopic(java.lang.String topic, int numPartitions, org.apache.kafka.common.utils.Time time, java.time.Duration timeout, java.util.function.Function<java.lang.String,java.util.Set<java.lang.Integer>> describeTopic, java.util.function.Consumer<java.lang.String> createTopic)
topic
- Name of topic to wait fornumPartitions
- Expected number of partitionstime
- Instance of time used for timeouttimeout
- Timeout durationdescribeTopic
- Topic describe function that returns set of partitions returned
from a metadata request. Returned set may be empty.createTopic
- Function used to create topic. If null, topic is not created and
this method just waits for topic to be available.java.lang.IllegalStateException
- if the actual number of partitions exceeds `numPartitions`org.apache.kafka.common.errors.TimeoutException
- if partition metadata for all of `numPartitions` partitions are
not available within timeoutorg.apache.kafka.common.KafkaException
- if describe or create fails with an non-retriable exception