public class RaftService extends Object implements ManagedService, SnapshotAwareService<MetadataRaftGroupSnapshot>, GracefulShutdownAwareService, MembershipAwareService, CPSubsystemManagementService, PreJoinAwareService
RaftNode instances that run the Raft consensus algorithm
for the created CP groups. Also implements CP subsystem management methods.| Modifier and Type | Field and Description |
|---|---|
static String |
SERVICE_NAME |
| Constructor and Description |
|---|
RaftService(NodeEngine nodeEngine) |
public static final String SERVICE_NAME
public RaftService(NodeEngine nodeEngine)
public void init(NodeEngine nodeEngine, Properties properties)
ManagedServiceinit in interface ManagedServicenodeEngine - the NodeEngine that this service belongs toproperties - the Properties (can be used to pass settings to the service)public void reset()
ManagedServiceTODO: what is the purpose of reset
reset in interface ManagedServicepublic void shutdown(boolean terminate)
ManagedServiceTODO: what is the purpose of the terminate variable
shutdown in interface ManagedServiceterminate - true to shut down this servicepublic MetadataRaftGroupSnapshot takeSnapshot(CPGroupId groupId, long commitIndex)
SnapshotAwareServiceCPGroupId.
The snapshot object returned from this method will be stored among
the Raft log and it can be sent to other Raft nodes anytime. Therefore,
this method must not return a snapshot object that can mutate after
the takeSnapshot() call.takeSnapshot in interface SnapshotAwareService<MetadataRaftGroupSnapshot>groupId - CPGroupId which is snapshot requested forcommitIndex - commitIndex of the taken snapshotCPGroupId.public void restoreSnapshot(CPGroupId groupId, long commitIndex, MetadataRaftGroupSnapshot snapshot)
SnapshotAwareServiceCPGroupId.restoreSnapshot in interface SnapshotAwareService<MetadataRaftGroupSnapshot>groupId - CPGroupId of the snapshot to be restoredcommitIndex - commitIndex of the restored snapshotsnapshot - snapshot for specified CPGroupIdpublic ICompletableFuture<Collection<CPGroupId>> getAllCPGroupIds()
public ICompletableFuture<Collection<CPGroupId>> getCPGroupIds()
CPSubsystemManagementServicegetCPGroupIds in interface CPSubsystemManagementServicepublic ICompletableFuture<CPGroup> getCPGroup(CPGroupId groupId)
public ICompletableFuture<CPGroup> getCPGroup(String name)
CPSubsystemManagementServicegetCPGroup in interface CPSubsystemManagementServicepublic ICompletableFuture<Void> restart()
CPSubsystemManagementServiceAfter this method is called, all CP state and data are wiped and the CP members start with empty state.
This method can be invoked only from the Hazelcast master member.
This method must not be called while there are membership changes in the cluster. Before calling this method, please make sure that there is no new member joining and all existing Hazelcast members have seen the same member list.
Use with caution: This method is NOT idempotent and multiple invocations can break the whole system! After calling this API, you must observe the system to see if the restart process is successfully completed or failed before making another call.
restart in interface CPSubsystemManagementServicepublic void restartLocal(long seed)
public ICompletableFuture<Void> promoteToCPMember()
CPSubsystemManagementServiceThis method is idempotent. If the local member is already in the active CP members list, then this method has no effect. When the current member is promoted to a CP member, its member UUID is assigned as CP member UUID.
Once the returned Future object is completed, the promoted CP
member has been added to the CP groups that have missing members, i.e.,
whose size is smaller than CPSubsystemConfig.getGroupSize().
If the local member is currently being removed from
the active CP members list, then the returned Future object
will throw IllegalArgumentException.
If there is an ongoing membership change in the CP subsystem when this
method is invoked, then the returned Future object throws
IllegalStateException
If the CP subsystem initial discovery process has not completed when
this method is invoked, then the returned Future object throws
IllegalStateException
promoteToCPMember in interface CPSubsystemManagementServicepublic ICompletableFuture<Void> removeCPMember(String cpMemberUuid)
CPSubsystemManagementServiceBefore removing a CP member from the CP subsystem, please make sure that it is declared as unreachable by Hazelcast's failure detector and removed from Hazelcast's member list. The behavior is undefined when a running CP member is removed from the CP subsystem.
removeCPMember in interface CPSubsystemManagementServicepublic ICompletableFuture<Void> forceDestroyCPGroup(String groupName)
forceDestroyCPGroup in interface CPSubsystemManagementServicepublic ICompletableFuture<Collection<CPMember>> getCPMembers()
CPSubsystemManagementServicegetCPMembers in interface CPSubsystemManagementServicepublic boolean onShutdown(long timeout,
TimeUnit unit)
GracefulShutdownAwareServiceonShutdown in interface GracefulShutdownAwareServicetimeout - timeout for graceful shutdownunit - time unitpublic Operation getPreJoinOperation()
PreJoinAwareServicePostJoinAwareService.getPostJoinOperation()s, no partition locks, no key-based locks, no service level
locks, no database interaction are allowed. Additionally, a pre-join operation is executed while the cluster
lock is being held on the joining member, so it is important that the operation finishes quickly and does not
interact with other locks.
The Operation.getPartitionId() method should return a negative value.
This means that the operations should not implement PartitionAwareOperation.
Pre join operations should return response, which may also be a null response.
getPreJoinOperation in interface PreJoinAwareServicenull.public void memberAdded(MembershipServiceEvent event)
MembershipAwareServicememberAdded in interface MembershipAwareServiceevent - the event for a new member added to the clusterpublic void memberRemoved(MembershipServiceEvent event)
MembershipAwareServicememberRemoved in interface MembershipAwareServiceevent - the event for an existing member leaving the clusterpublic void memberAttributeChanged(MemberAttributeServiceEvent event)
MembershipAwareServicememberAttributeChanged in interface MembershipAwareServiceevent - the event for a member attribute being changedpublic Collection<CPGroupId> getCPGroupIdsLocally()
public CPGroupInfo getCPGroupLocally(CPGroupId groupId)
public MetadataRaftGroupManager getMetadataGroupManager()
public RaftInvocationManager getInvocationManager()
public void handlePreVoteRequest(CPGroupId groupId, PreVoteRequest request, CPMember target)
public void handlePreVoteResponse(CPGroupId groupId, PreVoteResponse response, CPMember target)
public void handleVoteRequest(CPGroupId groupId, VoteRequest request, CPMember target)
public void handleVoteResponse(CPGroupId groupId, VoteResponse response, CPMember target)
public void handleAppendEntries(CPGroupId groupId, AppendRequest request, CPMember target)
public void handleAppendResponse(CPGroupId groupId, AppendSuccessResponse response, CPMember target)
public void handleAppendResponse(CPGroupId groupId, AppendFailureResponse response, CPMember target)
public void handleSnapshot(CPGroupId groupId, InstallSnapshot request, CPMember target)
public Collection<RaftNode> getAllRaftNodes()
public boolean isRaftGroupDestroyed(CPGroupId groupId)
public CPSubsystemConfig getConfig()
public CPMemberInfo getLocalCPMember()
public void createRaftNode(CPGroupId groupId, Collection<CPMemberInfo> members)
public void destroyRaftNode(CPGroupId groupId)
public void stepDownRaftNode(CPGroupId groupId)
public RaftGroupId createRaftGroupForProxy(String name)
public InternalCompletableFuture<RaftGroupId> createRaftGroupForProxyAsync(String name)
public RaftGroupId getMetadataGroupId()
public void handleActiveCPMembers(RaftGroupId latestMetadataGroupId, long membersCommitIndex, Collection<CPMemberInfo> members)
Copyright © 2019 Hazelcast, Inc.. All Rights Reserved.