Package io.atomix.primitive.service
Interface PrimitiveService
- All Known Implementing Classes:
AbstractPrimitiveService
public interface PrimitiveService
Base class for user-provided services.
- See Also:
Commit,ServiceContext,ServiceExecutor
-
Method Summary
Modifier and Type Method Description byte[]apply(Commit<byte[]> commit)Applies a commit to the state machine.voidbackup(BackupOutput output)Backs up the service state to the given buffer.default voidclose()Closes the state machine.voidclose(SessionId sessionId)Closes the session with the given identifier.voidexpire(SessionId sessionId)Expires the session with the given identifier.voidinit(ServiceContext context)Initializes the state machine.voidregister(Session session)Registers a primitive session.voidrestore(BackupInput input)Restores the service state from the given buffer.io.atomix.utils.serializer.Serializerserializer()Returns the primitive service serializer.voidtick(io.atomix.utils.time.WallClockTimestamp timestamp)Increments the Raft service time to the given timestamp.
-
Method Details
-
init
Initializes the state machine.- Parameters:
context- The state machine context.- Throws:
NullPointerException- ifcontextis null
-
tick
void tick(io.atomix.utils.time.WallClockTimestamp timestamp)Increments the Raft service time to the given timestamp.- Parameters:
timestamp- the service timestamp
-
serializer
io.atomix.utils.serializer.Serializer serializer()Returns the primitive service serializer.- Returns:
- the primitive service serializer
-
backup
Backs up the service state to the given buffer.- Parameters:
output- the buffer to which to back up the service state
-
restore
Restores the service state from the given buffer.- Parameters:
input- the buffer from which to restore the service state
-
apply
Applies a commit to the state machine.- Parameters:
commit- the commit to apply- Returns:
- the commit result
-
register
Registers a primitive session.- Parameters:
session- the session to register
-
expire
Expires the session with the given identifier.- Parameters:
sessionId- the session identifier
-
close
Closes the session with the given identifier.- Parameters:
sessionId- the session identifier
-
close
default void close()Closes the state machine.
-