W
- concrete type of the WaitKeyR
- concrete type of the resourceRR
- concrete ty;e lf the resource registrypublic abstract class AbstractBlockingService<W extends WaitKey,R extends BlockingResource<W>,RR extends ResourceRegistry<W,R>> extends Object implements RaftManagedService, RaftNodeLifecycleAwareService, RaftRemoteService, SessionAwareService, SnapshotAwareService<RR>, LiveOperationsTracker
Modifier and Type | Field and Description |
---|---|
protected ILogger |
logger |
protected NodeEngineImpl |
nodeEngine |
protected RaftService |
raftService |
static long |
WAIT_TIMEOUT_TASK_UPPER_BOUND_MILLIS |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBlockingService(NodeEngine nodeEngine) |
Modifier and Type | Method and Description |
---|---|
protected abstract RR |
createNewRegistry(CPGroupId groupId)
Creates a registry for the given Raft group.
|
boolean |
destroyRaftObject(CPGroupId groupId,
String name)
Destroys the given CP data structure on the CP group.
|
protected abstract Object |
expiredWaitKeyResponse()
Creates the response object that will be sent for a expired wait key.
|
void |
expireWaitKeys(CPGroupId groupId,
Collection<Tuple2<String,UUID>> keys) |
Collection<Long> |
getAttachedSessions(CPGroupId groupId)
Returns a collection of session ids that this service has attached some
resources.
|
Collection<Tuple2<Address,Long>> |
getLiveOperations(CPGroupId groupId) |
protected RR |
getOrInitRegistry(CPGroupId groupId) |
RR |
getRegistryOrNull(CPGroupId groupId) |
protected void |
heartbeatSession(CPGroupId groupId,
long sessionId) |
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this service.
|
protected void |
initImpl()
Subclasses can implement their custom initialization logic here
|
protected void |
notifyWaitKeys(CPGroupId groupId,
String name,
Collection<W> keys,
Object result) |
void |
onCPSubsystemRestart()
Called when the CP subsystem is restarted.
|
void |
onRaftGroupDestroyed(CPGroupId groupId)
Called on the thread of the Raft group when the given Raft node is
destroyed, either gracefully or forcefully.
|
void |
onRaftNodeSteppedDown(CPGroupId groupId)
Called on the thread of the Raft group when the given Raft node is
stepped down, either because it is shutting down, or it could not be
added to the Raft group
|
protected void |
onRegistryRestored(RR registry) |
void |
onSessionClose(CPGroupId groupId,
long sessionId)
Called when a session is closed.
|
void |
populate(LiveOperations liveOperations)
Populate the LiveOperations
|
void |
reset()
Resets this service back to its initial state.
|
void |
restoreSnapshot(CPGroupId groupId,
long commitIndex,
RR registry)
Restores the snapshot for specified
CPGroupId . |
protected void |
scheduleTimeout(CPGroupId groupId,
String name,
UUID invocationUid,
long timeoutMs) |
protected abstract String |
serviceName()
Returns name of the service.
|
void |
setSessionAccessor(SessionAccessor accessor)
Injects
SessionAccessor in order to enable the custom service to
validate and trigger session activity |
void |
shutdown(boolean terminate)
Shuts down this service.
|
protected void |
shutdownImpl(boolean terminate)
Subclasses can implement their custom shutdown logic here
|
RR |
takeSnapshot(CPGroupId groupId,
long commitIndex)
Creates a snapshot for specified
CPGroupId . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createProxy
public static final long WAIT_TIMEOUT_TASK_UPPER_BOUND_MILLIS
protected final NodeEngineImpl nodeEngine
protected final ILogger logger
protected volatile RaftService raftService
protected AbstractBlockingService(NodeEngine nodeEngine)
public final void init(NodeEngine nodeEngine, Properties properties)
ManagedService
init
in interface ManagedService
nodeEngine
- the NodeEngine that this service belongs toproperties
- the Properties (can be used to pass settings to the service)protected void initImpl()
public void reset()
ManagedService
TODO: what is the purpose of reset
reset
in interface ManagedService
public void onCPSubsystemRestart()
RaftManagedService
onCPSubsystemRestart
in interface RaftManagedService
public final void shutdown(boolean terminate)
ManagedService
TODO: what is the purpose of the terminate variable
shutdown
in interface ManagedService
terminate
- true
to shut down this serviceprotected void shutdownImpl(boolean terminate)
protected abstract String serviceName()
protected abstract RR createNewRegistry(CPGroupId groupId)
protected abstract Object expiredWaitKeyResponse()
protected void onRegistryRestored(RR registry)
public boolean destroyRaftObject(CPGroupId groupId, String name)
RaftRemoteService
destroyRaftObject
in interface RaftRemoteService
public final RR takeSnapshot(CPGroupId groupId, long commitIndex)
SnapshotAwareService
CPGroupId
.
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<RR extends ResourceRegistry<W,R>>
groupId
- CPGroupId
which is snapshot requested forcommitIndex
- commitIndex of the taken snapshotCPGroupId
.public final void restoreSnapshot(CPGroupId groupId, long commitIndex, RR registry)
SnapshotAwareService
CPGroupId
.restoreSnapshot
in interface SnapshotAwareService<RR extends ResourceRegistry<W,R>>
groupId
- CPGroupId
of the snapshot to be restoredcommitIndex
- commitIndex of the restored snapshotregistry
- snapshot for specified CPGroupId
public void setSessionAccessor(SessionAccessor accessor)
SessionAwareService
SessionAccessor
in order to enable the custom service to
validate and trigger session activitysetSessionAccessor
in interface SessionAwareService
public final void onSessionClose(CPGroupId groupId, long sessionId)
SessionAwareService
onSessionClose
in interface SessionAwareService
public final Collection<Long> getAttachedSessions(CPGroupId groupId)
SessionAwareService
getAttachedSessions
in interface SessionAwareService
public final void onRaftGroupDestroyed(CPGroupId groupId)
RaftNodeLifecycleAwareService
onRaftGroupDestroyed
in interface RaftNodeLifecycleAwareService
public final void onRaftNodeSteppedDown(CPGroupId groupId)
RaftNodeLifecycleAwareService
onRaftNodeSteppedDown
in interface RaftNodeLifecycleAwareService
public final void populate(LiveOperations liveOperations)
LiveOperationsTracker
populate
in interface LiveOperationsTracker
liveOperations
- the LiveOperations to populate.public final void expireWaitKeys(CPGroupId groupId, Collection<Tuple2<String,UUID>> keys)
public Collection<Tuple2<Address,Long>> getLiveOperations(CPGroupId groupId)
protected final void scheduleTimeout(CPGroupId groupId, String name, UUID invocationUid, long timeoutMs)
protected final void heartbeatSession(CPGroupId groupId, long sessionId)
protected final void notifyWaitKeys(CPGroupId groupId, String name, Collection<W> keys, Object result)
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.