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

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<Task>
                  extended by com.sun.enterprise.web.connector.grizzly.LinkedListPipeline
All Implemented Interfaces:
Pipeline, Serializable, Cloneable, Iterable<Task>, Collection<Task>, Deque<Task>, List<Task>, Queue<Task>
Direct Known Subclasses:
IsolationPipeline, SSLPipeline

public class LinkedListPipeline
extends LinkedList<Task>
implements Pipeline

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

Author:
Jean-Francois Arcand
See Also:
Serialized Form

Field Summary
protected  boolean isStarted
          Has the pipeline already started
protected  int maxQueueSizeInBytes
          Maximum pending connection before refusing requests.
protected  int maxThreads
          The maximum number of Thread
protected  int minSpareThreads
          The minimum numbers of spare WorkerThreadImpl
protected  int minThreads
          The minimum numbers of WorkerThreadImpl
protected  String name
          The name of this Pipeline
protected  PipelineStatistic pipelineStat
          The PipelineStatistic objects used when gathering statistics.
protected  int port
          The port used.
protected  int priority
          The Thread Priority
protected  int threadCount
          The number of WorkerThreadImpl
protected  int threadsIncrement
          The increment number used when adding new thread.
protected  int threadsTimeout
          The request times out during transaction.
protected  int waitingThreads
          The number of thread waiting for a Task
protected  WorkerThreadImpl[] workerThreads
          WorkerThreadImpl amanged by this pipeline.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedListPipeline()
           
LinkedListPipeline(int maxThreads, int minThreads, String name, int port)
           
LinkedListPipeline(int maxThreads, int minThreads, String name, int port, int priority)
           
 
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 number of active threads.
 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 getTaskQueuedCount()
          The number of Task currently queued
 int getWaitingThread()
          Return the number of waiting threads.
protected  void increaseWorkerThread(int increment, boolean startThread)
          Create new WorkerThreadImpl.
 void initPipeline()
          Init the Pipeline by initializing the required WorkerThreadImpl.
 boolean interruptThread(long threadID)
          Interrupt the Thread using it thread id
 boolean isEmpty()
          Return true if the size of this ArrayList minus the current waiting threads is lower than zero.
 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 maxQueueSizeInBytesCount)
          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.
 void startPipeline()
          Start the Pipeline and all associated WorkerThreadImpl
 void stopPipeline()
          Stop the Pipeline and all associated WorkerThreadImpl
 String toString()
           
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.enterprise.web.connector.grizzly.Pipeline
size
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Field Detail

waitingThreads

protected int waitingThreads
The number of thread waiting for a Task


maxThreads

protected int maxThreads
The maximum number of Thread


minThreads

protected int minThreads
The minimum numbers of WorkerThreadImpl


minSpareThreads

protected int minSpareThreads
The minimum numbers of spare WorkerThreadImpl


port

protected int port
The port used.


threadCount

protected int threadCount
The number of WorkerThreadImpl


name

protected String name
The name of this Pipeline


priority

protected int priority
The Thread Priority


isStarted

protected boolean isStarted
Has the pipeline already started


workerThreads

protected transient WorkerThreadImpl[] workerThreads
WorkerThreadImpl amanged by this pipeline.


maxQueueSizeInBytes

protected int maxQueueSizeInBytes
Maximum pending connection before refusing requests.


threadsIncrement

protected int threadsIncrement
The increment number used when adding new thread.


threadsTimeout

protected int threadsTimeout
The request times out during transaction.


pipelineStat

protected transient PipelineStatistic pipelineStat
The PipelineStatistic objects used when gathering statistics.

Constructor Detail

LinkedListPipeline

public LinkedListPipeline()

LinkedListPipeline

public LinkedListPipeline(int maxThreads,
                          int minThreads,
                          String name,
                          int port,
                          int priority)

LinkedListPipeline

public LinkedListPipeline(int maxThreads,
                          int minThreads,
                          String name,
                          int port)
Method Detail

initPipeline

public void initPipeline()
Init the Pipeline by initializing the required WorkerThreadImpl. Default value is 10

Specified by:
initPipeline in interface Pipeline

startPipeline

public void startPipeline()
Start the Pipeline and all associated WorkerThreadImpl

Specified by:
startPipeline in interface Pipeline

stopPipeline

public void stopPipeline()
Stop the Pipeline and all associated WorkerThreadImpl

Specified by:
stopPipeline in interface Pipeline

increaseWorkerThread

protected void increaseWorkerThread(int increment,
                                    boolean startThread)
Create new WorkerThreadImpl. This method must be invoked from a synchronized block.


interruptThread

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

Specified by:
interruptThread 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. All Threads will synchronize on that method

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.

isEmpty

public boolean isEmpty()
Return true if the size of this ArrayList minus the current waiting threads is lower than zero.

Specified by:
isEmpty in interface Collection<Task>
Specified by:
isEmpty in interface List<Task>
Overrides:
isEmpty in class AbstractCollection<Task>

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()
Description copied from interface: Pipeline
Return the number of active threads.

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

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

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.

toString

public String toString()
Overrides:
toString in class AbstractCollection<Task>

setThreadsIncrement

public void setThreadsIncrement(int threadsIncrement)
Set the number the Pipeline will use when increasing the thread pool

Specified by:
setThreadsIncrement in interface Pipeline

setThreadsTimeout

public void setThreadsTimeout(int threadsTimeout)
Set the timeout value a thread will use to times out the request.

Specified by:
setThreadsTimeout in interface Pipeline

getTaskQueuedCount

public int getTaskQueuedCount()
The number of Task currently queued

Returns:
number of queued connections

setQueueSizeInBytes

public void setQueueSizeInBytes(int maxQueueSizeInBytesCount)
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.


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.