public class AsyncExecution extends Object
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.
Execution
Modifier and Type | Field and Description |
---|---|
private Execution |
execution
The execution of this
|
private static Executor |
executorMain |
private static ThreadFactory |
threadFactory |
Constructor and Description |
---|
AsyncExecution(com.yahoo.component.chain.Chain<? extends Processor> chain,
Execution parent)
Create an async execution of a chain
|
AsyncExecution(Execution execution)
Creates an async execution from an existing execution.
|
AsyncExecution(Processor processor,
Execution parent)
Create an async execution of a single processor
|
Modifier and Type | Method and Description |
---|---|
private static Executor |
createExecutor() |
private static <T> Future<T> |
getFuture(Callable<T> callable) |
private FutureResponse |
getFutureResponse(Callable<Response> callable,
Request request) |
private static Response |
getTaskResponse(FutureResponse future) |
FutureResponse |
process(Request request)
Performs an async processing.
|
static List<Response> |
waitForAll(Collection<FutureResponse> tasks,
long timeout) |
private static final ThreadFactory threadFactory
private static final Executor executorMain
private final Execution execution
public AsyncExecution(Processor processor, Execution parent)
public AsyncExecution(com.yahoo.component.chain.Chain<? extends Processor> chain, Execution parent)
public AsyncExecution(Execution execution)
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.
execution
- the execution from which the state of this is createdprivate static final Executor createExecutor()
public FutureResponse process(Request request)
private FutureResponse getFutureResponse(Callable<Response> callable, Request request)
public static List<Response> waitForAll(Collection<FutureResponse> tasks, long timeout)
private static Response getTaskResponse(FutureResponse future)
Copyright © 2018. All rights reserved.