Package io.atomix.primitive.session
Interface Sessions
public interface Sessions extends Iterable<Session>
Provides a set of active server sessions.
Server state machines can use the Sessions object to access the list of sessions currently open to the
state machine. Session sets are guaranteed to be deterministic. All state machines will see the same set of
open sessions at the same point in the log except in cases where a session has already been closed and removed.
If a session has already been closed on another server, the session is guaranteed to have been expired on all
servers and thus operations like Session.publish(PrimitiveEvent) are effectively no-ops.
-
Method Summary
Modifier and Type Method Description SessionsaddListener(SessionListener listener)Adds a listener to the sessions.SessiongetSession(long sessionId)Returns a session by session ID.SessionsremoveListener(SessionListener listener)Removes a listener from the sessions.
-
Method Details
-
getSession
Returns a session by session ID.- Parameters:
sessionId- The session ID.- Returns:
- The session or
nullif no session with the givensessionIdexists.
-
addListener
Adds a listener to the sessions.- Parameters:
listener- The listener to add.- Returns:
- The sessions.
- Throws:
NullPointerException- if the sessionlistenerisnull
-
removeListener
Removes a listener from the sessions.- Parameters:
listener- The listener to remove.- Returns:
- The sessions.
-