Reputation: 21
I would like to execute an async method in Ignite cache and set a timeout for the execution. Moreover, I would like to specify the executor.
Using cache.getAsync
is very close to the desired functionality but it does not accept a timeout and executor arguments.
Currently, a sub-optimal solution can be found in the following Scala snippet:
val igniteFuture = cache.getAsync(key)
igniteFuture.listenAsync(
(f: IgniteFuture[T]) => f.get(timeout.toMillis, TimeUnit.MILLISECONDS)), executor)
How can the desired functionality can be achieved with current Ignite building blocks?
Upvotes: 1
Views: 358
Reputation: 3591
I think, you are mixing concepts of futures and asynchronous operations. Futures are the objects, that can be either completed, or waited on. So, when you ask Ignite to perform an asynchronous operation, it gives you a future, that will be completed later at some point. You can specify a period of time in a IgniteFuture.get()
method, or subscribe to completion of this future, by using IgniteFuture.listen()
method.
But the way, that operations are performed, is incapsulated from you. You can configure sizes of internal thread pools though: https://apacheignite.readme.io/docs/thread-pools
Upvotes: 1