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.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.Dumpable;
|
||||
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
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ThreadMonitor.class);
|
||||
|
@ -132,6 +135,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @return the scan interval
|
||||
*/
|
||||
@ManagedAttribute("scan interval")
|
||||
public int getScanInterval()
|
||||
{
|
||||
return _scanInterval;
|
||||
|
@ -154,6 +158,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @return the log interval
|
||||
*/
|
||||
@ManagedAttribute("log interval")
|
||||
public int getLogInterval()
|
||||
{
|
||||
return _logInterval;
|
||||
|
@ -176,6 +181,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @return the busy threshold
|
||||
*/
|
||||
@ManagedAttribute("busy threshold")
|
||||
public int getBusyThreshold()
|
||||
{
|
||||
return _busyThreshold;
|
||||
|
@ -198,6 +204,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @return the log threshold
|
||||
*/
|
||||
@ManagedAttribute("log threshold")
|
||||
public int getLogThreshold()
|
||||
{
|
||||
return _logThreshold;
|
||||
|
@ -220,6 +227,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @return the stack depth
|
||||
*/
|
||||
@ManagedAttribute("stack depth")
|
||||
public int getStackDepth()
|
||||
{
|
||||
return _stackDepth;
|
||||
|
@ -242,6 +250,7 @@ public class ThreadMonitor extends AbstractLifeCycle implements Runnable
|
|||
*
|
||||
* @param trailLength the new trail length
|
||||
*/
|
||||
@ManagedAttribute("trail length")
|
||||
public void setTrailLength(int trailLength)
|
||||
{
|
||||
_trailLength = trailLength;
|
||||
|
|
|
@ -22,6 +22,9 @@ import java.security.Security;
|
|||
import java.util.HashMap;
|
||||
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
|
||||
|
@ -29,6 +32,7 @@ import java.util.Map;
|
|||
*
|
||||
* @author kjkoster <kjkoster@gmail.com>
|
||||
*/
|
||||
@ManagedObject("retrieves information required by java-monitor")
|
||||
public class JavaMonitorTools
|
||||
{
|
||||
private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
|
||||
|
@ -74,6 +78,7 @@ public class JavaMonitorTools
|
|||
return threads;
|
||||
}
|
||||
|
||||
@ManagedAttribute("detailed report of deadlocked threads")
|
||||
public String getDeadlockStacktraces()
|
||||
{
|
||||
try
|
||||
|
@ -136,6 +141,7 @@ public class JavaMonitorTools
|
|||
return states.get(Thread.State.BLOCKED);
|
||||
}
|
||||
|
||||
@ManagedAttribute("number of new threads")
|
||||
public int getThreadsNew()
|
||||
{
|
||||
sampleThreads();
|
||||
|
@ -143,6 +149,7 @@ public class JavaMonitorTools
|
|||
return states.get(Thread.State.NEW);
|
||||
}
|
||||
|
||||
@ManagedAttribute("number of terminated threads")
|
||||
public int getThreadsTerminated()
|
||||
{
|
||||
sampleThreads();
|
||||
|
@ -150,6 +157,7 @@ public class JavaMonitorTools
|
|||
return states.get(Thread.State.TERMINATED);
|
||||
}
|
||||
|
||||
@ManagedAttribute("number of sleeping and waiting threads")
|
||||
public int getThreadsTimedWaiting()
|
||||
{
|
||||
sampleThreads();
|
||||
|
@ -157,6 +165,7 @@ public class JavaMonitorTools
|
|||
return states.get(Thread.State.TIMED_WAITING);
|
||||
}
|
||||
|
||||
@ManagedAttribute("number of waiting threads")
|
||||
public int getThreadsWaiting()
|
||||
{
|
||||
sampleThreads();
|
||||
|
@ -198,6 +207,7 @@ public class JavaMonitorTools
|
|||
|
||||
private static final String POLICY = "sun.net.InetAddressCachePolicy";
|
||||
|
||||
@ManagedAttribute("amount of time successful dns queries are cached for")
|
||||
public int getCacheSeconds() throws ClassNotFoundException,
|
||||
IllegalAccessException, InvocationTargetException,
|
||||
NoSuchMethodException {
|
||||
|
@ -209,6 +219,7 @@ public class JavaMonitorTools
|
|||
return seconds.intValue();
|
||||
}
|
||||
|
||||
@ManagedAttribute("Amount of time failed DNS queries are cached for")
|
||||
public int getCacheNegativeSeconds() throws ClassNotFoundException,
|
||||
IllegalAccessException, InvocationTargetException,
|
||||
NoSuchMethodException {
|
||||
|
@ -236,6 +247,7 @@ public class JavaMonitorTools
|
|||
|
||||
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() {
|
||||
if (Security.getProperty(SECURITY_TTL) != null) {
|
||||
if (System.getProperty(SYSTEM_TTL) != null) {
|
||||
|
@ -252,6 +264,7 @@ public class JavaMonitorTools
|
|||
return DEFAULT;
|
||||
}
|
||||
|
||||
@ManagedAttribute("Cache policy for failed DNS lookups was changed from the hard-coded default")
|
||||
public String getCacheNegativeTweakedFrom() {
|
||||
if (Security.getProperty(SECURITY_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.NoSqlSessionManager;
|
||||
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.Logger;
|
||||
|
||||
|
@ -34,6 +37,8 @@ import com.mongodb.DBCollection;
|
|||
import com.mongodb.DBObject;
|
||||
import com.mongodb.MongoException;
|
||||
|
||||
|
||||
@ManagedObject("Mongo Session Manager")
|
||||
public class MongoSessionManager extends NoSqlSessionManager
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(MongoSessionManager.class);
|
||||
|
@ -491,21 +496,26 @@ public class MongoSessionManager extends NoSqlSessionManager
|
|||
return __CONTEXT + "." + _contextId + "." + keybit;
|
||||
}
|
||||
|
||||
@ManagedOperation(value="purge invalid sessions in the session store based on normal criteria", impact="ACTION")
|
||||
public void purge()
|
||||
{
|
||||
((MongoSessionIdManager)_sessionIdManager).purge();
|
||||
}
|
||||
|
||||
|
||||
@ManagedOperation(value="full purge of invalid sessions in the session store", impact="ACTION")
|
||||
public void purgeFully()
|
||||
{
|
||||
((MongoSessionIdManager)_sessionIdManager).purgeFully();
|
||||
}
|
||||
|
||||
@ManagedOperation(value="scavenge sessions known to this manager", impact="ACTION")
|
||||
public void scavenge()
|
||||
{
|
||||
((MongoSessionIdManager)_sessionIdManager).scavenge();
|
||||
}
|
||||
|
||||
@ManagedOperation(value="scanvenge all sessions", impact="ACTION")
|
||||
public void 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
|
||||
* and avoid loading to client side.
|
||||
*/
|
||||
@ManagedAttribute("total number of known sessions in the store")
|
||||
public long getSessionStoreCount()
|
||||
{
|
||||
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.SessionHandler;
|
||||
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
|
||||
{
|
||||
|
||||
|
|
|
@ -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