@POST
@Path("/take")
public void handleTakeTask(HttpRequest request, HttpResponder responder) {
TakeTaskRequest takeRequest = HttpHelper.decodeRequestBody(request, responder, TakeTaskRequest.class, gson);
try {
String taskJson = taskQueueService.takeNextClusterTask(takeRequest);
if (taskJson == null) {
responder.sendStatus(HttpResponseStatus.NO_CONTENT);
return;
}
responder.sendString(HttpResponseStatus.OK, taskJson);
} catch (IOException e) {
LOG.error("Exception while taking task.", e);
responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Error taking task.");
} catch (MissingEntityException e) {
responder.sendError(HttpResponseStatus.FORBIDDEN, "Provisioner " + takeRequest.getProvisionerId()
+ " is not registered.");
}
}