Search in sources :

Example 1 with AsyncExecution

use of com.yahoo.processing.execution.AsyncExecution in project vespa by vespa-engine.

the class Federator method process.

@SuppressWarnings("unchecked")
@Override
public Response process(Request request, Execution execution) {
    List<FutureResponse> futureResponses = new ArrayList<>(chains.size());
    for (Chain<? extends Processor> chain : chains) {
        futureResponses.add(new AsyncExecution(chain, execution).process(request));
    }
    Response response = execution.process(request);
    AsyncExecution.waitForAll(futureResponses, 1000);
    for (FutureResponse futureResponse : futureResponses) {
        Response federatedResponse = futureResponse.get();
        response.data().add(federatedResponse.data());
        response.mergeWith(federatedResponse);
    }
    return response;
}
Also used : FutureResponse(com.yahoo.processing.response.FutureResponse) Response(com.yahoo.processing.Response) FutureResponse(com.yahoo.processing.response.FutureResponse) AsyncExecution(com.yahoo.processing.execution.AsyncExecution) ArrayList(java.util.ArrayList)

Aggregations

Response (com.yahoo.processing.Response)1 AsyncExecution (com.yahoo.processing.execution.AsyncExecution)1 FutureResponse (com.yahoo.processing.response.FutureResponse)1 ArrayList (java.util.ArrayList)1