Interface RaftMember
- All Known Implementing Classes:
DefaultRaftMember
This interface provides metadata and operations related to a specific member of a Raft
cluster. Each server in a RaftCluster has a view of the cluster state and can reference
and operate on specific members of the cluster via this API.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumIndicates how the member participates in voting and replication. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTypeChangeListener(Consumer<RaftMember.Type> listener) Adds a listener to be called when the member's type changes.demote()Demotes the member to the next lowest type.demote(RaftMember.Type type) Demotes the member to the given type.Returns the time at which the member was updated.getType()Returns the member type.inthash()Returns the member hash.memberId()Returns the member node ID.promote()Promotes the member to the next highest type.promote(RaftMember.Type type) Promotes the member to the given type.remove()Removes the member from the configuration.
-
Method Details
-
memberId
MemberId memberId()Returns the member node ID.- Returns:
- The member node ID.
-
hash
int hash()Returns the member hash.- Returns:
- The member hash.
-
addTypeChangeListener
Adds a listener to be called when the member's type changes.The type change callback will be called when the local server receives notification of the change in type to this member. Type changes may occur at different times from the perspective of different servers but are guaranteed to occur in the same order on all servers.
- Parameters:
listener- The listener to be called when the member's type changes.
-
promote
CompletableFuture<Void> promote()Promotes the member to the next highest type.If the member is promoted to
RaftMember.Type.ACTIVEthe Raft quorum size will increase.- Returns:
- A completable future to be completed once the member has been promoted.
-
promote
Promotes the member to the given type.If the member is promoted to
RaftMember.Type.ACTIVEthe Raft quorum size will increase.- Parameters:
type- The type to which to promote the member.- Returns:
- A completable future to be completed once the member has been promoted.
-
demote
CompletableFuture<Void> demote()Demotes the member to the next lowest type.If the member is an
RaftMember.Type.ACTIVEmember then demoting it will impact the Raft quorum size.- Returns:
- A completable future to be completed once the member has been demoted.
-
demote
Demotes the member to the given type.If the member is an
RaftMember.Type.ACTIVEmember then demoting it will impact the Raft quorum size.- Parameters:
type- The type to which to demote the member.- Returns:
- A completable future to be completed once the member has been demoted.
-
remove
CompletableFuture<Void> remove()Removes the member from the configuration.If the member is a part of the current Raft quorum (is an
RaftMember.Type.ACTIVEmember) then the quorum will be impacted by removing the member.- Returns:
- A completable future to be completed once the member has been removed from the configuration.
-
getLastUpdated
Instant getLastUpdated()Returns the time at which the member was updated.The member update time is not guaranteed to be consistent across servers or consistent across server restarts. The update time is guaranteed to be monotonically increasing.
- Returns:
- The time at which the member was updated.
-
getType
RaftMember.Type getType()Returns the member type.The member type is indicative of the member's level of participation in the Raft consensus algorithm and asynchronous replication within the cluster. Member types may change throughout the lifetime of the cluster. Types can be changed by
promotingordemotingthe member. Member types for a given member are guaranteed to change in the same order on all nodes, but the type of a member may be different from the perspective of different nodes at any given time.- Returns:
- The member type.
-