public class RaftSession extends io.atomix.primitive.session.impl.AbstractSession
Session.State| Constructor and Description |
|---|
RaftSession(SessionId sessionId,
MemberId member,
java.lang.String name,
PrimitiveType primitiveType,
ReadConsistency readConsistency,
long minTimeout,
long maxTimeout,
long lastUpdated,
Serializer serializer,
RaftServiceContext context,
io.atomix.protocols.raft.impl.RaftContext server,
io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<io.atomix.protocols.raft.impl.PendingCommand> |
clearCommands()
Clears and returns all pending commands.
|
void |
clearResults(long sequence)
Clears command results up to the given sequence number.
|
void |
close()
Closes the session.
|
void |
commit(long index)
Commits events for the given index.
|
boolean |
equals(java.lang.Object object) |
void |
expire()
Expires the session.
|
io.atomix.protocols.raft.impl.PendingCommand |
getCommand(long sequence)
Gets a pending command.
|
java.util.Collection<io.atomix.protocols.raft.impl.PendingCommand> |
getCommands()
Returns the collection of pending commands.
|
long |
getCommandSequence()
Returns the session operation sequence number.
|
long |
getEventIndex()
Returns the session event index.
|
long |
getLastApplied()
Returns the session index.
|
long |
getLastCompleted()
Returns the index of the highest event acked for the session.
|
long |
getLastUpdated()
Returns the session update timestamp.
|
long |
getRequestSequence()
Returns the session request number.
|
io.atomix.protocols.raft.impl.OperationResult |
getResult(long sequence)
Returns the session response for the given sequence number.
|
RaftServiceContext |
getService()
Returns the state machine context associated with the session.
|
Session.State |
getState() |
int |
hashCode() |
boolean |
isTimedOut(long timestamp)
Returns a boolean indicating whether the session is timed out.
|
long |
maxTimeout()
Returns the maximum session timeout.
|
long |
minTimeout()
Returns the minimum session timeout.
|
long |
nextCommandSequence()
Returns the next operation sequence number.
|
long |
nextRequestSequence()
Returns the next request sequence number.
|
void |
open()
Opens the session.
|
void |
publish(PrimitiveEvent event) |
ReadConsistency |
readConsistency()
Returns the session read consistency.
|
void |
registerCommand(long sequence,
io.atomix.protocols.raft.impl.PendingCommand pendingCommand)
Registers a pending command.
|
void |
registerIndexQuery(long index,
java.lang.Runnable query)
Registers a session index query.
|
void |
registerResult(long sequence,
io.atomix.protocols.raft.impl.OperationResult result)
Registers a session result.
|
void |
registerSequenceQuery(long sequence,
java.lang.Runnable query)
Registers a causal session query.
|
io.atomix.protocols.raft.impl.PendingCommand |
removeCommand(long sequence)
Removes and returns a pending command.
|
void |
resendEvents(long index)
Resends events from the given sequence.
|
void |
resetRequestSequence(long requestSequence)
Resets the current request sequence number.
|
void |
setCommandSequence(long sequence)
Sets the session operation sequence number.
|
void |
setEventIndex(long eventIndex)
Sets the session event index.
|
void |
setLastApplied(long index)
Sets the session index.
|
void |
setLastCompleted(long lastCompleted)
Sets the last completed event index for the session.
|
void |
setLastUpdated(long lastUpdated)
Updates the session timestamp.
|
void |
setRequestSequence(long requestSequence)
Sets the current request sequence number.
|
java.lang.String |
toString() |
accept, memberId, primitiveName, primitiveType, publish, sessionIdpublic RaftSession(SessionId sessionId, MemberId member, java.lang.String name, PrimitiveType primitiveType, ReadConsistency readConsistency, long minTimeout, long maxTimeout, long lastUpdated, Serializer serializer, RaftServiceContext context, io.atomix.protocols.raft.impl.RaftContext server, io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory)
public ReadConsistency readConsistency()
public long minTimeout()
public long maxTimeout()
public RaftServiceContext getService()
public long getLastUpdated()
public void setLastUpdated(long lastUpdated)
lastUpdated - The session timestamp.public boolean isTimedOut(long timestamp)
timestamp - the current timestamppublic Session.State getState()
public long getRequestSequence()
public long nextRequestSequence()
public void setRequestSequence(long requestSequence)
requestSequence - the current request sequence numberpublic void resetRequestSequence(long requestSequence)
requestSequence - The request sequence number.public long getCommandSequence()
public long nextCommandSequence()
public void setCommandSequence(long sequence)
sequence - The session operation sequence number.public long getLastApplied()
public void setLastApplied(long index)
index - The session index.public void registerSequenceQuery(long sequence,
java.lang.Runnable query)
sequence - The session sequence number at which to execute the query.query - The query to execute.public void registerIndexQuery(long index,
java.lang.Runnable query)
index - The state machine index at which to execute the query.query - The query to execute.public void registerCommand(long sequence,
io.atomix.protocols.raft.impl.PendingCommand pendingCommand)
sequence - the pending command sequence numberpendingCommand - the pending command to registerpublic io.atomix.protocols.raft.impl.PendingCommand getCommand(long sequence)
sequence - the pending command sequence numbernull if no command is pending for this sequence numberpublic java.util.Collection<io.atomix.protocols.raft.impl.PendingCommand> getCommands()
public io.atomix.protocols.raft.impl.PendingCommand removeCommand(long sequence)
sequence - the pending command sequence numbernull if no command is pending for this sequence numberpublic java.util.Collection<io.atomix.protocols.raft.impl.PendingCommand> clearCommands()
public void registerResult(long sequence,
io.atomix.protocols.raft.impl.OperationResult result)
Results are stored in memory on all servers in order to provide linearizable semantics. When a command is applied to the state machine, the command's return value is stored with the sequence number. Once the client acknowledges receipt of the command output the result will be cleared from memory.
sequence - The result sequence number.result - The result.public void clearResults(long sequence)
Command output is removed from memory up to the given sequence number. Additionally, since we know the client received a response for all commands up to the given sequence number, command futures are removed from memory as well.
sequence - The sequence to clear.public io.atomix.protocols.raft.impl.OperationResult getResult(long sequence)
sequence - The response sequence.public long getEventIndex()
public void setEventIndex(long eventIndex)
eventIndex - the session event indexpublic void publish(PrimitiveEvent event)
publish in interface Sessionpublish in class io.atomix.primitive.session.impl.AbstractSessionpublic void commit(long index)
public long getLastCompleted()
public void setLastCompleted(long lastCompleted)
lastCompleted - the last completed indexpublic void resendEvents(long index)
index - The index from which to resend events.public void open()
public void expire()
public void close()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2013-2019. All Rights Reserved.