|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.enterprise.web.connector.grizzly.TaskBase
com.sun.enterprise.web.connector.grizzly.DefaultReadTask
public class DefaultReadTask
Read available data on a non blocking SocketChannel.
StreamAlgorithm stategy will decide if more bytes are required
or not. Once the StreamAlgorithm is ready, the
ProcessorTask attached to this class will be executed.
| Field Summary | |
|---|---|
protected StreamAlgorithm |
algorithm
The Algorithm used to parse the request and determine
of the bytes has been all read from the SocketChannel |
protected ByteBuffer |
byteBuffer
The ByteBuffer used by this task to buffer the request
stream. |
protected boolean |
bytesAvailable
true only when another object has already read bytes
from the channel. |
protected ByteBufferInputStream |
inputStream
The recycled OutputStream used by this buffer. |
protected int |
maxPostSize
Max post size. |
protected ProcessorTask |
processorTask
The ProcessorTask used by this class. |
protected TaskContext |
taskContext
The TaskContext instance associated with this object. |
protected TaskEvent |
taskEvent
The TaskEvent instance used by this object to notify its
listeners |
protected boolean |
useByteBufferView
Create view ByteBuffer from another ByteBuffer |
protected boolean |
useDirectByteBuffer
Is the ByteBuffer used by the ReadTask use
direct ByteBuffer or not. |
| Fields inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase |
|---|
key, listeners, pipeline, recycle, selectorThread, type |
| Fields inherited from interface com.sun.enterprise.web.connector.grizzly.Task |
|---|
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK |
| Constructor Summary | |
|---|---|
DefaultReadTask()
|
|
| Method Summary | |
|---|---|
void |
attachProcessor(ProcessorTask processorTask)
Force this task to always use the same ProcessorTask instance. |
protected void |
configureProcessorTask()
Set appropriate attribute on the ProcessorTask. |
void |
detachProcessor()
Return the ProcessorTask to the pool. |
void |
doTask()
Read data from the socket and process it using this thread, and only if the StreamAlgorith stategy determine no more bytes are
are needed. |
protected void |
doTask(ByteBuffer byteBuffer)
Pull data from the socket and store it inside the ByteBuffer. |
boolean |
executeProcessorTask()
Execute the ProcessorTask only if the request has
been fully read. |
protected void |
finishConnection()
Cancel the SelectionKey and close its underlying
SocketChannel. |
ByteBuffer |
getByteBuffer()
Return the underlying ByteBuffer used by this class. |
long |
getIdleTime()
Return the time in milliseconds this Task is allowed to be idle. |
ProcessorTask |
getProcessorTask()
Return the associated ProcessorTask. |
void |
initialize(StreamAlgorithm algorithm,
boolean useDirectByteBuffer,
boolean useByteBufferView)
|
protected void |
manageKeepAlive(boolean keepAlive,
int count,
Exception exception)
Evaluate if the SelectionKey needs to be registered to
the main Selector |
void |
recycle()
Clear the current state and make this object ready for another request. |
void |
registerKey()
Register the SelectionKey with the Selector |
protected void |
returnTask()
Return this object to the pool |
void |
setByteBuffer(ByteBuffer byteBuffer)
Set the underlying ByteBuffer used by this class. |
void |
setBytesAvailable(boolean bytesAvailable)
If the attached byteBuffer was already filled, tell the Algorithm to re-use the bytes. |
void |
setIdleTime(long idleTime)
Set the time in milliseconds this Task is allowed to be idle. |
void |
taskEvent(TaskEvent event)
This method is invoked when a WorkerThread starts
processing a Task object. |
void |
terminate(boolean keepAlive)
Complete the processing. |
| Methods inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase |
|---|
addTaskListener, call, cancelTask, clearTaskListeners, execute, fireTaskEvent, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getSocket, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, run, setPipeline, setRecycle, setSelectionKey, setSelectorThread |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.enterprise.web.connector.grizzly.Task |
|---|
addTaskListener, cancelTask, clearTaskListeners, execute, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, setPipeline, setRecycle, setSelectionKey, setSelectorThread |
| Methods inherited from interface java.lang.Runnable |
|---|
run |
| Methods inherited from interface java.util.concurrent.Callable |
|---|
call |
| Field Detail |
|---|
protected TaskContext taskContext
TaskContext instance associated with this object.
The TaskContext is initialized at startup and then recycled.
protected TaskEvent taskEvent
TaskEvent instance used by this object to notify its
listeners
protected ByteBuffer byteBuffer
ByteBuffer used by this task to buffer the request
stream.
protected ProcessorTask processorTask
ProcessorTask used by this class.
protected int maxPostSize
protected ByteBufferInputStream inputStream
OutputStream used by this buffer.
protected StreamAlgorithm algorithm
Algorithm used to parse the request and determine
of the bytes has been all read from the SocketChannel
protected boolean bytesAvailable
true only when another object has already read bytes
from the channel.
protected boolean useDirectByteBuffer
ByteBuffer used by the ReadTask use
direct ByteBuffer or not.
protected boolean useByteBufferView
ByteBuffer from another ByteBuffer
| Constructor Detail |
|---|
public DefaultReadTask()
| Method Detail |
|---|
public void initialize(StreamAlgorithm algorithm,
boolean useDirectByteBuffer,
boolean useByteBufferView)
initialize in interface ReadTaskpublic void attachProcessor(ProcessorTask processorTask)
ProcessorTask instance.
attachProcessor in interface ReadTaskprotected void configureProcessorTask()
ProcessorTask.
public void detachProcessor()
ProcessorTask to the pool.
detachProcessor in interface ReadTask
public void doTask()
throws IOException
StreamAlgorith stategy determine no more bytes are
are needed.
doTask in interface TaskIOExceptionprotected void doTask(ByteBuffer byteBuffer)
ByteBuffer.
The StreamAlgorithM implementation will take care of
determining if we need to register again to the main Selector
or execute the request using temporary Selector
byteBuffer -
protected void manageKeepAlive(boolean keepAlive,
int count,
Exception exception)
SelectionKey needs to be registered to
the main Selector
public boolean executeProcessorTask()
throws IOException
ProcessorTask only if the request has
been fully read. Guest the size of the request by using the
content-type HTTP headers.
IOExceptionprotected void returnTask()
public void taskEvent(TaskEvent event)
TaskListenerWorkerThread starts
processing a Task object.
taskEvent in interface TaskListenertaskEvent in class TaskBasepublic void terminate(boolean keepAlive)
terminate in interface ReadTaskpublic void recycle()
recycle in interface Taskrecycle in class TaskBaseprotected void finishConnection()
SelectionKey and close its underlying
SocketChannel. Add this Task to the Keep-Alive
sub-system.
public void registerKey()
SelectionKey with the Selector
public ProcessorTask getProcessorTask()
ProcessorTask.
ProcessorTask, null if not used.public ByteBuffer getByteBuffer()
ByteBuffer used by this class.
getByteBuffer in interface ReadTaskpublic void setByteBuffer(ByteBuffer byteBuffer)
ByteBuffer used by this class.
public void setBytesAvailable(boolean bytesAvailable)
setBytesAvailable in interface ReadTaskpublic void setIdleTime(long idleTime)
Task is allowed to be idle.
setIdleTime in interface ReadTaskpublic long getIdleTime()
Task is allowed to be idle.
getIdleTime in interface ReadTask
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||