public interface AsyncQueueWriter<L> extends Writer<L>, AsyncQueue
AsyncQueue
, which implements asynchronous write queue.Modifier and Type | Interface and Description |
---|---|
static class |
AsyncQueueWriter.Reentrant
Write reentrants counter
|
AsyncQueue.AsyncResult
Modifier and Type | Field and Description |
---|---|
static int |
AUTO_SIZE
Constant set via
setMaxPendingBytesPerConnection(int) means
the async write queue size will be configured automatically per
NIOConnection depending on connections write buffer size. |
static int |
UNLIMITED_SIZE
Constant set via
setMaxPendingBytesPerConnection(int) means
the async write queue size is unlimited. |
EXPECTING_MORE_OPTION
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite(Connection connection) |
boolean |
canWrite(Connection connection,
int size)
Deprecated.
the size parameter will be ignored, use
canWrite(org.glassfish.grizzly.Connection) instead. |
int |
getMaxPendingBytesPerConnection() |
int |
getMaxWriteReentrants()
Returns the maximum number of write() method reentrants a thread
is allowed to made.
|
AsyncQueueWriter.Reentrant |
getWriteReentrant()
Returns the current write reentrants counter.
|
boolean |
isMaxReentrantsReached(AsyncQueueWriter.Reentrant reentrant)
Returns true, if max number of write->completion-handler reentrants
has been reached for the passed
AsyncQueueWriter.Reentrant object, and next write
will happen in the separate thread. |
void |
notifyWritePossible(Connection connection,
WriteHandler writeHandler)
Registers
WriteHandler , which will be notified ones the
Connection is able to accept more bytes to be written. |
void |
notifyWritePossible(Connection connection,
WriteHandler writeHandler,
int size)
Deprecated.
the size parameter will be ignored, use {@link #notifyWritePossible(org.glassfish.grizzly.Connection, org.glassfish.grizzly.WriteHandler) instead.
|
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.
|
void |
write(Connection connection,
SocketAddress dstAddress,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler,
MessageCloner<WritableMessage> cloner)
Method writes the
Buffer to the specific address. |
void |
write(Connection connection,
SocketAddress dstAddress,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler,
PushBackHandler pushBackHandler,
MessageCloner<WritableMessage> cloner)
Deprecated.
push back logic is deprecated
|
close, isReady, onClose, processAsync
static final int UNLIMITED_SIZE
setMaxPendingBytesPerConnection(int)
means
the async write queue size is unlimited.static final int AUTO_SIZE
setMaxPendingBytesPerConnection(int)
means
the async write queue size will be configured automatically per
NIOConnection
depending on connections write buffer size.void write(Connection connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, MessageCloner<WritableMessage> cloner)
Buffer
to the specific address.connection
- the Connection
to write todstAddress
- the destination address the WritableMessage
will be
sent tomessage
- the WritableMessage
, from which the data will be writtencompletionHandler
- CompletionHandler
,
which will get notified, when write will be completedcloner
- 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 queuevoid write(Connection connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, PushBackHandler pushBackHandler, MessageCloner<WritableMessage> cloner)
Buffer
to the specific address.connection
- the Connection
to write todstAddress
- the destination address the WritableMessage
will be
sent tomessage
- the WritableMessage
, from which the data will be writtencompletionHandler
- CompletionHandler
,
which will get notified, when write will be completedpushBackHandler
- PushBackHandler
, which will be notified
if message was accepted by transport write queue or refusedcloner
- 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 queueboolean canWrite(Connection connection)
connection
- the Connection
to test whether or not it's ready
to accept more bytes to write.true
if the queue has not exceeded it's maximum
size in bytes of pending writes, otherwise false
boolean canWrite(Connection connection, int size)
canWrite(org.glassfish.grizzly.Connection)
instead.connection
- the Connection
to test whether or not the
specified number of bytes can be written to.size
- number of bytes to write.true
if the queue has not exceeded it's maximum
size in bytes of pending writes, otherwise false
void notifyWritePossible(Connection connection, WriteHandler writeHandler, int size)
WriteHandler
, which will be notified ones the
Connection
is able to accept more bytes to be written.
Note: using this method from different threads simultaneously may lead
to quick situation changes, so at time WriteHandler
is called -
the queue may become busy again.connection
- Connection
writeHandler
- WriteHandler
to be notified.size
- number of bytes queue has to be able to accept before notifying
WriteHandler
.void notifyWritePossible(Connection connection, WriteHandler writeHandler)
WriteHandler
, which will be notified ones the
Connection
is able to accept more bytes to be written.connection
- Connection
writeHandler
- WriteHandler
to be notified.void setMaxPendingBytesPerConnection(int maxQueuedWrites)
Connection
.maxQueuedWrites
- maximum number of bytes that may be pending to be
written to a particular Connection
.int getMaxPendingBytesPerConnection()
Connection
. By default, this will be four
times the size of the Socket
send buffer size.int getMaxWriteReentrants()
void setMaxWriteReentrants(int maxWriteReentrants)
maxWriteReentrants
- the maximum number of write() method calls
a thread is allowed to make.AsyncQueueWriter.Reentrant getWriteReentrant()
canWrite(org.glassfish.grizzly.Connection, int)
and
various write methods.boolean isMaxReentrantsReached(AsyncQueueWriter.Reentrant reentrant)
AsyncQueueWriter.Reentrant
object, and next write
will happen in the separate thread.reentrant
- AsyncQueueWriter.Reentrant
object.AsyncQueueWriter.Reentrant
object, and next write
will happen in the separate thread.Copyright © 2013 Oracle Corporation. All Rights Reserved.