Package com.aerospike.client.async
Class Throttles
java.lang.Object
com.aerospike.client.async.Throttles
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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).
-
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 indexcount
- 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 indexcount
- count of commands to reclaim
-
getAvailable
public int getAvailable(int index) Get current number of commands that could be run for a throttle.
-