CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.coherence.servlet
Class AbstractHttpSessionCollection

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.coherence.servlet.AbstractHttpSessionCollection
All Implemented Interfaces:
HttpSessionCollection, XmlConfigurable
Direct Known Subclasses:
MonolithicHttpSessionCollection, TraditionalHttpSessionCollection

public abstract class AbstractHttpSessionCollection
extends Base
implements HttpSessionCollection, XmlConfigurable

An abstract base class from which implementations of HttpSessionCollection can be more easily built.

Version:
Coherence 2.3
Author:
cp 2003.10.14

Nested Class Summary
static class AbstractHttpSessionCollection.ExitAgent
          This agent is used to request the other servers in the cluster to unlock the specified session ID.
static class AbstractHttpSessionCollection.ExitObserver
          This InvocationObserver waits for an ExitAgent to report back that some server in the cluster did have the specified session id locked.
static class AbstractHttpSessionCollection.SimpleDistributedController
          A simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed in a distributed manner.
static class AbstractHttpSessionCollection.SimpleHybridController
          A simple implementation of the SessionDistributionController interface that forces all sessions and serializable attributes to be managed in a distributed manner.
static class AbstractHttpSessionCollection.SimpleLocalController
          A simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed locally.
 
Nested classes/interfaces inherited from interface com.tangosol.coherence.servlet.HttpSessionCollection
HttpSessionCollection.SessionDistributionController
 
Field Summary
static String CACHENAME_DEATHCERTS
          The name of the clustered cache that stores the IDs of "recently departed" sessions.
static 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).
static 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).
static String CACHENAME_SESSIONS
          The name of the clustered cache that stores the sessions.
static String CTX_INIT_ALLOW_LOCAL_ATTRIBUTES
          The configuration property that specifies whether non-serializable attributes should be preserved as local.
static String CTX_INIT_CACHENAME_DEATHCERTS
          The configuration property that overrides the name of the clustered cache that stores the IDs of "recently departed" sessions.
static String CTX_INIT_CACHENAME_LOCAL_ATTRIBUTES
          The configuration property that overrides the name of the local cache that stores non-distributed session attributes when the SessionDistributionController option is implemented.
static String CTX_INIT_CACHENAME_LOCAL_SESSIONS
          The configuration property that overrides the name of the local cache that stores non-distributed sessions when the SessionDistributionController option is implemented.
static String CTX_INIT_CACHENAME_SESSIONS
          The configuration property that overrides the name of the clustered cache that stores the sessions.
static String CTX_INIT_CONTROLLER_CLASS
          The configuration property that specifies an implementation of the SessionDistributionController interface to use.
static String CTX_INIT_DAEMON_ASSUME_LOCALITY
          True to assume that the sessions in the cache are split across only the servers that are doing reaping.
static String CTX_INIT_SERVICENAME_OWNERSHIP
          The configuration property that specifies the name of the invocation service that will be used to manage sticky session ownership.
static String CTX_INIT_SESSION_EXPIRE_SECS
          The configuration property that overrides the session expirty time.
static String CTX_INIT_SESSION_ID_LENGTH
          The configuration property that overrides the session id length.
static String CTX_INIT_SESSION_STICKY
          The configuration property that specifies whether sticky sessions optimizations will be used.
static String CTX_INIT_SESSION_STRICT_SPEC
          The configuration property that specifies strict spec adherence.
static String CTX_INIT_SESSION_THREAD_LOCK
          The configuration property that specifies thread level session locking.
static String SERVICENAME_OWNERSHIP
          The name of the clustered invocation service that manages sticky session ownership.
 
Constructor Summary
AbstractHttpSessionCollection()
          Default constructor (required).
 
Method Summary
 void activate(String sId, HttpSession session)
          Move the session into an active state, if it is not already.
 void addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
          Sign up the specified listener to receive HttpSessionBindingEvent objects.
 void addHttpSessionListener(HttpSessionListener listener)
          Sign up the specified listener to receive HttpSessionEvent objects.
 HttpSessionModel create(HttpSession session)
          This method creates a new session, returning the session model for the new session.
 void destroy(String sId)
          Destroy the specified session.
protected  void destroyLocalAttributesCache(String sId)
          Destroy the cache of local-only session attributes for the specified session ID.
protected  Map ensureLocalAttributesCache(String sId)
          Get the cache of local-only session attributes for the specified session ID.
 boolean enter(String sId, boolean fWait)
          Obtain any necessary ownership for the specified session.
 void exit(String sId)
          Release ownership for the specified session.
 void flush(String sId)
          In a distributed environment, ensure that any changes to the specified session are flushed.
protected  String generateSessionId()
          Generate a potential session ID.
 HttpSessionModel get(String sId)
          Obtain the HttpSessionModel for the specified session, or null if it does not exist.
 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.
 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.
 NamedCache getClusterCache()
          Get the cache of existent distributed session models.
protected static AbstractHttpSessionCollection getCollection()
          Obtain the AbstractHttpSessionCollection that is being used in the current application.
 XmlElement getConfig()
          Determine the current configuration of the object.
protected  long getCurrentTime()
          Determine the current time value in milliseconds.
 NamedCache getDeathCertCache()
          Get the cache of previously used session IDs (IDs of previously existent HttpSessionModel objects).
 int getDefaultMaxInactiveInterval()
          Determine the default maximum interval, in seconds, that a session will be kept alive without any activity.
protected  String getDescription()
          Returns a string representation of this object's attributes.
protected  HttpSessionCollection.SessionDistributionController getDistributionController()
          Get the SessionDistributionController for the session collection, if one was specified.
protected  Listeners getHttpSessionAttributeListeners()
          Determine the list of listeners that are registered for session attribute modification events.
protected  Listeners getHttpSessionListeners()
          Determine the list of listeners that are registered for session life cycle events.
 NamedCache getLocalAttributesCache()
          Get the cache of local-only session attributes.
 NamedCache getLocalCache()
          Get the cache of existent local-only session models.
 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.
 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.
protected  AbstractHttpSessionModel getModel(String sId)
          Obtain the specified session model.
 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.
 int getModelUpdates()
          Return the number of updates to session model objects since the last time statistics were reset.
protected  NamedCache getOwnedCache()
          Get the cache of owned ("locally live") session models.
protected  AbstractHttpSessionModel getOwnedModel(String sId)
          Obtain the specified session model that this thread owns, otherwise throw an exception.
 int getSessionIdLength()
          Determine the length that session IDs will be created with.
 NamedCache getStickyCache()
          Get the cache of sessions that are being managed by this member, if sticky ownership is used.
protected  InvocationService getStickyService()
          Get the invocation service to use to manage sticky session ownership.
protected abstract  AbstractHttpSessionModel instantiateModel(HttpSession session, String sId)
          Factory Method: Instantiate a AbstractHttpSessionModel or subclass thereof.
 boolean isActive(String sId)
          Determine if the specified session ID identifies a session that is in the active state.
protected  boolean isAllowLocalAttributes()
          Determine if non-serializable attributes should be preserved as local.
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.
 boolean isExistent(String sId)
          Determine if the specified session ID identifies a session that exists.
protected  boolean isModelSingleThreaded()
          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 on a specific server).
 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).
 boolean isOwnershipSticky()
          Determine if the sticky session ownership option is on.
 boolean isStrict()
          Determine if the Servlet specification is being followed strictly.
protected  boolean isStuck(String sId)
          Determine if the specified session is stuck.
 Iterator iterateIds()
          Obtain an iterator of the session IDs.
 Iterator iterateLocalIds()
          Obtain an iterator of the session IDs that this JVM is responsible for invalidating when the sessions for those IDs have timed out.
protected  boolean obtainClusterOwnership(String sId, boolean fWait)
          Obtain ownership within the cluster for the specified session.
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.
 void passivate(String sId)
          Move the session into a passive state, if it is not already.
 void postCreate(HttpSession session)
          This method is called at the end of the session creation process.
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.
 void releaseCache(NamedCache cache)
          Release the passed NamedCache instance.
protected  void releaseClusterOwnership(String sId)
          Release ownership within the cluster of the specified session.
protected  boolean releaseStuckSession(String sId)
          Determine if the specified session is stuck, and if it is, to release it (or mark it to be released).
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.
 void removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
          Sign off the specified listener so it no longer will receive HttpSessionBindingEvent objects.
 void removeHttpSessionListener(HttpSessionListener listener)
          Sign off the specified listener so it no longer will receive HttpSessionEvent objects.
 void resetStatistics()
          Reset all statistics maintained by this session collection.
 void setConfig(XmlElement xml)
          Specify the configuration for the object.
 void shutdown()
          Notify the session collection that it is being shut down.
 String toString()
          Returns a string representation of the object.
 

Field Detail

CTX_INIT_CACHENAME_SESSIONS

public static final String CTX_INIT_CACHENAME_SESSIONS
The configuration property that overrides the name of the clustered cache that stores the sessions.

See Also:
Constant Field Values

CTX_INIT_CACHENAME_LOCAL_SESSIONS

public static final String CTX_INIT_CACHENAME_LOCAL_SESSIONS
The configuration property that overrides the name of the local cache that stores non-distributed sessions when the SessionDistributionController option is implemented.

See Also:
Constant Field Values

CTX_INIT_CACHENAME_LOCAL_ATTRIBUTES

public static final String CTX_INIT_CACHENAME_LOCAL_ATTRIBUTES
The configuration property that overrides the name of the local cache that stores non-distributed session attributes when the SessionDistributionController option is implemented.

See Also:
Constant Field Values

CTX_INIT_CACHENAME_DEATHCERTS

public static final String CTX_INIT_CACHENAME_DEATHCERTS
The configuration property that overrides the name of the clustered cache that stores the IDs of "recently departed" sessions.

See Also:
Constant Field Values

CTX_INIT_SESSION_EXPIRE_SECS

public static final String CTX_INIT_SESSION_EXPIRE_SECS
The configuration property that overrides the session expirty time.

See Also:
Constant Field Values

CTX_INIT_SESSION_ID_LENGTH

public static final String CTX_INIT_SESSION_ID_LENGTH
The configuration property that overrides the session id length.

See Also:
Constant Field Values

CTX_INIT_SESSION_THREAD_LOCK

public static final String CTX_INIT_SESSION_THREAD_LOCK
The configuration property that specifies thread level session locking.

See Also:
Constant Field Values

CTX_INIT_DAEMON_ASSUME_LOCALITY

public static final String CTX_INIT_DAEMON_ASSUME_LOCALITY
True to assume that the sessions in the cache are split across only the servers that are doing reaping.

See Also:
Constant Field Values

CTX_INIT_SESSION_STRICT_SPEC

public static final String CTX_INIT_SESSION_STRICT_SPEC
The configuration property that specifies strict spec adherence.

See Also:
Constant Field Values

CTX_INIT_CONTROLLER_CLASS

public static final String CTX_INIT_CONTROLLER_CLASS
The configuration property that specifies an implementation of the SessionDistributionController interface to use.

See Also:
Constant Field Values

CTX_INIT_SESSION_STICKY

public static final String CTX_INIT_SESSION_STICKY
The configuration property that specifies whether sticky sessions optimizations will be used.

See Also:
Constant Field Values

CTX_INIT_SERVICENAME_OWNERSHIP

public static final String CTX_INIT_SERVICENAME_OWNERSHIP
The configuration property that specifies the name of the invocation service that will be used to manage sticky session ownership.

See Also:
Constant Field Values

CTX_INIT_ALLOW_LOCAL_ATTRIBUTES

public static final String CTX_INIT_ALLOW_LOCAL_ATTRIBUTES
The configuration property that specifies whether non-serializable attributes should be preserved as local.

See Also:
Constant Field Values

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

CACHENAME_DEATHCERTS

public static final String CACHENAME_DEATHCERTS
The name of the clustered cache that stores the IDs of "recently departed" sessions.

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
Constructor Detail

AbstractHttpSessionCollection

public AbstractHttpSessionCollection()
Default constructor (required).

Method Detail

getCollection

protected static AbstractHttpSessionCollection getCollection()
Obtain the AbstractHttpSessionCollection that is being used in the current application. Because this class must be included as part of the application deployment, the singleton pattern should be applicable.

Returns:
the singleton instance of the AbstractHttpSessionCollection

getConfig

public XmlElement getConfig()
Determine the current configuration of the object.

Specified by:
getConfig in interface XmlConfigurable
Returns:
the XML configuration or null

setConfig

public void setConfig(XmlElement xml)
Specify the configuration for the object.

Specified by:
setConfig in interface XmlConfigurable
Parameters:
xml - the XML configuration for the object
Throws:
IllegalStateException - if the object is not in a state that allows the configuration to be set; for example, if the object has already been configured and cannot be reconfigured

create

public HttpSessionModel create(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(sId) 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(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

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

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).

Specified by:
isOwned in interface HttpSessionCollection
Returns:
true if the session is owned; false otherwise.

exit

public void exit(String sId)
Release ownership for the specified session. This method must be called exactly once for each call to enter(sId), with the only exceptions being:

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

activate

public void activate(String sId,
                     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

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

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

iterateLocalIds

public Iterator iterateLocalIds()
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 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.

Specified by:
iterateLocalIds in interface HttpSessionCollection
Returns:
an iterator that iterates over the session IDs that this JVM is responsible for periodically checking for expiry

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

flush

public void flush(String sId)
In a distributed environment, ensure that any changes to the specified session are flushed. This method exists to allow changes to the session model to be accumulated over time and then communicated in bulk.

This method may only be called within the bounds of a call to enter(sId) and exit(sId).

Specified by:
flush in interface HttpSessionCollection
Parameters:
sId - the session ID; must not be null

addHttpSessionListener

public void addHttpSessionListener(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(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(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(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.

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

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

isModelSingleThreaded

protected boolean isModelSingleThreaded()
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 on a specific server).

Returns:
true to limit the access to a session to one request at a time

getCurrentTime

protected long getCurrentTime()
Determine the current time value in milliseconds.

Returns:
the current time value in milliseconds

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 sessions that are being managed by this member, if sticky ownership is used.

Returns:
a cache keyed by session ID

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

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

getClusterCache

public NamedCache getClusterCache()
Get the cache of existent distributed session models.

Returns:
a cache that maps from session ID to HttpSessionModel objects

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

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

getDeathCertCache

public NamedCache getDeathCertCache()
Get the cache of previously used session IDs (IDs of previously existent HttpSessionModel objects).

Returns:
a cache that maps from session ID to a Long object containing the date/time that the session was destroyed

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

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)
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
Returns:
true if the session is/was stuck here and is now released or is marked to be released

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

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

generateSessionId

protected String generateSessionId()
Generate a potential session ID. The returned id may be in use already.

Returns:
a seemingly random session id

getSessionIdLength

public int getSessionIdLength()
Determine the length that session IDs will be created with.

Returns:
the length, in characters, for session IDs

instantiateModel

protected abstract AbstractHttpSessionModel instantiateModel(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.

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)
Obtain the specified session model.

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

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

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation