use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture in project cruise-control by linkedin.
the class AbstractSyncRequest method getResponse.
@Override
public CruiseControlResponse getResponse(HttpServletRequest request, HttpServletResponse response) throws ExecutionException, InterruptedException {
LOG.info("Processing sync request {}.", name());
long requestExecutionStartTime = System.nanoTime();
int step = 0;
OperationFuture resultFuture = _userTaskManager.getOrCreateUserTask(request, response, uuid -> {
OperationFuture future = new OperationFuture(String.format("%s request", parameters().endPoint().toString()));
future.complete(handle());
return future;
}, step, false, parameters()).get(step);
CruiseControlResponse ccResponse = resultFuture.get();
_successfulRequestExecutionTimer.get(parameters().endPoint()).update(System.nanoTime() - requestExecutionStartTime, TimeUnit.NANOSECONDS);
return ccResponse;
}
use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture in project cruise-control by linkedin.
the class UserTaskManager method getFuture.
/**
* Get the future from the given request.
*
* @param request HTTP request received by Cruise Control.
* @param <T> The returned future type.
* @return The future from the given request.
*/
@SuppressWarnings("unchecked")
public <T> T getFuture(HttpServletRequest request) {
UUID userTaskId = getUserTaskId(request);
UserTaskInfo userTaskInfo = getUserTaskByUserTaskId(userTaskId, request);
List<OperationFuture> operationFutures = null;
if (userTaskInfo != null) {
operationFutures = userTaskInfo.futures();
}
if (operationFutures == null || operationFutures.isEmpty()) {
return null;
}
return (T) operationFutures.get(operationFutures.size() - 1);
}
use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture in project cruise-control by linkedin.
the class ClusterLoadRequest method handle.
@Override
protected OperationFuture handle(String uuid) {
OperationFuture future = new OperationFuture("Get broker stats");
pending(future.operationProgress());
_asyncKafkaCruiseControl.sessionExecutor().submit(new LoadRunnable(_asyncKafkaCruiseControl, future, _parameters));
return future;
}
use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture in project cruise-control by linkedin.
the class CruiseControlStateRequest method handle.
@Override
protected OperationFuture handle(String uuid) {
OperationFuture future = new OperationFuture("Get state");
pending(future.operationProgress());
_asyncKafkaCruiseControl.sessionExecutor().submit(new GetStateRunnable(_asyncKafkaCruiseControl, future, _parameters));
return future;
}
use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture in project cruise-control by linkedin.
the class FixOfflineReplicasRequest method handle.
@Override
protected OperationFuture handle(String uuid) {
OperationFuture future = new OperationFuture("Fix offline replicas");
pending(future.operationProgress());
_asyncKafkaCruiseControl.sessionExecutor().submit(new FixOfflineReplicasRunnable(_asyncKafkaCruiseControl, future, _parameters, uuid));
return future;
}
Aggregations