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, RaftGroupLifecycleAwareService, RaftRemoteService, SessionAwareService, SnapshotAwareService<RR>
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 Raft data structure on the Raft 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.
|
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 |
onGroupDestroy(CPGroupId groupId)
Called on the thread of the Raft group when the given Raft group is
destroyed, either gracefully or forcefully.
|
protected void |
onRegistryRestored(RR registry) |
void |
onSessionClose(CPGroupId groupId,
long sessionId)
Called when a session is closed.
|
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
createDistributedObject, destroyDistributedObject
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 onGroupDestroy(CPGroupId groupId)
RaftGroupLifecycleAwareService
onGroupDestroy
in interface RaftGroupLifecycleAwareService
public final void expireWaitKeys(CPGroupId groupId, Collection<Tuple2<String,UUID>> keys)
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 © 2019 Hazelcast, Inc.. All Rights Reserved.