Class AbstractHttpSessionCollection
- All Implemented Interfaces:
CoherenceHttpSessionCollection,HttpSessionCollection
- Direct Known Subclasses:
MonolithicHttpSessionCollection,TraditionalHttpSessionCollection
- Version:
- Coherence 2.3
- Author:
- cp 2003.10.14
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA simple implementation of the AttributeScopeController interface that scopes all attributes to the application by prepending the name of the application to all attribute names.static classA simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed in a distributed manner.static classA simple implementation of the AttributeScopeController interface that does not scope attributes.static classA simple implementation of the SessionDistributionController interface that forces all sessions and serializable attributes to be managed in a distributed manner.static classA simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed locally.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriterNested classes/interfaces inherited from interface com.tangosol.coherence.servlet.HttpSessionCollection
HttpSessionCollection.AttributeScopeController, HttpSessionCollection.SessionDistributionController -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the local cache that stores the session attributes that are not distributed (if there is a distribution controller or attributes are allowed to become local when serialization fails).static final StringThe name of the local cache that stores the sessions that are not yet distributed (if there is a distribution controller).static final StringThe name of the clustered cache that stores the sessions.static final StringConfiguration property to enable debug logging for Session access.static final StringConfiguration property to enable debug logging for Session access.protected final ConcurrentHashMap<String, String> Data structure for recording lock and unlock calls of session IDs for triaging Bug 27854987static final StringThe name of the clustered invocation service that manages sticky session ownership. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMove the session into an active state, if it is not already.voidaddHttpSessionAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener) Sign up the specified listener to receive HttpSessionBindingEvent objects.voidaddHttpSessionListener(javax.servlet.http.HttpSessionListener listener) Sign up the specified listener to receive HttpSessionEvent objects.protected voidcleanUpDeletedSessions(Set<String> setDeletedIds) Clean up the HttpSession objects that are no longer alive.protected voidClear the cluster cache reference.voidconfigure(XmlElement xml, SessionHelper sessionHelper) Configure the session collection using the xml document.create(javax.servlet.http.HttpSession session) This method creates a new session, returning the session model for the new session.This method attempts to create a new session with a specific ID, returning the session model for the new session.Deletes the locally opened sessions in the session-cache which have timed out, using an EntryProcessor and return the ids of the deleted sessions.Delete the sessions in the session-cache which have timed out, using an EntryProcessor and return the ids of deleted sessions.protected voidvoidDestroy the specified session.protected voidDestroy the cache of local-only session attributes for the specified session ID.Ensure the cache of existent distributed session models.protected MapGet the cache of local-only session attributes for the specified session ID.booleanObtain any necessary ownership for the specified session.booleanObtain any necessary ownership for the specified session.voidRelease ownership for the specified session.voidRelease ownership for the specified session.protected voidprotected StringGenerate a potential session ID.Obtain the HttpSessionModel for the specified session, or null if it does not exist.protected NamedCacheGet the cache of active sessions.protected NamedCacheGet the cache used to control concurrent access to a session by multiple applications, if application locking is used.intCalculate the average lifetime (in seconds) of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset.intCalculate the average size (in bytes) of session model objects placed in the session storage clustered cache since the last time statistics were reset.protected CacheDelegatorGet the cache delegator.Get the cache of existent distributed session models.protected AbstractHttpSessionCollectionObtain the AbstractHttpSessionCollection that is being used in the current application.Get the XML configuration document.protected longDetermine the current time value in milliseconds.intDetermine the default maximum interval, in seconds, that a session will be kept alive without any activity.protected StringReturns a string representation of this object's attributes.Get the SessionDistributionController for the session collection, if one was specified.protected ListenersDetermine the list of listeners that are registered for session attribute modification events.protected com.tangosol.coherence.servlet.HttpSessionCollectionConfigurationGet the instantiated Configurationprotected ListenersDetermine the list of listeners that are registered for session life cycle events.Get the cache of local-only session attributes.Get the cache of existent local-only session models.Get the local-only session model cache nameReturns the set of ids locally opened session.Returns a snapshot of the set of ids locally opened session.intReturn the maximum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset.intReturn the minimum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset.protected AbstractHttpSessionModelObtain the specified session model.protected AbstractHttpSessionModelObtain the specified session model.intReturn the number of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset.intReturn the number of updates to session model objects since the last time statistics were reset.protected NamedCacheGet the cache of owned ("locally live") session models.protected AbstractHttpSessionModelgetOwnedModel(String sId) Obtain the specified session model that this thread owns, otherwise throw an exception.Get the AttributeScopeController for the session collection, if one was specified.Get the serializer used to serialize and deserialize session attributes.protected StringGet the Session Access Debug Logging attribute filterprotected FilterGenerates a session expiry filter based on the configured factories.Retrieve the HttpSessionIdGenerator used by this session collection to generate session identifiers.intDetermine the length that session IDs will be created with.protected MemberDetermine which cluster member (if any) holds the lock for the given session ID.Get the cache of information about sessions that are stuck to this member, if sticky ownership is used.Get the cache of session ExitTasks for sessions that are stuck to this member, if sticky ownership is used.protected InvocationServiceGet the invocation service to use to manage sticky session ownership.protected abstract AbstractHttpSessionModelinstantiateModel(javax.servlet.http.HttpSession session, String sId) Factory Method: Instantiate a AbstractHttpSessionModel or subclass thereof.booleanDetermine if the specified session ID identifies a session that is in the active state.protected booleanDetermine if non-serializable attributes should be preserved as local.protected booleanDetermine whether or not two or more applications should be prevented from accessing the same session simultaneously.protected booleanDetermine if it can be assumed that each existent session is managed on a server that is doing reaping, and thus each server can reap only the sessions that are managed on it.protected booleanDetermines if attribute listeners should be executed if the same instance of a session attribute is being replaced in the session.protected booleanDetermine if Session Access Debug Logging is Enabledprotected booleanDetermine if suspect attributes need special treatment.booleanisExistent(String sId) Determine if the specified session ID identifies a session that exists.protected booleanDetermine whether or not two or more JVMs should be prevented from accessing the same session simultaneously.booleanDetermine if the specified session ID identifies a session that exists and that this thread has ownership for, either by a call toenter(sId)orcreate()without a corresponding call toexit(sId).booleanDetermine if the sticky session ownership option is on.protected booleanDetermine whether concurrent access to a session is permitted.booleanisStrict()Determine if the Servlet specification is being followed strictly.protected booleanDetermine if the specified session is stuck.protected booleanDetermine whether a session should be single threaded (only one request per session accessing the session at a time) or multithreaded (any number of requests accessing the session at a time).Obtain an iterator of the session IDs.Obtain an iterator of the session IDs that this JVM is responsible for invalidating when the sessions for those IDs have timed out.Obtain an iterator of the locally opened session IDs that are opened in this web application instance and have timed out.booleanDetermine whether to log exceptions thrown by the session during invalidation.protected booleanobtainAppOwnership(String sId, boolean fWait) Obtain application ownership for the specified session.protected booleanobtainClusterOwnership(String sId, boolean fWait) Obtain ownership within the cluster for the specified session.protected booleanObtain thread ownership of the specified session, if necessary.protected voidonModelUpdate(int cb) Notify the session collection that a model of the specified size (in bytes) was updated in the session storage clustered cache.voidMove the session into a passive state, if it is not already.voidpostCreate(javax.servlet.http.HttpSession session) This method is called at the end of the session creation process.protected static voidPuts the specified key/value pair into the specified map using the putAll() method, which does not return the previous value and thus may be more efficient in a distributed environment.protected voidrecordMapLocksState(String sKey, String sValue) Method to record mapLocks stateprotected voidRelease application ownership of the specified session.voidreleaseCache(NamedCache cache) Release the passed NamedCache instance.protected voidRelease ownership within the cluster of the specified session.protected booleanreleaseStuckSession(String sId, boolean fWait) Determine if the specified session is stuck, and if it is, to release it (or mark it to be released).protected booleanRelease thread ownership of the specified session.protected voidprotected static voidremoveAllBlind(Map map, Set<Object> colKeys) Removes the specified key/value pairs from the specified map using the keySet().removeAll() method, which does not return the previous value and thus may be more efficient in a distributed environment.protected static voidremoveBlind(Map map, Object oKey) Removes the specified key/value pair from the specified map using the keySet().remove() method, which does not return the previous value and thus may be more efficient in a distributed environment.voidremoveHttpSessionAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener) Sign off the specified listener so it no longer will receive HttpSessionBindingEvent objects.voidremoveHttpSessionListener(javax.servlet.http.HttpSessionListener listener) Sign off the specified listener so it no longer will receive HttpSessionEvent objects.protected ObjectremoveMapLocksState(String sKey) Method to remove mapLocks statevoidReset all statistics maintained by this session collection.protected voidsetCacheDelegator(CacheDelegator cacheDelegator) Set the cache delegator object.protected voidsetConfiguration(com.tangosol.coherence.servlet.HttpSessionCollectionConfiguration config) Set the configuration object.voidsetSerializer(Serializer serializer) Set the serializer used to serialize and deserialize session attributes.voidshutdown()Notify the session collection that it is being shut down.toString()Returns a string representation of the object.protected voidupdateSessionStatitics(String sId, AbstractHttpSessionModel model) Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Field Details
-
CTX_INIT_ENABLE_SESSION_ACCESS_DEBUG_LOGGING
Configuration property to enable debug logging for Session access.- See Also:
-
CTX_INIT_SESSION_ACCESS_DEBUG_LOGGING_FILTER
Configuration property to enable debug logging for Session access.- See Also:
-
CACHENAME_SESSIONS
The name of the clustered cache that stores the sessions.- See Also:
-
CACHENAME_LOCAL_SESSIONS
The name of the local cache that stores the sessions that are not yet distributed (if there is a distribution controller).- See Also:
-
CACHENAME_LOCAL_ATTRIBUTES
The name of the local cache that stores the session attributes that are not distributed (if there is a distribution controller or attributes are allowed to become local when serialization fails).- See Also:
-
SERVICENAME_OWNERSHIP
The name of the clustered invocation service that manages sticky session ownership.- See Also:
-
f_mapLocks
Data structure for recording lock and unlock calls of session IDs for triaging Bug 27854987
-
-
Constructor Details
-
AbstractHttpSessionCollection
public AbstractHttpSessionCollection()Default constructor (required).
-
-
Method Details
-
getCollection
Obtain the AbstractHttpSessionCollection that is being used in the current application.- Returns:
- the singleton instance of the AbstractHttpSessionCollection
-
getConfig
Get the XML configuration document.- Returns:
- the XML configuration document
-
configure
Configure the session collection using the xml document.- Specified by:
configurein interfaceCoherenceHttpSessionCollection- Parameters:
xml- the xml elementsessionHelper- the session helper
-
create
This method creates a new session, returning the session model for the new session.The session is created with the default timeout, and has an ID that is unique within the domain that the session management layer is configured for (e.g. within the JVM, or within the cluster.)
When the session model is returned, the session state is exists, owned, active. Note that the responsibilities associated with the
enter()method are included as part of the session creation process.The model will retain the reference to the HttpSession object until it is passivated or destroyed.
- Specified by:
createin interfaceHttpSessionCollection- Parameters:
session- the HttpSession object to bind the session model to; used for issuing events; must not be null- Returns:
- the HttpSessionModel object for the new session
-
postCreate
public void postCreate(javax.servlet.http.HttpSession session) This method is called at the end of the session creation process.When this method is called, the session state is exists, owned, active.
- Specified by:
postCreatein interfaceHttpSessionCollection- Parameters:
session- the HttpSession object; must not be null
-
isExistent
Determine if the specified session ID identifies a session that exists.The notion of ownership will affect whether or not the answer can be trusted once the method has returned it. If the ownership state is owned (the current thread called
enter(sId)), then the caller should assume that session still exists. Otherwise, the caller can only assume that the session did exist at the point in time that the call to this method was made.- Specified by:
isExistentin interfaceHttpSessionCollection- Parameters:
sId- the session ID to check for existence- Returns:
- true if the session exists; false otherwise
-
destroy
Destroy the specified session.This method may only be called on a session that is exists, owned, active.
Session attributes will receive HttpSessionBindingListener as per the Servlet specification.
At the return point from this method, the session state is does not exist. Note that the responsibilities associated with the
exit(sId)method are included as part of the session destruction process.After this method completes, the model's HttpSession reference will be null.
- Specified by:
destroyin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be null
-
fireSessionDestroyedListeners
-
deleteModelFromLocalCaches
-
updateSessionStatitics
-
enter
Obtain any necessary ownership for the specified session. Ownership requirements are expected to be declarative, so this method may be a no-op, or it may involve thread-level, application-level, or even cluster-wide locking.If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
This method must support Multiple Possession Semantics, meaning that this method may be invoked multiple times, and each invocation will require a corresponding call to the
exit(sId)method in order to release the ownership.- Specified by:
enterin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be nullfWait- true if the thread should block until the session becomes available; false otherwise- Returns:
- true if the session is now owned by the calling thread
-
enter
Obtain any necessary ownership for the specified session. Ownership requirements are expected to be declarative, so this method may be a no-op, or it may involve thread-level, application-level, or even cluster-wide locking.If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
This method must support Multiple Possession Semantics, meaning that this method may be invoked multiple times, and each invocation will require a corresponding call to the
exit(sId)method in order to release the ownership.- Specified by:
enterin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be nullfWait- true if the thread should block until the session becomes available; false otherwisefExclusive- if true, prevent other threads from entering the specified session until a corresponding call toHttpSessionCollection.exit(String, boolean, boolean)is made by the calling thread- Returns:
- true if the session is now owned by the calling thread
-
isOwned
Determine if the specified session ID identifies a session that exists and that this thread has ownership for, either by a call toenter(sId)orcreate()without a corresponding call toexit(sId). NOTE! Since an asynchronous exit task could have been scheduled bySessionHelper.requestAsyncOwnership(String), this method should not be used to determine if exit should be called or not.NOTE, since an asynchronous exit task could have been scheduled by
SessionHelper.requestAsyncOwnership(String), this method should not be used to determine if exit should be called or not.- Specified by:
isOwnedin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be null- Returns:
- true if the session is owned; false otherwise.
-
exit
Release ownership for the specified session. This method must be called exactly once for each call toenter(sId), with the only exceptions being:- If the session no longer exists, exit should not be called.
- If the session was created as part of the HTTP request processing,
this method must be invoked even though the corresponding
enter(sId)method was never invoked.
When ownership state of a new session changes from owned to not owned, the session will no longer be considered new.
If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
- Specified by:
exitin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be nullfFlush- pass true if the session has been potentially modified; even then, there's no guarantee that the session state will be flushed if there is another thread that is using the session concurrently. In this case, the last exiting thread will flush
-
exit
Release ownership for the specified session. This method must be called exactly once for each call toenter(sId), with the only exceptions being:- If the session no longer exists, exit should not be called.
- If the session was created as part of the HTTP request processing,
this method must be invoked even though the corresponding
enter(sId)method was never invoked.
When ownership state of a new session changes from owned to not owned, the session will no longer be considered new.
If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
- Specified by:
exitin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be nullfFlush- pass true if the session has been potentially modified; even then, there's no guarantee that the session state will be flushed if there is another thread that is using the session concurrently. In this case, the last exiting thread will flushfExclusive- if true, a previous call toHttpSessionCollection.enter(String, boolean, boolean)should have been made where the fExclusive was set to true
-
remapSessionId
-
activate
Move the session into an active state, if it is not already. The active state is defined as the state in which the session is considered to be "live" in a particular JVM. This primarily relates to the optional event interfce (HttpSessionActivationListener) that session attributes can implement to find out when the session is passivated and activated.Invoking this method will issue activation events for session attributes that implement the HttpSessionActivationListener interface. The model will retain the reference to the HttpSession object until it is passivated or destroyed.
- Specified by:
activatein interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be nullsession- the HttpSession object to bind the session model to; used for issuing events; must not be null
-
logInvalidationExceptions
public boolean logInvalidationExceptions()Determine whether to log exceptions thrown by the session during invalidation.- Returns:
- true, if exceptions should be logged
-
isActive
Determine if the specified session ID identifies a session that is in the active state.This method may only be called within the bounds of a call to
enter(sId)andexit(sId).- Specified by:
isActivein interfaceHttpSessionCollection- Parameters:
sId- the session ID to check for the active state- Returns:
- true if the session exists and is active; false otherwise
-
passivate
Move the session into a passive state, if it is not already.Invoking this method will issue passivation events for session attributes that implement the HttpSessionActivationListener interface.
After this method completes, the model's HttpSession reference will be null.
- Specified by:
passivatein interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be null
-
deleteExpiredSessions
Delete the sessions in the session-cache which have timed out, using an EntryProcessor and return the ids of deleted sessions.- Specified by:
deleteExpiredSessionsin interfaceHttpSessionCollection- Returns:
- the set of ids of sessions that are deleted
-
deleteExpiredLocalSessions
Deletes the locally opened sessions in the session-cache which have timed out, using an EntryProcessor and return the ids of the deleted sessions.- Specified by:
deleteExpiredLocalSessionsin interfaceHttpSessionCollection- Returns:
- the set of ids of sessions that are deleted
-
cleanUpDeletedSessions
Clean up the HttpSession objects that are no longer alive. This will remove the sessions from local maps etc.- Parameters:
setDeletedIds- the set of deleted ids
-
iterateIds
Obtain an iterator of the session IDs.The list of IDs is completely dynamic because of the nature of multi-threaded and distributed systems. The fact that an ID is returned from an iterator is no guarantee that the ID is still valid.
- Specified by:
iterateIdsin interfaceHttpSessionCollection- Returns:
- an iterator that iterates over all String session IDs
-
iteratePotentiallyExpiredIds
Obtain an iterator of the session IDs that this JVM is responsible for invalidating when the sessions for those IDs have timed out.This may return an iterator with the same contents as the one returned by the
HttpSessionCollection.iterateIds()method, or it may return an iterator that iterates over a subset of those contents.The list of IDs is completely dynamic because of the nature of multi-threaded and distributed systems. The fact that an ID is returned from an iterator is no guarantee that the ID is still valid, or that it has expired.
- Specified by:
iteratePotentiallyExpiredIdsin interfaceHttpSessionCollection- Returns:
- an iterator that iterates over the session IDs that this JVM is responsible for periodically checking for expiry
-
iteratePotentiallyExpiredLocalIds
Obtain an iterator of the locally opened session IDs that are opened in this web application instance and have timed out. Ideally, an implementation should use an EntryProcessor to filter the local session set and return only timed out sessions- Specified by:
iteratePotentiallyExpiredLocalIdsin interfaceHttpSessionCollection- Returns:
- an iterator that iterates over the session IDs that are local to this web application instance and has timed out
-
getSessionExpiryFilter
Generates a session expiry filter based on the configured factories.- Returns:
- A session expiry filter
-
get
Obtain the HttpSessionModel for the specified session, or null if it does not exist.This method may only be called within the bounds of a call to
enter(sId)andexit(sId).- Specified by:
getin interfaceHttpSessionCollection- Parameters:
sId- the session ID; must not be null- Returns:
- the HttpSessionModel for the requested session or null
-
getLocalSessionIds
Returns the set of ids locally opened session.- Returns:
- the set of ids of locally opened sessions
-
getLocalSessonIdsSnapshot
Returns a snapshot of the set of ids locally opened session.- Returns:
- a snapshot of the set of ids of locally opened sessions
-
addHttpSessionListener
public void addHttpSessionListener(javax.servlet.http.HttpSessionListener listener) Sign up the specified listener to receive HttpSessionEvent objects.- Specified by:
addHttpSessionListenerin interfaceHttpSessionCollection- Parameters:
listener- the HttpSessionListener to sign up for events
-
removeHttpSessionListener
public void removeHttpSessionListener(javax.servlet.http.HttpSessionListener listener) Sign off the specified listener so it no longer will receive HttpSessionEvent objects.- Specified by:
removeHttpSessionListenerin interfaceHttpSessionCollection- Parameters:
listener- the HttpSessionListener that was previously signed up for events
-
addHttpSessionAttributeListener
public void addHttpSessionAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener) Sign up the specified listener to receive HttpSessionBindingEvent objects.- Specified by:
addHttpSessionAttributeListenerin interfaceHttpSessionCollection- Parameters:
listener- the HttpSessionAttributeListener to sign up for events
-
removeHttpSessionAttributeListener
public void removeHttpSessionAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener) Sign off the specified listener so it no longer will receive HttpSessionBindingEvent objects.- Specified by:
removeHttpSessionAttributeListenerin interfaceHttpSessionCollection- Parameters:
listener- the HttpSessionAttributeListener that was previously signed up for events
-
shutdown
public void shutdown()Notify the session collection that it is being shut down. After this method invocation has been made, the session collection may throw IllegalStateException for any subsequent method invocation made to it.- Specified by:
shutdownin interfaceHttpSessionCollection
-
toString
Returns a string representation of the object. -
getHttpSessionListeners
Determine the list of listeners that are registered for session life cycle events.- Returns:
- the non-null Listeners object containing zero or more HttpSessionListeners
-
getHttpSessionAttributeListeners
Determine the list of listeners that are registered for session attribute modification events.- Returns:
- the non-null Listeners object containing zero or more HttpSessionAttributeListeners
-
getHttpSessionCollectionConfiguration
protected com.tangosol.coherence.servlet.HttpSessionCollectionConfiguration getHttpSessionCollectionConfiguration()Get the instantiated Configuration- Returns:
- HttpSessionCollectionConfiguration
-
isStrict
public boolean isStrict()Determine if the Servlet specification is being followed strictly.- Returns:
- true if the Servlet specification is being followed strictly
-
getDefaultMaxInactiveInterval
public int getDefaultMaxInactiveInterval()Determine the default maximum interval, in seconds, that a session will be kept alive without any activity.- Returns:
- the default number of seconds to keep an inactive session
-
isSessionLockingEnforced
protected boolean isSessionLockingEnforced()Determine whether concurrent access to a session is permitted. IfisMemberLockingEnforced()orisAppLockingEnforced()orisMemberLockingEnforced()return true, then so will this method.If this is set to false, then concurrent access is permitted and the last update wins.
- Returns:
- true if concurrent access to a session is limited.
-
isMemberLockingEnforced
protected boolean isMemberLockingEnforced()Determine whether or not two or more JVMs should be prevented from accessing the same session simultaneously.- Returns:
- true to limit the access to a session to one JVM at a time
-
isAppLockingEnforced
protected boolean isAppLockingEnforced()Determine whether or not two or more applications should be prevented from accessing the same session simultaneously.Note that application-level locking requires that member-level session locking is enabled. In other words, if this method returns true, the value of
isMemberLockingEnforced()will also be true.- Returns:
- true to limit the access to a session to one application at a time
-
isThreadLockingEnforced
protected boolean isThreadLockingEnforced()Determine whether a session should be single threaded (only one request per session accessing the session at a time) or multithreaded (any number of requests accessing the session at a time).Note that a single threaded session requires that both member-level and application-level session locking are enabled. In other words, if this method returns true, the value of
isMemberLockingEnforced()andisAppLockingEnforced()will also be true.- Returns:
- true to limit the access to a session to one thread at a time
-
getCurrentTime
protected long getCurrentTime()Determine the current time value in milliseconds.- Returns:
- the current time value in milliseconds
-
isEnabledSessionAccessDebugLogging
protected boolean isEnabledSessionAccessDebugLogging()Determine if Session Access Debug Logging is Enabled- Returns:
- true if coherence-enable-session-access-debug-logging=true in application web.xml
-
getSessionAccessDebugLoggingFilter
Get the Session Access Debug Logging attribute filter- Returns:
- Comma Delimited String of session attribute prefixes configured in application web.xml
-
getSerializer
Get the serializer used to serialize and deserialize session attributes.- Specified by:
getSerializerin interfaceHttpSessionCollection- Returns:
- a serializer; never null
-
setSerializer
Set the serializer used to serialize and deserialize session attributes.- Specified by:
setSerializerin interfaceHttpSessionCollection- Parameters:
serializer- a serializer; must not be null
-
create
This method attempts to create a new session with a specific ID, returning the session model for the new session. It is assumed that the specified ID isn't used by any existing session.The session is created with the default timeout.
When the session model is returned, the session state is exists, owned, active. Note that the responsibilities associated with the
enter()method are included as part of the session creation process.The model will retain the reference to the HttpSession object until it is passivated or destroyed.
- Specified by:
createin interfaceHttpSessionCollection- Parameters:
session- the HttpSession object to bind the session model to; used for issuing events; must not be nullsId- the session id- Returns:
- the HttpSessionModel object for the new session
-
getDescription
Returns a string representation of this object's attributes.- Returns:
- a string representation of this object's attributes
-
getStickyCache
Get the cache of information about sessions that are stuck to this member, if sticky ownership is used.- Returns:
- a cache mapping from session id to sticky status (either Boolean.TRUE to indicate stuck or Boolean.FALSE to indicate that it is stuck but that it has been marked for release)
-
getStickyExitTaskCache
Get the cache of session ExitTasks for sessions that are stuck to this member, if sticky ownership is used.- Returns:
- a cache mapping from session id to ExitTask that can be used to exit (thus unstick) the corresponding session
-
getStickyService
Get the invocation service to use to manage sticky session ownership.- Returns:
- the invocation service to use to manage sticky session ownership
-
getAppControlCache
Get the cache used to control concurrent access to a session by multiple applications, if application locking is used.- Returns:
- a cache mapping from session id to application ownership information (an object array of size two, with the first element being the owning HttpSessionCollection and the second element being an Integer reference count)
-
getActiveCache
Get the cache of active sessions.- Returns:
- a cache of active sessions; the cache maps from session ID to HttpSession objects
-
getOwnedCache
Get the cache of owned ("locally live") session models. The concept of "locally live" is internal to this collection implementation, and is not part of the collection/model design itself. A model is considered "locally live" if it is existent and has been entered, until the point that it is fully exited or destroyed.- Returns:
- a cache of owned session models; the cache maps from session ID to HttpSessionModel objects
-
ensureClusterCache
Ensure the cache of existent distributed session models.- Returns:
- a cache that maps from session ID to HttpSessionModel objects
-
getClusterCache
Get the cache of existent distributed session models.- Returns:
- a cache that maps from session ID to HttpSessionModel objects
-
clearClusterCache
protected void clearClusterCache()Clear the cluster cache reference. -
getCacheDelegator
Get the cache delegator.- Returns:
- the CacheDelegator obj
-
setCacheDelegator
Set the cache delegator object.- Parameters:
cacheDelegator- the cache delegator
-
setConfiguration
protected void setConfiguration(com.tangosol.coherence.servlet.HttpSessionCollectionConfiguration config) Set the configuration object.- Parameters:
config- the configuration object.
-
getDistributionController
Get the SessionDistributionController for the session collection, if one was specified.- Returns:
- the controller object, or null if none was specified
-
getScopeController
Get the AttributeScopeController for the session collection, if one was specified.- Returns:
- the controller object, or null if none was specified
-
getLocalCacheName
Get the local-only session model cache name- Returns:
- the local-only session model cache name
-
getLocalCache
Get the cache of existent local-only session models.- Returns:
- a cache that maps from session ID to HttpSessionModel objects
-
getLocalAttributesCache
Get the cache of local-only session attributes.- Returns:
- a cache that maps from session ID and attribute name to AttributeHolder objects
-
ensureLocalAttributesCache
Get the cache of local-only session attributes for the specified session ID.- Parameters:
sId- the session ID- Returns:
- a cache that maps attribute name to AttributeHolder objects
-
destroyLocalAttributesCache
Destroy the cache of local-only session attributes for the specified session ID.- Parameters:
sId- the session ID
-
isOwnershipSticky
public boolean isOwnershipSticky()Determine if the sticky session ownership option is on.This is available only if an Enterprise Edition or Grid Edition license is available.
- Returns:
- true iff the sticky session ownership option is on
-
isStuck
Determine if the specified session is stuck.- Parameters:
sId- the session id- Returns:
- true iff the specified session is stuck
-
getSessionOwnershipInfo
Determine which cluster member (if any) holds the lock for the given session ID.- Parameters:
sId- the session ID- Returns:
- the member that holds the lock for the given session ID
-
obtainClusterOwnership
Obtain ownership within the cluster for the specified session.This method assumes that the owned cache is locked for the passed session id.
- Parameters:
sId- the id of the session to obtain ownership forfWait- true to wait for the session to become available, false to give up immediately if ownership of the session is currently unavailable- Returns:
- true on successfully obtaining ownership, false otherwise
-
releaseClusterOwnership
Release ownership within the cluster of the specified session.This method assumes that the owned cache is locked for the passed session ID.
- Parameters:
sId- the ID of the session to release ownership of
-
releaseStuckSession
Determine if the specified session is stuck, and if it is, to release it (or mark it to be released). This method is only designed to be called from an invocation agent.- Parameters:
sId- the session id to unstick if it's stuck herefWait- true to wait for the session to be release or be marked to be released, false to give up immediately if ownership of the session is currently unavailable- Returns:
- true if the session is/was stuck here and is now released or is marked to be released
-
obtainAppOwnership
Obtain application ownership for the specified session.This method assumes that the owned cache is locked for the passed session ID.
- Parameters:
sId- the ID of the session to obtain ownership forfWait- true to wait for the session to become available, false to give up immediately if ownership of the session is currently unavailable- Returns:
- true on successfully obtaining ownership, false otherwise
-
releaseAppOwnership
Release application ownership of the specified session.This method assumes that the owned cache is locked and cluster ownership has been obtained for the passed session ID.
- Parameters:
sId- the ID of the session to release ownership of
-
obtainThreadOwnership
Obtain thread ownership of the specified session, if necessary.If thread locking is enforced this method has no effect and false is returned; otherwise, the given ID is locked in the local owned cache and true is returned. A return value of true implies that
releaseThreadOwnership(sId)must be called when exclusive access to the session is no longer required.This method may only be called within the bounds of a call to
enter(sId)andexit(sId).- Parameters:
sId- the ID of the session to obtain ownership for- Returns:
- true if the given ID was locked in the local owned cache; false otherwise
-
releaseThreadOwnership
Release thread ownership of the specified session.This method may only be called within the bounds of a call to
enter(sId)andexit(sId).- Parameters:
sId- the ID of the session to release ownership of- Returns:
- true if the thread ownership is released; false otherwise
-
isAllowLocalAttributes
protected boolean isAllowLocalAttributes()Determine if non-serializable attributes should be preserved as local.This feature is available only if the sticky session ownership option is on and is enforced if a distribution controller is specified.
- Returns:
- true iff non-serializable attributes should be preserved
-
isEnableSuspectAttributes
protected boolean isEnableSuspectAttributes()Determine if suspect attributes need special treatment.- Returns:
- true iff suspect attributes need special treatment
-
isEnableAttributeListenerOptimization
protected boolean isEnableAttributeListenerOptimization()Determines if attribute listeners should be executed if the same instance of a session attribute is being replaced in the session.- Returns:
- true if the optimization should be used
-
isAssumeLocality
protected boolean isAssumeLocality()Determine if it can be assumed that each existent session is managed on a server that is doing reaping, and thus each server can reap only the sessions that are managed on it.- Returns:
- return true if and only if each existent session is managed on a server that is doing reaping
-
getSessionIdLength
public int getSessionIdLength()Determine the length that session IDs will be created with.- Returns:
- the length, in characters, for session IDs
-
getSessionIdGenerator
Retrieve the HttpSessionIdGenerator used by this session collection to generate session identifiers.- Returns:
- the HttpSessionIdGenerator
-
generateSessionId
Generate a potential session ID. The returned id may be in use already.- Returns:
- a seemingly random session id
-
instantiateModel
protected abstract AbstractHttpSessionModel instantiateModel(javax.servlet.http.HttpSession session, String sId) Factory Method: Instantiate a AbstractHttpSessionModel or subclass thereof.- Parameters:
session- the session that delegates to this modelsId- the session ID- Returns:
- a new instance of AbstractHttpSessionModel or subclass thereof
-
getOwnedModel
Obtain the specified session model that this thread owns, otherwise throw an exception.- Parameters:
sId- the session ID- Returns:
- the specified model if it exists and this thread owns it
- Throws:
IllegalStateException- if the model does not exist, or it is not owned by this thread
-
getModel
Obtain the specified session model.- Parameters:
sId- the session ID * @param fLite when set to true then if a near cache is used, the front map is avoided; thus avoiding listener registration and unnecessary eviction on the front map- Returns:
- the specified model if it exists, null otherwise * @since 12.1.3.0.7
-
getModel
Obtain the specified session model.- Parameters:
sId- the session ID- Returns:
- the specified model if it exists, null otherwise
-
putBlind
Puts the specified key/value pair into the specified map using the putAll() method, which does not return the previous value and thus may be more efficient in a distributed environment.- Parameters:
map- the map to store the key/value pair intooKey- the key to storeoValue- the value to store
-
removeBlind
Removes the specified key/value pair from the specified map using the keySet().remove() method, which does not return the previous value and thus may be more efficient in a distributed environment.- Parameters:
map- the map to remove the key/value pair fromoKey- the key to remove
-
removeAllBlind
Removes the specified key/value pairs from the specified map using the keySet().removeAll() method, which does not return the previous value and thus may be more efficient in a distributed environment.- Parameters:
map- the map to remove the key/value pairs fromcolKeys- the collection of keys which needs to be removed
-
releaseCache
Release the passed NamedCache instance.- Parameters:
cache- a NamedCache instance to release (may be null)
-
getAverageModelLifetime
public int getAverageModelLifetime()Calculate the average lifetime (in seconds) of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset.- Returns:
- the average model lifetime (in seconds)
-
getAverageModelSize
public int getAverageModelSize()Calculate the average size (in bytes) of session model objects placed in the session storage clustered cache since the last time statistics were reset.- Returns:
- the average model size (in bytes)
-
getMaxModelSize
public int getMaxModelSize()Return the maximum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset.- Returns:
- the maximum model size (in bytes)
-
getMinModelSize
public int getMinModelSize()Return the minimum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset.- Returns:
- the minimum model size (in bytes)
-
getModelDeaths
public int getModelDeaths()Return the number of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset.- Returns:
- the number of invalidated session models
-
getModelUpdates
public int getModelUpdates()Return the number of updates to session model objects since the last time statistics were reset.- Returns:
- the number of updates to the session storage cache
-
resetStatistics
public void resetStatistics()Reset all statistics maintained by this session collection. -
onModelUpdate
protected void onModelUpdate(int cb) Notify the session collection that a model of the specified size (in bytes) was updated in the session storage clustered cache.- Parameters:
cb- the size (in bytes) of the session model
-
recordMapLocksState
Method to record mapLocks state- Parameters:
sKey- key to record the mapLocks statesValue- value of the recorded mapLocks state
-
removeMapLocksState
Method to remove mapLocks state- Parameters:
sKey- key to remove the mapLocks state
-