use of com.netflix.conductor.common.metadata.tasks.TaskResult in project conductor by Netflix.
the class TaskServiceImpl method updateTask.
@Override
public void updateTask(TaskServicePb.UpdateTaskRequest req, StreamObserver<TaskServicePb.UpdateTaskResponse> response) {
try {
TaskResult task = PROTO_MAPPER.fromProto(req.getResult());
taskService.updateTask(task);
response.onNext(TaskServicePb.UpdateTaskResponse.newBuilder().setTaskId(task.getTaskId()).build());
response.onCompleted();
} catch (Exception e) {
GRPC_HELPER.onError(response, e);
}
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project conductor by Netflix.
the class AbstractProtoMapper method fromProto.
public TaskResult fromProto(TaskResultPb.TaskResult from) {
TaskResult to = new TaskResult();
to.setWorkflowInstanceId(from.getWorkflowInstanceId());
to.setTaskId(from.getTaskId());
to.setReasonForIncompletion(from.getReasonForIncompletion());
to.setCallbackAfterSeconds(from.getCallbackAfterSeconds());
to.setWorkerId(from.getWorkerId());
to.setStatus(fromProto(from.getStatus()));
Map<String, Object> outputDataMap = new HashMap<String, Object>();
for (Map.Entry<String, Value> pair : from.getOutputDataMap().entrySet()) {
outputDataMap.put(pair.getKey(), fromProto(pair.getValue()));
}
to.setOutputData(outputDataMap);
if (from.hasOutputMessage()) {
to.setOutputMessage(fromProto(from.getOutputMessage()));
}
to.setRetryDelaySeconds(from.getRetryDelaySeconds());
return to;
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project conductor by Netflix.
the class TaskResourceTest method testUpdateTask.
@Test
public void testUpdateTask() throws Exception {
TaskResult taskResult = new TaskResult();
taskResult.setStatus(TaskResult.Status.COMPLETED);
taskResult.setTaskId("123");
when(mockTaskService.updateTask(any(TaskResult.class))).thenReturn("123");
assertEquals("123", taskResource.updateTask(taskResult));
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project conductor by Netflix.
the class TaskPollExecutor method updateWithRetry.
private void updateWithRetry(int count, Task task, TaskResult result, Worker worker) {
try {
String updateTaskDesc = String.format("Retry updating task result: %s for task: %s in worker: %s", result.toString(), task.getTaskDefName(), worker.getIdentity());
String evaluatePayloadDesc = String.format("Evaluate Task payload for task: %s in worker: %s", task.getTaskDefName(), worker.getIdentity());
String methodName = "updateWithRetry";
TaskResult finalResult = new RetryUtil<TaskResult>().retryOnException(() -> {
TaskResult taskResult = result.copy();
taskClient.evaluateAndUploadLargePayload(taskResult, task.getTaskType());
return taskResult;
}, null, null, count, evaluatePayloadDesc, methodName);
new RetryUtil<>().retryOnException(() -> {
taskClient.updateTask(finalResult);
return null;
}, null, null, count, updateTaskDesc, methodName);
} catch (Exception e) {
worker.onErrorUpdate(task);
MetricsContainer.incrementTaskUpdateErrorCount(worker.getTaskDefName(), e);
LOGGER.error(String.format("Failed to update result: %s for task: %s in worker: %s", result.toString(), task.getTaskDefName(), worker.getIdentity()), e);
}
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project conductor by Netflix.
the class TaskServiceImpl method failTask.
/**
* Updates the task with FAILED status; On exception, fails the workflow.
* @param task
* @param errorMsg
*/
private void failTask(Task task, String errorMsg) {
try {
TaskResult taskResult = new TaskResult();
taskResult.setStatus(TaskResult.Status.FAILED);
taskResult.setTaskId(task.getTaskId());
taskResult.setWorkflowInstanceId(task.getWorkflowInstanceId());
taskResult.setReasonForIncompletion(errorMsg);
executionService.updateTask(taskResult);
} catch (Exception e) {
LOGGER.error("Unable to fail task: {} in workflow: {}", task.getTaskId(), task.getWorkflowInstanceId(), e);
executionService.terminateWorkflow(task.getWorkflowInstanceId(), "Failed to ack task: " + task.getTaskId());
}
}
Aggregations