Class Throttles

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

public final class Throttles extends Object
Use multiple throttles that enforce a limit on the maximum number of commands. Useful in sync scan/async touch situations where scan thread needs to slow down sending commands to event loops, so the event loop queues do not get overloaded. Warning: Do not wait for slots directly from event loop threads. Deadlock may occur in that situation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Throttles(int size, int maxCommandsPerEventLoop)
    Construct throttles.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSlot(int index, int count)
    Recover slot(s) from commands that have completed.
    int
    getAvailable(int index)
    Get current number of commands that could be run for a throttle.
    boolean
    waitForSlot(int index, int count)
    Wait for a throttle's command slot(s).

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Throttles

      public Throttles(int size, int maxCommandsPerEventLoop)
      Construct throttles.
  • Method Details

    • waitForSlot

      public boolean waitForSlot(int index, int count)
      Wait for a throttle's command slot(s).
      Parameters:
      index - array index
      count - count of commands to reserve
      Returns:
      if command should be processed
    • addSlot

      public void addSlot(int index, int count)
      Recover slot(s) from commands that have completed.
      Parameters:
      index - array index
      count - count of commands to reclaim
    • getAvailable

      public int getAvailable(int index)
      Get current number of commands that could be run for a throttle.