com.sun.grizzly.async
Class TCPAsyncQueueWriter
java.lang.Object
com.sun.grizzly.async.AbstractAsyncQueueWriter
com.sun.grizzly.async.TCPAsyncQueueWriter
- All Implemented Interfaces:
- AsyncQueueWriter
public class TCPAsyncQueueWriter
- extends AbstractAsyncQueueWriter
TCP implementation of AsyncQueueWriter
- Author:
- Alexey Stashok
| Methods inherited from class com.sun.grizzly.async.AbstractAsyncQueueWriter |
close, doWrite, getAsyncQueue, isReady, onClose, onWrite, registerForWriting, write, write, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TCPAsyncQueueWriter
public TCPAsyncQueueWriter(SelectorHandler selectorHandler)
write
public Future<AsyncQueueWriteUnit> write(SelectionKey key,
SocketAddress dstAddress,
ByteBuffer buffer,
AsyncWriteCallbackHandler callbackHandler,
AsyncQueueDataProcessor writePreProcessor,
ByteBufferCloner cloner)
throws IOException
- Method sends
ByteBuffer to the SocketAddress
First, if SelectableChannel associated write queue is empty -
it tries to write ByteBuffer to the given
SocketAddress directly (without putting to the queue).
If associated write queue is not empty or after direct writing
ByteBuffer still has ready data to be written -
ByteBuffer will be added to AsyncQueue
and SelectableChannel will be registered on
SelectorHandler, waiting for OP_WRITE event.
If an exception occurs, during direct writing - it will be propagated
to the caller directly and come via
AsyncWriteCallbackHandler.onIOException()
Before data will be written on SelectableChannel, first it
will be passed for preprocessing to AsyncQueueDataProcessor,
and then preprocessor result data
(AsyncQueueDataProcessor.getResultByteBuffer()) will be
written on the SelectableChannel.
- Specified by:
write in interface AsyncQueueWriter- Overrides:
write in class AbstractAsyncQueueWriter
- Parameters:
key - SelectionKey associated with
SelectableChannel ByteBuffer
should be written todstAddress - destination address ByteBuffer will be sent tobuffer - ByteBuffercallbackHandler - AsyncWriteCallbackHandler,
which will get notified, when
ByteBuffer will be completely writtenwritePreProcessor - AsyncQueueDataProcessor, which
will perform data processing, before it will be
written on SelectableChannel
- Throws:
IOException
doWrite
protected OperationResult doWrite(WritableByteChannel channel,
SocketAddress dstAddress,
ByteBuffer byteBuffer,
OperationResult dstResult)
throws IOException
- Specified by:
doWrite in class AbstractAsyncQueueWriter
- Throws:
IOException
Copyright © 2009 SUN Microsystems. All Rights Reserved.