|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.tcp.http11.InternalOutputBuffer
com.sun.grizzly.http.SocketChannelOutputBuffer
public class SocketChannelOutputBuffer
Output buffer.
Buffer the bytes until the ByteChunk
is full or the request is completed.
| Nested Class Summary | |
|---|---|
protected static class |
SocketChannelOutputBuffer.AsyncWriteCallbackHandlerImpl
AsyncWriteCallbackHandler implementation, which is responsible
for returning cloned ByteBuffers to the pool |
protected class |
SocketChannelOutputBuffer.ByteBufferClonerImpl
ByteBufferCloner implementation, which is called by Grizzly
framework at the time, when asynchronous write queue can not write
the buffer directly on socket and instead will put it in queue. |
| Nested classes/interfaces inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer |
|---|
InternalOutputBuffer.OutputStreamOutputBuffer |
| Field Summary | |
|---|---|
protected static java.nio.ByteBuffer |
ACK
ACK static bytes. |
protected ByteBufferCloner |
asyncHttpByteBufferCloner
ByteBufferCloner implementation, which is called by Grizzly
framework at the time, when asynchronous write queue can not write
the buffer directly on socket and instead will put it in queue. |
protected AsyncQueueWriter |
asyncQueueWriter
Asynchronous queue writer, which will be used if asyncHttp mode is enabled |
protected static java.util.Queue<java.nio.ByteBuffer> |
bufferPool
ByteBuffer pool to be used with async write |
protected java.nio.channels.Channel |
channel
Underlying output channel. |
protected static int |
DEFAULT_BUFFER_POOL_SIZE
|
protected boolean |
discardBytes
|
protected boolean |
isAsyncHttpWriteEnabled
Flag, which indicates if async HTTP write is enabled |
protected static java.util.logging.Logger |
logger
|
protected static int |
maxBufferedBytes
Default max cached bytes. |
protected static int |
maxBufferPoolSize
|
protected java.nio.ByteBuffer |
outputByteBuffer
Underlying ByteByteBuffer |
protected java.nio.channels.SelectionKey |
selectionKey
Underlying selection key of the output channel. |
| Fields inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer |
|---|
activeFilters, buf, committed, filterLibrary, finished, headers, lastActiveFilter, outputStream, outputStreamOutputBuffer, pos, response, socketBuffer, useSocketBuffer |
| Constructor Summary | |
|---|---|
SocketChannelOutputBuffer(Response response,
int sendBufferSize,
boolean useSocketBuffer)
Alternate constructor. |
|
| Method Summary | |
|---|---|
protected java.nio.ByteBuffer |
createByteBuffer(int size)
Create the output ByteBuffer |
void |
discardUpstreamBytes()
Stop buffering bytes, discard any upcoming writes. |
void |
endRequest()
End request. |
void |
flush()
Flush the buffered bytes, |
void |
flushBuffer()
Writes bytes to the underlying channel. |
void |
flushChannel(java.nio.ByteBuffer bb)
Flush the buffer by looping until the ByteBuffer is empty |
protected AsyncQueueWriter |
getAsyncQueueWriter()
Gets the asynchronous queue writer, which will be used if asyncHttp mode is enabled |
java.nio.channels.Channel |
getChannel()
Return the underlying SocketChannel |
static int |
getMaxBufferedBytes()
Return the maximum of buffered bytes. |
static int |
getMaxBufferPoolSize()
Return the maximum number of cached ByteBuffer |
java.nio.ByteBuffer |
getOutputByteBuffer()
|
java.nio.channels.SelectionKey |
getSelectionKey()
Gets the underlying selection key of the output channel. |
boolean |
isAsyncHttpWriteEnabled()
Is async HTTP write enabled. |
boolean |
isSupportFileSend()
|
void |
realWriteBytes(byte[] cbuf,
int off,
int len)
Callback to write data from the buffer. |
void |
recycle()
Recycle the output buffer. |
void |
reset()
Reset current response. |
void |
sendAck()
Send an acknoledgement without buffering. |
long |
sendFile(java.nio.channels.FileChannel fileChannel,
long position,
long length)
|
void |
setAsyncHttpWriteEnabled(boolean isAsyncHttpWriteEnabled)
Set if async HTTP write enabled. |
protected void |
setAsyncQueueWriter(AsyncQueueWriter asyncQueueWriter)
Sets the asynchronous queue writer, which will be used if asyncHttp mode is enabled |
void |
setChannel(java.nio.channels.Channel channel)
Set the underlying socket output stream. |
static void |
setMaxBufferedBytes(int aMaxBufferedBytes)
Set the maximum number of bytes before flushing the ByteBuffer
content. |
static void |
setMaxBufferPoolSize(int size)
Set the maximum size of cached ByteBuffer when async
write is enabled. |
void |
setSelectionKey(java.nio.channels.SelectionKey selectionKey)
Sets the underlying selection key of the output channel. |
protected void |
write(CharChunk cc)
|
protected void |
write(java.lang.String s,
boolean replacingCRLF)
|
| Methods inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer |
|---|
addActiveFilter, addFilter, addLastOutputFilter, clearFilters, commit, doWrite, endHeaders, flush, getFilters, getOutputStream, nextRequest, sendHeader, sendHeader, sendHeader, sendStatus, setOutputStream, setSocketBuffer, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.util.logging.Logger logger
protected static final int DEFAULT_BUFFER_POOL_SIZE
protected static int maxBufferPoolSize
protected static java.util.Queue<java.nio.ByteBuffer> bufferPool
protected final ByteBufferCloner asyncHttpByteBufferCloner
ByteBufferCloner implementation, which is called by Grizzly
framework at the time, when asynchronous write queue can not write
the buffer directly on socket and instead will put it in queue.
This implementation tries to get temporary ByteBuffer from the pool,
if no ByteBuffer is available - then new one will be created.
protected java.nio.channels.Channel channel
protected java.nio.channels.SelectionKey selectionKey
protected boolean isAsyncHttpWriteEnabled
protected AsyncQueueWriter asyncQueueWriter
protected java.nio.ByteBuffer outputByteBuffer
protected static final java.nio.ByteBuffer ACK
protected static int maxBufferedBytes
protected boolean discardBytes
| Constructor Detail |
|---|
public SocketChannelOutputBuffer(Response response,
int sendBufferSize,
boolean useSocketBuffer)
| Method Detail |
|---|
protected java.nio.ByteBuffer createByteBuffer(int size)
ByteBuffer
public void setChannel(java.nio.channels.Channel channel)
public java.nio.channels.Channel getChannel()
public java.nio.channels.SelectionKey getSelectionKey()
public void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
selectionKey - the underlying selection key of the output channel.public boolean isAsyncHttpWriteEnabled()
public void setAsyncHttpWriteEnabled(boolean isAsyncHttpWriteEnabled)
isAsyncHttpWriteEnabled - true, if async HTTP write
enabled, or false otherwise.protected AsyncQueueWriter getAsyncQueueWriter()
protected void setAsyncQueueWriter(AsyncQueueWriter asyncQueueWriter)
asyncQueueWriter - The asynchronous queue writer, which will be
used if asyncHttp mode is enabled
public void sendAck()
throws java.io.IOException
sendAck in class InternalOutputBufferjava.io.IOExceptionprotected void write(CharChunk cc)
write in class InternalOutputBuffer
protected void write(java.lang.String s,
boolean replacingCRLF)
write in class InternalOutputBuffer
public void realWriteBytes(byte[] cbuf,
int off,
int len)
throws java.io.IOException
realWriteBytes in interface ByteChunk.ByteOutputChannelrealWriteBytes in class InternalOutputBufferjava.io.IOException
public void flushChannel(java.nio.ByteBuffer bb)
throws java.io.IOException
ByteBuffer is empty
bb - the ByteBuffer to write.
java.io.IOExceptionpublic boolean isSupportFileSend()
isSupportFileSend in interface FileOutputBuffer
public long sendFile(java.nio.channels.FileChannel fileChannel,
long position,
long length)
throws java.io.IOException
sendFile in interface FileOutputBufferjava.io.IOException
public void flush()
throws java.io.IOException
flush in class InternalOutputBufferjava.io.IOException
public void endRequest()
throws java.io.IOException
endRequest in class InternalOutputBufferjava.io.IOException - an undelying I/O error occured
public void flushBuffer()
throws java.io.IOException
java.io.IOExceptionpublic void recycle()
recycle in class InternalOutputBufferpublic void reset()
reset in class InternalOutputBufferjava.lang.IllegalStateException - if the response has already been committedpublic void discardUpstreamBytes()
public static int getMaxBufferedBytes()
public static void setMaxBufferedBytes(int aMaxBufferedBytes)
ByteBuffer
content.
aMaxBufferedBytes - public static void setMaxBufferPoolSize(int size)
ByteBuffer when async
write is enabled.
size - public static int getMaxBufferPoolSize()
ByteBuffer
public java.nio.ByteBuffer getOutputByteBuffer()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||