aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Missing alternative to former MaxCommandAction.BLOCK #181

Closed monrealis closed 3 years ago

monrealis commented 3 years ago

I see that this no longer works https://www.aerospike.com/apidocs/java/com/aerospike/client/async/MaxCommandAction.html#BLOCK. Is there an alternative in you client? I cannot find any.

monrealis commented 3 years ago

I can use Semaphore of course, but is there anything in a client?

BrianNichols commented 3 years ago

BLOCK still works, but I would recommend using DELAY instead.

monrealis commented 3 years ago

How can it work if there is no such class? image

BrianNichols commented 3 years ago

MaxCommandAction is an enum.

BrianNichols commented 3 years ago

Ok, now I understand your issue. MaxCommandAction only exists in the C# client. You are trying to find MaxCommandAction in the java client which does not exist.

In the java client, async command throttling is configured via EventPolicy.

monrealis commented 3 years ago

MaxCommandAction is an enum.

Enum is a class in Java.

monrealis commented 3 years ago

Is there a way to configure event policy so that it works like BLOCK used to work? My conjecture is "No, it can't". Then why was this feature removed? :)

BrianNichols commented 3 years ago

BLOCK can lead to deadlock when a new async command is initiated from a callback in the eventloop thread. Any blocking should be performed outside of the eventloop.

monrealis commented 3 years ago

With BLOCK I was able to fulfill use case: write a bunch of records, waiting as long as needed, but not exceeding some load parameters. Now there is no way to do it.

BrianNichols commented 3 years ago

That use case is best supported by the sync API.