|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<Callable>
com.sun.grizzly.DefaultPipeline
public class DefaultPipeline
Simple Thread Pool based on the wait/notify/synchronized mechanism.
Field Summary | |
---|---|
protected int |
initialByteBufferSize
The initial ByteBuffer size for newly created WorkerThread instances |
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 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 |
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 | |
---|---|
DefaultPipeline()
|
|
DefaultPipeline(int maxThreads,
int minThreads,
String name,
int port)
|
|
DefaultPipeline(int maxThreads,
int minThreads,
String name,
int port,
int priority)
|
Method Summary | |
---|---|
void |
execute(Callable callable)
Add an object to this pipeline |
boolean |
expireKey(SelectionKey key)
Invoked when the SelectorThread is about to expire a SelectionKey. |
ByteBufferFactory.ByteBufferType |
getByteBufferType()
The ByteBufferType used to create the ByteBuffer
associated with WorkerThreadImpl s created by this instance. |
int |
getCurrentThreadCount()
Return current thread count |
int |
getCurrentThreadsBusy()
Return the curent number of threads that are currently processing a task. |
int |
getInitialByteBufferSize()
Get the initial WorkerThreadImpl ByteBuffer size |
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 |
int |
getQueueSizeInBytes()
Get the maximum pending connections this Pipeline
can handle. |
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 |
setByteBufferType(ByteBufferFactory.ByteBufferType byteBufferType)
Set the ByteBufferType to use when creating the
ByteBuffer associated with WorkerThreadImpl s
created by this instance. |
void |
setInitialByteBufferSize(int size)
Set the initial WorkerThreadImpl ByteBuffer size |
void |
setMaxThreads(int maxThreads)
Set the number of threads used by this pipeline. |
void |
setMinSpareThreads(int minSpareThreads)
Set the minimum spare 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 |
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 |
startPipeline()
Start the Pipeline and all associated
WorkerThreadImpl |
void |
stopPipeline()
Stop the Pipeline and all associated
WorkerThreadImpl |
String |
toString()
|
Callable |
waitForIoTask()
Return a Callable object available in the pipeline. |
Methods inherited from class java.util.LinkedList |
---|
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, remove, remove, removeFirst, removeLast, 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.grizzly.Pipeline |
---|
size |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
protected int waitingThreads
Task
protected int maxThreads
protected int minThreads
WorkerThreadImpl
protected int minSpareThreads
WorkerThreadImpl
protected int port
protected int threadCount
WorkerThreadImpl
protected String name
protected int priority
protected boolean isStarted
protected transient WorkerThreadImpl[] workerThreads
WorkerThreadImpl
amanged by this pipeline.
protected int maxQueueSizeInBytes
protected int threadsIncrement
protected int initialByteBufferSize
Constructor Detail |
---|
public DefaultPipeline()
public DefaultPipeline(int maxThreads, int minThreads, String name, int port, int priority)
public DefaultPipeline(int maxThreads, int minThreads, String name, int port)
Method Detail |
---|
public void initPipeline()
Pipeline
by initializing the required
WorkerThreadImpl
. Default value is 10
initPipeline
in interface Pipeline<Callable>
public void startPipeline()
Pipeline
and all associated
WorkerThreadImpl
startPipeline
in interface Pipeline<Callable>
public void stopPipeline()
Pipeline
and all associated
WorkerThreadImpl
stopPipeline
in interface Pipeline<Callable>
protected void increaseWorkerThread(int increment, boolean startThread)
WorkerThreadImpl
. This method must be invoked
from a synchronized block.
increment
- - how many additional WorkerThreadImpl
objects to addstartThread
- - should newly added WorkerThreadImpl
objects be started after creation?public boolean interruptThread(long threadID)
Thread
using it thread id
threadID
- - id of Thread
to interrupt
public void execute(Callable callable) throws PipelineFullException
execute
in interface Pipeline<Callable>
callable
- a Callable
to add to this Pipeline
PipelineFullException
- if Pipeline is fullpublic Callable waitForIoTask()
Callable
object available in the pipeline.
All Threads will synchronize on that method
waitForIoTask
in interface Pipeline<Callable>
Callable
public boolean expireKey(SelectionKey key)
expireKey
in interface Pipeline<Callable>
key
- - A SelectionKey
to expire
public boolean isEmpty()
true
if the size of this ArrayList
minus the current waiting threads is lower than zero.
isEmpty
in interface Collection<Callable>
isEmpty
in interface List<Callable>
isEmpty
in class AbstractCollection<Callable>
public int getWaitingThread()
getWaitingThread
in interface Pipeline<Callable>
public void setMaxThreads(int maxThreads)
setMaxThreads
in interface Pipeline<Callable>
maxThreads
- maximum number of threads to usepublic int getMaxThreads()
getMaxThreads
in interface Pipeline<Callable>
public int getCurrentThreadCount()
getCurrentThreadCount
in interface Pipeline<Callable>
public int getCurrentThreadsBusy()
getCurrentThreadsBusy
in interface Pipeline<Callable>
public int getMaxSpareThreads()
public int getMinSpareThreads()
public void setMinSpareThreads(int minSpareThreads)
Pipeline
can handle.
minSpareThreads
- minimum number of spare threads to handlepublic void setPriority(int priority)
Pipeline
setPriority
in interface Pipeline<Callable>
priority
- thread priority to usepublic void setName(String name)
Pipeline
setName
in interface Pipeline<Callable>
name
- Pipeline name to usepublic String getName()
Pipeline
getName
in interface Pipeline<Callable>
Pipeline
public void setPort(int port)
Pipeline
setPort
in interface Pipeline<Callable>
port
- the port used by this Pipeline
public void setMinThreads(int minThreads)
Pipeline
will creates
when initializing.
setMinThreads
in interface Pipeline<Callable>
minThreads
- the minimum number of threads.public String toString()
toString
in class AbstractCollection<Callable>
public void setThreadsIncrement(int threadsIncrement)
Pipeline
will use when increasing the
thread pool
setThreadsIncrement
in interface Pipeline<Callable>
threadsIncrement
- amount to increase thread pool bypublic int getTaskQueuedCount()
Task
currently queued
public void setQueueSizeInBytes(int maxQueueSizeInBytesCount)
Pipeline
can handle.
setQueueSizeInBytes
in interface Pipeline<Callable>
maxQueueSizeInBytesCount
- maximum queue size (in bytes) this
Pipeline should usepublic int getQueueSizeInBytes()
Pipeline
can handle.
public int getInitialByteBufferSize()
ByteBuffer
size
ByteBuffwaitingThreadser
sizepublic void setInitialByteBufferSize(int size)
ByteBuffer
size
size
- initial WorkerThreadImpl ByteBuffer
sizepublic ByteBufferFactory.ByteBufferType getByteBufferType()
ByteBufferType
used to create the ByteBuffer
associated with WorkerThreadImpl
s created by this instance.
ByteBufferType
used to create the ByteBuffer
associated with WorkerThreadImpl
s created by this instance.public void setByteBufferType(ByteBufferFactory.ByteBufferType byteBufferType)
ByteBufferType
to use when creating the
ByteBuffer
associated with WorkerThreadImpl
s
created by this instance.
byteBufferType
- The ByteBuffer type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |