Class EventPolicy

java.lang.Object
com.aerospike.client.async.EventPolicy

public final class EventPolicy extends Object
Asynchronous event loop configuration.
  • Field Details

    • maxCommandsInProcess

      public int maxCommandsInProcess
      Maximum number of async commands that can be processed in each event loop at any point in time. Each executing async command requires a socket connection. Consuming too many sockets can negatively affect application reliability and performance. If the user does not limit async command count in their application, this field should be used to enforce a limit internally in the client.

      If this limit is reached, the next async command will be placed on the event loop's delay queue for later execution. If this limit is zero, all async commands will be executed immediately and the delay queue will not be used.

      If defined, a reasonable value is 40. The optimal value will depend on cpu count, cpu speed, network bandwidth and the number of event loops employed.

      Default: 0 (execute all async commands immediately)

    • maxCommandsInQueue

      public int maxCommandsInQueue
      Maximum number of async commands that can be stored in each event loop's delay queue for later execution. Queued commands consume memory, but they do not consume sockets. This limit should be defined when it's possible that the application executes so many async commands that memory could be exhausted.

      If this limit is reached, the next async command will be rejected with exception AerospikeException.AsyncQueueFull. If this limit is zero, all async commands will be accepted into the delay queue.

      The optimal value will depend on your application's magnitude of command bursts and the amount of memory available to store commands.

      Default: 0 (no delay queue limit)

    • queueInitialCapacity

      public int queueInitialCapacity
      Initial capacity of each event loop's delay queue. The delay queue can resize beyond this initial capacity.

      Default: 256 (if delay queue is used)

    • minTimeout

      public int minTimeout
      Minimum command timeout in milliseconds that will be specified for this event loop group. If command timeouts are less than minTimeout, the actual command timeout will be minTimeout. The absolute minimum timeout value is 5ms.

      minTimeout is used to specify the tick duration for HashedWheelTimer in each event loop. minTimeout is also used to specify the direct NIO event loop selector timeout.

      Default: 100ms

    • ticksPerWheel

      public int ticksPerWheel
      The number of ticks per wheel for HashedWheelTimer in each event loop.

      Default: 256

    • commandsPerEventLoop

      public int commandsPerEventLoop
      Expected number of concurrent asynchronous commands in each event loop that are active at any point in time. This value is used as each event loop's timeout queue and ByteBuffer pool initial capacity. This value is not a fixed limit and the queues will dynamically resize when necessary.

      The real event loop limiting factor is the maximum number of async connections allowed per node (defined in ClientPolicy.maxConnsPerNode).

      Default: 256

  • Constructor Details

    • EventPolicy

      public EventPolicy()
  • Method Details

    • setMaxCommandsInProcess

      public void setMaxCommandsInProcess(int maxCommandsInProcess)
    • setMaxCommandsInQueue

      public void setMaxCommandsInQueue(int maxCommandsInQueue)
    • setQueueInitialCapacity

      public void setQueueInitialCapacity(int queueInitialCapacity)
    • setMinTimeout

      public void setMinTimeout(int minTimeout)
    • setTicksPerWheel

      public void setTicksPerWheel(int ticksPerWheel)
    • setCommandsPerEventLoop

      public void setCommandsPerEventLoop(int commandsPerEventLoop)