Hi everyone,
I'm looking for advice on how to use Futures#transform[1] and friends
(#addCallback, #withFallback)
These methods all have an overloaded version which takes a JDK Executor
instance as additional argument.
When the base method is called, Guava will use the so-called
"sameThreadExecutor". Consequently, the code will be executed:
* by the caller thread, if the underlying Future has completed already
* otherwise, by the thread completing the underlying Future
When the overloaded method is called, Guava will submit tasks to the
provided executor.
In the metrics code right now, the base method is used almost
everywhere. Considering that in most cases it will take more time to get
the response from C* than to complete the REST Handler code, it's the
Datastax driver threads which will execute the chain of callbacks, down
to the call to javax.ws.rs.container.AsyncResponse#resume
Could that be a problem? I guess it's safe when callbacks only
transforms the data loaded. I'm not sure about the call to
AsyncResponse#resume.
Thoughts?
Thanks,
Thomas
[1]
http://docs.guava-libraries.googlecode.com/git-history/v16.0.1/javadoc/co...