Package com.yahoo.processing.execution
Class AsyncExecution
- java.lang.Object
-
- com.yahoo.processing.execution.AsyncExecution
-
public class AsyncExecution extends java.lang.Object
Provides asynchronous execution of processing chains. Usage:
Execution execution = new Execution(chain); AsyncExecution asyncExecution = new AsyncExecution(execution); Future<Response> future = asyncExecution.process(request) try { result = future.get(timeout, TimeUnit.milliseconds); } catch(TimeoutException e) { // Handle timeout }
The request is not thread safe. A clone() must be made for each parallel processing.
- Author:
- bratseth
- See Also:
Execution
-
-
Constructor Summary
Constructors Constructor Description AsyncExecution(com.yahoo.component.chain.Chain<? extends Processor> chain, Execution parent)
Create an async execution of a chainAsyncExecution(Execution execution)
Creates an async execution from an existing execution.AsyncExecution(Processor processor, Execution parent)
Create an async execution of a single processor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FutureResponse
process(Request request)
Performs an async processing.static java.util.List<Response>
waitForAll(java.util.Collection<FutureResponse> tasks, long timeout)
-
-
-
Constructor Detail
-
AsyncExecution
public AsyncExecution(Processor processor, Execution parent)
Create an async execution of a single processor
-
AsyncExecution
public AsyncExecution(com.yahoo.component.chain.Chain<? extends Processor> chain, Execution parent)
Create an async execution of a chain
-
AsyncExecution
public AsyncExecution(Execution execution)
Creates an async execution from an existing execution. This async execution will execute the chain from the given execution, starting from the next processor in that chain. This is handy to execute multiple executions to the rest of the chain in parallel.The state of the given execution is read on construction of this and not used later - the argument execution can be reused for other purposes.
- Parameters:
execution
- the execution from which the state of this is created
-
-
Method Detail
-
process
public FutureResponse process(Request request)
Performs an async processing. Note that the given request cannot be simultaneously used in multiple such processings - a clone must be created for each.
-
waitForAll
public static java.util.List<Response> waitForAll(java.util.Collection<FutureResponse> tasks, long timeout)
-
-