Class PrimaryTerm

java.lang.Object
io.atomix.primitive.partition.PrimaryTerm

public class PrimaryTerm
extends Object
Partition primary term.

The primary term represents a single instance of a unique primary for a partition. Every term must have a unique term() number, and term numbers must be monotonically increasing, though not necessarily sequential. The candidates() should either list the set of non-primary members in order of priority such that the default backups(int) implementation can properly select backups or else backups(int) should be overridden.

  • Constructor Details

  • Method Details

    • term

      public long term()
      Returns the primary term number.

      The term number is monotonically increasing and guaranteed to be unique for a given primary(). No two primaries may ever have the same term.

      Returns:
      the primary term number
    • primary

      public GroupMember primary()
      Returns the primary member.

      The primary is the node through which writes are replicated in the primary-backup protocol.

      Returns:
      the primary member
    • candidates

      public List<GroupMember> candidates()
      Returns the list of members.

      The candidate list represents the list of members that are participating in the election but not necessarily in replication. This list is used to select a set of backups based on a primitive configuration.

      Returns:
      the list of members
    • backups

      public List<GroupMember> backups​(int numBackups)
      Returns an ordered list of backup members.

      The backups are populated from the set of candidates() based on order and group information. The list of backups is guaranteed not to contain any duplicate MemberGroups unless not enough groups exist to satisfy the number of backups.

      Parameters:
      numBackups - the number of backups to return
      Returns:
      an ordered list of backup members
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object