public class RaftSession extends Object implements io.atomix.primitive.session.Session
| Constructor and Description |
|---|
RaftSession(io.atomix.primitive.session.SessionId sessionId,
io.atomix.cluster.NodeId member,
String name,
io.atomix.primitive.PrimitiveType primitiveType,
ReadConsistency readConsistency,
long minTimeout,
long maxTimeout,
long lastUpdated,
RaftServiceContext context,
io.atomix.protocols.raft.impl.RaftContext server,
io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(io.atomix.primitive.session.SessionEventListener listener) |
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(Object object) |
void |
expire()
Expires the session.
|
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.
|
io.atomix.primitive.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.
|
io.atomix.cluster.NodeId |
nodeId() |
void |
open()
Opens the session.
|
void |
publish(io.atomix.primitive.event.PrimitiveEvent event) |
ReadConsistency |
readConsistency()
Returns the session read consistency.
|
void |
registerIndexQuery(long index,
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,
Runnable query)
Registers a causal session query.
|
void |
removeListener(io.atomix.primitive.session.SessionEventListener listener) |
void |
resendEvents(long index)
Resends events from the given sequence.
|
void |
resetRequestSequence(long requestSequence)
Resets the current request sequence number.
|
String |
serviceName() |
io.atomix.primitive.PrimitiveType |
serviceType() |
io.atomix.primitive.session.SessionId |
sessionId() |
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.
|
String |
toString() |
public RaftSession(io.atomix.primitive.session.SessionId sessionId,
io.atomix.cluster.NodeId member,
String name,
io.atomix.primitive.PrimitiveType primitiveType,
ReadConsistency readConsistency,
long minTimeout,
long maxTimeout,
long lastUpdated,
RaftServiceContext context,
io.atomix.protocols.raft.impl.RaftContext server,
io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory)
public io.atomix.primitive.session.SessionId sessionId()
sessionId in interface io.atomix.primitive.session.Sessionpublic String serviceName()
serviceName in interface io.atomix.primitive.session.Sessionpublic io.atomix.primitive.PrimitiveType serviceType()
serviceType in interface io.atomix.primitive.session.Sessionpublic io.atomix.cluster.NodeId nodeId()
nodeId in interface io.atomix.primitive.session.Sessionpublic 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 io.atomix.primitive.session.Session.State getState()
getState in interface io.atomix.primitive.session.Sessionpublic void addListener(io.atomix.primitive.session.SessionEventListener listener)
addListener in interface io.atomix.primitive.session.Sessionpublic void removeListener(io.atomix.primitive.session.SessionEventListener listener)
removeListener in interface io.atomix.primitive.session.Sessionpublic 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,
Runnable query)
sequence - The session sequence number at which to execute the query.query - The query to execute.public void registerIndexQuery(long index,
Runnable query)
index - The state machine index at which to execute the query.query - The query to execute.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(io.atomix.primitive.event.PrimitiveEvent event)
publish in interface io.atomix.primitive.session.Sessionpublic 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()
Copyright © 2013–2018. All rights reserved.