public class RaftServiceContext extends Object implements ServiceContext
| Constructor and Description |
|---|
RaftServiceContext(PrimitiveId primitiveId,
String serviceName,
PrimitiveType primitiveType,
ServiceConfig config,
PrimitiveService service,
io.atomix.protocols.raft.impl.RaftContext raft,
io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeSession(long index,
long timestamp,
RaftSession session,
boolean expired)
Unregister the given session.
|
void |
completeKeepAlive(long index,
long timestamp)
Completes a keep-alive.
|
long |
currentIndex()
Returns the current state machine index.
|
OperationType |
currentOperation()
Returns the current operation type.
|
Session |
currentSession()
Returns the current session.
|
io.atomix.protocols.raft.impl.OperationResult |
executeCommand(long index,
long sequence,
long timestamp,
RaftSession session,
PrimitiveOperation operation)
Executes the given command on the state machine.
|
CompletableFuture<io.atomix.protocols.raft.impl.OperationResult> |
executeQuery(long index,
long sequence,
long timestamp,
RaftSession session,
PrimitiveOperation operation)
Executes the given query on the state machine.
|
void |
installSnapshot(io.atomix.protocols.raft.storage.snapshot.SnapshotReader reader)
Installs a snapshot.
|
boolean |
keepAlive(long index,
long timestamp,
RaftSession session,
long commandSequence,
long eventIndex)
Keeps the given session alive.
|
void |
keepAliveSessions(long index,
long timestamp)
Keeps all sessions alive using the given timestamp.
|
LogicalClock |
logicalClock()
Returns the state machine's logical clock.
|
long |
openSession(long index,
long timestamp,
RaftSession session)
Registers the given session.
|
Serializer |
serializer() |
<C extends ServiceConfig> |
serviceConfig()
Returns the service configuration.
|
PrimitiveId |
serviceId()
Returns the state machine identifier.
|
String |
serviceName()
Returns the state machine name.
|
PrimitiveType |
serviceType()
Returns the state machine type.
|
void |
takeSnapshot(io.atomix.protocols.raft.storage.snapshot.SnapshotWriter writer)
Takes a snapshot of the service state.
|
String |
toString() |
WallClock |
wallClock()
Returns the state machine's wall clock.
|
public RaftServiceContext(PrimitiveId primitiveId, String serviceName, PrimitiveType primitiveType, ServiceConfig config, PrimitiveService service, io.atomix.protocols.raft.impl.RaftContext raft, io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory)
public PrimitiveId serviceId()
ServiceContextserviceId in interface ServiceContextpublic String serviceName()
ServiceContextserviceName in interface ServiceContextpublic PrimitiveType serviceType()
ServiceContextserviceType in interface ServiceContextpublic <C extends ServiceConfig> C serviceConfig()
ServiceContextserviceConfig in interface ServiceContextC - the configuration typepublic Serializer serializer()
public long currentIndex()
ServiceContextThe state index is indicative of the index of the current operation being applied to the server state machine. If a query is being applied, the index of the last command applied will be used.
currentIndex in interface ServiceContextpublic Session currentSession()
ServiceContextcurrentSession in interface ServiceContextpublic OperationType currentOperation()
ServiceContextcurrentOperation in interface ServiceContextpublic LogicalClock logicalClock()
ServiceContextlogicalClock in interface ServiceContextpublic WallClock wallClock()
ServiceContextwallClock in interface ServiceContextpublic void installSnapshot(io.atomix.protocols.raft.storage.snapshot.SnapshotReader reader)
public void takeSnapshot(io.atomix.protocols.raft.storage.snapshot.SnapshotWriter writer)
public long openSession(long index,
long timestamp,
RaftSession session)
index - The index of the registration.timestamp - The timestamp of the registration.session - The session to register.public boolean keepAlive(long index,
long timestamp,
RaftSession session,
long commandSequence,
long eventIndex)
index - The index of the keep-alive.timestamp - The timestamp of the keep-alive.session - The session to keep-alive.commandSequence - The session command sequence number.eventIndex - The session event index.public void completeKeepAlive(long index,
long timestamp)
index - the keep-alive indextimestamp - the keep-alive timestamppublic void keepAliveSessions(long index,
long timestamp)
index - the index of the timestamptimestamp - the timestamp with which to reset session timeoutspublic void closeSession(long index,
long timestamp,
RaftSession session,
boolean expired)
index - The index of the unregister.timestamp - The timestamp of the unregister.session - The session to unregister.expired - Whether the session was expired by the leader.public io.atomix.protocols.raft.impl.OperationResult executeCommand(long index,
long sequence,
long timestamp,
RaftSession session,
PrimitiveOperation operation)
index - The index of the command.timestamp - The timestamp of the command.sequence - The command sequence number.session - The session that submitted the command.operation - The command to execute.public CompletableFuture<io.atomix.protocols.raft.impl.OperationResult> executeQuery(long index, long sequence, long timestamp, RaftSession session, PrimitiveOperation operation)
index - The index of the query.sequence - The query sequence number.timestamp - The timestamp of the query.session - The session that submitted the query.operation - The query to execute.Copyright © 2013–2018. All rights reserved.