Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
public interface AdminClient extends AutoCloseable {
    static AdminClient create(Map<String, Object> conf);

    /**
     * Close the AdminClient and release all associated resources.
     */
    void close();

    /**
     * Create a singlebatch of new topictopics with the default options.
     *
     * @param newTopicnewTopics          The new topictopics to create.
     * @return                  The CreateTopicsResults.
     */
    CreateTopicResults createTopiccreateTopics(NewTopicCollection<NewTopic> newTopicnewTopics);

    /**
     * Create a batch singleof new topictopics.
     *
     * @param newTopicnewTopics          The new topictopics to create.
     * @param options           The options to use when creating the new topictopics.
     * @return                  The CreateTopicsResults.
     */
    CreateTopicResults createTopiccreateTopics(NewTopicCollection<NewTopic> newTopicnewTopics, CreateTopicsOptions options);

    /**
     * Create a batch of new topics with Similar to #{@link AdminClient#deleteTopics(Collection<String>, DeleteTopicsOptions),
     * but uses the default options.
      *
     * @param newTopicstopics            The newtopic topicsnames to createdelete.
     * @return                  The CreateTopicsResultsDeleteTopicsResults.
     */
    CreateTopicResultsDeleteTopicResults createTopicsdeleteTopics(Collection<NewTopic>Collection<String> newTopicstopics);

    /**
     * CreateDelete a batch of new topics.
     *
     * @paramIt newTopicsmay take several seconds after AdminClient#deleteTopics returns
   The new topics* tosuccess create.
for all the brokers to *become @paramaware optionsthat the topics are gone. 
     * TheDuring optionsthis totime, useAdminClient#listTopics when creating the new topics.and AdminClient#describeTopic
     * @returnmay continue to return information about the            The CreateTopicsResults.
     */
    CreateTopicResults createTopics(Collection<NewTopic> newTopics, CreateTopicsOptions options);

deleted topics.
     /**
     * Delete a topic with the default options.
     *
     * @param topic             The topic name to delete.
     * @return                  The DeleteTopicsResults.
     */
    DeleteTopicResults deleteTopic(String topic);

    /**
     * Delete a topic.
     *
     * @param topic             The topic name to delete.
     * @param options           The options to use when deleting the topics.
     * @return                  The DeleteTopicsResults.
     */
    DeleteTopicResults deleteTopic(String topic, DeleteTopicsOptions options);

    /**
     * Similar to #{@link AdminClient#deleteTopics(Collection<String>, DeleteTopicsOptions),
     * but uses the default options.
     *
     * @param topics            The topic names to delete.
     * @return                  The DeleteTopicsResults.
     */
    DeleteTopicResults deleteTopics(Collection<String> topics);

    /**
     * Delete a batch of topics.
     *
     * It may take several seconds after AdminClient#deleteTopics returns
     * success for all the brokers to become aware that the topics are gone. 
     * During this time, AdminClient#listTopics and AdminClient#describeTopic
     * may continue to return information about the deleted topics.
     *
     * If delete.topic.enable is false on the brokers, deleteTopics will mark
     * the topics for deletion, but not actually delete them.  The futures will
     * return successfully in this case.
     *
     * @param topics            The topic names to delete.
     * @param options           The options to use when deleting the topics.
     * @return                  The DeleteTopicsResults.
     */
    DeleteTopicResults deleteTopics(Collection<String> topics, DeleteTopicsOptions options);

    /**
     * List the topics available in the cluster with the default options.
     * @return                  The ListTopicsResults.If delete.topic.enable is false on the brokers, deleteTopics will mark
     * the topics for deletion, but not actually delete them.  The futures will
     */
 return successfully in ListTopicsResults listTopics();

this case.
    / **
     * List the topics available in the cluster.
     * @param topics            The topic names to delete.
     * @param options           The options to use when listingdeleting the topics.
     * @return                  The ListTopicsResultsDeleteTopicsResults.
     */
    ListTopicsResultsDeleteTopicResults listTopics(ListTopicsOptionsdeleteTopics(Collection<String> topics, DeleteTopicsOptions options);

    /**
     * SimilarList tothe {@link AdminClient#describeTopic(String, DescribeTopicOptions)},
     * but uses the default options.
     *
     * @param topicName         The topic to describetopics available in the cluster with the default options.
     * @return                  The DescribeTopicResultsListTopicsResults.
     */
    DescribeTopicResultsListTopicsResults describeTopiclistTopics(String topicName);

    /**
     * DescripeList anthe individualtopics topicavailable in the cluster.
     *
     * Note@param thatoptions if auto.create.topics.enable is true on the brokers,
     * AdminClient#describeTopic(topicName) may create a topic named topicNameThe options to use when listing the topics.
     * @return  There are two workarounds: either use AdminClient#listTopics and ensure
     * that the topicThe isListTopicsResults.
 present before describing, or disable*/
    ListTopicsResults * auto.create.topics.enable.listTopics(ListTopicsOptions options);

     /**
      * @paramSimilar topicNameto {@link AdminClient#describeTopic(String, DescribeTopicOptions)},
     * but Theuses topicthe todefault describeoptions.
     *
 @param options   * @param topicName      The options to use when describing theThe topic to describe.
     * @return                  The DescribeTopicResults.
     */
    DescribeTopicResults describeTopic(String topicName, DescribeTopicOptions options);

    /**
     * Descripe an individual topic in the cluster.
     *
     * Describe the cluster information, using the default options Note that if auto.create.topics.enable is true on the brokers,
     * AdminClient#describeTopic(topicName) may create a topic named topicName.
     *
 There are two workarounds: *either @returnuse AdminClient#listTopics and ensure
     * that the topic is present before describing, or  The ListNodesResults.disable
     */ auto.create.topics.enable.
    DescribeClusterResults describeCluster();*

    /* *
 @param topicName   * Describe the cluster information.
  The topic to *describe.
     * @param options           The options to use when describing the clustertopic.
     * @return                  The ListNodesResultsDescribeTopicResults.
     */
    DescribeClusterResultsDescribeTopicResults describeCluster(DescribeClusterOptionsdescribeTopic(String topicName, DescribeTopicOptions options);

    /**
     * Get information aboutDescribe the apicluster versions of a node in the cluster withinformation, using the default options.
     *
     * @param nodes             The node to get information about. options.
     *
     * @return                  The ApiVersionsResultsListNodesResults.
     */
    ApiVersionsResultsDescribeClusterResults apiVersiondescribeCluster(Node node, );

    /**
     * Get informationDescribe about the api versions of a node in the cluster.
     *
     * @param nodes             The node to get information about.cluster information.
     *
     * @param options           The options to use when getting api versions of describing the nodecluster.
     * @return                  The ApiVersionsResultsListNodesResults.
     */
    ApiVersionsResultsDescribeClusterResults apiVersiondescribeCluster(NodeDescribeClusterOptions node, ApiVersionsOptions options);

    /**
     * Get information about the api versions of nodes in the cluster with the default options.
     *
     * @param nodes             The nodes to get information about.
     * @return                  The ApiVersionsResults.
     */
    ApiVersionsResults apiVersions(Collection<Node> nodes);

    /**
     * Get information about the api versions of nodes in the cluster.
     *
     * @param nodes             The nodes to get information about.
     * @param options           The options to use when getting api versions of the nodes.
     * @return                  The ApiVersionsResults.
     */
    ApiVersionsResults apiVersions(Collection<Node> nodes, ApiVersionsOptions options);
}

/**
 * The base class for a request to create a new topic.
 */
abstract class NewTopic {
    public NewTopic(String name, int numPartitions, short replicationFactor);
    public NewTopic(String name, Map<Integer, List<Integer>> replicasAssignments);

    public String name();

    /**
      * Set the configuration to use on the new topic.
      *
      * @param configs               The configuration map.
      * @return                      This NewTopic object.
      */
    public NewTopic setConfigs(Map<String, String> configs);
}

 /**
  * Options for the newTopics call.
  */
class CreateTopicsOptions {
    private intInteger timeoutMs = -1null;
    private boolean validateOnly = false;
    public CreateTopicsOptions setTimeoutMs(int timeoutMs);
    public CreateTopicsOptions setValidateOnly(boolean validateOnly);
    public boolean validateOnly();
}

/**
  * The result of the createTopics call.
  */
class CreateTopicResults {
    /**
      * Return a map from topic names to futures, which can be used to check the status of individual
      * topic creations.
      */
    public Map<String, CompletableFuture<Void>>KafkaFuture<Void>> results();
 
    /**
      * Return a future which succeeds if all the topic creations succeed.
      */
    public CompletableFuture<Void>KafkaFuture<Void> all();
}

/**
  * Options for the deleteTopics call.
  */
class DeleteTopicsOptions {
    private intInteger timeoutMs = -1null;
    public DeleteTopicsOptions setTimeoutMs(int timeoutMs);
    public int timeoutMs();
}
 
/**
  * The result of the deleteTopics call.
  */
class DeleteTopicResults {
    /**
      * Return a map from topic names to futures which can be used to check the status of
      * individual deletions.
      */
    public Map<String, CompletableFuture<Void>>KafkaFuture<Void>> results();

    /**
      * Return a future which succeeds only if all the topic deletions succeed.
      */
    public CompletableFuture<Void>KafkaFuture<Void> all();
}

class ListTopicsOptions {
    private intInteger timeoutMs = -1null;
    private boolean listInternal = true;
    public ListTopicsOptions setTimeoutMs(intInteger timeoutMs);
    public intInteger timeoutMs();

    /**
      * Set whether we should list internal topics.
      *
      * @param listInternal  Whether we should list internal topics.
      * @return              This ListTopicsOptions object.
      */
    public ListTopicsOptions setListInternal(boolean listInternal);

    public boolean listInternal();
}
 
/**
  * The result of the listTopics call.
  */
class ListTopicsResults {
    /**
      * Return a future which yields a map of topic names to TopicListing objects.
      */
    public CompletableFuture<Map<StringKafkaFuture<Map<String, TopicListing>> namesToDescriptions();

    /**
      * Return a future which yields a collection of TopicListing objects.
      */
    public CompletableFuture<Collection<TopicListing>>KafkaFuture<Collection<TopicListing>> descriptions();

    /**
      * Return a future which yields a collection of topic names.
      */
    public CompletableFuture<Collection<String>>KafkaFuture<Collection<String>> names();
}

class TopicListing {
    public String name();
    public boolean internal();
}

/**
  * A detailed description of a single topic in the cluster.
  */
class TopicDescription {
    public String name();
    public boolean internal();
    public Map<Integer, TopicPartitionInfo> partitions();
    public String toString();
}

class TopicPartitionInfo {
    public int partition();
    public Node leader();
    public List<Node> replicas();
    public List<Node> isr();
    public String toString();
}
 
class DescribeTopicsOptions {
    public DescribeTopicOptions setTimeoutMs(int timeoutMs);
    public int timeoutMs();
}

/**
  * The results of the describeTopic call.
  */
class DescribeTopicResults {
    /**
      * Return a future which yields a map of topic names to TopicDescription objects.
      */
    public CompletableFuture<Map<String, TopicDescription>> namesToDescriptions();

    /**
      * Return a future which yields a collection of TopicDescription objects.
      */
    public CompletableFuture<Collection<TopicDescription>> descriptions();
}

/**
  * Options for the listNodes call.
  */
class DescribeClusterOptions {
    public DescribeClusterOptions setTimeoutMs(intInteger timeoutMs);
    public intInteger timeoutMs();
}

/**
  * The results of the describeCluster call.
  */
class DescribeClusterOptionsResults {
    public CompletableFuture<Collection<Node>> nodes();
    public CompletableFuture<Node> controller();
    public CompletableFuture<String> clusterId();
}

/**
  * Options for the apiVersions call.
  */
class ApiVersionsOptions {
    public ApiVersionsOptions timeoutMs(intInteger timeoutMs);
    public intInteger timeoutMs();
}

/**
  * Results of the apiVersions call.
  */
class ApiVersionsResults {
    ApiVersionsResults(Map<Node, CompletableFuture<NodeApiVersions>>KafkaFuture<NodeApiVersions>> futures);
    public Map<Node, CompletableFuture<NodeApiVersions>>KafkaFuture<NodeApiVersions>> results();
    public CompletableFuture<Map<NodeKafkaFuture<Map<Node, NodeApiVersions>> all();
}


...