Class AbstractPartitionDiscoverer
- Direct Known Subclasses:
KafkaPartitionDiscoverer
This partition discoverer base class implements the logic around bookkeeping discovered partitions, and using the information to determine whether or not there are new partitions that the consumer subtask should subscribe to.
Subclass implementations should simply implement the logic of using the version-specific Kafka clients to fetch topic and partition metadata.
Since Kafka clients are generally not thread-safe, partition discoverers should not be
concurrently accessed. The only exception for this would be the wakeup() call, which
allows the discoverer to be interrupted during a discoverPartitions() call.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDeprecated.Thrown if this discoverer was used to discover partitions after it was closed.static final classDeprecated.Signaling exception to indicate that an actual Kafka call was interrupted. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractPartitionDiscoverer(KafkaTopicsDescriptor topicsDescriptor, int indexOfThisSubtask, int numParallelSubtasks) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Deprecated.Closes the partition discoverer, cleaning up all Kafka connections.protected abstract voidDeprecated.Close all established connections.Deprecated.Execute a partition discovery attempt for this subtask.protected abstract List<KafkaTopicPartition> getAllPartitionsForTopics(List<String> topics) Deprecated.Fetch the list of all partitions for a specific topics list from Kafka.Deprecated.Fetch the list of all topics from Kafka.protected abstract voidDeprecated.Establish the required connections in order to fetch topics and partitions metadata.voidopen()Deprecated.Opens the partition discoverer, initializing all required Kafka connections.booleanDeprecated.Sets a partition as discovered.voidwakeup()Deprecated.Interrupt an in-progress discovery attempt by throwing aAbstractPartitionDiscoverer.WakeupException.protected abstract voidDeprecated.Attempt to eagerly wakeup from blocking calls to Kafka ingetAllTopics()andgetAllPartitionsForTopics(List).
-
Constructor Details
-
AbstractPartitionDiscoverer
public AbstractPartitionDiscoverer(KafkaTopicsDescriptor topicsDescriptor, int indexOfThisSubtask, int numParallelSubtasks) Deprecated.
-
-
Method Details
-
open
Deprecated.Opens the partition discoverer, initializing all required Kafka connections.NOTE: thread-safety is not guaranteed.
- Throws:
Exception
-
close
Deprecated.Closes the partition discoverer, cleaning up all Kafka connections.NOTE: thread-safety is not guaranteed.
- Throws:
Exception
-
wakeup
public void wakeup()Deprecated.Interrupt an in-progress discovery attempt by throwing aAbstractPartitionDiscoverer.WakeupException. If no attempt is in progress, the immediate next attempt will throw aAbstractPartitionDiscoverer.WakeupException.This method can be called concurrently from a different thread.
-
discoverPartitions
public List<KafkaTopicPartition> discoverPartitions() throws AbstractPartitionDiscoverer.WakeupException, AbstractPartitionDiscoverer.ClosedExceptionDeprecated.Execute a partition discovery attempt for this subtask. This method lets the partition discoverer update what partitions it has discovered so far.- Returns:
- List of discovered new partitions that this subtask should subscribe to.
- Throws:
AbstractPartitionDiscoverer.WakeupExceptionAbstractPartitionDiscoverer.ClosedException
-
setAndCheckDiscoveredPartition
Deprecated.Sets a partition as discovered. Partitions are considered as new if its partition id is larger than all partition ids previously seen for the topic it belongs to. Therefore, for a set of discovered partitions, the order that this method is invoked with each partition is important.If the partition is indeed newly discovered, this method also returns whether the new partition should be subscribed by this subtask.
- Parameters:
partition- the partition to set and check- Returns:
true, if the partition wasn't seen before and should be subscribed by this subtask;falseotherwise
-
initializeConnections
Deprecated.Establish the required connections in order to fetch topics and partitions metadata.- Throws:
Exception
-
wakeupConnections
protected abstract void wakeupConnections()Deprecated.Attempt to eagerly wakeup from blocking calls to Kafka ingetAllTopics()andgetAllPartitionsForTopics(List).If the invocation indeed results in interrupting an actual blocking Kafka call, the implementations of
getAllTopics()andgetAllPartitionsForTopics(List)are responsible of throwing aAbstractPartitionDiscoverer.WakeupException. -
closeConnections
Deprecated.Close all established connections.- Throws:
Exception
-
getAllTopics
Deprecated.Fetch the list of all topics from Kafka. -
getAllPartitionsForTopics
protected abstract List<KafkaTopicPartition> getAllPartitionsForTopics(List<String> topics) throws AbstractPartitionDiscoverer.WakeupException Deprecated.Fetch the list of all partitions for a specific topics list from Kafka.
-