Class DistributedL2SessionManager
java.lang.Object
com.mulesoft.connectors.mcp.internal.server.session.DistributedL2SessionManager
- All Implemented Interfaces:
SessionManager
A
SessionManager implementation intended for cases in which the session information needs to be replicated across
several replicas that (might or might not) be using OSv2 and/or be part of a Hazelcast cluster.
For instance, consider the case of streamable Http transport in which the sessions outlast the lifespan of an http request but CloudHub doesn't support sticky sessions. Therefore, we need to make sure that whatever replica handles each request it gets access to the session even if it was established by another node.
For this we use a two-layer cache, in which L1 is backed by a Guava cache (with idle invalidation) and the L2 is an ObjectStore that might or might not be backed by Hazelcast or OSv2.
- Since:
- 0.2.0
-
Constructor Summary
ConstructorsConstructorDescriptionDistributedL2SessionManager(String ownerConfigName, org.mule.runtime.api.store.ObjectStore<MuleServerSession> l2ObjectStore, org.mule.runtime.api.lock.LockFactory lockFactory, Long sessionTimeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this instanceFor distributed implementations, it returns the sessions that were created in this particular Mule instances.recoverSession(String sessionId) booleanunregisterAndClose(String sessionId) Unregisters the session associated to thesessionIdand callsMcpSessionDecorator.close()on itvoidupsert(MuleServerSession session) Registers or updates the givensession
-
Constructor Details
-
DistributedL2SessionManager
public DistributedL2SessionManager(String ownerConfigName, org.mule.runtime.api.store.ObjectStore<MuleServerSession> l2ObjectStore, org.mule.runtime.api.lock.LockFactory lockFactory, Long sessionTimeoutMillis)
-
-
Method Details
-
recoverSession
- Specified by:
recoverSessionin interfaceSessionManager- Parameters:
sessionId- the session id- Returns:
- Optionally recover the session of the given
sessionId
-
upsert
Description copied from interface:SessionManagerRegisters or updates the givensession- Specified by:
upsertin interfaceSessionManager
-
unregisterAndClose
Description copied from interface:SessionManagerUnregisters the session associated to thesessionIdand callsMcpSessionDecorator.close()on it- Specified by:
unregisterAndClosein interfaceSessionManager- Parameters:
sessionId- the session id- Returns:
- whether a matching session existed or not
-
getLocalSessions
Description copied from interface:SessionManagerFor distributed implementations, it returns the sessions that were created in this particular Mule instances. For non distributed implementations, it just returns all sessions.- Specified by:
getLocalSessionsin interfaceSessionManager- Returns:
- a collection of sessions
-
close
public void close()Description copied from interface:SessionManagerCloses this instance- Specified by:
closein interfaceSessionManager
-