org.eclipse.jetty.monitor
Class ThreadMonitor

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.monitor.ThreadMonitor
All Implemented Interfaces:
Runnable, LifeCycle

public class ThreadMonitor
extends AbstractLifeCycle
implements Runnable


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
ThreadMonitor()
          Instantiates a new thread monitor.
ThreadMonitor(int intervalMs)
          Instantiates a new thread monitor.
ThreadMonitor(int intervalMs, int threshold)
          Instantiates a new thread monitor.
ThreadMonitor(int intervalMs, int threshold, int depth)
          Instantiates a new thread monitor.
ThreadMonitor(int intervalMs, int threshold, int depth, int trail)
          Instantiates a new thread monitor.
 
Method Summary
 void doStart()
           
 void doStop()
           
protected  long[] getAllThreadIds()
          Retrieve all avaliable thread ids
 int getBusyThreshold()
          Gets the busy threshold.
 Dumpable getDumpable()
           
 int getLogInterval()
          Gets the log interval.
 int getLogThreshold()
          Gets the log threshold.
 int getScanInterval()
          Gets the scan interval.
 int getStackDepth()
          Gets the stack depth.
protected  long getThreadCpuTime(long id)
          Retrieve the cpu time for specified thread.
 int getTrailLength()
          Gets the stack trace trail length.
protected  void init()
          Initialize JMX objects.
 void logCpuUsage(int frequencyMs, int thresholdPercent)
          Enable logging of CPU usage.
protected  void logThreadInfo(boolean logAll)
           
 void run()
           
 void setBusyThreshold(int percent)
          Sets the busy threshold.
 void setDumpable(Dumpable dumpable)
           
 void setLogInterval(int ms)
          Sets the log interval.
 void setLogThreshold(int percent)
          Sets the log threshold.
 void setScanInterval(int ms)
          Sets the scan interval.
 void setStackDepth(int stackDepth)
          Sets the stack depth.
 void setTrailLength(int trailLength)
          Sets the stack trace trail length.
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadMonitor

public ThreadMonitor()
              throws Exception
Instantiates a new thread monitor.

Throws:
Exception

ThreadMonitor

public ThreadMonitor(int intervalMs)
              throws Exception
Instantiates a new thread monitor.

Parameters:
intervalMs - scan interval
Throws:
Exception

ThreadMonitor

public ThreadMonitor(int intervalMs,
                     int threshold)
              throws Exception
Instantiates a new thread monitor.

Parameters:
intervalMs - scan interval
threshold - busy threshold
Throws:
Exception

ThreadMonitor

public ThreadMonitor(int intervalMs,
                     int threshold,
                     int depth)
              throws Exception
Instantiates a new thread monitor.

Parameters:
intervalMs - scan interval
threshold - busy threshold
depth - stack compare depth
Throws:
Exception

ThreadMonitor

public ThreadMonitor(int intervalMs,
                     int threshold,
                     int depth,
                     int trail)
              throws Exception
Instantiates a new thread monitor.

Parameters:
intervalMs - scan interval
threshold - busy threshold
depth - stack compare depth
trail - length of stack trail
Throws:
Exception
Method Detail

getScanInterval

public int getScanInterval()
Gets the scan interval.

Returns:
the scan interval

setScanInterval

public void setScanInterval(int ms)
Sets the scan interval.

Parameters:
ms - the new scan interval

getLogInterval

public int getLogInterval()
Gets the log interval.

Returns:
the log interval

setLogInterval

public void setLogInterval(int ms)
Sets the log interval.

Parameters:
ms - the new log interval

getBusyThreshold

public int getBusyThreshold()
Gets the busy threshold.

Returns:
the busy threshold

setBusyThreshold

public void setBusyThreshold(int percent)
Sets the busy threshold.

Parameters:
percent - the new busy threshold

getLogThreshold

public int getLogThreshold()
Gets the log threshold.

Returns:
the log threshold

setLogThreshold

public void setLogThreshold(int percent)
Sets the log threshold.

Parameters:
percent - the new log threshold

getStackDepth

public int getStackDepth()
Gets the stack depth.

Returns:
the stack depth

setStackDepth

public void setStackDepth(int stackDepth)
Sets the stack depth.

Parameters:
stackDepth - the new stack depth

setTrailLength

public void setTrailLength(int trailLength)
Sets the stack trace trail length.

Parameters:
trailLength - the new trail length

getTrailLength

public int getTrailLength()
Gets the stack trace trail length.

Returns:
the trail length

logCpuUsage

public void logCpuUsage(int frequencyMs,
                        int thresholdPercent)
Enable logging of CPU usage.

Parameters:
frequencyMs - the logging frequency
thresholdPercent - the logging threshold

getDumpable

public Dumpable getDumpable()
Returns:
A Dumpable that is dumped whenever spinning threads are detected

setDumpable

public void setDumpable(Dumpable dumpable)
Parameters:
dumpable - A Dumpable that is dumped whenever spinning threads are detected

doStart

public void doStart()
Overrides:
doStart in class AbstractLifeCycle
See Also:
AbstractLifeCycle.doStart()

doStop

public void doStop()
Overrides:
doStop in class AbstractLifeCycle
See Also:
AbstractLifeCycle.doStop()

getAllThreadIds

protected long[] getAllThreadIds()
Retrieve all avaliable thread ids

Returns:
array of thread ids

getThreadCpuTime

protected long getThreadCpuTime(long id)
Retrieve the cpu time for specified thread.

Parameters:
id - thread id
Returns:
cpu time of the thread

init

protected void init()
Initialize JMX objects.


run

public void run()
Specified by:
run in interface Runnable
See Also:
Runnable.run()

logThreadInfo

protected void logThreadInfo(boolean logAll)


Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.