Class PrimaryTerm
public class PrimaryTerm extends Object
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 Summary
Constructors Constructor Description PrimaryTerm(long term, GroupMember primary, List<GroupMember> candidates) -
Method Summary
Modifier and Type Method Description List<GroupMember>backups(int numBackups)Returns an ordered list of backup members.List<GroupMember>candidates()Returns the list of members.booleanequals(Object object)inthashCode()GroupMemberprimary()Returns the primary member.longterm()Returns the primary term number.StringtoString()
-
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
Returns the primary member.The primary is the node through which writes are replicated in the primary-backup protocol.
- Returns:
- the primary member
-
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
backupsbased on a primitive configuration.- Returns:
- the list of members
-
backups
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 duplicateMemberGroups 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() -
equals
-
toString
-