Make NEVER_EVICT default session eviction policy; add more debug logging
This commit is contained in:
parent
f826d1365b
commit
7fd93f1929
|
@ -74,7 +74,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
/**
|
||||
* When, if ever, to evict sessions: never; only when the last request for them finishes; after inactivity time (expressed as secs)
|
||||
*/
|
||||
protected int _evictionPolicy;
|
||||
protected int _evictionPolicy = SessionCache.NEVER_EVICT;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -447,6 +447,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
|
||||
if (_sessionDataStore == null)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("No SessionDataStore, putting into SessionCache only id={}", id);
|
||||
session.setResident(true);
|
||||
if (doPutIfAbsent(id, session) == null) //ensure it is in our map
|
||||
session.updateInactivityTimer();
|
||||
|
@ -464,6 +465,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
//if we evict on session exit, boot it from the cache
|
||||
if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Eviction on request exit id={}", id);
|
||||
doDelete(session.getId());
|
||||
session.setResident(false);
|
||||
}
|
||||
|
@ -472,12 +474,14 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
session.setResident(true);
|
||||
if (doPutIfAbsent(id,session) == null) //ensure it is in our map
|
||||
session.updateInactivityTimer();
|
||||
if (LOG.isDebugEnabled())LOG.debug("Non passivating SessionDataStore, session in SessionCache only id={}",id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//backing store supports passivation, call the listeners
|
||||
session.willPassivate();
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Session passivating id={}", id);
|
||||
_sessionDataStore.store(id, session.getSessionData());
|
||||
|
||||
if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT)
|
||||
|
@ -485,6 +489,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
//throw out the passivated session object from the map
|
||||
doDelete(id);
|
||||
session.setResident(false);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Evicted on request exit id={}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -493,11 +498,13 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements
|
|||
session.setResident(true);
|
||||
if (doPutIfAbsent(id,session) == null) //ensure it is in our map
|
||||
session.updateInactivityTimer();
|
||||
if (LOG.isDebugEnabled())LOG.debug("Session reactivated id={}",id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Req count={} for id={}",session.getRequests(),id);
|
||||
session.setResident(true);
|
||||
if (doPutIfAbsent(id, session) == null) //ensure it is the map, but don't save it to the backing store until the last request exists
|
||||
session.updateInactivityTimer();
|
||||
|
|
|
@ -485,7 +485,7 @@ public class Session implements SessionHandler.SessionIf
|
|||
{
|
||||
//we do not want to evict inactive sessions
|
||||
setInactivityTimer(-1L);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Session is immortal && never evict: timer cancelled");
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Session is immortal && bo inactivity eviction: timer cancelled");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -402,7 +402,6 @@ public class SessionHandler extends ScopedHandler
|
|||
//check if session management is set up, if not set up HashSessions
|
||||
final Server server=getServer();
|
||||
|
||||
|
||||
_context=ContextHandler.getCurrentContext();
|
||||
_loader=Thread.currentThread().getContextClassLoader();
|
||||
|
||||
|
@ -1361,18 +1360,6 @@ public class SessionHandler extends ScopedHandler
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return (_context==null?super.toString():_context.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -1574,12 +1561,12 @@ public class SessionHandler extends ScopedHandler
|
|||
{
|
||||
//if there is a session that was created during handling this context, then complete it
|
||||
HttpSession finalSession = baseRequest.getSession(false);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("FinalSession="+finalSession+" old_session_manager="+old_session_manager+" this="+this);
|
||||
if ((finalSession != null) && (old_session_manager != this))
|
||||
{
|
||||
complete((Session)finalSession, baseRequest);
|
||||
}
|
||||
|
||||
|
||||
if (old_session_manager != null && old_session_manager != this)
|
||||
{
|
||||
baseRequest.setSessionHandler(old_session_manager);
|
||||
|
|
Loading…
Reference in New Issue