SessionIdManager
, org.eclipse.jetty.util.component.LifeCycle
public class MongoSessionIdManager extends AbstractSessionIdManager
Theory is that we really only need the session id manager for the local instance so we have something to scavenge on, namely the list of known ids
This class has a timer that runs a periodic scavenger thread to query for all id's known to this node whose precalculated expiry time has passed.
These found sessions are then run through the invalidateAll(id) method that is a bit hinky but is supposed to notify all handlers this id is now DOA and ought to be cleaned up. this ought to result in a save operation on the session that will change the valid field to false (this conjecture is unvalidated atm)
Modifier and Type | Class | Description |
---|---|---|
protected class |
MongoSessionIdManager.Purger |
Purger
|
protected class |
MongoSessionIdManager.Scavenger |
Scavenger
|
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
_ownScheduler |
|
protected org.eclipse.jetty.util.thread.Scheduler.Task |
_purgerTask |
|
protected org.eclipse.jetty.util.thread.Scheduler.Task |
_scavengerTask |
|
protected org.eclipse.jetty.util.thread.Scheduler |
_scheduler |
|
protected Server |
_server |
|
protected java.util.Set<java.lang.String> |
_sessionsIds |
the collection of session ids known to this manager
|
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
_random, _reseed, _weakRandom, _workerAttr, _workerName
Constructor | Description |
---|---|
MongoSessionIdManager(Server server) |
|
MongoSessionIdManager(Server server,
com.mongodb.DBCollection sessions) |
Modifier and Type | Method | Description |
---|---|---|
void |
addSession(javax.servlet.http.HttpSession session) |
|
protected void |
doStart() |
|
protected void |
doStop() |
|
void |
expireAll(java.lang.String sessionId) |
Expire this session for all contexts that are sharing the session
id.
|
long |
getPurgeInvalidAge() |
|
int |
getPurgeLimit() |
|
long |
getPurgeValidAge() |
|
int |
getScavengeBlockSize() |
|
com.mongodb.DBCollection |
getSessions() |
|
boolean |
idInUse(java.lang.String sessionId) |
Searches database to find if the session id known to mongo, and is it valid
|
void |
idle() |
|
void |
invalidateAll(java.lang.String sessionId) |
Remove the session id from the list of in-use sessions.
|
boolean |
isPurgeEnabled() |
|
protected void |
purge() |
Purge is a process that cleans the mongodb cluster of old sessions that are no
longer valid.
|
protected void |
purgeFully() |
Purge is a process that cleans the mongodb cluster of old sessions that are no
longer valid.
|
void |
removeSession(javax.servlet.http.HttpSession session) |
|
void |
renewSessionId(java.lang.String oldClusterId,
java.lang.String oldNodeId,
javax.servlet.http.HttpServletRequest request) |
|
protected void |
scavenge() |
Scavenge is a process that periodically checks the tracked session
ids of this given instance of the session id manager to see if they
are past the point of expiration.
|
protected void |
scavengeBlock(long atTime,
java.util.Set<java.lang.String> ids) |
Check a block of session ids for expiry and thus scavenge.
|
protected void |
scavengeFully() |
ScavengeFully will expire all sessions.
|
void |
setPurge(boolean purge) |
|
void |
setPurgeDelay(long purgeDelay) |
|
void |
setPurgeInvalidAge(long purgeValidAge) |
sets how old a session is to be persisted past the point it is
no longer valid
|
void |
setPurgeLimit(int purgeLimit) |
The maximum number of items to return from a purge query.
|
void |
setPurgeValidAge(long purgeValidAge) |
sets how old a session is to be persist past the point it is
considered no longer viable and should be removed
NOTE: set this value to 0 to disable purging of valid sessions
|
void |
setScavengeBlockSize(int size) |
When scavenging, the max number of session ids in the query.
|
void |
setScavengePeriod(long scavengePeriod) |
The period in seconds between scavenge checks.
|
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
getClusterId, getNodeId, getRandom, getReseed, getWorkerName, initRandom, newSessionId, newSessionId, setRandom, setReseed, setWorkerName
protected Server _server
protected org.eclipse.jetty.util.thread.Scheduler _scheduler
protected boolean _ownScheduler
protected org.eclipse.jetty.util.thread.Scheduler.Task _scavengerTask
protected org.eclipse.jetty.util.thread.Scheduler.Task _purgerTask
protected final java.util.Set<java.lang.String> _sessionsIds
public MongoSessionIdManager(Server server) throws java.net.UnknownHostException, com.mongodb.MongoException
java.net.UnknownHostException
com.mongodb.MongoException
public MongoSessionIdManager(Server server, com.mongodb.DBCollection sessions)
protected void scavenge()
protected void scavengeBlock(long atTime, java.util.Set<java.lang.String> ids)
atTime
- purge at timeids
- set of session idsprotected void scavengeFully()
protected void purge()
protected void purgeFully()
public com.mongodb.DBCollection getSessions()
public boolean isPurgeEnabled()
public void setPurge(boolean purge)
public void setScavengePeriod(long scavengePeriod)
scavengePeriod
- the scavenge period in secondspublic void setScavengeBlockSize(int size)
size
- the scavenge block sizepublic int getScavengeBlockSize()
public void setPurgeLimit(int purgeLimit)
purgeLimit
- the purge limitpublic int getPurgeLimit()
public void setPurgeDelay(long purgeDelay)
public long getPurgeInvalidAge()
public void setPurgeInvalidAge(long purgeValidAge)
purgeValidAge
- the purge valid agepublic long getPurgeValidAge()
public void setPurgeValidAge(long purgeValidAge)
purgeValidAge
- the purge valid ageprotected void doStart() throws java.lang.Exception
doStart
in class AbstractSessionIdManager
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class AbstractSessionIdManager
java.lang.Exception
public boolean idInUse(java.lang.String sessionId)
public void addSession(javax.servlet.http.HttpSession session)
public void removeSession(javax.servlet.http.HttpSession session)
public void invalidateAll(java.lang.String sessionId)
public void expireAll(java.lang.String sessionId)
sessionId
- the session idpublic void idle()
public void renewSessionId(java.lang.String oldClusterId, java.lang.String oldNodeId, javax.servlet.http.HttpServletRequest request)
renewSessionId
in interface SessionIdManager
renewSessionId
in class AbstractSessionIdManager
Copyright © 1995–2018 Webtide. All rights reserved.