Interface Context

All Known Implementing Classes:
LeaderInitiator.CuratorContext, LeaderInitiator.HazelcastContext
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Context
Interface that defines the context for candidate leadership. Instances of this object are passed to candidates upon granting and revoking of leadership.

The Context is FunctionalInterface with no-op implementation for the yield().

Author:
Patrick Peralta, Janne Valkealahti, Artem Bilan, Gary Russell
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Get the role for the Candidate.
    boolean
    Checks if the Candidate this context was passed to is the leader.
    default void
    Causes the Candidate this context was passed to to relinquish leadership.
  • Method Details

    • isLeader

      boolean isLeader()
      Checks if the Candidate this context was passed to is the leader.
      Returns:
      true if the Candidate this context was passed to is the leader
    • yield

      default void yield()
      Causes the Candidate this context was passed to to relinquish leadership. This method has no effect if the candidate is not currently the leader.
    • getRole

      @Nullable default String getRole()
      Get the role for the Candidate.
      Returns:
      the role.
      Since:
      5.0.6