com.sun.enterprise.web.connector.grizzly
Class ThreadPoolExecutorPipeline

java.lang.Object
  extended by com.sun.enterprise.web.connector.grizzly.ThreadPoolExecutorPipeline
All Implemented Interfaces:
Pipeline, RejectedExecutionHandler

public class ThreadPoolExecutorPipeline
extends Object
implements Pipeline, RejectedExecutionHandler

A wrapper around an ThreadPoolExecutor. This thread pool is bounded by an ArrayBlockingQueue

Author:
Jean-Francois Arcand

Field Summary
protected  PipelineStatistic pipelineStat
          The PipelineStatistic objects used when gathering statistics.
 
Constructor Summary
ThreadPoolExecutorPipeline()
           
 
Method Summary
 void addTask(Task task)
          Add an object to this pipeline
 boolean expireKey(SelectionKey key)
          Invoked when the SelectorThread is about to expire a SelectionKey.
 int getCurrentThreadCount()
          Return the current number of threads used.
 int getCurrentThreadsBusy()
          Return the curent number of threads that are currently processing a task.
 int getMaxSpareThreads()
          Return the maximum spare thread.
 int getMaxThreads()
          Return the number of threads used by this pipeline.
 int getMinSpareThreads()
          Return the minimum spare thread.
 String getName()
          Return the name of this Pipeline
 PipelineStatistic getPipelineStatistic()
          Return the PipelineStatistic object used to gather statistic;
 int getQueueSizeInBytes()
          Get the maximum pending connection this Pipeline can handle.
 Task getTask()
          Return a Task object available in the pipeline.
 int getWaitingThread()
          Return the number of waiting threads.
 void initPipeline()
          Init the Pipeline by initializing the required ThreadPoolExecutor.
 boolean interruptThread(long threadID)
          Interrupt the Thread using it thread id
 void rejectedExecution(Runnable r, ThreadPoolExecutor executor)
          When the maxQueueSizeInBytesConnection is reached, terminate Task
 void setMaxThreads(int maxThreads)
          Set the number of threads used by this pipeline.
 void setMinSpareThreads(int minSpareThreads)
          Set the minimum space thread this Pipeline can handle.
 void setMinThreads(int minThreads)
          Set the minimum thread this Pipeline will creates when initializing.
 void setName(String name)
          Set the name of this Pipeline
 void setPipelineStatistic(PipelineStatistic pipelineStatistic)
          Set the PipelineStatistic object used to gather statistic;
 void setPort(int port)
          Set the port used by this Pipeline
 void setPriority(int priority)
          Set the thread priority of the Pipeline
 void setQueueSizeInBytes(int maxQueueSizeInBytes)
          Set the maximum pending connection this Pipeline can handle.
 void setThreadsIncrement(int threadsIncrement)
          Set the number the Pipeline will use when increasing the thread pool
 void setThreadsTimeout(int threadsTimeout)
          Set the timeout value a thread will use to times out the request.
 int size()
          Returns the number of tasks in this Pipeline.
 void startPipeline()
          Start the Pipeline
 void stopPipeline()
          Stop the Pipeline
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pipelineStat

protected PipelineStatistic pipelineStat
The PipelineStatistic objects used when gathering statistics.

Constructor Detail

ThreadPoolExecutorPipeline

public ThreadPoolExecutorPipeline()
Method Detail

initPipeline

public void initPipeline()
Init the Pipeline by initializing the required ThreadPoolExecutor.

Specified by:
initPipeline in interface Pipeline

startPipeline

public void startPipeline()
Start the Pipeline

Specified by:
startPipeline in interface Pipeline

stopPipeline

public void stopPipeline()
Stop the Pipeline

Specified by:
stopPipeline in interface Pipeline

addTask

public void addTask(Task task)
Add an object to this pipeline

Specified by:
addTask in interface Pipeline

getTask

public Task getTask()
Return a Task object available in the pipeline.

Specified by:
getTask in interface Pipeline

expireKey

public boolean expireKey(SelectionKey key)
Invoked when the SelectorThread is about to expire a SelectionKey.

Specified by:
expireKey in interface Pipeline
Returns:
true if the SelectorThread should expire the SelectionKey, false if not.

size

public int size()
Returns the number of tasks in this Pipeline.

Specified by:
size in interface Pipeline
Returns:
Number of tasks in this Pipeline.

interruptThread

public boolean interruptThread(long threadID)
Interrupt the Thread using it thread id

Specified by:
interruptThread in interface Pipeline

getWaitingThread

public int getWaitingThread()
Return the number of waiting threads.

Specified by:
getWaitingThread in interface Pipeline

setMaxThreads

public void setMaxThreads(int maxThreads)
Set the number of threads used by this pipeline.

Specified by:
setMaxThreads in interface Pipeline

getMaxThreads

public int getMaxThreads()
Return the number of threads used by this pipeline.

Specified by:
getMaxThreads in interface Pipeline

getCurrentThreadCount

public int getCurrentThreadCount()
Return the current number of threads used.

Specified by:
getCurrentThreadCount in interface Pipeline

getCurrentThreadsBusy

public int getCurrentThreadsBusy()
Return the curent number of threads that are currently processing a task.

Specified by:
getCurrentThreadsBusy in interface Pipeline

getMaxSpareThreads

public int getMaxSpareThreads()
Return the maximum spare thread.

Specified by:
getMaxSpareThreads in interface Pipeline

setPriority

public void setPriority(int priority)
Set the thread priority of the Pipeline

Specified by:
setPriority in interface Pipeline

setName

public void setName(String name)
Set the name of this Pipeline

Specified by:
setName in interface Pipeline

getName

public String getName()
Return the name of this Pipeline

Specified by:
getName in interface Pipeline
Returns:
the name of this Pipeline

setPort

public void setPort(int port)
Set the port used by this Pipeline

Specified by:
setPort in interface Pipeline
Parameters:
port - the port used by this Pipeline

setMinThreads

public void setMinThreads(int minThreads)
Set the minimum thread this Pipeline will creates when initializing.

Specified by:
setMinThreads in interface Pipeline
Parameters:
minThreads - the minimum number of threads.

setQueueSizeInBytes

public void setQueueSizeInBytes(int maxQueueSizeInBytes)
Set the maximum pending connection this Pipeline can handle.

Specified by:
setQueueSizeInBytes in interface Pipeline

getQueueSizeInBytes

public int getQueueSizeInBytes()
Get the maximum pending connection this Pipeline can handle.


toString

public String toString()
Overrides:
toString in class Object

rejectedExecution

public void rejectedExecution(Runnable r,
                              ThreadPoolExecutor executor)
When the maxQueueSizeInBytesConnection is reached, terminate Task

Specified by:
rejectedExecution in interface RejectedExecutionHandler

setThreadsIncrement

public void setThreadsIncrement(int threadsIncrement)
Description copied from interface: Pipeline
Set the number the Pipeline will use when increasing the thread pool

Specified by:
setThreadsIncrement in interface Pipeline

setThreadsTimeout

public void setThreadsTimeout(int threadsTimeout)
Description copied from interface: Pipeline
Set the timeout value a thread will use to times out the request.

Specified by:
setThreadsTimeout in interface Pipeline

getMinSpareThreads

public int getMinSpareThreads()
Return the minimum spare thread.

Specified by:
getMinSpareThreads in interface Pipeline

setMinSpareThreads

public void setMinSpareThreads(int minSpareThreads)
Set the minimum space thread this Pipeline can handle.

Specified by:
setMinSpareThreads in interface Pipeline

setPipelineStatistic

public void setPipelineStatistic(PipelineStatistic pipelineStatistic)
Set the PipelineStatistic object used to gather statistic;

Specified by:
setPipelineStatistic in interface Pipeline

getPipelineStatistic

public PipelineStatistic getPipelineStatistic()
Return the PipelineStatistic object used to gather statistic;

Specified by:
getPipelineStatistic in interface Pipeline


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.