Class AbstractHttpSessionCollection

    • Field Detail

      • CACHENAME_SESSIONS

        public static final String CACHENAME_SESSIONS
        The name of the clustered cache that stores the sessions.
        See Also:
        Constant Field Values
      • CACHENAME_LOCAL_SESSIONS

        public static final String 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:
        Constant Field Values
      • CACHENAME_LOCAL_ATTRIBUTES

        public static final String 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:
        Constant Field Values
      • SERVICENAME_OWNERSHIP

        public static final String SERVICENAME_OWNERSHIP
        The name of the clustered invocation service that manages sticky session ownership.
        See Also:
        Constant Field Values
      • f_mapLocks

        protected final ConcurrentHashMap<String,​String> f_mapLocks
        Data structure for recording lock and unlock calls of session IDs for triaging Bug 27854987
    • Constructor Detail

      • AbstractHttpSessionCollection

        public AbstractHttpSessionCollection()
        Default constructor (required).
    • Method Detail

      • getCollection

        protected AbstractHttpSessionCollection getCollection()
        Obtain the AbstractHttpSessionCollection that is being used in the current application.
        Returns:
        the singleton instance of the AbstractHttpSessionCollection
      • getConfig

        public XmlElement getConfig()
        Get the XML configuration document.
        Returns:
        the XML configuration document
      • create

        public HttpSessionModel create​(javax.servlet.http.HttpSession session)
        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:
        create in interface HttpSessionCollection
        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:
        postCreate in interface HttpSessionCollection
        Parameters:
        session - the HttpSession object; must not be null
      • isExistent

        public boolean isExistent​(String sId)
        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:
        isExistent in interface HttpSessionCollection
        Parameters:
        sId - the session ID to check for existence
        Returns:
        true if the session exists; false otherwise
      • destroy

        public void destroy​(String sId)
        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:
        destroy in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
      • deleteModelFromLocalCaches

        protected void deleteModelFromLocalCaches​(String sId)
      • enter

        public boolean enter​(String sId,
                             boolean fWait)
        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:
        enter in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        fWait - 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

        public boolean enter​(String sId,
                             boolean fWait,
                             boolean fExclusive)
        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:
        enter in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        fWait - true if the thread should block until the session becomes available; false otherwise
        fExclusive - if true, prevent other threads from entering the specified session until a corresponding call to HttpSessionCollection.exit(String, boolean, boolean) is made by the calling thread
        Returns:
        true if the session is now owned by the calling thread
      • isOwned

        public boolean isOwned​(String sId)
        Determine if the specified session ID identifies a session that exists and that this thread has ownership for, either by a call to enter(sId) or create() without a corresponding call to exit(sId). 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.

        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:
        isOwned in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        Returns:
        true if the session is owned; false otherwise.
      • exit

        public void exit​(String sId,
                         boolean fFlush)
        Release ownership for the specified session. This method must be called exactly once for each call to enter(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:
        exit in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        fFlush - 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

        public void exit​(String sId,
                         boolean fFlush,
                         boolean fExclusive)
        Release ownership for the specified session. This method must be called exactly once for each call to enter(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:
        exit in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        fFlush - 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
        fExclusive - if true, a previous call to HttpSessionCollection.enter(String, boolean, boolean) should have been made where the fExclusive was set to true
      • activate

        public void activate​(String sId,
                             javax.servlet.http.HttpSession session)
        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:
        activate in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        session - 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

        public boolean isActive​(String sId)
        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) and exit(sId).

        Specified by:
        isActive in interface HttpSessionCollection
        Parameters:
        sId - the session ID to check for the active state
        Returns:
        true if the session exists and is active; false otherwise
      • passivate

        public void passivate​(String sId)
        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:
        passivate in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
      • deleteExpiredSessions

        public Set<String> deleteExpiredSessions()
        Delete the sessions in the session-cache which have timed out, using an EntryProcessor and return the ids of deleted sessions.
        Specified by:
        deleteExpiredSessions in interface HttpSessionCollection
        Returns:
        the set of ids of sessions that are deleted
      • deleteExpiredLocalSessions

        public Set<String> 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:
        deleteExpiredLocalSessions in interface HttpSessionCollection
        Returns:
        the set of ids of sessions that are deleted
      • cleanUpDeletedSessions

        protected void cleanUpDeletedSessions​(Set<String> setDeletedIds)
        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

        public Iterator 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:
        iterateIds in interface HttpSessionCollection
        Returns:
        an iterator that iterates over all String session IDs
      • iteratePotentiallyExpiredIds

        public Iterator 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:
        iteratePotentiallyExpiredIds in interface HttpSessionCollection
        Returns:
        an iterator that iterates over the session IDs that this JVM is responsible for periodically checking for expiry
      • iteratePotentiallyExpiredLocalIds

        public Iterator 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:
        iteratePotentiallyExpiredLocalIds in interface HttpSessionCollection
        Returns:
        an iterator that iterates over the session IDs that are local to this web application instance and has timed out
      • getSessionExpiryFilter

        protected Filter getSessionExpiryFilter()
        Generates a session expiry filter based on the configured factories.
        Returns:
        A session expiry filter
      • get

        public HttpSessionModel get​(String sId)
        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) and exit(sId).

        Specified by:
        get in interface HttpSessionCollection
        Parameters:
        sId - the session ID; must not be null
        Returns:
        the HttpSessionModel for the requested session or null
      • getLocalSessionIds

        public Set<String> getLocalSessionIds()
        Returns the set of ids locally opened session.
        Returns:
        the set of ids of locally opened sessions
      • getLocalSessonIdsSnapshot

        public Set<String> 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:
        addHttpSessionListener in interface HttpSessionCollection
        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:
        removeHttpSessionListener in interface HttpSessionCollection
        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:
        addHttpSessionAttributeListener in interface HttpSessionCollection
        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:
        removeHttpSessionAttributeListener in interface HttpSessionCollection
        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:
        shutdown in interface HttpSessionCollection
      • toString

        public String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class Object
        Returns:
        a string representation of the object
      • getHttpSessionListeners

        protected Listeners 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

        protected Listeners 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. If isMemberLockingEnforced() or isAppLockingEnforced() or isMemberLockingEnforced() 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() and isAppLockingEnforced() 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

        protected String getSessionAccessDebugLoggingFilter()
        Get the Session Access Debug Logging attribute filter
        Returns:
        Comma Delimited String of session attribute prefixes configured in application web.xml
      • getSerializer

        public Serializer getSerializer()
        Get the serializer used to serialize and deserialize session attributes.
        Specified by:
        getSerializer in interface HttpSessionCollection
        Returns:
        a serializer; never null
      • setSerializer

        public void setSerializer​(Serializer serializer)
        Set the serializer used to serialize and deserialize session attributes.
        Specified by:
        setSerializer in interface HttpSessionCollection
        Parameters:
        serializer - a serializer; must not be null
      • create

        public AbstractHttpSessionModel create​(javax.servlet.http.HttpSession session,
                                               String sId)
        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:
        create in interface HttpSessionCollection
        Parameters:
        session - the HttpSession object to bind the session model to; used for issuing events; must not be null
        sId - the session id
        Returns:
        the HttpSessionModel object for the new session
      • getDescription

        protected String getDescription()
        Returns a string representation of this object's attributes.
        Returns:
        a string representation of this object's attributes
      • getStickyCache

        public NamedCache 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

        public NamedCache 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

        protected InvocationService getStickyService()
        Get the invocation service to use to manage sticky session ownership.
        Returns:
        the invocation service to use to manage sticky session ownership
      • getAppControlCache

        protected NamedCache 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

        protected NamedCache getActiveCache()
        Get the cache of active sessions.
        Returns:
        a cache of active sessions; the cache maps from session ID to HttpSession objects
      • getOwnedCache

        protected NamedCache 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

        public NamedCache ensureClusterCache()
        Ensure the cache of existent distributed session models.
        Returns:
        a cache that maps from session ID to HttpSessionModel objects
      • getClusterCache

        public NamedCache 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

        protected CacheDelegator getCacheDelegator()
        Get the cache delegator.
        Returns:
        the CacheDelegator obj
      • setCacheDelegator

        protected void setCacheDelegator​(CacheDelegator cacheDelegator)
        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

        protected HttpSessionCollection.SessionDistributionController getDistributionController()
        Get the SessionDistributionController for the session collection, if one was specified.
        Returns:
        the controller object, or null if none was specified
      • getScopeController

        protected HttpSessionCollection.AttributeScopeController getScopeController()
        Get the AttributeScopeController for the session collection, if one was specified.
        Returns:
        the controller object, or null if none was specified
      • getLocalCacheName

        public String getLocalCacheName()
        Get the local-only session model cache name
        Returns:
        the local-only session model cache name
      • getLocalCache

        public NamedCache getLocalCache()
        Get the cache of existent local-only session models.
        Returns:
        a cache that maps from session ID to HttpSessionModel objects
      • getLocalAttributesCache

        public NamedCache getLocalAttributesCache()
        Get the cache of local-only session attributes.
        Returns:
        a cache that maps from session ID and attribute name to AttributeHolder objects
      • ensureLocalAttributesCache

        protected Map ensureLocalAttributesCache​(String sId)
        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

        protected void destroyLocalAttributesCache​(String sId)
        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

        protected boolean isStuck​(String sId)
        Determine if the specified session is stuck.
        Parameters:
        sId - the session id
        Returns:
        true iff the specified session is stuck
      • getSessionOwnershipInfo

        protected Member getSessionOwnershipInfo​(String sId)
        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

        protected boolean obtainClusterOwnership​(String sId,
                                                 boolean fWait)
        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 for
        fWait - 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

        protected void releaseClusterOwnership​(String sId)
        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

        protected boolean releaseStuckSession​(String sId,
                                              boolean fWait)
        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 here
        fWait - 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

        protected boolean obtainAppOwnership​(String sId,
                                             boolean fWait)
        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 for
        fWait - 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

        protected void releaseAppOwnership​(String sId)
        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

        protected boolean obtainThreadOwnership​(String sId)
        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) and exit(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

        protected boolean releaseThreadOwnership​(String sId)
        Release thread ownership of the specified session.

        This method may only be called within the bounds of a call to enter(sId) and exit(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

        public HttpSessionIdGenerator getSessionIdGenerator()
        Retrieve the HttpSessionIdGenerator used by this session collection to generate session identifiers.
        Returns:
        the HttpSessionIdGenerator
      • generateSessionId

        protected String 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 model
        sId - the session ID
        Returns:
        a new instance of AbstractHttpSessionModel or subclass thereof
      • getOwnedModel

        protected AbstractHttpSessionModel getOwnedModel​(String sId)
        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

        protected AbstractHttpSessionModel getModel​(String sId,
                                                    boolean fLite)
        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

        protected AbstractHttpSessionModel getModel​(String sId)
        Obtain the specified session model.
        Parameters:
        sId - the session ID
        Returns:
        the specified model if it exists, null otherwise
      • putBlind

        protected static void putBlind​(Map map,
                                       Object oKey,
                                       Object oValue)
        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 into
        oKey - the key to store
        oValue - the value to store
      • removeBlind

        protected static void removeBlind​(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.
        Parameters:
        map - the map to remove the key/value pair from
        oKey - the key to remove
      • removeAllBlind

        protected static void removeAllBlind​(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.
        Parameters:
        map - the map to remove the key/value pairs from
        colKeys - the collection of keys which needs to be removed
      • releaseCache

        public void releaseCache​(NamedCache cache)
        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

        protected void recordMapLocksState​(String sKey,
                                           String sValue)
        Method to record mapLocks state
        Parameters:
        sKey - key to record the mapLocks state
        sValue - value of the recorded mapLocks state
      • removeMapLocksState

        protected Object removeMapLocksState​(String sKey)
        Method to remove mapLocks state
        Parameters:
        sKey - key to remove the mapLocks state