Class NotLeaderException

All Implemented Interfaces:
Serializable

public final class NotLeaderException extends LoomException
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 Details

    • NotLeaderException

      public NotLeaderException(@Nullable String leaderId, @Nullable String leaderAddress)
      Creates a new NotLeaderException with leader information.
      Parameters:
      leaderId - the ID of the current leader, or null if unknown
      leaderAddress - the address of the current leader (host:port), or null if unknown
    • NotLeaderException

      public NotLeaderException(@Nullable String leaderId)
      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