Interface RaftManager

All Superinterfaces:
org.infinispan.commons.api.Lifecycle
All Known Implementing Classes:
EmptyRaftManager

public interface RaftManager extends org.infinispan.commons.api.Lifecycle
Use this class to create and register RaftStateMachine.

Each RaftStateMachine is identified by its name and they are independent of each other; each RaftStateMachine has it own RaftChannel.

Since:
14.0
  • Method Details

    • getOrRegisterStateMachine

      <T extends RaftStateMachine> T getOrRegisterStateMachine(String channelName, Supplier<T> supplier, RaftChannelConfiguration configuration)
      Register a RaftStateMachine.

      If the RAFT protocol is not supported, this method return null. If a RaftStateMachine already exists with name channelName, the existing instance is returned.

      If isRaftAvailable() return false, this method always returns null.

      Type Parameters:
      T - The concrete RaftStateMachine implementation.
      Parameters:
      channelName - The name identifying the RaftStateMachine.
      supplier - The factory to create a new instance of RaftStateMachine.
      configuration - The RaftChannelConfiguration for the RaftChannel.
      Returns:
      The RaftStateMachine instance of null if unable to create or configure the RaftChannel.
    • isRaftAvailable

      boolean isRaftAvailable()
      Returns:
      true if the RAFT protocol is available to be used, false otherwise.
    • hasLeader

      boolean hasLeader(String channelName)
      Check if a RAFT leader is elected for the RaftStateMachine with name channelName.
      Parameters:
      channelName - The name identifying the RaftStateMachine.
      Returns:
      true if the leader exists, false otherwise.
    • raftId

      String raftId()
      Returns:
      This node raft-id.
    • addMember

      CompletionStage<Void> addMember(String raftId)
      Adds a new member to the RAFT cluster through consensus.

      All registered RaftStateMachine are updated with the new membership. Warning: This method is not atomic, the membership might diverge because of failures.

      Parameters:
      raftId - : A unique name of the new node joining.
      Returns:
      A CompletionStage that finishes after the operation is applied.
    • removeMembers

      CompletionStage<Void> removeMembers(String raftId)
      Removes an existing member of the RAFT cluster through consensus.

      All registered RaftStateMachine are updated with the new membership. Warning: This method is not atomic, the membership might diverge because of failures.

      Parameters:
      raftId - : The node name to remove.
      Returns:
      A CompletionStage that finishes after the operation is applied.
    • raftMembers

      Collection<String> raftMembers()
      The actual members in the cluster.
      Returns:
      An unmodifiable list containing the IDs of all cluster members.