public interface Writer<L>
Buffer
to Connection
.
There are two basic Writer implementations in Grizzly:
AsyncQueueWriter
,
TemporarySelectorWriter
.Modifier and Type | Interface and Description |
---|---|
static class |
Writer.Reentrant
Write reentrants counter
|
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite(Connection<L> connection)
Return
true if the connection has not exceeded it's maximum
size in bytes of pending writes, otherwise false . |
void |
notifyWritePossible(Connection<L> connection,
WriteHandler writeHandler)
Registers
WriteHandler , which will be notified ones at least one
byte can be written. |
GrizzlyFuture<WriteResult<WritableMessage,L>> |
write(Connection connection,
L dstAddress,
WritableMessage message)
Method writes the
WritableMessage to the specific address. |
void |
write(Connection connection,
L dstAddress,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,L>> completionHandler)
Method writes the
WritableMessage to the specific address. |
void |
write(Connection connection,
L dstAddress,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,L>> completionHandler,
MessageCloner<WritableMessage> messageCloner)
Method writes the
WritableMessage to the specific address. |
void |
write(Connection connection,
L dstAddress,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,L>> completionHandler,
PushBackHandler pushBackHandler)
Deprecated.
push back logic is deprecated
|
GrizzlyFuture<WriteResult<WritableMessage,L>> |
write(Connection connection,
WritableMessage message)
Method writes the
WritableMessage . |
void |
write(Connection connection,
WritableMessage message,
CompletionHandler<WriteResult<WritableMessage,L>> completionHandler)
Method writes the
WritableMessage . |
GrizzlyFuture<WriteResult<WritableMessage,L>> write(Connection connection, WritableMessage message) throws IOException
WritableMessage
.connection
- the Connection
to write tomessage
- the WritableMessage
, from which the data will be writtenFuture
, using which it's possible to check the
resultIOException
void write(Connection connection, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,L>> completionHandler)
WritableMessage
.connection
- the Connection
to write tomessage
- the WritableMessage
, from which the data will be writtencompletionHandler
- CompletionHandler
,
which will get notified, when write will be completedGrizzlyFuture<WriteResult<WritableMessage,L>> write(Connection connection, L dstAddress, WritableMessage message)
WritableMessage
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 writtenFuture
, using which it's possible to check the
resultvoid write(Connection connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,L>> completionHandler)
WritableMessage
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 completedvoid write(Connection connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,L>> completionHandler, PushBackHandler pushBackHandler)
WritableMessage
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 refusedvoid write(Connection connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,L>> completionHandler, MessageCloner<WritableMessage> messageCloner)
WritableMessage
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 completedmessageCloner
- the MessageCloner
, which will be able to
clone the message in case it can't be completely written in the
current thread.boolean canWrite(Connection<L> connection)
true
if the connection has not exceeded it's maximum
size in bytes of pending writes, otherwise false
.connection
- the Connection
to test whether or not the
specified number of bytes can be written to.true
if the connection has not exceeded it's maximum
size in bytes of pending writes, otherwise false
void notifyWritePossible(Connection<L> connection, WriteHandler writeHandler)
WriteHandler
, which will be notified ones at least one
byte can be written.
This method call is equivalent to call notifyWritePossible(connection, writeHandler, 1);
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.Copyright © 2014 Oracle Corporation. All rights reserved.