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 Summary
Modifier and TypeMethodDescriptionAdds a new member to the RAFT cluster through consensus.<T extends RaftStateMachine>
TgetOrRegisterStateMachine(String channelName, Supplier<T> supplier, RaftChannelConfiguration configuration) Register aRaftStateMachine.booleanCheck if a RAFT leader is elected for theRaftStateMachinewith namechannelName.booleanraftId()The actual members in the cluster.removeMembers(String raftId) Removes an existing member of the RAFT cluster through consensus.Methods inherited from interface org.infinispan.commons.api.Lifecycle
start, stop
-
Method Details
-
getOrRegisterStateMachine
<T extends RaftStateMachine> T getOrRegisterStateMachine(String channelName, Supplier<T> supplier, RaftChannelConfiguration configuration) Register aRaftStateMachine.If the RAFT protocol is not supported, this method return
null. If aRaftStateMachinealready exists with namechannelName, the existing instance is returned.If
isRaftAvailable()returnfalse, this method always returnsnull.- Type Parameters:
T- The concreteRaftStateMachineimplementation.- Parameters:
channelName- The name identifying theRaftStateMachine.supplier- The factory to create a new instance ofRaftStateMachine.configuration- TheRaftChannelConfigurationfor theRaftChannel.- Returns:
- The
RaftStateMachineinstance ofnullif unable to create or configure theRaftChannel.
-
isRaftAvailable
boolean isRaftAvailable()- Returns:
trueif the RAFT protocol is available to be used,falseotherwise.
-
hasLeader
Check if a RAFT leader is elected for theRaftStateMachinewith namechannelName.- Parameters:
channelName- The name identifying theRaftStateMachine.- Returns:
trueif the leader exists,falseotherwise.
-
raftId
String raftId()- Returns:
- This node raft-id.
-
addMember
Adds a new member to the RAFT cluster through consensus.All registered
RaftStateMachineare 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
CompletionStagethat finishes after the operation is applied.
-
removeMembers
Removes an existing member of the RAFT cluster through consensus.All registered
RaftStateMachineare 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
CompletionStagethat 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.
-