Search in sources :

Example 1 with ProgressResult

use of com.linkedin.kafka.cruisecontrol.servlet.response.ProgressResult in project cruise-control by linkedin.

the class AbstractAsyncRequest method getResponse.

@Override
public CruiseControlResponse getResponse(HttpServletRequest request, HttpServletResponse response) throws ExecutionException, InterruptedException {
    LOG.info("Processing async request {}.", name());
    int step = _asyncOperationStep.get();
    List<OperationFuture> futures = _userTaskManager.getOrCreateUserTask(request, response, this::handle, step, true, parameters());
    _asyncOperationStep.set(step + 1);
    CruiseControlResponse ccResponse;
    try {
        ccResponse = futures.get(step).get(_maxBlockMs, TimeUnit.MILLISECONDS);
        LOG.info("Computation is completed for async request: {}.", request.getPathInfo());
    } catch (TimeoutException te) {
        ccResponse = new ProgressResult(futures, _asyncKafkaCruiseControl.config());
        LOG.info("Computation is in progress for async request: {}.", request.getPathInfo());
    }
    return ccResponse;
}
Also used : CruiseControlResponse(com.linkedin.cruisecontrol.servlet.response.CruiseControlResponse) ProgressResult(com.linkedin.kafka.cruisecontrol.servlet.response.ProgressResult) OperationFuture(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

CruiseControlResponse (com.linkedin.cruisecontrol.servlet.response.CruiseControlResponse)1 OperationFuture (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture)1 ProgressResult (com.linkedin.kafka.cruisecontrol.servlet.response.ProgressResult)1 TimeoutException (java.util.concurrent.TimeoutException)1