Package org.kiwiproject.curator.leader
Interface LeadershipStatus
- All Known Subinterfaces:
LeadershipStatus.ErrorLeadershipStatus,LeadershipStatus.ValidLeadershipStatus
- All Known Implementing Classes:
LeadershipStatus.CuratorNotStarted,LeadershipStatus.IsLeader,LeadershipStatus.LatchNotStarted,LeadershipStatus.NoLatchParticipants,LeadershipStatus.NotLeader,LeadershipStatus.OtherError
public sealed interface LeadershipStatus
permits LeadershipStatus.ErrorLeadershipStatus, LeadershipStatus.ValidLeadershipStatus
Defines a type that can be returned when checking if a
LeaderLatch
has leadership, taking into account the various issues that can cause problems.
There are two sub-interfaces, LeadershipStatus.ValidLeadershipStatus and
LeadershipStatus.ErrorLeadershipStatus, each of which has several record implementations.
This allows you to determine whether the return value is a valid status or if
there is some kind of error.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordRepresents an invalid latch state; Curator is not in theSTARTEDstate.static interfaceDefines an invalid leadership status caused by an error or erroneous state.static final recordRepresents a valid latch state, where the participant is the current leader.static final recordRepresents an invalid latch state; the LeaderLatch is not in theSTARTEDstate.static final recordRepresents an invalid latch state; theLeaderLatchhas no participants.static final recordRepresents a valid latch state, where the participant is not the leader.static final recordRepresents an invalid latch state; an unexpected Exception was thrown.static interfaceDefines a valid leadership status. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck whether the status is from a bad latch state, where the Curator client or theLeaderLatchmight not be started or there are no participants in the latch.default booleanCheck whether the status is from a valid state, where the Curator client and theLeaderLatchare both started, and there are latch participants.
-
Method Details
-
isValidStatus
default boolean isValidStatus()Check whether the status is from a valid state, where the Curator client and theLeaderLatchare both started, and there are latch participants.- Returns:
- true if the leadership status is from a valid latch, otherwise false
-
isErrorStatus
boolean isErrorStatus()Check whether the status is from a bad latch state, where the Curator client or theLeaderLatchmight not be started or there are no participants in the latch.- Returns:
- true if the leadership status is from an invalid latch state, otherwise false
-