Class FencedException

All Implemented Interfaces:
Serializable

public final class FencedException extends CoordinationException
Reports that the broker refused a write, because another member holds the role now.

This is the expected end of a leadership. The transport throws it for broker error code 47 INVALID_PRODUCER_EPOCH and for broker error code 90 PRODUCER_FENCED. A deposed leader learns that it lost the role from this exception, and from nothing else. No clock takes part in the check.

The epoch that the member held is superseded, so the cluster already rejects every write that the member makes. The caller stops the work of the role at once. A retry of the same write cannot succeed.

Example

try {
    leadership.renew();
} catch (FencedException lost) {
    controller.stop();
}
See Also:
  • Constructor Details

    • FencedException

      public FencedException(Role role, Throwable cause)
      Creates an exception for the role that this member no longer holds.
      Parameters:
      role - the role another member took
      cause - the broker error that reported the fence, or null when the fence came from a state comparison rather than from a write
  • Method Details

    • role

      public Role role()
      Returns the role that this member no longer holds.
      Returns:
      the fenced role