Versions Compared

Key

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

...

Code Block
languagejava
titleClusterMetadata.java
public interface ClusterMetadata {      
    
    /**
     * Get a maplist of brokers.
     * The key is the broker node ID, and the value is the metadataKafka broker node IDs in the cluster.
     */
    List<Integer> brokerIds();

    /**
     * associatedGet withspecific thatbroker brokerinformation.
     */
    Map<Integer, BrokerMetadata> brokers(Optional<BrokerMetadata> broker(int nodeId);

    /**
     * Get specific brokerpartition information.
     */
    Optional<BrokerMetadata>PartitionMetadata brokerpartition(intTopicPartition nodeIdtopicPartition);

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

    /**
     * Get partition information for aof specific node.
     * The key is the TopicPartition, and the value is the metadata
     * associated with that partition.
     * Return an empty map if the node does not exist.
     */
    Map<TopicPartition, PartitionMetadata> partitionsForNode(int nodeId);

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

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

    /**
     * Get ClusterResource, whichthat includes the cluster ID.id
     */
    ClusterResource clusterResource();

    /**
     * Given a partition metadata, return the subset of the replicas that are offline.
     * If there is no offline replica in the partition, return an empty array.
     */
    int[]List<Integer> offlineReplicas(PartitionMetadata partitionMetadata);
}

...

Code Block
languagejava
titlePartitionMetadata.java
public interface PartitionMetadata {

    /**
     * The node IDid of the node currently acting as thea leader for this partition or -1 if there is no leader.
     */
    int leader();

    /**
     * The complete set of replicas for this partition, regardless of whether they are alive or up-to-date.
     */
    int[]List<Integer> replicas();

    /**
     * The subset of the replicas that are in sync, meaningthat theyis arecaught-up up-to-dateto the leader and ready to take over as the leader if
     * the currentleader leadershould fails.fail
     */
    int[]List<Integer> inSyncReplicas();

    /**
     * Check if the partition is available.
     */
    default boolean isAvailable() {
        return leader() != Node.noNode().id();
    }
}

...