Versions Compared

Key

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

...

Code Block
languagejava
titleClusterMetadata.java
public interface ClusterMetadata {      
    
    /**
     * Get a list of Kafka broker node IDs in the cluster.
     */
    List<Integer> brokerIds();

    /**
     * Get specific broker information.
     */
    Optional<BrokerMetadata> broker(int nodeId);

    /**
     * Get specific partition information.
     */
    Optional<PartitionMetadata> partition(TopicPartition topicPartition);

    /**
     * Get partition information of specific topic.
     * The key is the partition id, and the value is the metadata
     * associated with that partition. 
     * Return an empty map if topic does not exist.
     */
    Map<Integer, PartitionMetadata> partitionsForTopicpartitions(String topic);

    /**
     * Get partition information of specific topic and specific node.
     * The key is the TopicPartitionpartition id, and the value is the metadata
     * associated with that partition.
     * Return an empty map if the topic or node id does not exist.
     */
    Map<TopicPartitionMap<Integer, PartitionMetadata> partitionsForNodepartitions(String topic, int nodeId);

    /**
     * Get a map of topics.
     * The key is the topic id, and the value is the topic name.
     */
    Map<Uuid, String> topics();

    /**
     * Get ClusterResource that includes cluster id
     */
    ClusterResource clusterResource();

    /**
     * Given a partition metadata, return the subset of the replicas that are offline.
     * Return an empty list if there is no offline replicas.
     */
    List<Integer> offlineReplicas(PartitionMetadata partitionMetadata);
}

...

For example, the implementation of ClusterMetadata#partitionsForTopicClusterMetadata#partitions(String) simply wraps the map returned by TopicImage.partitions().

...