public interface MultiCall
extends java.lang.Cloneable
A MultiCall object can execute several calls one after another. MultiCall objects can and should be reused via the clone() method.
Note that all Request objects to add to a MultiCall should be opted for the same Endpoint
MultiCallback
,
Call
,
Response
,
MultiResponse
,
Request
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels all the calls within this MultiCall
|
MultiCall |
clone()
Clones this MultiCall object into a new instance with all the same parameters in order for it to be reused.
|
void |
enqueue(MultiCallback callback)
Executes the call on another thread and does not block the calling thread
|
MultiResponse |
enqueueAndWait()
Executes the calls on another thread but blocks the calling thread until the operation is complete or an exception is thrown.
|
MultiResponse |
enqueueAndWait(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Executes the calls on another thread but blocks the calling thread for at most the duration specified in the arguments.
|
MultiResponse |
execute()
Executes the calls on the same thread and blocks it until the operation is complete or an exception is thrown.
|
boolean |
isCancelled()
Returns true if this MultiCall has been cancelled, false otherwise
|
boolean |
isExecuted()
Returns true if the all the calls have been executed already, false otherwise
|
java.util.List<Request> |
requests()
|
Interactor |
start()
Start executing the call and return a Interactor
|
java.util.List<Request> requests()
MultiResponse execute() throws java.io.IOException
java.io.IOException
- On failed IO operationsInteractor start()
For more details on usage, see Interactor
MultiResponse enqueueAndWait() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
- On failed IO operationsjava.lang.InterruptedException
- On interruption of the waiting threadMultiResponse enqueueAndWait(long timeout, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Note that it is not guaranteed that all the calls will execute in time and you are not guaranteed to receive a MultiResponse within the time you specified.
timeout
- The maximum amount of waiting time before an attempt to collect and return a MultiResponsetimeUnit
- The TimeUnit in which you have specified the waiting timejava.io.IOException
- On failed IO operationsjava.lang.InterruptedException
- On interruption of the waiting threadjava.util.concurrent.TimeoutException
- If all the calls have not been executed prior to the maximum time specified running outvoid enqueue(MultiCallback callback)
callback
- A MultiCallback to be fired upon a successful execution of a call,
upon an exception being thrown or upon completion of all the callsboolean isExecuted()
void cancel()
boolean isCancelled()