Implement different intervals for scavenge and idlepassivation checks; update all tests

This commit is contained in:
Jan Bartel 2016-03-04 18:06:22 +01:00
parent 436c4835a4
commit 3c2f5bbcb6
128 changed files with 787 additions and 463 deletions

View File

@ -245,10 +245,10 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
if (LOG.isDebugEnabled()) LOG.debug("Writing session {} to DataStore", data.getId());

View File

@ -125,6 +125,8 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore
@Override
public boolean delete(String id) throws Exception
{
if (LOG.isDebugEnabled())
LOG.debug("Deleting session with id {} from infinispan", id);
return (_cache.remove(getCacheKey(id, _context)) != null);
}
@ -166,10 +168,10 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
//Put an idle timeout on the cache entry if the session is not immortal -
//if no requests arrive at any node before this timeout occurs, or no node

View File

@ -264,7 +264,7 @@ public class InfinispanSessionIdManager extends AbstractSessionIdManager
* @param id the session id
* @return unique cache id
*/
protected String makeKey (String id)
public String makeKey (String id)
{
return ID_KEY+id;
}

View File

@ -397,10 +397,10 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
NoSqlSessionData nsqd = (NoSqlSessionData)data;
@ -416,7 +416,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
Object version = ((NoSqlSessionData)data).getVersion();
// New session
if (isNew)
if (lastSaveTime <= 0)
{
upsert = true;
version = new Long(1);
@ -455,7 +455,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
Set<String> names = nsqd.takeDirtyAttributes();
if (isNew)
if (lastSaveTime <= 0)
{
names.addAll(nsqd.getAllAttributeNames()); // note dirty may include removed names
}

View File

@ -143,7 +143,6 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
Long expiry = (Long)o.get(MongoSessionDataStore.__EXPIRY);
if (expiry < System.currentTimeMillis())
return false;
return valid;
}

View File

@ -29,6 +29,7 @@ import javax.servlet.http.HttpSession;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.server.session.SessionStore;
import org.eclipse.jetty.util.component.LifeCycle;
/* --------------------------------------------------------------------- */
@ -308,4 +309,13 @@ public interface SessionManager extends LifeCycle
* @param newExtendedId the new session id including worker suffix
*/
public void renewSessionId(String oldId, String oldExtendedId, String newId, String newExtendedId);
/**
* Get the session store for this manager
* @return
*/
public SessionStore getSessionStore();
}

View File

@ -37,10 +37,10 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
*
* @param id identity of session to store
* @param data info of the session
* @param isNew has session been written out before or not
* @param lastSaveTime time of previous save or 0 if never saved
* @throws Exception
*/
public abstract void doStore(String id, SessionData data, boolean isNew) throws Exception;
public abstract void doStore(String id, SessionData data, long lastSaveTime) throws Exception;
@ -63,19 +63,19 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
{
long lastSave = data.getLastSaved();
//set the last saved time to now
data.setLastSaved(System.currentTimeMillis());
try
{
doStore(id, data, (lastSave<=0));
//call the specific store method, passing in previous save time
doStore(id, data, lastSave);
data.setDirty(false); //only undo the dirty setting if we saved it
}
catch (Exception e)
{
//reset last save time
//reset last save time if save failed
data.setLastSaved(lastSave);
}
finally
{
data.setDirty(false);
throw e;
}
}

View File

@ -55,7 +55,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
protected String _workerAttr;
protected long _reseed=100000L;
protected Server _server;
protected PeriodicSessionInspector _scavenger;
protected PeriodicSessionInspector _inspector;
/* ------------------------------------------------------------ */
/**
@ -100,12 +100,12 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
/* ------------------------------------------------------------ */
/**
* @param scavenger a SessionScavenger
* @param period inspector of sessions
*/
public void setSessionScavenger (PeriodicSessionInspector scavenger)
public void setSessionInspector (PeriodicSessionInspector inspector)
{
_scavenger = scavenger;
_scavenger.setSessionIdManager(this);
_inspector = inspector;
_inspector.setSessionIdManager(this);
}
@ -282,14 +282,14 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
initRandom();
_workerAttr=(_workerName!=null && _workerName.startsWith("$"))?_workerName.substring(1):null;
if (_scavenger == null)
if (_inspector == null)
{
LOG.warn("No SessionScavenger set, using defaults");
_scavenger = new PeriodicSessionInspector();
_scavenger.setSessionIdManager(this);
_inspector = new PeriodicSessionInspector();
_inspector.setSessionIdManager(this);
}
_scavenger.start();
_inspector.start();
}
/* ------------------------------------------------------------ */
@ -299,7 +299,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
@Override
protected void doStop() throws Exception
{
_scavenger.stop();
_inspector.stop();
}
/* ------------------------------------------------------------ */

View File

@ -19,15 +19,15 @@
package org.eclipse.jetty.server.session;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Stream;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -43,12 +43,15 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
protected ArrayList<SessionInspector> _inspectors = new ArrayList<SessionInspector>();
protected SessionDataStore _sessionDataStore;
protected SessionManager _manager;
protected SessionContext _context;
protected int _idlePassivationTimeoutSec;
protected int _expiryTimeoutSec;
private IdleInspector _idleInspector;
private ExpiryInspector _expiryInspector;
private boolean _passivateOnComplete;
/**
@ -180,7 +183,15 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
_sessionDataStore.initialize(_context);
_sessionDataStore.start();
if (_expiryTimeoutSec >= 0)
{
synchronized (_inspectors)
{
_expiryInspector = new ExpiryInspector(this, _manager.getSessionIdManager());
_expiryInspector.setTimeoutSet(_expiryTimeoutSec);
_inspectors.add(0, _expiryInspector);
}
}
super.doStart();
}
@ -228,12 +239,47 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
* @see org.eclipse.jetty.server.session.SessionStore#setIdlePassivationTimeoutSec(int)
*/
public void setIdlePassivationTimeoutSec(int idleTimeoutSec)
{
synchronized (_inspectors)
{
_idlePassivationTimeoutSec = idleTimeoutSec;
if (_idlePassivationTimeoutSec == 0)
{
if (_idleInspector != null)
_inspectors.remove(_idleInspector);
_idleInspector = null;
else if (_idleInspector == null)
}
else
{
if (_idleInspector == null)
{
_idleInspector = new IdleInspector(this);
_inspectors.add(_idleInspector);
}
_idleInspector.setTimeoutSet(_idlePassivationTimeoutSec);
}
}
}
/**
* @return the expiryTimeoutSec
*/
public int getExpiryTimeoutSec()
{
return _expiryTimeoutSec;
}
/**
* @param expiryTimeoutSec the expiryTimeoutSec to set
*/
public void setExpiryTimeoutSec(int expiryTimeoutSec)
{
_expiryTimeoutSec = expiryTimeoutSec;
}
@ -245,10 +291,10 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
* the data for it from a SessionDataStore associated with the
* session manager.
*
* @see org.eclipse.jetty.server.session.SessionStore#get(java.lang.String, boolean)
* @see org.eclipse.jetty.server.session.SessionStore#get(java.lang.String)
*/
@Override
public Session get(String id, boolean staleCheck) throws Exception
public Session get(String id) throws Exception
{
Session session = null;
Exception ex = null;
@ -380,7 +426,10 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
}
/**
* Put the Session object into the session store.
* Put the Session object back into the session store.
*
* This should be called by Session.complete when a request exists the session.
*
* If the session manager supports a session data store, write the
* session data through to the session data store.
*
@ -394,7 +443,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
//if the session is new, the data has changed, or the cache is considered stale, write it to any backing store
//if the session is new or data has changed write it to any backing store
try (Lock lock = session.lock())
{
session.setSessionManager(_manager);
@ -405,7 +454,45 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
if (!session.isValid())
return;
if ((session.isNew() || session.getSessionData().isDirty()) && _sessionDataStore != null)
if (_sessionDataStore == null)
{
doPutIfAbsent(id, session); //ensure it is in our map
return;
}
if ((session.getRequests() <= 0))
{
//only save if all requests have finished
if (!_sessionDataStore.isPassivating())
{
//if our backing datastore isn't the passivating kind, just save the session
_sessionDataStore.store(id, session.getSessionData());
}
else
{
//backing store supports passivation
session.willPassivate();
_sessionDataStore.store(id, session.getSessionData());
session.setPassivated();
if (isPassivateOnComplete())
{
//throw out the passivated session object from the map
doDelete(id);
}
else
{
//reactivate the session
session.setActive();
session.didActivate();
}
}
}
doPutIfAbsent(id,session); //ensure it is in our map
}
/* if ((session.isNew() || session.getSessionData().isDirty()) && _sessionDataStore != null)
{
if (_sessionDataStore.isPassivating())
{
@ -424,8 +511,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
}
doPutIfAbsent(id,session);
}
doPutIfAbsent(id,session);*/
}
/**
@ -450,7 +536,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
public Session delete(String id) throws Exception
{
//get the session, if its not in memory, this will load it
Session session = get(id, false);
Session session = get(id);
//Always delete it from the backing data store
if (_sessionDataStore != null)
@ -490,20 +576,32 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
public void inspect ()
{
Stream<Session> stream = getStream();
synchronized (_inspectors)
{
try
{
_expiryInspector.preInspection();
if (_idleInspector != null)
_idleInspector.preInspection();
stream.forEach(s->{_expiryInspector.inspect(s); if (_idleInspector != null) _idleInspector.inspect(s);});
_expiryInspector.postInspection();
_idleInspector.postInspection();
final ArrayList<Boolean> wantInspect = new ArrayList<Boolean>();
for (SessionInspector i:_inspectors)
wantInspect.add(Boolean.valueOf(i.preInspection()));
stream.forEach(s->{for (int i=0;i<_inspectors.size(); i++) { if (wantInspect.get(i)) _inspectors.get(i).inspect(s);}});
}
finally
{
try
{
for (SessionInspector i:_inspectors)
i.postInspection();
}
catch (Exception e)
{
LOG.warn(e);
}
stream.close();
}
}
}
@ -548,7 +646,6 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
LOG.debug("Passivating idle session {}", id);
s.willPassivate();
_sessionDataStore.store(id, s.getSessionData());
s.getSessionData().setDirty(false);
s.setPassivated();
doDelete(id); //Take the session object of this session store
}
@ -564,6 +661,57 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
}
/**
* @see org.eclipse.jetty.server.session.SessionStore#renewSessionId(java.lang.String, java.lang.String)
*/
public Session renewSessionId (String oldId, String newId)
throws Exception
{
if (StringUtil.isBlank(oldId))
throw new IllegalArgumentException ("Old session id is null");
if (StringUtil.isBlank(newId))
throw new IllegalArgumentException ("New session id is null");
Session session = get(oldId);
if (session == null)
return null;
try (Lock lock = session.lock())
{
session.checkValidForWrite(); //can't change id on invalid session
session.getSessionData().setId(newId);
session.getSessionData().setLastSaved(0); //pretend that the session has never been saved before to get a full save
session.getSessionData().setDirty(true); //ensure we will try to write the session out
doPutIfAbsent(newId, session); //put the new id into our map
doDelete (oldId); //take old out of map
if (_sessionDataStore != null)
{
_sessionDataStore.delete(oldId); //delete the session data with the old id
_sessionDataStore.store(newId, session.getSessionData()); //save the session data with the new id
}
LOG.info("Session id {} swapped for new id {}", oldId, newId);
return session;
}
}
/**
* @param passivateOnComplete
*/
public void setPassivateOnComplete (boolean passivateOnComplete)
{
_passivateOnComplete = passivateOnComplete;
}
/**
* @return
*/
public boolean isPassivateOnComplete ()
{
return _passivateOnComplete;
}
/**
* @see org.eclipse.jetty.server.session.SessionStore#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)

View File

@ -127,14 +127,14 @@ public class CachingSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
//write to the SessionDataStore first
if (_delegateDataStore instanceof AbstractSessionDataStore)
((AbstractSessionDataStore)_delegateDataStore).doStore(id, data, isNew);
((AbstractSessionDataStore)_delegateDataStore).doStore(id, data, lastSaveTime);
//else??????

View File

@ -31,11 +31,11 @@ import org.eclipse.jetty.util.log.Logger;
*
*
*/
public class ExpiryInspector implements SessionInspector
public class ExpiryInspector extends AbstractSessionInspector
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
protected Set<String> _expiryCandidates;
protected Set<String> _expiryCandidates = new HashSet<String>();
protected SessionIdManager _idManager;
protected AbstractSessionStore _sessionStore;
@ -78,11 +78,16 @@ public class ExpiryInspector implements SessionInspector
* @see org.eclipse.jetty.server.session.SessionInspector#preInspection()
*/
@Override
public void preInspection()
public boolean preInspection()
{
_expiryCandidates.clear();
boolean shouldInspect = super.preInspection();
if (LOG.isDebugEnabled())
LOG.debug("PreInspection");
_expiryCandidates = new HashSet<String>();
LOG.debug("ExpiryInspector, will inspect:{}", shouldInspect);
return shouldInspect;
}
/**
@ -108,7 +113,7 @@ public class ExpiryInspector implements SessionInspector
}
finally
{
_expiryCandidates = null;
_expiryCandidates.clear();
}
}
}

View File

@ -179,10 +179,10 @@ public class FileSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
File file = null;
if (_storeDir != null)

View File

@ -30,10 +30,17 @@ public class HashSessionManager extends SessionManager
protected NullSessionDataStore _sessionDataStore = new NullSessionDataStore();
/**
*
*/
public HashSessionManager ()
{
_sessionStore = new MemorySessionStore();
}
@Override
public void doStart() throws Exception
{
_sessionStore = new MemorySessionStore();
((AbstractSessionStore)_sessionStore).setSessionDataStore(_sessionDataStore);
super.doStart();

View File

@ -31,11 +31,11 @@ import org.eclipse.jetty.util.log.Logger;
*
* Checks if a session is idle
*/
public class IdleInspector implements SessionInspector
public class IdleInspector extends AbstractSessionInspector
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
protected Set<String> _idleCandidates;
protected Set<String> _idleCandidates = new HashSet<String>();;
protected AbstractSessionStore _sessionStore;
/**
@ -78,11 +78,12 @@ public class IdleInspector implements SessionInspector
* @see org.eclipse.jetty.server.session.SessionInspector#preInspection()
*/
@Override
public void preInspection()
public boolean preInspection()
{
_idleCandidates = new HashSet<String>();
boolean shouldInspect = super.preInspection();
if (LOG.isDebugEnabled())
LOG.debug("IdleInspector preinspection");
LOG.debug("IdleInspector will inspect:{}", shouldInspect);
return shouldInspect;
}
@ -108,6 +109,6 @@ public class IdleInspector implements SessionInspector
}
}
_idleCandidates = null;
_idleCandidates.clear();
}
}

View File

@ -750,12 +750,12 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
if (data==null || id==null)
return;
if (isNew)
if (lastSaveTime <= 0)
{
doInsert(id, data);
}
@ -807,6 +807,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
private void doUpdate (String id, SessionData data)
throws Exception
{
//TODO check if it is actually dirty && try to optimize the writing of lastAccessTime and expiryTime
try (Connection connection = _dbAdaptor.getConnection())
{
connection.setAutoCommit(true);

View File

@ -59,10 +59,10 @@ public class NullSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
*/
@Override
public void doStore(String id, SessionData data, boolean isNew) throws Exception
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
//noop
}

View File

@ -46,7 +46,7 @@ public class PeriodicSessionInspector extends AbstractLifeCycle
protected Runner _runner;
protected boolean _ownScheduler = false;
private long _intervalMs = DEFAULT_PERIOD_MS;
private long _lastTime = 0L;
@ -97,7 +97,6 @@ public class PeriodicSessionInspector extends AbstractLifeCycle
if (!(_sessionIdManager instanceof AbstractSessionIdManager))
throw new IllegalStateException ("SessionIdManager is not an AbstractSessionIdManager");
_lastTime = System.currentTimeMillis(); //set it to a non zero value
//try and use a common scheduler, fallback to own
_scheduler = ((AbstractSessionIdManager)_sessionIdManager).getServer().getBean(Scheduler.class);
@ -200,33 +199,12 @@ public class PeriodicSessionInspector extends AbstractLifeCycle
if (LOG.isDebugEnabled())
LOG.debug("Inspecting sessions");
long now = System.currentTimeMillis();
//find the session managers
for (SessionManager manager:((AbstractSessionIdManager)_sessionIdManager).getSessionManagers())
{
if (manager != null)
{
manager.inspect();
/*
//call scavenge on each manager to find keys for sessions that have expired
Set<String> expiredKeys = manager.scavenge();
//for each expired session, tell the session id manager to invalidate its key on all contexts
for (String key:expiredKeys)
{
// if it recently expired
try
{
((AbstractSessionIdManager)_sessionIdManager).expireAll(key);
}
catch (Exception e)
{
LOG.warn(e);
}
}*/
}
}
}

View File

@ -671,7 +671,7 @@ public class Session implements SessionManager.SessionIf
* @param newId
* @param newExtendedId
*/
public void renewId (String oldId, String oldExtendedId, String newId, String newExtendedId)
/* public void renewId (String oldId, String oldExtendedId, String newId, String newExtendedId)
{
try (Lock lock = _lock.lockIfNotHeld())
{
@ -680,13 +680,12 @@ public class Session implements SessionManager.SessionIf
if (!oldId.equals(getId()))
throw new IllegalStateException("Id clash detected on renewal: was "+oldId+" but is "+ getId());
//save session with new id
_sessionData.setId(newId);
setExtendedId(newExtendedId);
_sessionData.setLastSaved(0); //forces an insert
_sessionData.setDirty(true); //forces an insert
}
}
}*/
/* ------------------------------------------------------------- */
/** Called by users to invalidate a session, or called by the

View File

@ -28,7 +28,9 @@ package org.eclipse.jetty.server.session;
*/
public interface SessionInspector
{
public void preInspection();
public int getTimeoutSec();
public void setTimeoutSet(int sec);
public boolean preInspection();
public void inspect(Session s);
public void postInspection (); //on completion
}

View File

@ -588,9 +588,7 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
try
{
_sessionStore.put(id, session);
_sessionsCreatedStats.increment();
_sessionIdManager.useId(session);
if (_sessionListeners!=null)
@ -714,7 +712,7 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
{
try
{
Session session = _sessionStore.get(id, true);
Session session = _sessionStore.get(id);
if (session != null)
{
//If the session we got back has expired
@ -951,13 +949,29 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
{
try
{
Session session =_sessionStore.delete(oldId);
Session session = _sessionStore.renewSessionId (oldId, newId); //swap the id over
session.setExtendedId(newExtendedId); //remember the extended id
_sessionIdManager.useId(session); //tell id manager new id is in use
//inform the listeners
if (!_sessionIdListeners.isEmpty())
{
HttpSessionEvent event = new HttpSessionEvent(session);
for (HttpSessionIdListener l:_sessionIdListeners)
{
l.sessionIdChanged(event, oldId);
}
}
/* Session session =_sessionStore.get(oldId);
if (session == null)
{
LOG.warn("Unable to renew id to "+newId+" for non-existant session "+oldId);
return;
}
try (Lock lock = session.lock())
{
//swap the ids
session.renewId(oldId, oldExtendedId, newId, newExtendedId);
@ -975,6 +989,9 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
l.sessionIdChanged(event, oldId);
}
}
}*/
}
catch (Exception e)
{
@ -1025,7 +1042,6 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
return;
_sessionStore.inspect();
//return _sessionStore.getExpired();
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.server.session;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
@ -40,7 +39,8 @@ public interface SessionStore extends LifeCycle
{
void initialize(SessionContext context);
Session newSession (HttpServletRequest request, String id, long time, long maxInactiveMs);
Session get(String id, boolean staleCheck) throws Exception;
Session renewSessionId (String oldId, String newId) throws Exception;
Session get(String id) throws Exception;
void put(String id, Session session) throws Exception;
boolean exists (String id) throws Exception;
Session delete (String id) throws Exception;
@ -49,5 +49,7 @@ public interface SessionStore extends LifeCycle
void inspect();
void setIdlePassivationTimeoutSec(int sec);
int getIdlePassivationTimeoutSec();
int getExpiryTimeoutSec();
void setExpiryTimeoutSec(int sec);
Stream<Session> getStream();
}

View File

@ -122,12 +122,12 @@ public class FileTestServer extends AbstractTestServer
public FileTestServer(int port)
{
super(port, 30, 10);
super(port, 30, 10,1,2);
}
public FileTestServer(int port, int maxInactivePeriod, int scavengePeriod)
public FileTestServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod)
{
super(port, maxInactivePeriod, scavengePeriod);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod);
}

View File

@ -48,25 +48,9 @@ public class IdleSessionTest extends AbstractIdleSessionTest
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int idleSec)
public AbstractTestServer createServer(final int port, final int max, final int scavenge, int inspectPeriod, final int idleSec)
{
FileTestServer server = new FileTestServer(port,max,scavenge)
{
/**
* @see org.eclipse.jetty.server.session.FileTestServer#newSessionManager()
*/
@Override
public SessionManager newSessionManager()
{
FileSessionManager manager = (FileSessionManager)super.newSessionManager();
manager.getSessionStore().setIdlePassivationTimeoutSec(idleSec);
return manager;
}
};
return server;
return new FileTestServer(port,max,scavenge, inspectPeriod, idleSec);
}

View File

@ -37,9 +37,9 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge, inspectionPeriod, idlePassivatePeriod);
}
}

View File

@ -40,9 +40,9 @@ public class NewSessionTest extends AbstractNewSessionTest
FileTestServer.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge,inspectionPeriod, idlePassivatePeriod);
}
@Test

View File

@ -39,9 +39,9 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest
FileTestServer.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge,inspectionPeriod, idlePassivatePeriod);
}
@Test

View File

@ -50,9 +50,9 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod )
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge, inspectionPeriod, idlePassivatePeriod);
}

View File

@ -40,9 +40,10 @@ public class ReentrantRequestSessionTest extends AbstractReentrantRequestSession
FileTestServer.teardown();
}
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port);
return new FileTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod);
}
@Test

View File

@ -38,9 +38,9 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge,inspectionPeriod, idlePassivatePeriod);
}
@Test

View File

@ -40,9 +40,9 @@ public class SessionCookieTest extends AbstractSessionCookieTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port, max, scavenge);
return new FileTestServer(port, max, scavenge,inspectionPeriod,idlePassivatePeriod);
}
}

View File

@ -38,9 +38,9 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge,inspectionPeriod,idlePassivatePeriod);
}
@Test

View File

@ -43,9 +43,9 @@ public class SessionRenewTest extends AbstractSessionRenewTest
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port, max, scavenge);
return new FileTestServer(port, max, scavenge,inspectionPeriod,idlePassivatePeriod);
}
@Test
@ -54,5 +54,16 @@ public class SessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
((FileTestServer)_server).assertFileExists(oldSessionId, false);
((FileTestServer)_server).assertFileExists(newSessionId, true);
return true;
}
}

View File

@ -38,9 +38,9 @@ public class SessionValueSharedSaving extends AbstractSessionValueSavingTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new FileTestServer(port,max,scavenge);
return new FileTestServer(port,max,scavenge,inspectionPeriod,idlePassivatePeriod);
}
}

View File

@ -35,8 +35,10 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.resource.JarResource;
@ -311,6 +313,25 @@ public class GCloudSessionTestSupport
System.err.println("END OF SESSIONS::::::::");
}
public Set<String> getSessionIds () throws Exception
{
HashSet<String> ids = new HashSet<String>();
ensureDatastore();
GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+GCloudSessionDataStore.KIND);
Query<Entity> query = builder.build();
QueryResults<Entity> results = _ds.run(query);
assertNotNull(results);
while (results.hasNext())
{
Entity e = results.next();
ids.add(e.getString("id"));
}
return ids;
}
public void assertSessions(int count) throws Exception
{
ensureDatastore();

View File

@ -38,6 +38,11 @@ public class GCloudTestServer extends AbstractTestServer
{
static int __workers=0;
static protected int __maxInactivePeriod = 30;
static protected int __scavengePeriod = 10;
static protected int __inspectPeriod = 1;
static protected int __idlePeriod = 2;
/**
@ -46,9 +51,9 @@ public class GCloudTestServer extends AbstractTestServer
* @param scavengePeriod
* @param sessionIdMgrConfig
*/
public GCloudTestServer(int port, int maxInactivePeriod, int scavengePeriod, GCloudConfiguration config)
public GCloudTestServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod, GCloudConfiguration config)
{
super(port, maxInactivePeriod, scavengePeriod, config);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod, config);
}
/**
@ -57,7 +62,7 @@ public class GCloudTestServer extends AbstractTestServer
*/
public GCloudTestServer(int port, GCloudConfiguration configuration)
{
super(port, 30,10, configuration);
super(port, 30,10, __inspectPeriod, __idlePeriod, configuration);
}
/**

View File

@ -53,9 +53,9 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs)
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, _testSupport.getConfiguration());
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, inspectionPeriod, idlePassivatePeriod,_testSupport.getConfiguration());
}
@Test

View File

@ -53,9 +53,9 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest
* @see org.eclipse.jetty.server.session.AbstractInvalidationSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int inspectInterval)
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int inspectInterval, int idlePassivateInterval)
{
GCloudTestServer server = new GCloudTestServer(port, maxInactive, inspectInterval, _testSupport.getConfiguration())
GCloudTestServer server = new GCloudTestServer(port, maxInactive, scavengeInterval, inspectInterval, idlePassivateInterval,_testSupport.getConfiguration())
{
/**
* @see org.eclipse.jetty.gcloud.session.GCloudTestServer#newSessionManager()

View File

@ -50,9 +50,9 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
* @see org.eclipse.jetty.server.session.AbstractLastAccessTimeTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -51,9 +51,9 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -57,9 +57,9 @@ public class NewSessionTest extends AbstractNewSessionTest
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -52,9 +52,9 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest
* @see org.eclipse.jetty.server.session.AbstractOrphanedSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -51,9 +51,9 @@ public class ReentrantRequestSessionTest extends AbstractReentrantRequestSession
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port,int max, int scavengePeriod,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavengePeriod, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -54,9 +54,9 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest
* @see org.eclipse.jetty.server.session.AbstractRemoveSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge,int inspectionPeriod, int idlePassivatePeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -47,13 +47,15 @@ public class SameNodeLoadTest extends AbstractSameNodeLoadTest
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int)
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int, int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivationPeriod, _testSupport.getConfiguration());
}
@Test

View File

@ -57,9 +57,9 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
* @see org.eclipse.jetty.server.session.AbstractSessionExpiryTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivationPeriod,_testSupport.getConfiguration());
}
@Test

View File

@ -53,9 +53,9 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivationPeriod,_testSupport.getConfiguration());
}
@Test

View File

@ -19,8 +19,11 @@
package org.eclipse.jetty.gcloud.session;
import java.util.Set;
import org.eclipse.jetty.server.session.AbstractSessionRenewTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import static org.junit.Assert.fail;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -51,9 +54,9 @@ public class SessionRenewTest extends AbstractSessionRenewTest
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new GCloudTestServer(port,max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port,max, scavenge, inspectionPeriod, idlePassivationPeriod,_testSupport.getConfiguration());
}
@Test
@ -63,5 +66,24 @@ public class SessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
try
{
Set<String> ids = _testSupport.getSessionIds();
return (!ids.contains(oldSessionId) && ids.contains(newSessionId));
}
catch (Exception e)
{
fail(e.getMessage());
return false;
}
}
}

View File

@ -52,9 +52,9 @@ public class SessionValueSavingTest extends AbstractSessionValueSavingTest
* @see org.eclipse.jetty.server.session.AbstractSessionValueSavingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
return new GCloudTestServer(port, max, scavenge, inspectionPeriod, idlePassivationPeriod,_testSupport.getConfiguration());
}
@Test

View File

@ -30,12 +30,12 @@ public class HashTestServer extends AbstractTestServer
public HashTestServer(int port)
{
super(port, 30, 10);
super(port, 30, 10, 1, 2);
}
public HashTestServer(int port, int maxInactivePeriod, int scavengePeriod)
public HashTestServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod)
{
super(port, maxInactivePeriod, scavengePeriod);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod);
}

View File

@ -22,9 +22,9 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port,max,scavenge);
return new HashTestServer(port,max,scavenge,inspectionPeriod, idlePassivationPeriod);
}
}

View File

@ -26,9 +26,9 @@ import org.junit.Test;
public class NewSessionTest extends AbstractNewSessionTest
{
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port,max,scavenge);
return new HashTestServer(port,max,scavenge,inspectionPeriod,idlePassivationPeriod);
}
@Test

View File

@ -25,9 +25,14 @@ import org.junit.Test;
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
public AbstractTestServer createServer(int port)
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int, int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivatePeriod)
{
return new HashTestServer(port);
return new HashTestServer(port, max, scavenge, inspectionPeriod, idlePassivatePeriod);
}
@Test

View File

@ -23,10 +23,6 @@ import org.junit.Test;
public class RemoveSessionTest extends AbstractRemoveSessionTest
{
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new HashTestServer(port,max,scavenge);
}
@Test
public void testRemoveSession() throws Exception
@ -34,4 +30,13 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest
super.testRemoveSession();
}
/**
* @see org.eclipse.jetty.server.session.AbstractRemoveSessionTest#createServer(int, int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer (port, max, scavenge, inspectionPeriod, idlePassivationPeriod);
}
}

View File

@ -22,9 +22,9 @@ public class SessionCookieTest extends AbstractSessionCookieTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port, max, scavenge);
return new HashTestServer(port, max, scavenge, inspectionPeriod, idlePassivationPeriod);
}
}

View File

@ -24,9 +24,9 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port,max,scavenge);
return new HashTestServer(port,max,scavenge,inspectionPeriod, idlePassivationPeriod);
}
@Test

View File

@ -30,9 +30,9 @@ public class SessionRenewTest extends AbstractSessionRenewTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port, max, scavenge);
return new HashTestServer(port, max, scavenge,inspectionPeriod, idlePassivationPeriod);
}
@Test
@ -41,5 +41,14 @@ public class SessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
return true; //no other tests possible, sessions only in memory
}
}

View File

@ -22,9 +22,9 @@ public class SessionValueSharedSaving extends AbstractSessionValueSavingTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivationPeriod)
{
return new HashTestServer(port,max,scavenge);
return new HashTestServer(port,max,scavenge,inspectionPeriod, idlePassivationPeriod);
}
}

View File

@ -56,9 +56,9 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs)
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavengeMs, __testSupport.getCache());
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -37,14 +37,14 @@ public class InfinispanTestSessionServer extends AbstractTestServer
public InfinispanTestSessionServer(int port, BasicCache config)
{
this(port, 30, 10, config);
this(port, 30, 10, 1, 2, config);
}
public InfinispanTestSessionServer(int port, int maxInactivePeriod, int scavengePeriod, BasicCache config)
public InfinispanTestSessionServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod, BasicCache config)
{
super(port, maxInactivePeriod, scavengePeriod, config);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod, config);
}
@ -79,7 +79,7 @@ public class InfinispanTestSessionServer extends AbstractTestServer
BasicCache cache = ((InfinispanSessionIdManager)_sessionIdManager).getCache();
if (cache != null)
{
return cache.containsKey(id);
return cache.containsKey(((InfinispanSessionIdManager)_sessionIdManager).makeKey(id));
}
return false;
@ -90,7 +90,7 @@ public class InfinispanTestSessionServer extends AbstractTestServer
BasicCache cache = ((InfinispanSessionIdManager)_sessionIdManager).getCache();
if (cache != null)
{
return cache.get(id);
return cache.get(((InfinispanSessionIdManager)_sessionIdManager).makeKey(id));
}
return null;

View File

@ -42,9 +42,9 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}
@Override

View File

@ -51,9 +51,9 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}
}

View File

@ -50,9 +50,9 @@ public class NewSessionTest extends AbstractNewSessionTest
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}

View File

@ -49,9 +49,9 @@ public class ReentrantRequestSessionTest extends AbstractReentrantRequestSession
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port,int maxInactive, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, __testSupport.getCache());
return new InfinispanTestSessionServer(port, maxInactive, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -43,9 +43,9 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
return s;
}

View File

@ -51,9 +51,9 @@ public class SameNodeLoadTest extends AbstractSameNodeLoadTest
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port,int maxInactive, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, __testSupport.getCache());
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port,maxInactive, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
return server;
}

View File

@ -42,9 +42,9 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
return server;
}

View File

@ -50,9 +50,9 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -19,6 +19,8 @@
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -52,9 +54,9 @@ public class SessionRenewTest extends AbstractSessionRenewTest
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}
@Test
@ -63,5 +65,16 @@ public class SessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
assertTrue(((InfinispanTestSessionServer)_server).exists(newSessionId));
assertFalse(((InfinispanTestSessionServer)_server).exists(oldSessionId));
return (!((InfinispanTestSessionServer)_server).exists(oldSessionId)) && ((InfinispanTestSessionServer)_server).exists(newSessionId);
}
}

View File

@ -59,9 +59,9 @@ public class RemoteImmortalSessionTest extends AbstractImmortalSessionTest
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs)
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavengeMs, __testSupport.getCache());
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -58,24 +58,9 @@ public class RemoteInvalidationSessionTest extends AbstractInvalidationSessionTe
* @see org.eclipse.jetty.server.session.AbstractInvalidationSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInterval, int inspectInterval)
public AbstractTestServer createServer(int port, int maxInterval, int scavengeInterval, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, maxInterval, inspectInterval, __testSupport.getCache())
{
/**
* @see org.eclipse.jetty.server.session.InfinispanTestSessionServer#newSessionManager()
*/
@Override
public SessionManager newSessionManager()
{
InfinispanSessionManager mgr = (InfinispanSessionManager)super.newSessionManager();
mgr.getSessionStore().setIdlePassivationTimeoutSec(IDLE_PASSIVATE_SEC);
return mgr;
}
};
return server;
return new InfinispanTestSessionServer(port, maxInterval, scavengeInterval, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}

View File

@ -52,9 +52,9 @@ public class RemoteLastAccessTimeTest extends AbstractLastAccessTimeTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -53,9 +53,9 @@ public class RemoteLocalSessionScavengingTest extends AbstractLocalSessionScaven
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
}

View File

@ -53,9 +53,9 @@ public class RemoteNewSessionTest extends AbstractNewSessionTest
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}

View File

@ -52,9 +52,9 @@ public class RemoteReentrantRequestSessionTest extends AbstractReentrantRequestS
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port, int maxInactive, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, __testSupport.getCache());
return new InfinispanTestSessionServer(port, maxInactive, scavenge, inspectInterval, idlePassivateInterval, __testSupport.getCache());
}
@Override

View File

@ -46,9 +46,9 @@ public class RemoteRemoveSessionTest extends AbstractRemoveSessionTest
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge,inspectInterval, idlePassivateInterval, __testSupport.getCache());
return s;
}

View File

@ -54,9 +54,9 @@ public class RemoteSameNodeLoadTest extends AbstractSameNodeLoadTest
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port, int maxInactive, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, __testSupport.getCache());
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, maxInactive, scavenge,inspectInterval, idlePassivateInterval, __testSupport.getCache());
return server;
}

View File

@ -45,9 +45,9 @@ public class RemoteSessionExpiryTest extends AbstractSessionExpiryTest
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
return server;
}

View File

@ -53,9 +53,9 @@ public class RemoteSessionInvalidateAndCreateTest extends AbstractSessionInvalid
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Override

View File

@ -55,9 +55,9 @@ public class RemoteSessionRenewTest extends AbstractSessionRenewTest
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectInterval, int idlePassivateInterval)
{
return new InfinispanTestSessionServer(port, max, scavenge, __testSupport.getCache());
return new InfinispanTestSessionServer(port, max, scavenge, inspectInterval, idlePassivateInterval,__testSupport.getCache());
}
@Test
@ -66,5 +66,12 @@ public class RemoteSessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
return !((InfinispanTestSessionServer)_server).exists(oldSessionId) && ((InfinispanTestSessionServer)_server).exists(newSessionId);
}
}

View File

@ -57,11 +57,13 @@ public class DirtyAttributeTest
public static String THE_NAME = "__theName";
public static int INACTIVE = 4;
public static int SCAVENGE = 1;
public static int INSPECT = 1;
public static int IDLE_PASSIVATE = 3;
@Test
public void testDirtyWrite() throws Exception
{
AbstractTestServer server = new JdbcTestServer(0,INACTIVE,SCAVENGE);
AbstractTestServer server = new JdbcTestServer(0,INACTIVE,SCAVENGE, INSPECT, IDLE_PASSIVATE);
ServletContextHandler ctxA = server.addContext("/mod");
ctxA.addServlet(TestDirtyServlet.class, "/test");

View File

@ -29,9 +29,9 @@ import org.junit.Test;
public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs)
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs, int inspect, int idlePassivate)
{
return new JdbcTestServer(port, maxInactiveMs, scavengeMs);
return new JdbcTestServer(port, maxInactiveMs, scavengeMs, inspect, idlePassivate);
}
@Test

View File

@ -29,24 +29,9 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest
{
public static final int IDLE_PASSIVATE_SEC = 3;
public AbstractTestServer createServer(int port, int maxInactive, int inspectInterval)
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int inspectInterval, int idlePassivateInterval)
{
JdbcTestServer server = new JdbcTestServer(port, maxInactive, inspectInterval)
{
/**
* @see org.eclipse.jetty.server.session.JdbcTestServer#newSessionManager()
*/
@Override
public SessionManager newSessionManager()
{
JDBCSessionManager manager = (JDBCSessionManager)super.newSessionManager();
manager.getSessionStore().setIdlePassivationTimeoutSec(IDLE_PASSIVATE_SEC);
return manager;
}
};
return server;
return new JdbcTestServer(port, maxInactive, scavengeInterval, inspectInterval, idlePassivateInterval);
}
public void pause()

View File

@ -85,14 +85,14 @@ public class JdbcTestServer extends AbstractTestServer
super(port);
}
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, String connectionUrl)
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod, String connectionUrl)
{
super(port, maxInactivePeriod, scavengePeriod, connectionUrl);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod, connectionUrl);
}
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod)
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int inspectPeriod, int idlePassivatePeriod)
{
super(port, maxInactivePeriod, scavengePeriod, DEFAULT_CONNECTION_URL);
super(port, maxInactivePeriod, scavengePeriod, inspectPeriod, idlePassivatePeriod, DEFAULT_CONNECTION_URL);
}

View File

@ -26,9 +26,9 @@ import org.junit.Test;
*/
public class LastAccessTimeTest extends AbstractLastAccessTimeTest
{
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge, inspect, idlePassivate);
}
@Test

View File

@ -43,9 +43,9 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
}
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge, inspect, idlePassivate);
}
@Test

View File

@ -61,8 +61,8 @@ public class MaxInactiveMigrationTest
@Before
public void setUp() throws Exception {
testServer1 = new JdbcTestServer(0, -1, 2);
testServer2 = new JdbcTestServer(0, -1, 2);
testServer1 = new JdbcTestServer(0, -1, 2, 1, -1);
testServer2 = new JdbcTestServer(0, -1, 2, 1, -1);
ServletContextHandler context = testServer1.addContext("");
context.addServlet(TestServlet.class, "/test");
ServletContextHandler context2 = testServer2.addContext("");

View File

@ -46,14 +46,16 @@ import org.junit.Test;
public class ModifyMaxInactiveIntervalTest
{
public static int inactive = 4;
public static int __inactive = 4;
public static int newMaxInactive = 20;
public static int scavenge = 1;
public static int __scavenge = 1;
public static int __inspect = 1;
public static int __idlePassivate = -1;
@Test
public void testSessionExpiryAfterModifiedMaxInactiveInterval() throws Exception
{
AbstractTestServer server = new JdbcTestServer(0,inactive,scavenge);
AbstractTestServer server = new JdbcTestServer(0,__inactive,__scavenge, __inspect, __idlePassivate);
ServletContextHandler ctxA = server.addContext("/mod");
ctxA.addServlet(TestModServlet.class, "/test");

View File

@ -29,9 +29,9 @@ public class NewSessionTest extends AbstractNewSessionTest
/**
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int)
*/
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge, inspect, idlePassivate);
}
@Test

View File

@ -26,9 +26,9 @@ import org.junit.Test;
*/
public class OrphanedSessionTest extends AbstractOrphanedSessionTest
{
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge,inspect, idlePassivate);
}
@Test

View File

@ -35,9 +35,9 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port, max, scavenge);
return new JdbcTestServer(port, max, scavenge, inspect, idlePassivate);
}
/**

View File

@ -28,9 +28,9 @@ import org.junit.Test;
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
public AbstractTestServer createServer(int port)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectionPeriod, int idlePassivatePeriod)
{
return new JdbcTestServer(port);
return new JdbcTestServer(port,max,scavenge,inspectionPeriod,idlePassivatePeriod);
}
@Test

View File

@ -59,7 +59,7 @@ public class SaveIntervalTest
@Test
public void testSaveInterval() throws Exception
{
AbstractTestServer server = new JdbcTestServer(0,INACTIVE,SCAVENGE);
AbstractTestServer server = new JdbcTestServer(0,INACTIVE,SCAVENGE, 20, -1);
ServletContextHandler ctxA = server.addContext("/mod");
ServletHolder holder = new ServletHolder();

View File

@ -34,9 +34,9 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
* @see org.eclipse.jetty.server.session.AbstractSessionExpiryTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge, inspect, idlePassivate);
}
@Test

View File

@ -26,9 +26,9 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge,inspect,idlePassivate);
}
@Test

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Test;
@ -25,11 +28,36 @@ public class SessionRenewTest extends AbstractSessionRenewTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port, max, scavenge);
return new JdbcTestServer(port, max, scavenge, inspect, idlePassivate);
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(String oldSessionId, String newSessionId)
{
try
{
//assert the new one exists
assertTrue(((JdbcTestServer)_server).existsInSessionTable(newSessionId, false));
assertFalse(((JdbcTestServer)_server).existsInSessionTable(oldSessionId, false));
return true;
}
catch (Exception e)
{
fail(e.getMessage());
}
return false;
}
@Test
public void testSessionRenewal() throws Exception
{

View File

@ -26,9 +26,9 @@ import org.junit.Test;
*/
public class SessionValueSavingTest extends AbstractSessionValueSavingTest
{
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
{
return new JdbcTestServer(port,max,scavenge);
return new JdbcTestServer(port,max,scavenge,inspect, idlePassivate);
}
@Test

View File

@ -64,10 +64,10 @@ public class AttributeNameTest
MongoTestServer.dropCollection();
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspect, int idlePassivate)
throws Exception
{
MongoTestServer server = new MongoTestServer(port,max,scavenge,true);
MongoTestServer server = new MongoTestServer(port,max,scavenge,inspect, idlePassivate, true);
return server;
@ -80,12 +80,14 @@ public class AttributeNameTest
String servletMapping = "/server";
int maxInactivePeriod = 10000;
int scavengePeriod = 20000;
AbstractTestServer server1 = createServer(0,maxInactivePeriod,scavengePeriod);
int inspectPeriod = 60;
int idlePassivatePeriod = -1;
AbstractTestServer server1 = createServer(0,maxInactivePeriod,scavengePeriod, inspectPeriod, idlePassivatePeriod);
server1.addContext(contextPath).addServlet(TestServlet.class,servletMapping);
server1.start();
int port1 = server1.getPort();
AbstractTestServer server2 = createServer(0,maxInactivePeriod,scavengePeriod);
AbstractTestServer server2 = createServer(0,maxInactivePeriod,scavengePeriod,inspectPeriod, idlePassivatePeriod);
server2.addContext(contextPath).addServlet(TestServlet.class,servletMapping);
server2.start();
int port2 = server2.getPort();

View File

@ -43,24 +43,9 @@ public class IdleSessionTest extends AbstractIdleSessionTest
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int idleSec)
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int inspectSec, final int idleSec)
{
MongoTestServer server = new MongoTestServer(port,max,scavenge)
{
/**
* @see org.eclipse.jetty.nosql.mongodb.MongoTestServer#newSessionManager()
*/
@Override
public SessionManager newSessionManager()
{
MongoSessionManager manager = (MongoSessionManager)super.newSessionManager();
manager.getSessionStore().setIdlePassivationTimeoutSec(idleSec);
return manager;
}
};
return server;
return new MongoTestServer(port,max,scavenge, inspectSec, idleSec);
}
/**

View File

@ -44,24 +44,9 @@ public class InvalidateSessionTest extends AbstractInvalidationSessionTest
}
@Override
public AbstractTestServer createServer(int port, int maxInterval, int inspectInterval)
public AbstractTestServer createServer(int port, int maxInterval, int scavengeInterval, int inspectInterval, int idleInterval)
{
MongoTestServer server = new MongoTestServer(port, maxInterval, inspectInterval)
{
/**
* @see org.eclipse.jetty.nosql.mongodb.MongoTestServer#newSessionManager()
*/
@Override
public SessionManager newSessionManager()
{
MongoSessionManager manager = (MongoSessionManager)super.newSessionManager();
manager.getSessionStore().setIdlePassivationTimeoutSec(IDLE_PASSIVATE_SEC);
return manager;
}
};
return server;
return new MongoTestServer(port, maxInterval, scavengeInterval, inspectInterval, idleInterval);
}
@Override

View File

@ -41,9 +41,9 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
MongoTestServer.dropCollection();
}
public AbstractTestServer createServer(int port, int max, int scavenge)
public AbstractTestServer createServer(int port, int max, int scavenge, int inspectSec, int idlePassivateSec)
{
return new MongoTestServer(port,max,scavenge);
return new MongoTestServer(port,max,scavenge, inspectSec, idlePassivateSec);
}

Some files were not shown because too many files have changed in this diff Show More