Class NotLeaderException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.loomcache.common.exception.LoomException
com.loomcache.common.exception.NotLeaderException
- All Implemented Interfaces:
Serializable
Thrown when a non-leader node receives a write request.
This exception is returned to clients when they attempt to perform a write operation on a follower node. The exception includes information about the current leader (if known), allowing clients to redirect their request.
Clients should catch this exception, extract the leader information, and retry the write operation against the leader node.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNotLeaderException(@Nullable String leaderId) Creates a new NotLeaderException with only the leader ID.NotLeaderException(@Nullable String leaderId, @Nullable String leaderAddress) Creates a new NotLeaderException with leader information. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this exception has valid leader information.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
NotLeaderException
-
NotLeaderException
Creates a new NotLeaderException with only the leader ID.- Parameters:
leaderId- the ID of the current leader, or null if unknown
-
-
Method Details
-
hasLeaderInfo
public boolean hasLeaderInfo()Checks if this exception has valid leader information.- Returns:
- true if both leaderId and leaderAddress are available
-