Versions Compared

Key

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

...

Code Block
languagejava
titlePartitionMetadata.java
public interface PartitionMetadata {

    /**
     * The node id of the node currently acting as a 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
     */
    List<Integer> replicas();

    /**
     * The subset of the replicas that are in sync, that is caught-up to the leader and ready to take over as leader if
     * the leader should fail. Note that there is no guarantee the first element is leader, please use leader()
     * to get the leader of partition.
     */
    List<Integer> inSyncReplicas();

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

...