Class SessionMgr
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault timeout before an app session is disposed of when no more client sessions are present, default 10 minutes.static final longDefault heartbeat interval to keep the communication link up, 45 seconds: the default of the server setting$heartBeatInterval(ServerSettings.getClientHeartBeatInterval).static final longDefault timeout before a client session is disposed when it has not processes any transactions, default 2 hours.static final longThe longest heartbeat interval allowed, 5 minutes.static final longThe shortest heartbeat interval allowed, 30 seconds.static final longThe shortest idle time-out of a client's WebSocket link, 60 seconds, the fixed value it had before the time-out was derived from the heartbeat interval.Method Summary
Modifier and TypeMethodDescriptionlongGets the time-out of dormant sessions (paused/broken).longGets the heart-beat interval in milliseconds.longGets the idle time-out of session.static SessionMgrGets the Session Manager singleton.longGets the idle time-out of a client's WebSocket link, derived from the heartbeat interval in effect:max(MIN_LINK_IDLE_TIMEOUT, 2 x interval + 15 s)(WS-D-3).intGets the maximum queued transaction to keep.voidsetup(long dormatTimeout, long idleTimeout, long heartBeatInterval) Assigns the timeouts and heartbeat interval.
Field Details
DEFAULT_IDLE_TIMEOUT
public static final long DEFAULT_IDLE_TIMEOUTDefault timeout before a client session is disposed when it has not processes any transactions, default 2 hours. Value in milliseconds.- See Also:
DEFAULT_DORMANT_TIMEOUT
public static final long DEFAULT_DORMANT_TIMEOUTDefault timeout before an app session is disposed of when no more client sessions are present, default 10 minutes. Value in milliseconds.- See Also:
DEFAULT_HEARTBEAT_INTERVAL
public static final long DEFAULT_HEARTBEAT_INTERVALDefault heartbeat interval to keep the communication link up, 45 seconds: the default of the server setting$heartBeatInterval(ServerSettings.getClientHeartBeatInterval). Value in milliseconds.- See Also:
MIN_HEARTBEAT_INTERVAL
public static final long MIN_HEARTBEAT_INTERVALThe shortest heartbeat interval allowed, 30 seconds. Value in milliseconds.This is the one range of the heartbeat (WS-D-4):
ServerSettings.getClientHeartBeatIntervalclamps the configured value toMIN_HEARTBEAT_INTERVAL..MAX_HEARTBEAT_INTERVAL, andsetup(long, long, long)accepts exactly that range - before, the setting allowed up to 300 seconds and the setup threw above 120, so a configured value above two minutes stopped the server at start-up.- See Also:
MAX_HEARTBEAT_INTERVAL
public static final long MAX_HEARTBEAT_INTERVALThe longest heartbeat interval allowed, 5 minutes. Value in milliseconds. SeeMIN_HEARTBEAT_INTERVAL.- See Also:
MIN_LINK_IDLE_TIMEOUT
public static final long MIN_LINK_IDLE_TIMEOUTThe shortest idle time-out of a client's WebSocket link, 60 seconds, the fixed value it had before the time-out was derived from the heartbeat interval. Value in milliseconds. SeegetLinkIdleTimeout().- See Also:
Method Details
getInstance
Gets the Session Manager singleton.- Returns:
- The singleton instance.
setup
public void setup(long dormatTimeout, long idleTimeout, long heartBeatInterval) Assigns the timeouts and heartbeat interval. The new settings are taken into account directly. All values are in milliseconds.One INFO line names the values in effect: the heartbeat interval, the idle time-out of a client's WebSocket link derived from it, and the session idle and dormant time-outs (WS-D-6). The server calls this once at start-up, after its settings have clamped the configured values, so the line shows what runs, not what was configured.
- Parameters:
dormatTimeout- Timeout of dormant sessions (paused/broken), 30_000 to 43_200_000.idleTimeout- Idle timeout of session, 120_000 to 172_800_000.heartBeatInterval- Heartbeat interval,MIN_HEARTBEAT_INTERVALtoMAX_HEARTBEAT_INTERVAL.- Throws:
IllegalArgumentException- If the values are out of range.
getHeartBeatInterval
public long getHeartBeatInterval()Gets the heart-beat interval in milliseconds.getLinkIdleTimeout
public long getLinkIdleTimeout()Gets the idle time-out of a client's WebSocket link, derived from the heartbeat interval in effect:max(MIN_LINK_IDLE_TIMEOUT, 2 x interval + 15 s)(WS-D-3).The server's WebSocket (
InternalWebSocket) sets this on every client link it opens. Jetty expires a link that moved no byte in either direction for this long. The heartbeat PING the server writes every interval is such a byte, so a link whose PINGs are written never expires, and the time-out ends a link whose PINGs can no longer be written. It is derived so that two heartbeat intervals, with the tolerance ofSessionTransMgr.doTimeoutCheck, always fit inside it: with the fixed 60 seconds it had before, every interval of 60 seconds or more expired every idle client on every heartbeat, and a skipped 30 second tick raced the time-out.- Returns:
- The time-out in milliseconds, at least
MIN_LINK_IDLE_TIMEOUT.
getDormantTimeout
public long getDormantTimeout()Gets the time-out of dormant sessions (paused/broken).This value is used to check if dormant sessions is allowed or not.
- Returns:
- Time-out in milliseconds, -1L for indefinite, zero for not allowed (dormant sessions not allowed).
getIdleTimeout
public long getIdleTimeout()Gets the idle time-out of session. The idle-timeout includes dormant session time-out, i.e. when this time-out is reached, the session is disposed of.- Returns:
- Timeout in milliseconds, -1 for indefinite (i.e. no time-out).
getMaxTransactionQueue
public int getMaxTransactionQueue()Gets the maximum queued transaction to keep.