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 will be wiped and CP members will start with empty state.
This method can be invoked only from the Hazelcast master member.
Use with caution: This method is NOT idempotent and multiple invocations can break the whole system!
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 will have no effect. When the current member is promoted to CP member, its member UUID is assigned as CP member UUID.
If the local member is currently being removed from
the active CP members list, then the returning Future object
will throw IllegalArgumentException.
promoteToCPMember in interface CPSubsystemManagementServicepublic ICompletableFuture<Void> removeCPMember(String cpMemberUuid)
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 getLocalMember()
public void createRaftNode(CPGroupId groupId, Collection<CPMemberInfo> members)
public void destroyRaftNode(CPGroupId groupId)
public RaftGroupId createRaftGroupForProxy(String name)
public RaftGroupId getGroupIdForProxy(String name)
public CPGroupId getMetadataGroupId()
Copyright © 2019. All Rights Reserved.