migrate jetty-nosql and jetty-monitor to jmx annotations
This commit is contained in:
parent
2d9c4e823c
commit
129fb06f1f
|
@ -25,6 +25,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jetty.monitor.thread.ThreadMonitorException;
|
import org.eclipse.jetty.monitor.thread.ThreadMonitorException;
|
||||||
import org.eclipse.jetty.monitor.thread.ThreadMonitorInfo;
|
import org.eclipse.jetty.monitor.thread.ThreadMonitorInfo;
|
||||||
|
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.AbstractLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
@ -33,6 +35,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ManagedObject("detect and report spinning and deadlocked threads")
|
||||||
public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(ThreadMonitor.class);
|
private static final Logger LOG = Log.getLogger(ThreadMonitor.class);
|
||||||
|
@ -132,6 +135,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @return the scan interval
|
* @return the scan interval
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("scan interval")
|
||||||
public int getScanInterval()
|
public int getScanInterval()
|
||||||
{
|
{
|
||||||
return _scanInterval;
|
return _scanInterval;
|
||||||
|
@ -154,6 +158,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @return the log interval
|
* @return the log interval
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("log interval")
|
||||||
public int getLogInterval()
|
public int getLogInterval()
|
||||||
{
|
{
|
||||||
return _logInterval;
|
return _logInterval;
|
||||||
|
@ -176,6 +181,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @return the busy threshold
|
* @return the busy threshold
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("busy threshold")
|
||||||
public int getBusyThreshold()
|
public int getBusyThreshold()
|
||||||
{
|
{
|
||||||
return _busyThreshold;
|
return _busyThreshold;
|
||||||
|
@ -198,6 +204,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @return the log threshold
|
* @return the log threshold
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("log threshold")
|
||||||
public int getLogThreshold()
|
public int getLogThreshold()
|
||||||
{
|
{
|
||||||
return _logThreshold;
|
return _logThreshold;
|
||||||
|
@ -220,6 +227,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @return the stack depth
|
* @return the stack depth
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("stack depth")
|
||||||
public int getStackDepth()
|
public int getStackDepth()
|
||||||
{
|
{
|
||||||
return _stackDepth;
|
return _stackDepth;
|
||||||
|
@ -242,6 +250,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
||||||
*
|
*
|
||||||
* @param trailLength the new trail length
|
* @param trailLength the new trail length
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("trail length")
|
||||||
public void setTrailLength(int trailLength)
|
public void setTrailLength(int trailLength)
|
||||||
{
|
{
|
||||||
_trailLength = trailLength;
|
_trailLength = trailLength;
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.security.Security;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Derived from the JMX bean classes created by Kees Jan Koster for the java-monitor
|
* Derived from the JMX bean classes created by Kees Jan Koster for the java-monitor
|
||||||
|
@ -29,6 +32,7 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author kjkoster <kjkoster@gmail.com>
|
* @author kjkoster <kjkoster@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
@ManagedObject("retrieves information required by java-monitor")
|
||||||
public class JavaMonitorTools
|
public class JavaMonitorTools
|
||||||
{
|
{
|
||||||
private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
|
private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
|
||||||
|
@ -74,6 +78,7 @@ public class JavaMonitorTools
|
||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("detailed report of deadlocked threads")
|
||||||
public String getDeadlockStacktraces()
|
public String getDeadlockStacktraces()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -136,6 +141,7 @@ public class JavaMonitorTools
|
||||||
return states.get(Thread.State.BLOCKED);
|
return states.get(Thread.State.BLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("number of new threads")
|
||||||
public int getThreadsNew()
|
public int getThreadsNew()
|
||||||
{
|
{
|
||||||
sampleThreads();
|
sampleThreads();
|
||||||
|
@ -143,6 +149,7 @@ public class JavaMonitorTools
|
||||||
return states.get(Thread.State.NEW);
|
return states.get(Thread.State.NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("number of terminated threads")
|
||||||
public int getThreadsTerminated()
|
public int getThreadsTerminated()
|
||||||
{
|
{
|
||||||
sampleThreads();
|
sampleThreads();
|
||||||
|
@ -150,6 +157,7 @@ public class JavaMonitorTools
|
||||||
return states.get(Thread.State.TERMINATED);
|
return states.get(Thread.State.TERMINATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("number of sleeping and waiting threads")
|
||||||
public int getThreadsTimedWaiting()
|
public int getThreadsTimedWaiting()
|
||||||
{
|
{
|
||||||
sampleThreads();
|
sampleThreads();
|
||||||
|
@ -157,6 +165,7 @@ public class JavaMonitorTools
|
||||||
return states.get(Thread.State.TIMED_WAITING);
|
return states.get(Thread.State.TIMED_WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("number of waiting threads")
|
||||||
public int getThreadsWaiting()
|
public int getThreadsWaiting()
|
||||||
{
|
{
|
||||||
sampleThreads();
|
sampleThreads();
|
||||||
|
@ -198,6 +207,7 @@ public class JavaMonitorTools
|
||||||
|
|
||||||
private static final String POLICY = "sun.net.InetAddressCachePolicy";
|
private static final String POLICY = "sun.net.InetAddressCachePolicy";
|
||||||
|
|
||||||
|
@ManagedAttribute("amount of time successful dns queries are cached for")
|
||||||
public int getCacheSeconds() throws ClassNotFoundException,
|
public int getCacheSeconds() throws ClassNotFoundException,
|
||||||
IllegalAccessException, InvocationTargetException,
|
IllegalAccessException, InvocationTargetException,
|
||||||
NoSuchMethodException {
|
NoSuchMethodException {
|
||||||
|
@ -209,6 +219,7 @@ public class JavaMonitorTools
|
||||||
return seconds.intValue();
|
return seconds.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Amount of time failed DNS queries are cached for")
|
||||||
public int getCacheNegativeSeconds() throws ClassNotFoundException,
|
public int getCacheNegativeSeconds() throws ClassNotFoundException,
|
||||||
IllegalAccessException, InvocationTargetException,
|
IllegalAccessException, InvocationTargetException,
|
||||||
NoSuchMethodException {
|
NoSuchMethodException {
|
||||||
|
@ -236,6 +247,7 @@ public class JavaMonitorTools
|
||||||
|
|
||||||
private static final String SYSTEM_NEGATIVE_TTL = "sun.net.inetaddr.negative.ttl";
|
private static final String SYSTEM_NEGATIVE_TTL = "sun.net.inetaddr.negative.ttl";
|
||||||
|
|
||||||
|
@ManagedAttribute("Cache policy for successful DNS lookups was changed from the hard-coded default")
|
||||||
public String getCacheTweakedFrom() {
|
public String getCacheTweakedFrom() {
|
||||||
if (Security.getProperty(SECURITY_TTL) != null) {
|
if (Security.getProperty(SECURITY_TTL) != null) {
|
||||||
if (System.getProperty(SYSTEM_TTL) != null) {
|
if (System.getProperty(SYSTEM_TTL) != null) {
|
||||||
|
@ -252,6 +264,7 @@ public class JavaMonitorTools
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute("Cache policy for failed DNS lookups was changed from the hard-coded default")
|
||||||
public String getCacheNegativeTweakedFrom() {
|
public String getCacheNegativeTweakedFrom() {
|
||||||
if (Security.getProperty(SECURITY_NEGATIVE_TTL) != null) {
|
if (Security.getProperty(SECURITY_NEGATIVE_TTL) != null) {
|
||||||
if (System.getProperty(SYSTEM_NEGATIVE_TTL) != null) {
|
if (System.getProperty(SYSTEM_NEGATIVE_TTL) != null) {
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
JavaMonitorTools: Retrieves additional information required by java-monitor
|
|
||||||
DeadlockStacktraces: RO:Detailed report on the deadlocked threads.
|
|
||||||
ThreadsNew: RO:Number of new threads
|
|
||||||
ThreadsRunnable: RO:Number of runnable threads
|
|
||||||
ThreadsBlocked: RO:Number of blocked threads
|
|
||||||
ThreadsWaiting: RO:Number of waiting threads
|
|
||||||
ThreadsTimedWaiting: RO:Number of sleeping and waiting threads
|
|
||||||
ThreadsTerminated: RO:Number of terminated threads
|
|
||||||
CacheSeconds: RO:Amount of time successful DNS queries are cached for
|
|
||||||
CacheTweakedFrom: RO:Cache policy for successful DNS lookups was changed from the hard-coded default
|
|
||||||
CacheNegativeSeconds: RO:Amount of time failed DNS queries are cached for
|
|
||||||
CacheNegativeTweakedFrom: RO:Cache policy for failed DNS lookups was changed from the hard-coded default
|
|
|
@ -1 +0,0 @@
|
||||||
ThreadMonitor: Detect and report spinning and deadlocked threads
|
|
|
@ -26,6 +26,9 @@ import java.util.Set;
|
||||||
import org.eclipse.jetty.nosql.NoSqlSession;
|
import org.eclipse.jetty.nosql.NoSqlSession;
|
||||||
import org.eclipse.jetty.nosql.NoSqlSessionManager;
|
import org.eclipse.jetty.nosql.NoSqlSessionManager;
|
||||||
import org.eclipse.jetty.server.SessionIdManager;
|
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.annotation.ManagedOperation;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -34,6 +37,8 @@ import com.mongodb.DBCollection;
|
||||||
import com.mongodb.DBObject;
|
import com.mongodb.DBObject;
|
||||||
import com.mongodb.MongoException;
|
import com.mongodb.MongoException;
|
||||||
|
|
||||||
|
|
||||||
|
@ManagedObject("Mongo Session Manager")
|
||||||
public class MongoSessionManager extends NoSqlSessionManager
|
public class MongoSessionManager extends NoSqlSessionManager
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(MongoSessionManager.class);
|
private static final Logger LOG = Log.getLogger(MongoSessionManager.class);
|
||||||
|
@ -491,21 +496,26 @@ public class MongoSessionManager extends NoSqlSessionManager
|
||||||
return __CONTEXT + "." + _contextId + "." + keybit;
|
return __CONTEXT + "." + _contextId + "." + keybit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedOperation(value="purge invalid sessions in the session store based on normal criteria", impact="ACTION")
|
||||||
public void purge()
|
public void purge()
|
||||||
{
|
{
|
||||||
((MongoSessionIdManager)_sessionIdManager).purge();
|
((MongoSessionIdManager)_sessionIdManager).purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ManagedOperation(value="full purge of invalid sessions in the session store", impact="ACTION")
|
||||||
public void purgeFully()
|
public void purgeFully()
|
||||||
{
|
{
|
||||||
((MongoSessionIdManager)_sessionIdManager).purgeFully();
|
((MongoSessionIdManager)_sessionIdManager).purgeFully();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedOperation(value="scavenge sessions known to this manager", impact="ACTION")
|
||||||
public void scavenge()
|
public void scavenge()
|
||||||
{
|
{
|
||||||
((MongoSessionIdManager)_sessionIdManager).scavenge();
|
((MongoSessionIdManager)_sessionIdManager).scavenge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedOperation(value="scanvenge all sessions", impact="ACTION")
|
||||||
public void scavengeFully()
|
public void scavengeFully()
|
||||||
{
|
{
|
||||||
((MongoSessionIdManager)_sessionIdManager).scavengeFully();
|
((MongoSessionIdManager)_sessionIdManager).scavengeFully();
|
||||||
|
@ -518,6 +528,7 @@ public class MongoSessionManager extends NoSqlSessionManager
|
||||||
* the count() operation itself is optimized to perform on the server side
|
* the count() operation itself is optimized to perform on the server side
|
||||||
* and avoid loading to client side.
|
* and avoid loading to client side.
|
||||||
*/
|
*/
|
||||||
|
@ManagedAttribute("total number of known sessions in the store")
|
||||||
public long getSessionStoreCount()
|
public long getSessionStoreCount()
|
||||||
{
|
{
|
||||||
return _sessions.find().count();
|
return _sessions.find().count();
|
||||||
|
|
|
@ -18,7 +18,10 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.server.session.AbstractSessionManager;
|
import org.eclipse.jetty.server.session.AbstractSessionManager;
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
import org.eclipse.jetty.server.session.jmx.AbstractSessionManagerMBean;
|
import org.eclipse.jetty.server.session.jmx.AbstractSessionManagerMBean;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
|
||||||
|
@ManagedObject("Mongo Session Manager MBean")
|
||||||
public class MongoSessionManagerMBean extends AbstractSessionManagerMBean
|
public class MongoSessionManagerMBean extends AbstractSessionManagerMBean
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
MongoSessionManager: Mongo Session Manager
|
|
||||||
sessionStoreCount: total number of known sessions in the store
|
|
||||||
purge(): force a purge() of invalid sessions in the session store based on normal criteria
|
|
||||||
purgeFully(): force a full purge of invalid sessions in the session store
|
|
||||||
scavenge(): force a scavenge() of sessions known to this manager in the session store
|
|
||||||
scavengeFully(): force a scavenge of all sessions in the session store
|
|
Loading…
Reference in New Issue