This commit is contained in:
Jan Bartel 2017-04-06 15:01:17 +10:00
parent 3b979ff554
commit 7e2f08a7ad
13 changed files with 78 additions and 5 deletions

View File

@ -33,6 +33,8 @@ import org.eclipse.jetty.server.session.UnreadableSessionDataException;
import org.eclipse.jetty.server.session.UnwriteableSessionDataException;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -55,6 +57,7 @@ import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
*
*
*/
@ManagedObject
public class GCloudSessionDataStore extends AbstractSessionDataStore
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -410,11 +413,13 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
_namespace = namespace;
}
@ManagedAttribute(value="gclound namespace", readonly=true)
public String getNamespace ()
{
return _namespace;
}
@ManagedAttribute(value="unit in ms of exponential backoff")
public int getBackoffMs ()
{
return _backoff;
@ -426,7 +431,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
_maxRetries = retries;
}
@ManagedAttribute(value="max number of retries for failed writes")
public int getMaxRetries ()
{
return _maxRetries;
@ -480,6 +485,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
_dsProvided = true;
}
@ManagedAttribute(value="max number of results to return from gcloud searches")
public int getMaxResults()
{
return _maxResults;
@ -978,6 +984,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@ManagedAttribute(value="does gcloud serialize session data", readonly=true)
@Override
public boolean isPassivating()
{

View File

@ -27,6 +27,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.server.session.AbstractSessionDataStore;
import org.eclipse.jetty.server.session.SessionData;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.infinispan.commons.api.BasicCache;
@ -36,6 +38,7 @@ import org.infinispan.commons.api.BasicCache;
*
*
*/
@ManagedObject
public class InfinispanSessionDataStore extends AbstractSessionDataStore
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -231,6 +234,7 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@ManagedAttribute(value="does store serialize sessions", readonly=true)
@Override
public boolean isPassivating()
{
@ -307,6 +311,8 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore
_infinispanIdleTimeoutSec = sec;
}
@ManagedAttribute(value="infinispan idle timeout sec", readonly=true)
public int getInfinispanIdleTimeoutSec ()
{
return _infinispanIdleTimeoutSec;

View File

@ -25,6 +25,8 @@ import java.util.List;
import org.eclipse.jetty.server.session.SessionContext;
import org.eclipse.jetty.server.session.SessionData;
import org.eclipse.jetty.server.session.SessionDataMap;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import net.rubyeye.xmemcached.MemcachedClient;
@ -37,6 +39,7 @@ import net.rubyeye.xmemcached.XMemcachedClientBuilder;
*
* Uses memcached as a cache for SessionData.
*/
@ManagedObject
public class MemcachedSessionDataMap extends AbstractLifeCycle implements SessionDataMap
{
public static final String DEFAULT_HOST = "localhost";
@ -91,8 +94,17 @@ public class MemcachedSessionDataMap extends AbstractLifeCycle implements Sessio
_expirySec = sec;
}
/**
* Expiry time for memached entries.
* @return memcached expiry time in sec
*/
@ManagedAttribute(value="memcached expiry time in sec", readonly=true)
public int getExpirySec ()
{
return _expirySec;
}
@ManagedAttribute(value="enable memcached heartbeats", readonly=true)
public boolean isHeartbeats()
{
return _heartbeats;

View File

@ -44,6 +44,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.nosql.NoSqlSessionDataStore;
import org.eclipse.jetty.server.session.SessionData;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -96,6 +98,7 @@ import org.eclipse.jetty.util.log.Logger;
*
*
*/
@ManagedObject
public class MongoSessionDataStore extends NoSqlSessionDataStore
{
@ -171,7 +174,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
_dbSessions = collection;
}
@ManagedAttribute(value="DBCollection", readonly=true)
public DBCollection getDBCollection ()
{
return _dbSessions;
@ -695,6 +698,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
/**
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@ManagedAttribute(value="does store serialize sessions", readonly=true)
@Override
public boolean isPassivating()
{

View File

@ -27,6 +27,8 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.DumpableCollection;
import org.eclipse.jetty.util.log.Log;
@ -53,6 +55,7 @@ import org.eclipse.jetty.util.thread.Locker.Lock;
* passivated before it is evicted from the cache.
*
*/
@ManagedObject
public abstract class AbstractSessionCache extends ContainerLifeCycle implements SessionCache
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -257,6 +260,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
/**
* @see org.eclipse.jetty.server.session.SessionCache#getEvictionPolicy()
*/
@ManagedAttribute(value="session eviction policy", readonly=true)
public int getEvictionPolicy()
{
return _evictionPolicy;
@ -275,7 +279,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
_evictionPolicy = evictionTimeout;
}
@ManagedAttribute(value="immediately save new sessions", readonly=true)
@Override
public boolean isSaveOnCreate()
{
@ -293,6 +297,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
/**
* @return true if sessions that can't be loaded are deleted from the store
*/
@ManagedAttribute(value="delete unreadable stored sessions", readonly=true)
@Override
public boolean isRemoveUnloadableSessions()
{
@ -779,6 +784,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
*
* @return true if an inactive session will be saved before being evicted
*/
@ManagedAttribute(value="save sessions before evicting from cache", readonly=true)
@Override
public boolean isSaveOnInactiveEviction ()
{

View File

@ -23,6 +23,8 @@ package org.eclipse.jetty.server.session;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
@ -33,6 +35,7 @@ import org.eclipse.jetty.util.log.Logger;
*
*
*/
@ManagedObject
public abstract class AbstractSessionDataStore extends ContainerLifeCycle implements SessionDataStore
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -153,7 +156,9 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem
super.doStart();
}
@ManagedAttribute(value="interval in secs to prevent too eager session scavenging", readonly=true)
public int getGracePeriodSec()
{
return _gracePeriodSec;
@ -168,6 +173,7 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem
/**
* @return the savePeriodSec
*/
@ManagedAttribute(value="min secs between saves", readonly=true)
public int getSavePeriodSec()
{
return _savePeriodSec;

View File

@ -23,6 +23,9 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.statistic.CounterStatistic;
@ -32,6 +35,7 @@ import org.eclipse.jetty.util.statistic.CounterStatistic;
*
* A session store that keeps its sessions in memory in a hashmap
*/
@ManagedObject
public class DefaultSessionCache extends AbstractSessionCache
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -58,6 +62,7 @@ public class DefaultSessionCache extends AbstractSessionCache
/**
* @return the number of sessions in the cache
*/
@ManagedAttribute(value="current sessions in cache", readonly=true)
public long getSessionsCurrent ()
{
return _stats.getCurrent();
@ -67,6 +72,7 @@ public class DefaultSessionCache extends AbstractSessionCache
/**
* @return the max number of sessions in the cache
*/
@ManagedAttribute(value="max sessions in cache", readonly=true)
public long getSessionsMax()
{
return _stats.getMax();
@ -76,6 +82,7 @@ public class DefaultSessionCache extends AbstractSessionCache
/**
* @return a running total of sessions in the cache
*/
@ManagedAttribute(value="total sessions in cache", readonly=true)
public long getSessionsTotal()
{
return _stats.getTotal();
@ -84,6 +91,7 @@ public class DefaultSessionCache extends AbstractSessionCache
/**
*
*/
@ManagedOperation(value="reset statistics", impact="ACTION")
public void resetStats()
{
_stats.reset();

View File

@ -31,6 +31,8 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -49,6 +51,7 @@ import org.eclipse.jetty.util.log.Logger;
*
* @see HouseKeeper
*/
@ManagedObject
public class DefaultSessionIdManager extends ContainerLifeCycle implements SessionIdManager
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -137,6 +140,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
* @return name or null
*/
@Override
@ManagedAttribute(value="unique name for this node", readonly=true)
public String getWorkerName()
{
return _workerName;

View File

@ -41,6 +41,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -49,6 +51,7 @@ import org.eclipse.jetty.util.log.Logger;
*
* A file-based store of session data.
*/
@ManagedObject
public class FileSessionDataStore extends AbstractSessionDataStore
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -70,6 +73,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore
super.doStop();
}
@ManagedAttribute(value="dir where sessions are stored", readonly=true)
public File getStoreDir()
{
return _storeDir;
@ -307,6 +311,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@Override
@ManagedAttribute(value="are sessions serialized by this store", readonly=true)
public boolean isPassivating()
{
return true;

View File

@ -22,6 +22,8 @@ package org.eclipse.jetty.server.session;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -34,6 +36,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
* There is 1 session HouseKeeper per SessionIdManager instance.
*
*/
@ManagedObject
public class HouseKeeper extends AbstractLifeCycle
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -238,6 +241,7 @@ public class HouseKeeper extends AbstractLifeCycle
*
* @return the interval (in seconds)
*/
@ManagedAttribute(value="secs between scavenge cycles", readonly=true)
public long getIntervalSec ()
{
return _intervalMs/1000;

View File

@ -38,6 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -46,6 +48,7 @@ import org.eclipse.jetty.util.log.Logger;
*
* Session data stored in database
*/
@ManagedObject
public class JDBCSessionDataStore extends AbstractSessionDataStore
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
@ -1020,6 +1023,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@Override
@ManagedAttribute(value="does this store serialize sessions", readonly=true)
public boolean isPassivating()
{
return true;

View File

@ -21,11 +21,15 @@ package org.eclipse.jetty.server.session;
import java.util.Set;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
/**
* NullSessionDataStore
*
* Does not actually store anything, useful for testing.
*/
@ManagedObject
public class NullSessionDataStore extends AbstractSessionDataStore
{
@ -81,6 +85,7 @@ public class NullSessionDataStore extends AbstractSessionDataStore
/**
* @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating()
*/
@ManagedAttribute(value="does this store serialize sessions", readonly=true)
@Override
public boolean isPassivating()
{

View File

@ -57,6 +57,7 @@ import org.eclipse.jetty.server.handler.ScopedHandler;
import org.eclipse.jetty.util.ConcurrentHashSet;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -70,6 +71,7 @@ import org.eclipse.jetty.util.thread.Locker.Lock;
/**
* SessionHandler.
*/
@ManagedObject
public class SessionHandler extends ScopedHandler
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");