Interface PubSubAdminAdapter

    • 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.
      • 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.
      • 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 returned
        expectedResult - 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()