com.sun.grizzly.http
Class StatsThreadPool

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by com.sun.grizzly.util.GrizzlyExecutorService
          extended by com.sun.grizzly.http.StatsThreadPool
All Implemented Interfaces:
ExtendedThreadPool, Executor, ExecutorService

public class StatsThreadPool
extends GrizzlyExecutorService

Internal FIFO used by the Worker Threads to pass information between Task objects.

Author:
Jean-Francois Arcand

Nested Class Summary
protected static class StatsThreadPool.HttpWorkerThreadFactory
          Create new HttpWorkerThread.
 
Field Summary
static int DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT
           
static int DEFAULT_MAX_TASKS_QUEUED
           
static int DEFAULT_MAX_THREAD_COUNT
           
static int DEFAULT_MIN_THREAD_COUNT
           
protected  int port
          Port, which is served by this thread pool
protected  ThreadPoolStatistic threadPoolStat
           
 
Fields inherited from class com.sun.grizzly.util.GrizzlyExecutorService
config
 
Constructor Summary
StatsThreadPool()
           
StatsThreadPool(int maxTasksCount)
           
StatsThreadPool(int corePoolSize, int maximumPoolSize, int maxTasksCount, long keepAliveTime, TimeUnit unit)
           
StatsThreadPool(String name, int corePoolSize, int maximumPoolSize, int maxTasksCount, long keepAliveTime, TimeUnit unit)
           
StatsThreadPool(ThreadPoolConfig config)
           
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
           
 void execute(Runnable r)
           
 int getActiveCount()
          Returns the approximate number of threads that are actively executing tasks.
 long getCompletedTaskCount()
          Returns the approximate total number of tasks that have completed execution.
 int getLargestPoolSize()
          Returns the largest number of threads that have ever simultaneously been in the pool.
 int getPoolSize()
          Returns the current number of threads in the pool.
 int getPort()
          Get the port number, which is served by the thread pool
 int getQueueSize()
          Returns the number of tasks, which are currently waiting in the queue.
 ThreadPoolStatistic getStatistic()
          Return the ThreadPoolStatistic object used to gather statistic;
 int getTaskCount()
          Returns the approximate total number of tasks that have been scheduled for execution.
protected  void injectToStringAttributes(StringBuilder sb)
          Deprecated.  
 boolean isShutdown()
           
 boolean isTerminated()
           
 GrizzlyExecutorService reconfigure(ThreadPoolConfig config)
          Sets the ThreadPoolConfig
 void setPort(int port)
          Set the port number, which is served by the thread pool
 void setStatistic(ThreadPoolStatistic threadPoolStatistic)
          Set the ThreadPoolStatistic object used to gather statistic;
 void shutdown()
           
 List<Runnable> shutdownNow()
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class com.sun.grizzly.util.GrizzlyExecutorService
createInstance, createInstance, getConfiguration, getCorePoolSize, getKeepAliveTime, getMaximumPoolSize, getMaxQueuedTasksCount, getName, getPriority, getQueue, getThreadFactory, setCorePoolSize, setImpl, setKeepAliveTime, setMaximumPoolSize, setMaxQueuedTasksCount, setName, setPriority, setThreadFactory
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
 

Field Detail

DEFAULT_MIN_THREAD_COUNT

public static int DEFAULT_MIN_THREAD_COUNT

DEFAULT_MAX_THREAD_COUNT

public static int DEFAULT_MAX_THREAD_COUNT

DEFAULT_MAX_TASKS_QUEUED

public static int DEFAULT_MAX_TASKS_QUEUED

DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT

public static int DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT

port

protected int port
Port, which is served by this thread pool


threadPoolStat

protected transient ThreadPoolStatistic threadPoolStat
Constructor Detail

StatsThreadPool

public StatsThreadPool()

StatsThreadPool

public StatsThreadPool(int maxTasksCount)

StatsThreadPool

public StatsThreadPool(int corePoolSize,
                       int maximumPoolSize,
                       int maxTasksCount,
                       long keepAliveTime,
                       TimeUnit unit)

StatsThreadPool

public StatsThreadPool(String name,
                       int corePoolSize,
                       int maximumPoolSize,
                       int maxTasksCount,
                       long keepAliveTime,
                       TimeUnit unit)

StatsThreadPool

public StatsThreadPool(ThreadPoolConfig config)
Method Detail

start

public void start()

stop

public void stop()

execute

public final void execute(Runnable r)
Specified by:
execute in interface Executor
Overrides:
execute in class GrizzlyExecutorService

shutdown

public void shutdown()
Specified by:
shutdown in interface ExecutorService
Overrides:
shutdown in class GrizzlyExecutorService

shutdownNow

public List<Runnable> shutdownNow()
Specified by:
shutdownNow in interface ExecutorService
Overrides:
shutdownNow in class GrizzlyExecutorService

getPort

public int getPort()
Get the port number, which is served by the thread pool

Returns:
the port number, which is served by the thread pool

setPort

public void setPort(int port)
Set the port number, which is served by the thread pool

Parameters:
port - the port number, which is served by the thread pool

setStatistic

public void setStatistic(ThreadPoolStatistic threadPoolStatistic)
Set the ThreadPoolStatistic object used to gather statistic;


getStatistic

public ThreadPoolStatistic getStatistic()
Return the ThreadPoolStatistic object used to gather statistic;


reconfigure

public GrizzlyExecutorService reconfigure(ThreadPoolConfig config)
Description copied from class: GrizzlyExecutorService
Sets the ThreadPoolConfig

Overrides:
reconfigure in class GrizzlyExecutorService
Returns:
returns GrizzlyExecutorService

getLargestPoolSize

public int getLargestPoolSize()
Description copied from interface: ExtendedThreadPool
Returns the largest number of threads that have ever simultaneously been in the pool.

Specified by:
getLargestPoolSize in interface ExtendedThreadPool
Overrides:
getLargestPoolSize in class GrizzlyExecutorService
Returns:
the number of threads

getPoolSize

public int getPoolSize()
Description copied from interface: ExtendedThreadPool
Returns the current number of threads in the pool.

Specified by:
getPoolSize in interface ExtendedThreadPool
Overrides:
getPoolSize in class GrizzlyExecutorService
Returns:
the number of threads

getQueueSize

public int getQueueSize()
Description copied from interface: ExtendedThreadPool
Returns the number of tasks, which are currently waiting in the queue.

Specified by:
getQueueSize in interface ExtendedThreadPool
Overrides:
getQueueSize in class GrizzlyExecutorService
Returns:
the number of tasks, which are currently waiting in the queue.

getActiveCount

public int getActiveCount()
Description copied from interface: ExtendedThreadPool
Returns the approximate number of threads that are actively executing tasks.

Specified by:
getActiveCount in interface ExtendedThreadPool
Overrides:
getActiveCount in class GrizzlyExecutorService
Returns:
the number of threads

getTaskCount

public int getTaskCount()
Description copied from interface: ExtendedThreadPool
Returns the approximate total number of tasks that have been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Specified by:
getTaskCount in interface ExtendedThreadPool
Overrides:
getTaskCount in class GrizzlyExecutorService
Returns:
the number of tasks

getCompletedTaskCount

public long getCompletedTaskCount()
Description copied from interface: ExtendedThreadPool
Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Specified by:
getCompletedTaskCount in interface ExtendedThreadPool
Overrides:
getCompletedTaskCount in class GrizzlyExecutorService
Returns:
the number of tasks

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface ExecutorService
Overrides:
isShutdown in class GrizzlyExecutorService

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface ExecutorService
Overrides:
isTerminated in class GrizzlyExecutorService

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Specified by:
awaitTermination in interface ExecutorService
Overrides:
awaitTermination in class GrizzlyExecutorService
Throws:
InterruptedException

toString

public String toString()
Overrides:
toString in class Object

injectToStringAttributes

protected void injectToStringAttributes(StringBuilder sb)
Deprecated. 

Inject toString() to a specific StringBuilder

Parameters:
sb -


Copyright © 2012 Oracle Corporation. All Rights Reserved.