jrunx.scheduler
Class ThreadPool

java.lang.Object
  |
  +--java.lang.ThreadGroup
        |
        +--jrunx.scheduler.ThreadPool
All Implemented Interfaces:
MetricsConstants

public final class ThreadPool
extends java.lang.ThreadGroup
implements MetricsConstants

This is the class that encapsulates the configuration of threads for a NetworkService. This class creates the handler threads, managing the low and high water mark of the thread pool being used. It has methods to set and get the different configuration information to manage the threads that are associated with the RunnableFactory that this object manages.

Author:
Paul Colton, Edwin Smith

Field Summary
protected  int activeHandlers
           
protected  int busyMetric
          metric for The number of handlers that are in targetServlet.service().
protected  int delayMetric
          metric to measure the average waiting time
protected  int gotDelayed
          metric for number of requests that were delayed
protected  int gotDropped
          metric for number of requests that were dropped
protected  int idleMetric
          metric for number of handlers that are idle waiting for a request
protected  int listeningMetric
          metric for The number of handlers that are waiting for new connections.
protected  int maxHandlers
           
protected  int minHandlers
          The min/active/max number of handler threads.
protected  Metrics mm
           
protected  RunnableFactory service
           
protected  int threadTimeout
           
protected  int totalMetric
          metric to track total number of threads
protected  int waitingMetric
          metric for number of handlers that are waiting to run
 
Fields inherited from interface jrunx.metrics.MetricsConstants
METRICS_BUSY_TH, METRICS_DELAY_MS, METRICS_DELAY_RQ, METRICS_DELAY_TH, METRICS_DROPPED_RQ, METRICS_FREE_MEMORY, METRICS_IDLE_TH, METRICS_LISTEN_TH, METRICS_TOTAL_MEMORY, METRICS_TOTAL_TH
 
Constructor Summary
ThreadPool(java.lang.String groupName)
           
ThreadPool(java.lang.String groupName, RunnableFactory factory)
          Construct a ThreadPool object for this endpoint.
 
Method Summary
 void cleanupHandler()
           
 int getThreadWaitTimeout()
           
 void init(RunnableFactory service, Metrics mm)
           
 void setActiveThreads(int i)
          sets the max active handlers (those not in getEndpoint)
 void setMaxThreads(int i)
          Sets the maximum number of handler threads.
 void setMinThreads(int i)
          Sets the minimum number of handler threads.
 void setThreadWaitTimeout(int timeoutSeconds)
           
 void shutdown()
          Initiate shutdown.
protected  void spawnHandler()
          spawn another worker thread
 void start()
           
 
Methods inherited from class java.lang.ThreadGroup
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

service

protected RunnableFactory service

mm

protected Metrics mm

minHandlers

protected int minHandlers
The min/active/max number of handler threads.

activeHandlers

protected int activeHandlers

maxHandlers

protected int maxHandlers

threadTimeout

protected int threadTimeout

listeningMetric

protected int listeningMetric
metric for The number of handlers that are waiting for new connections.

busyMetric

protected int busyMetric
metric for The number of handlers that are in targetServlet.service().

waitingMetric

protected int waitingMetric
metric for number of handlers that are waiting to run

delayMetric

protected int delayMetric
metric to measure the average waiting time

idleMetric

protected int idleMetric
metric for number of handlers that are idle waiting for a request

totalMetric

protected int totalMetric
metric to track total number of threads

gotDelayed

protected int gotDelayed
metric for number of requests that were delayed

gotDropped

protected int gotDropped
metric for number of requests that were dropped
Constructor Detail

ThreadPool

public ThreadPool(java.lang.String groupName,
                  RunnableFactory factory)
Construct a ThreadPool object for this endpoint.
Parameters:
groupName - the name of this threadgroup
factory - the source of all runnable objects

ThreadPool

public ThreadPool(java.lang.String groupName)
Method Detail

init

public void init(RunnableFactory service,
                 Metrics mm)

start

public void start()

spawnHandler

protected void spawnHandler()
spawn another worker thread

cleanupHandler

public void cleanupHandler()

setMinThreads

public void setMinThreads(int i)
Sets the minimum number of handler threads.

setActiveThreads

public void setActiveThreads(int i)
sets the max active handlers (those not in getEndpoint)

setMaxThreads

public void setMaxThreads(int i)
Sets the maximum number of handler threads.

setThreadWaitTimeout

public void setThreadWaitTimeout(int timeoutSeconds)

getThreadWaitTimeout

public int getThreadWaitTimeout()

shutdown

public void shutdown()
Initiate shutdown.


Copyright � 2002 Macromedia Corporation. All Rights Reserved.