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
Modifier and TypeInterfaceDescriptionstatic final record
Represents an invalid latch state; Curator is not in theSTARTED
state.static interface
Defines an invalid leadership status caused by an error or erroneous state.static final record
Represents a valid latch state, where the participant is the current leader.static final record
Represents an invalid latch state; the LeaderLatch is not in theSTARTED
state.static final record
Represents an invalid latch state; theLeaderLatch
has no participants.static final record
Represents a valid latch state, where the participant is not the leader.static final record
Represents an invalid latch state; an unexpected Exception was thrown.static interface
Defines a valid leadership status. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check whether the status is from a bad latch state, where the Curator client or theLeaderLatch
might not be started or there are no participants in the latch.default boolean
Check whether the status is from a valid state, where the Curator client and theLeaderLatch
are 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 theLeaderLatch
are 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 theLeaderLatch
might 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
-