Interface AsyncQueueWriter<L>

Type Parameters:
L - the destination address type
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
  • Field Details

    • UNLIMITED_SIZE

      static final int UNLIMITED_SIZE
      Constant set via setMaxPendingBytesPerConnection(int) means the async write queue size is unlimited.
      See Also:
    • AUTO_SIZE

      static final 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.
      See Also:
    • DEFAULT_PENDING_BYTES_HARD_LIMIT_MULTIPLIER

      static final int DEFAULT_PENDING_BYTES_HARD_LIMIT_MULTIPLIER
      Default multiplier used to calculate the hard limit for the asynchronous write queue reservation size per connection.

      The hard limit is calculated by multiplying the connection's configured soft limit by this value. If a write would exceed the hard limit, the write fails and the connection is closed.

      See Also:
  • Method Details

    • write

      @Deprecated void write(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage,L>> completionHandler, PushBackHandler pushBackHandler, MessageCloner<WritableMessage> cloner)
      Deprecated.
      push back logic is deprecated
      Method writes the Buffer to the specific address.
      Parameters:
      connection - the Connection to write to
      dstAddress - the destination address the WritableMessage will be sent to
      message - the WritableMessage, from which the data will be written
      completionHandler - CompletionHandler, which will get notified, when write will be completed
      pushBackHandler - PushBackHandler, which will be notified if message was accepted by transport write queue or refused
      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
    • canWrite

      @Deprecated boolean canWrite(Connection<L> connection, int size)
      Deprecated.
      the size parameter will be ignored, use Writer.canWrite(org.glassfish.grizzly.Connection) instead.
      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
      Since:
      2.2
    • notifyWritePossible

      @Deprecated void notifyWritePossible(Connection<L> connection, WriteHandler writeHandler, int size)
      Deprecated.
      the size parameter will be ignored, use invalid input: 'instead.'
      Registers 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.
      Parameters:
      connection - Connection
      writeHandler - WriteHandler to be notified.
      size - number of bytes queue has to be able to accept before notifying WriteHandler.
      Since:
      2.2
    • setMaxPendingBytesPerConnection

      void setMaxPendingBytesPerConnection(int maxPendingBytes)
      Configures the soft limit for the maximum number of bytes pending to be written for a particular Connection.
      Parameters:
      maxPendingBytes - the soft limit for the maximum number of bytes that may be pending to be written to a particular Connection.
    • getMaxPendingBytesPerConnection

      int getMaxPendingBytesPerConnection()
      Gets the configured soft limit for the maximum number of bytes pending to be written per connection for asynchronous writes.
      Returns:
      the configured soft limit. By default, this will be four times the size of the Socket send buffer size.
    • setPendingBytesHardLimitMultiplier

      void setPendingBytesHardLimitMultiplier(int multiplier)
      Sets the multiplier used to calculate the hard limit for the asynchronous write queue reservation size per connection.

      The hard limit is calculated by multiplying the connection's configured soft limit by this value. If adding a write would cause the reservation size to exceed the calculated hard limit, the write fails and the connection is closed.

      The default multiplier is 4.

      Parameters:
      multiplier - the hard limit multiplier; must be greater than or equal to 1
      Throws:
      IllegalArgumentException - if multiplier is less than 1
    • getPendingBytesHardLimitMultiplier

      int getPendingBytesHardLimitMultiplier()
      Gets the multiplier used to calculate the hard limit for the asynchronous write queue reservation size per connection.

      If adding a write would cause the reservation size to exceed the calculated hard limit, the write fails and the connection is closed.

      The default multiplier is 4.

      Returns:
      the hard limit multiplier
    • isAllowDirectWrite

      boolean isAllowDirectWrite()
      Returns true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.
      Returns:
      true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.
    • setAllowDirectWrite

      void setAllowDirectWrite(boolean isAllowDirectWrite)
      Set true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.
      Parameters:
      isAllowDirectWrite - true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.