Class AsyncExecution

java.lang.Object
com.yahoo.processing.execution.AsyncExecution

public class AsyncExecution extends 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:
  • Constructor Details

    • AsyncExecution

      public AsyncExecution(Processor processor, Execution parent)
      Create an async execution of a single processor
    • AsyncExecution

      public AsyncExecution(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 Details

    • 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 List<Response> waitForAll(Collection<FutureResponse> tasks, long timeout)