Class TemporarySelectorWriter
- java.lang.Object
-
- org.glassfish.grizzly.AbstractWriter<SocketAddress>
-
- org.glassfish.grizzly.nio.tmpselectors.TemporarySelectorWriter
-
- All Implemented Interfaces:
Writer<SocketAddress>
- Direct Known Subclasses:
TCPNIOTemporarySelectorWriter,UDPNIOTemporarySelectorWriter
public abstract class TemporarySelectorWriter extends AbstractWriter<SocketAddress>
- Author:
- oleksiys
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.grizzly.Writer
Writer.Reentrant
-
-
Field Summary
Fields Modifier and Type Field Description protected TemporarySelectorsEnabledTransporttransport
-
Constructor Summary
Constructors Constructor Description TemporarySelectorWriter(TemporarySelectorsEnabledTransport transport)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanWrite(Connection connection)Returntrueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse.TemporarySelectorsEnabledTransportgetTransport()voidnotifyWritePossible(Connection connection, WriteHandler writeHandler)RegistersWriteHandler, which will be notified ones at least one byte can be written.voidwrite(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, long timeout, TimeUnit timeunit)Method writes theWritableMessageto the specific address.voidwrite(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, MessageCloner<WritableMessage> messageCloner)Method writes theWritableMessageto the specific address.voidwrite(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, PushBackHandler pushBackHandler)Deprecated.voidwrite(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, PushBackHandler pushBackHandler, long timeout, TimeUnit timeunit)Method writes theWritableMessageto the specific address.protected longwrite0(NIOConnection connection, SocketAddress dstAddress, WritableMessage message, WriteResult<WritableMessage,SocketAddress> currentResult, long timeout, TimeUnit timeunit)Flush the buffer by looping until theBufferis emptyprotected abstract longwriteNow0(NIOConnection connection, SocketAddress dstAddress, WritableMessage message, WriteResult<WritableMessage,SocketAddress> currentResult)-
Methods inherited from class org.glassfish.grizzly.AbstractWriter
write, write, write, write
-
-
-
-
Field Detail
-
transport
protected final TemporarySelectorsEnabledTransport transport
-
-
Constructor Detail
-
TemporarySelectorWriter
public TemporarySelectorWriter(TemporarySelectorsEnabledTransport transport)
-
-
Method Detail
-
write
public void write(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, MessageCloner<WritableMessage> messageCloner)
Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completedmessageCloner- theMessageCloner, which will be able to clone the message in case it can't be completely written in the current thread.
-
write
@Deprecated public void write(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, PushBackHandler pushBackHandler)
Deprecated.Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, 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 refused
-
write
public void write(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, long timeout, TimeUnit timeunit)
Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address the message will be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completed
-
write
public void write(Connection<SocketAddress> connection, SocketAddress dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,SocketAddress>> completionHandler, PushBackHandler pushBackHandler, long timeout, TimeUnit timeunit)
Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address the message will be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completed
-
write0
protected long write0(NIOConnection connection, SocketAddress dstAddress, WritableMessage message, WriteResult<WritableMessage,SocketAddress> currentResult, long timeout, TimeUnit timeunit) throws IOException
Flush the buffer by looping until theBufferis empty- Parameters:
connection- theConnection.dstAddress- the destination address.message-currentResult- the result of the write operationtimeout- operation timeout value valuetimeunit- the timeout unit- Returns:
- The number of bytes written.
- Throws:
IOException
-
getTransport
public TemporarySelectorsEnabledTransport getTransport()
-
writeNow0
protected abstract long writeNow0(NIOConnection connection, SocketAddress dstAddress, WritableMessage message, WriteResult<WritableMessage,SocketAddress> currentResult) throws IOException
- Throws:
IOException
-
canWrite
public boolean canWrite(Connection connection)
Returntrueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse.- Parameters:
connection- theConnectionto test whether or not the specified number of bytes can be written to.- Returns:
trueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse
-
notifyWritePossible
public void notifyWritePossible(Connection connection, WriteHandler writeHandler)
RegistersWriteHandler, 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 timeWriteHandleris called - the queue may become busy again.- Parameters:
connection-ConnectionwriteHandler-WriteHandlerto be notified.
-
-