Package com.linkedin.venice.pubsub.api
Interface PubSubAdminAdapter
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
ApacheKafkaAdminAdapter
,MockInMemoryAdminAdapter
public interface PubSubAdminAdapter extends java.io.Closeable
An adapter for PubSubAdmin to create/delete/list/update topics. For APIs that do not have a timeout parameter, the default timeout is specified byPubSubConstants.PUBSUB_ADMIN_API_DEFAULT_TIMEOUT_MS
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
containsTopic(PubSubTopic pubSubTopic)
Checks if a PubSub topic exists.default boolean
containsTopicWithExpectationAndRetry(PubSubTopic pubSubTopic, int maxAttempts, boolean expectedResult)
Retry up to a maximum number of attempts to get the expected result.default boolean
containsTopicWithExpectationAndRetry(PubSubTopic pubSubTopic, int maxAttempts, boolean expectedResult, java.time.Duration initialBackoff, java.time.Duration maxBackoff, java.time.Duration maxDuration)
boolean
containsTopicWithPartitionCheck(PubSubTopicPartition pubSubTopicPartition)
Checks if a PubSub topic exists and has the given partitiondefault boolean
containsTopicWithPartitionCheckExpectationAndRetry(PubSubTopicPartition pubSubTopicPartition, int maxAttempts, boolean expectedResult)
default boolean
containsTopicWithPartitionCheckExpectationAndRetry(PubSubTopicPartition pubSubTopicPartition, int maxAttempts, boolean expectedResult, java.time.Duration attemptDuration)
void
createTopic(PubSubTopic pubSubTopic, int numPartitions, int replicationFactor, PubSubTopicConfiguration pubSubTopicConfiguration)
Creates a new topic in the PubSub system with the given parameters.void
deleteTopic(PubSubTopic pubSubTopic, java.time.Duration timeout)
Delete a given topic.java.util.Map<PubSubTopic,java.lang.Long>
getAllTopicRetentions()
Retrieves the retention settings for all PubSub topics.java.lang.String
getClassName()
default java.util.List<java.lang.Class<? extends java.lang.Throwable>>
getRetriableExceptions()
java.util.Map<PubSubTopic,PubSubTopicConfiguration>
getSomeTopicConfigs(java.util.Set<PubSubTopic> pubSubTopics)
Retrieves the configurations for a set of PubSub topics.PubSubTopicConfiguration
getTopicConfig(PubSubTopic pubSubTopic)
Retrieves the configuration of a PubSub topic.default long
getTopicConfigMaxRetryInMs()
default PubSubTopicConfiguration
getTopicConfigWithRetry(PubSubTopic pubSubTopic)
java.util.Set<PubSubTopic>
listAllTopics()
Retrieves a set of all available PubSub topics from the PubSub cluster.void
setTopicConfig(PubSubTopic pubSubTopic, PubSubTopicConfiguration pubSubTopicConfiguration)
Sets the configuration for a PubSub topic.
-
-
-
Method Detail
-
createTopic
void createTopic(PubSubTopic pubSubTopic, int numPartitions, int replicationFactor, PubSubTopicConfiguration pubSubTopicConfiguration)
Creates a new topic in the PubSub system with the given parameters.- Parameters:
pubSubTopic
- The topic to be created.numPartitions
- The number of partitions to be created for the topic.replicationFactor
- The number of replicas for each partition.pubSubTopicConfiguration
- Additional topic configuration such as retention, compaction policy, etc.- Throws:
java.lang.IllegalArgumentException
- If the replication factor is invalid.PubSubTopicExistsException
- If a topic with the same name already exists.PubSubClientRetriableException
- If the operation failed due to a retriable error.PubSubClientException
- For all other issues related to the PubSub client.
-
deleteTopic
void deleteTopic(PubSubTopic pubSubTopic, java.time.Duration timeout)
Delete a given topic. The calling thread will block until the topic is deleted or the timeout is reached.- Parameters:
pubSubTopic
- The topic to delete.timeout
- The maximum duration to wait for the deletion to complete.- Throws:
PubSubTopicDoesNotExistException
- If the topic does not exist.PubSubOpTimeoutException
- If the operation times out.PubSubClientRetriableException
- If the operation fails and can be retried.PubSubClientException
- For all other issues related to the PubSub client.
-
getTopicConfig
PubSubTopicConfiguration getTopicConfig(PubSubTopic pubSubTopic)
Retrieves the configuration of a PubSub topic.- Parameters:
pubSubTopic
- The PubSubTopic for which to retrieve the configuration.- Returns:
- The configuration of the specified PubSubTopic as a PubSubTopicConfiguration object.
- Throws:
PubSubTopicDoesNotExistException
- If the specified PubSubTopic topic does not exist.PubSubClientRetriableException
- If a retriable error occurs while attempting to retrieve the configuration.PubSubClientException
- If an error occurs while attempting to retrieve the configuration or if the current thread is interrupted while attempting to retrieve the configuration.
-
getTopicConfigWithRetry
default PubSubTopicConfiguration getTopicConfigWithRetry(PubSubTopic pubSubTopic)
-
listAllTopics
java.util.Set<PubSubTopic> listAllTopics()
Retrieves a set of all available PubSub topics from the PubSub cluster.- Returns:
- A Set of PubSubTopic objects representing all available topics.
- Throws:
PubSubClientRetriableException
- If a retriable error occurs while attempting to retrieve the list of topics.PubSubClientException
- If an error occurs while attempting to retrieve the list of topics or the current thread is interrupted while attempting to retrieve the list of topics.
-
setTopicConfig
void setTopicConfig(PubSubTopic pubSubTopic, PubSubTopicConfiguration pubSubTopicConfiguration) throws PubSubTopicDoesNotExistException
Sets the configuration for a PubSub topic.- Parameters:
pubSubTopic
- The PubSubTopic for which to set the configuration.pubSubTopicConfiguration
- The configuration to be set for the specified PubSub topic.- Throws:
PubSubTopicDoesNotExistException
- If the specified PubSub topic does not exist.PubSubClientException
- If an error occurs while attempting to set the topic configuration or if the current thread is interrupted while attempting to set the topic configuration.
-
containsTopic
boolean containsTopic(PubSubTopic pubSubTopic)
Checks if a PubSub topic exists.- Parameters:
pubSubTopic
- The PubSubTopic to check for existence.- Returns:
- true if the specified topic exists, false otherwise.
- Throws:
PubSubClientRetriableException
- If a retriable error occurs while attempting to check topic existence.PubSubClientException
- If an error occurs while attempting to check topic existence.
-
containsTopicWithPartitionCheck
boolean containsTopicWithPartitionCheck(PubSubTopicPartition pubSubTopicPartition)
Checks if a PubSub topic exists and has the given partition- Parameters:
pubSubTopicPartition
- The PubSubTopicPartition representing th topic and partition to check.- Returns:
- true if the specified topic partition exists, false otherwise.
- Throws:
PubSubClientRetriableException
- If a retriable error occurs while attempting to check partition existence.PubSubClientException
- If an error occurs while attempting to check partition existence or of the current thread is interrupted while attempting to check partition existence.
-
containsTopicWithExpectationAndRetry
default boolean containsTopicWithExpectationAndRetry(PubSubTopic pubSubTopic, int maxAttempts, boolean expectedResult)
Retry up to a maximum number of attempts to get the expected result. If the topic existence check returns with expected result, return the expected result immediately instead of retrying. This method exists since Kafka metadata is eventually consistent so that it takes time for all Kafka brokers to learn about a topic creation takes. So checking multiple times give us a more certain result of whether a topic exists.- Parameters:
pubSubTopic
-maxAttempts
- maximum number of attempts to check if no expected result is returnedexpectedResult
- expected result- Returns:
-
containsTopicWithPartitionCheckExpectationAndRetry
default boolean containsTopicWithPartitionCheckExpectationAndRetry(PubSubTopicPartition pubSubTopicPartition, int maxAttempts, boolean expectedResult)
-
containsTopicWithExpectationAndRetry
default boolean containsTopicWithExpectationAndRetry(PubSubTopic pubSubTopic, int maxAttempts, boolean expectedResult, java.time.Duration initialBackoff, java.time.Duration maxBackoff, java.time.Duration maxDuration)
-
containsTopicWithPartitionCheckExpectationAndRetry
default boolean containsTopicWithPartitionCheckExpectationAndRetry(PubSubTopicPartition pubSubTopicPartition, int maxAttempts, boolean expectedResult, java.time.Duration attemptDuration)
-
getRetriableExceptions
default java.util.List<java.lang.Class<? extends java.lang.Throwable>> getRetriableExceptions()
- Returns:
- Returns a list of exceptions that are retriable for this PubSubClient.
-
getAllTopicRetentions
java.util.Map<PubSubTopic,java.lang.Long> getAllTopicRetentions()
Retrieves the retention settings for all PubSub topics.- Returns:
- A map of pub-sub topics and their corresponding retention settings in milliseconds.
If a topic does not have a retention setting, it will be mapped to
PubSubConstants.PUBSUB_TOPIC_UNKNOWN_RETENTION
. - Throws:
PubSubClientRetriableException
- If a retriable error occurs while attempting to retrieve retention settings.PubSubClientException
- If an error occurs while attempting to retrieve retention settings or if the current thread is interrupted while attempting to retrieve retention settings.
-
getClassName
java.lang.String getClassName()
-
getSomeTopicConfigs
java.util.Map<PubSubTopic,PubSubTopicConfiguration> getSomeTopicConfigs(java.util.Set<PubSubTopic> pubSubTopics)
Retrieves the configurations for a set of PubSub topics.- Parameters:
pubSubTopics
- The set of PubSub topics to retrieve configurations for.- Returns:
- A map of PubSub topics and their corresponding configurations.
- Throws:
PubSubClientRetriableException
- If a retriable error occurs while attempting to retrieve configurations.PubSubClientException
- If an error occurs while attempting to retrieve configurations or if the current thread is interrupted while attempting to retrieve configurations.
-
getTopicConfigMaxRetryInMs
default long getTopicConfigMaxRetryInMs()
-
-