This commit is contained in:
Jan Bartel 2016-10-20 12:37:22 +11:00
parent b08fa971a5
commit 6ff5a3a7e9
10 changed files with 156 additions and 7 deletions

View File

@ -73,6 +73,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
protected boolean _dsProvided = false; protected boolean _dsProvided = false;
protected boolean _indexesPresent = false; protected boolean _indexesPresent = false;
protected EntityDataModel _model; protected EntityDataModel _model;
protected boolean _modelProvided;
private String _namespace; private String _namespace;
@ -301,6 +302,18 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
_attributes = attributes; _attributes = attributes;
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s==%s:%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",this.getClass().getName(),
_kind,_accessed,_attributes,_contextPath,_cookieSetTime,_createTime,_expiry,_id,_lastAccessed,_lastNode,_maxInactive,_vhost);
}
} }
@ -356,7 +369,9 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
public void setEntityDataModel(EntityDataModel model) public void setEntityDataModel(EntityDataModel model)
{ {
updateBean(_model, model);
_model = model; _model = model;
_modelProvided = true;
} }
@ -413,7 +428,10 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
} }
if (_model == null) if (_model == null)
{
_model = new EntityDataModel(); _model = new EntityDataModel();
addBean(_model,true);
}
_keyFactory = _datastore.newKeyFactory().kind(_model.getKind()); _keyFactory = _datastore.newKeyFactory().kind(_model.getKind());
@ -430,15 +448,17 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
@Override @Override
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
super.doStop();
if (!_dsProvided) if (!_dsProvided)
_datastore = null; _datastore = null;
super.doStop(); if (!_modelProvided)
_model = null;
} }
public void setDatastore (Datastore datastore) public void setDatastore (Datastore datastore)
{ {
_datastore = datastore; _datastore = datastore;
_dsProvided = true; _dsProvided = true;
} }
public int getMaxResults() public int getMaxResults()
@ -928,4 +948,14 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
} }
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#toString()
*/
@Override
public String toString()
{
return String.format("%s[namespace=%s,backoff=%d,maxRetries=%d,maxResults=%d,indexes=%b]",super.toString(), _namespace, _backoff, _maxRetries, _maxResults,_indexesPresent);
}
} }

View File

@ -311,4 +311,17 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore
{ {
return _infinispanIdleTimeoutSec; return _infinispanIdleTimeoutSec;
} }
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#toString()
*/
@Override
public String toString()
{
return String.format("%s[cache=%s,idleTimeoutSec=%d]",super.toString(), (_cache==null?"":_cache.getName()),_infinispanIdleTimeoutSec);
}
} }

View File

@ -689,4 +689,15 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
return true; return true;
} }
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#toString()
*/
@Override
public String toString()
{
return String.format("%s[collection=%s]", super.toString(),getDBCollection());
}
} }

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.session; package org.eclipse.jetty.server.session;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
@ -26,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Locker.Lock; import org.eclipse.jetty.util.thread.Locker.Lock;
@ -782,4 +784,12 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
} }
return session; return session;
} }
@Override
public String toString()
{
return String.format("%s@%x[evict=%d,removeUnloadable=%b,saveOnCreate=%b,saveOnInactiveEvict=%b]",
this.getClass().getName(),this.hashCode(),_evictionPolicy,_removeUnloadableSessions,_saveOnCreate,_saveOnInactiveEviction);
}
} }

View File

@ -23,13 +23,14 @@ package org.eclipse.jetty.server.session;
import java.util.Set; import java.util.Set;
import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
/** /**
* AbstractSessionDataStore * AbstractSessionDataStore
* *
* *
*/ */
public abstract class AbstractSessionDataStore extends AbstractLifeCycle implements SessionDataStore public abstract class AbstractSessionDataStore extends ContainerLifeCycle implements SessionDataStore
{ {
protected SessionContext _context; //context associated with this session data store protected SessionContext _context; //context associated with this session data store
protected int _gracePeriodSec = 60 * 60; //default of 1hr protected int _gracePeriodSec = 60 * 60; //default of 1hr
@ -146,4 +147,16 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
_gracePeriodSec = sec; _gracePeriodSec = sec;
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s@%x[passivating=%b,graceSec=%d]",this.getClass().getName(),this.hashCode(),isPassivating(),getGracePeriodSec());
}
} }

View File

@ -303,4 +303,13 @@ public class DatabaseAdaptor
return DriverManager.getConnection(_connectionUrl); return DriverManager.getConnection(_connectionUrl);
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s[jndi=%s,driver=%s]", super.toString(),_jndiName, _driverClassName);
}
} }

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionIdManager; import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -48,7 +49,7 @@ import org.eclipse.jetty.util.log.Logger;
* *
* @see HouseKeeper * @see HouseKeeper
*/ */
public class DefaultSessionIdManager extends AbstractLifeCycle implements SessionIdManager public class DefaultSessionIdManager extends ContainerLifeCycle implements SessionIdManager
{ {
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -63,6 +64,7 @@ public class DefaultSessionIdManager extends AbstractLifeCycle implements Sessio
protected long _reseed=100000L; protected long _reseed=100000L;
protected Server _server; protected Server _server;
protected HouseKeeper _houseKeeper; protected HouseKeeper _houseKeeper;
protected boolean _ownHouseKeeper;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -112,6 +114,7 @@ public class DefaultSessionIdManager extends AbstractLifeCycle implements Sessio
*/ */
public void setSessionHouseKeeper (HouseKeeper houseKeeper) public void setSessionHouseKeeper (HouseKeeper houseKeeper)
{ {
updateBean(_houseKeeper, houseKeeper);
_houseKeeper = houseKeeper; _houseKeeper = houseKeeper;
_houseKeeper.setSessionIdManager(this); _houseKeeper.setSessionIdManager(this);
} }
@ -344,8 +347,10 @@ public class DefaultSessionIdManager extends AbstractLifeCycle implements Sessio
if (_houseKeeper == null) if (_houseKeeper == null)
{ {
LOG.warn("No SessionScavenger set, using defaults"); LOG.warn("No SessionScavenger set, using defaults");
_ownHouseKeeper = true;
_houseKeeper = new HouseKeeper(); _houseKeeper = new HouseKeeper();
_houseKeeper.setSessionIdManager(this); _houseKeeper.setSessionIdManager(this);
addBean(_houseKeeper,true);
} }
_houseKeeper.start(); _houseKeeper.start();
@ -359,6 +364,11 @@ public class DefaultSessionIdManager extends AbstractLifeCycle implements Sessio
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
_houseKeeper.stop(); _houseKeeper.stop();
if (_ownHouseKeeper)
{
_houseKeeper = null;
}
_random = null;
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -499,4 +509,15 @@ public class DefaultSessionIdManager extends AbstractLifeCycle implements Sessio
} }
return handlers; return handlers;
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s[worker=%s]", super.toString(),_workerName);
}
} }

View File

@ -455,6 +455,15 @@ public class FileSessionDataStore extends AbstractSessionDataStore
} }
} }
/**
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#toString()
*/
@Override
public String toString()
{
return String.format("%s[dir=%s,deleteUnrestorableFiles=%b]",super.toString(),_storeDir,_deleteUnrestorableFiles);
}
} }

View File

@ -53,6 +53,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
protected boolean _initialized = false; protected boolean _initialized = false;
private DatabaseAdaptor _dbAdaptor; private DatabaseAdaptor _dbAdaptor;
private SessionTableSchema _sessionTableSchema; private SessionTableSchema _sessionTableSchema;
private boolean _schemaProvided;
@ -616,6 +617,19 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
statement.executeUpdate(getCreateIndexOverSessionStatementAsString(index2)); statement.executeUpdate(getCreateIndexOverSessionStatementAsString(index2));
} }
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]",super.toString(),
_schemaName,_tableName,_idColumn,_contextPathColumn,_virtualHostColumn,_cookieTimeColumn,_createTimeColumn,
_expiryTimeColumn,_accessTimeColumn,_lastAccessTimeColumn,_lastNodeColumn,_lastSavedTimeColumn,_maxIntervalColumn);
}
} }
@ -647,6 +661,9 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
super.doStop(); super.doStop();
_initialized = false;
if (!_schemaProvided)
_sessionTableSchema = null;
} }
@ -660,7 +677,10 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
//taking the defaults if one not set //taking the defaults if one not set
if (_sessionTableSchema == null) if (_sessionTableSchema == null)
{
_sessionTableSchema = new SessionTableSchema(); _sessionTableSchema = new SessionTableSchema();
addBean(_sessionTableSchema,true);
}
_dbAdaptor.initialize(); _dbAdaptor.initialize();
_sessionTableSchema.setDatabaseAdaptor(_dbAdaptor); _sessionTableSchema.setDatabaseAdaptor(_dbAdaptor);
@ -981,13 +1001,16 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
public void setDatabaseAdaptor (DatabaseAdaptor dbAdaptor) public void setDatabaseAdaptor (DatabaseAdaptor dbAdaptor)
{ {
checkStarted(); checkStarted();
updateBean(_dbAdaptor, dbAdaptor);
_dbAdaptor = dbAdaptor; _dbAdaptor = dbAdaptor;
} }
public void setSessionTableSchema (SessionTableSchema schema) public void setSessionTableSchema (SessionTableSchema schema)
{ {
checkStarted(); checkStarted();
updateBean(_sessionTableSchema, schema);
_sessionTableSchema = schema; _sessionTableSchema = schema;
_schemaProvided = true;
} }

View File

@ -1682,4 +1682,14 @@ public class SessionHandler extends ScopedHandler
} }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return String.format("%s%d==dftMaxIdleSec=%d", this.getClass().getName(),this.hashCode(),_dftMaxIdleSecs);
}
} }