org.glassfish.grizzly.asyncqueue
Interface AsyncQueueWriter<L>

All Superinterfaces:
AsyncQueue, Writer<L>
All Known Implementing Classes:
AbstractNIOAsyncQueueWriter, TCPNIOAsyncQueueWriter, UDPNIOAsyncQueueWriter

public interface AsyncQueueWriter<L>
extends Writer<L>, AsyncQueue

The AsyncQueue, which implements asynchronous write queue.

Author:
Alexey Stashok, Ryan Lubke

Method Summary
 boolean canWrite(Connection connection, int size)
           
 int getMaxPendingBytesPerConnection()
           
 int getMaxWriteReentrants()
          Returns the maximum number of write() method reentrants a thread is allowed to made.
 void setMaxPendingBytesPerConnection(int maxQueuedWrites)
          Configures the maximum number of bytes pending to be written for a particular Connection.
 void setMaxWriteReentrants(int maxWriteReentrants)
          Sets the maximum number of write() method reentrants a thread is allowed to made.
 GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> write(Connection connection, java.net.SocketAddress dstAddress, Buffer buffer, CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler, Interceptor<WriteResult<Buffer,java.net.SocketAddress>> interceptor, MessageCloner<Buffer> cloner)
          Method writes the Buffer to the specific address.
 
Methods inherited from interface org.glassfish.grizzly.Writer
write, write, write, write, write
 
Methods inherited from interface org.glassfish.grizzly.asyncqueue.AsyncQueue
close, isReady, onClose, processAsync
 

Method Detail

write

GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> write(Connection connection,
                                                                java.net.SocketAddress dstAddress,
                                                                Buffer buffer,
                                                                CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
                                                                Interceptor<WriteResult<Buffer,java.net.SocketAddress>> interceptor,
                                                                MessageCloner<Buffer> cloner)
                                                                throws java.io.IOException
Method writes the Buffer to the specific address.

Parameters:
connection - the Connection to write to
dstAddress - the destination address the message will be sent to
buffer - the Buffer from which the data will be written
completionHandler - CompletionHandler, which will get notified, when write will be completed
interceptor - Interceptor, which will be able to intercept control each time new portion of a data was written from a buffer. The interceptor can decide, whether asynchronous write is completed or not, or provide other processing instructions.
cloner - MessageCloner, which will be invoked by AsyncQueueWriter, if message could not be written to a channel directly and has to be put on a asynchronous queue
Returns:
Future, using which it's possible to check the result
Throws:
java.io.IOException

canWrite

boolean canWrite(Connection connection,
                 int size)
Parameters:
connection - the Connection to test whether or not the specified number of bytes can be written to.
size - number of bytes to write.
Returns:
true if the queue has not exceeded it's maximum size in bytes of pending writes, otherwise false

setMaxPendingBytesPerConnection

void setMaxPendingBytesPerConnection(int maxQueuedWrites)
Configures the maximum number of bytes pending to be written for a particular Connection.

Parameters:
maxQueuedWrites - maximum number of bytes that may be pending to be written to a particular Connection.

getMaxPendingBytesPerConnection

int getMaxPendingBytesPerConnection()
Returns:
the maximum number of bytes that may be pending to be written to a particular Connection.

getMaxWriteReentrants

int getMaxWriteReentrants()
Returns the maximum number of write() method reentrants a thread is allowed to made. This is related to possible write()->onComplete()->write()->... chain, which may grow infinitely and cause StackOverflow. Using maxWriteReentrants value it's possible to limit such a chain.

Returns:
the maximum number of write() method reentrants a thread is allowed to make.

setMaxWriteReentrants

void setMaxWriteReentrants(int maxWriteReentrants)
Sets the maximum number of write() method reentrants a thread is allowed to made. This is related to possible write()->onComplete()->write()->... chain, which may grow infinitely and cause StackOverflow. Using maxWriteReentrants value it's possible to limit such a chain.

Parameters:
maxWriteReentrants - the maximum number of write() method calls a thread is allowed to make.


Copyright © 2011 Oracle Corpration. All Rights Reserved.