New Async API usage and examples


#1

I haven’t found a lot of documentation about the new async api in Java client other than the example in http://www.aerospike.com/docs/client/java/usage/async

Specifically:

  1. What is the the difference between direct nio, Netty nio and Netty epoll.
  2. What is the recommended method of usage, assuming the service running the client runs on Linux machine?
  3. Could you clarify the usage of the event loop (and calling eventLoop.next() as concept - why do I need it and when should it be used (as opposed to the thread pool that the old AsyncClient was using)?
  4. Do you have any other examples and documentations for the new Async API?

#2
  1. Direct nio uses the built-in java runtime NIO event loop abstraction API without requiring Netty. Portable.

    Netty nio uses the built-in java runtime NIO event loop abstraction API. Portable.

    Netty epoll bypasses the NIO event loop abstraction and uses epoll event loops directly. Available only on Linux.

    Netty is usually chosen when you want to share your application event loops with AerospikeClient.

  2. Netty epoll should provide the best performance on Linux.

  3. The old AsyncClient allowed for both event loop threads and a thread pool to offload user callbacks. AerospikeClient removed the thread pool so the code could become more efficient (single-threaded).

    Specifying the event loop gives you more control and allows commands that interact with each other to be treated as single-threaded. EventLoop.next() is used to randomly distribute disparate commands across event loops.

  4. Async API