aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Unclear why AerospikeClient accepts EventLoops #184

Closed monrealis closed 3 years ago

monrealis commented 3 years ago

EventLoops is part of client policy: image

ClientPolicy is part of AerospikeClient: image

Yet every time I want to execute asynchronous operation I have to pass EventLoop as a mandatory parameter. image

So what's the point of passing EventLoops to the client if I have to pass EventLoop during each operation?

BrianNichols commented 3 years ago

The eventloop argument was added to every async command because it allows the user to execute a group of related commands on the same eventloop. This allows shared data between these commands to be accessed without atomics (faster).

If round-robin distribution of commands to eventloops is desired and specifying EventLoops.next() as the argument is not desired, then perform the following:

1) Upgrade to java client 5.0.3. 2) Pass in null for eventloop argument.

The client will then call EventLoops.next() when eventloop is null.

monrealis commented 3 years ago

Currently I use 4.4.18. Newer versions do not work with server versions that I have. Thanks for the info.

P.S. I see that event loops that I pass to aerospike client in this version are used (almost) only in Cluster.getStats(). But still how do you know if the same event loops that are passed to AerospikeClient are actually used when executing CRUD operations.

image

BrianNichols commented 3 years ago

The client assumes that the eventloops specified in ClientPolicy contains all possible eventloops. If a different eventloop is passed to a command, an array out of bounds exception is the likely result.