com.netflix.conductor.common.metadata.tasks.Task.setReasonForIncompletion()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中com.netflix.conductor.common.metadata.tasks.Task.setReasonForIncompletion()方法的一些代码示例,展示了Task.setReasonForIncompletion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.setReasonForIncompletion()方法的具体详情如下:
包路径:com.netflix.conductor.common.metadata.tasks.Task
类名称:Task
方法名:setReasonForIncompletion

Task.setReasonForIncompletion介绍

暂无

代码示例

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("Missing '" + QUERY_EXPRESSION_PARAMETER + "' in input parameters");
task.setStatus(Task.Status.FAILED);
return;
logger.error(e.getMessage(), e);
task.setStatus(Task.Status.FAILED);
task.setReasonForIncompletion(e.getMessage());
taskOutput.put("error", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());

代码示例来源:origin: Netflix/conductor

@VisibleForTesting
void failTask(Task task, PayloadType payloadType, String errorMsg) {
  logger.error(errorMsg);
  task.setReasonForIncompletion(errorMsg);
  task.setStatus(Task.Status.FAILED_WITH_TERMINAL_ERROR);
  if (payloadType == PayloadType.TASK_INPUT) {
    task.setInputData(null);
  } else {
    task.setOutputData(null);
  }
  throw new TerminateWorkflowException(errorMsg, Workflow.WorkflowStatus.FAILED, task);
}

代码示例来源:origin: Netflix/conductor

private void timeoutTask(TaskDef taskDef, Task task) {
  String reason = "responseTimeout: " + taskDef.getResponseTimeoutSeconds() + " exceeded for the taskId: " + task.getTaskId() + " with Task Definition: " + task.getTaskDefName();
  LOGGER.debug(reason);
  task.setStatus(TIMED_OUT);
  task.setReasonForIncompletion(reason);
}

代码示例来源:origin: Netflix/conductor

@SuppressWarnings("unchecked")
@Override
public void start(Workflow workflow, Task task, WorkflowExecutor provider) {
  Map<String, Object> input = task.getInputData();
  String name = input.get("subWorkflowName").toString();
  int version = (int) input.get("subWorkflowVersion");
  Map<String, Object> wfInput = (Map<String, Object>) input.get("workflowInput");
  if (wfInput == null || wfInput.isEmpty()) {
    wfInput = input;
  }
  String correlationId = workflow.getCorrelationId();
  
  try {
    String subWorkflowId = provider.startWorkflow(name, version, wfInput, null, correlationId, workflow.getWorkflowId(), task.getTaskId(), null, workflow.getTaskToDomain());
    task.getOutputData().put(SUB_WORKFLOW_ID, subWorkflowId);
    task.getInputData().put(SUB_WORKFLOW_ID, subWorkflowId);
    task.setStatus(Status.IN_PROGRESS);
  } catch (Exception e) {
    task.setStatus(Status.FAILED);
    task.setReasonForIncompletion(e.getMessage());
    logger.error(e.getMessage(), e);
  }
}

代码示例来源:origin: Netflix/conductor

if (task.getInputData().get("sink") == null) {
  task.setStatus(Status.FAILED);
  task.setReasonForIncompletion("No sink specified in task");
  return null;
  } else {
    task.setStatus(Status.FAILED);
    task.setReasonForIncompletion("Invalid / Unsupported sink specified: " + sinkValue);
    return null;
  logger.error("Error setting up queue: {} for task:{}, workflow:{}", queueName, task.getTaskId(), workflow.getWorkflowId(), e);
  task.setStatus(Status.FAILED);
  task.setReasonForIncompletion("Error when trying to access the specified queue/topic: " + sinkValue + ", error: " + e.getMessage());
  return null;

代码示例来源:origin: Netflix/conductor

task.setWorkerId(config.getServerId());
if(request == null) {
  task.setReasonForIncompletion(MISSING_REQUEST);
  task.setStatus(Status.FAILED);
  return;
if(input.getUri() == null) {
  String reason = "Missing HTTP URI.  See documentation for HttpTask for required input parameters";
  task.setReasonForIncompletion(reason);
  task.setStatus(Status.FAILED);
  return;
  task.setReasonForIncompletion(reason);
  task.setStatus(Status.FAILED);
  return;
  } else {
    if(response.body != null) {
      task.setReasonForIncompletion(response.body.toString());
    } else {
      task.setReasonForIncompletion("No response from the remote service");
  logger.error(String.format("Failed to invoke http task - uri: %s, vipAddress: %s", input.getUri(), input.getVipAddress()), e);
  task.setStatus(Status.FAILED);
  task.setReasonForIncompletion("Failed to invoke http task due to: " + e.toString());
  task.getOutputData().put("response", e.toString());

代码示例来源:origin: Netflix/conductor

@Override
public void start(Workflow workflow, Task task, WorkflowExecutor provider) {
  Map<String, Object> payload = new HashMap<>(task.getInputData());
  payload.put("workflowInstanceId", workflow.getWorkflowId());
  payload.put("workflowType", workflow.getWorkflowName());
  payload.put("workflowVersion", workflow.getWorkflowVersion());
  payload.put("correlationId", workflow.getCorrelationId());
  String payloadJson;
  try {
    payloadJson = objectMapper.writeValueAsString(payload);
  } catch (JsonProcessingException e) {
    String msg = String.format("Error serializing JSON payload for task: %s, workflow: %s", task.getTaskId(), workflow.getWorkflowId());
    throw new ApplicationException(INTERNAL_ERROR, msg);
  }
  Message message = new Message(task.getTaskId(), payloadJson, task.getTaskId());
  ObservableQueue queue = getQueue(workflow, task);
  if(queue != null) {
    queue.publish(Collections.singletonList(message));
    task.getOutputData().putAll(payload);
    task.setStatus(Status.COMPLETED);
  } else {
    task.setReasonForIncompletion("No queue found to publish.");
    task.setStatus(Status.FAILED);
  }
}

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion(failureReason.toString());
  task.setStatus(Status.FAILED);
}else{

代码示例来源:origin: Netflix/conductor

@Override
public boolean execute(Workflow workflow, Task task, WorkflowExecutor provider) {
  String workflowId = (String) task.getOutputData().get(SUB_WORKFLOW_ID);
  if (workflowId == null) {
    workflowId = (String) task.getInputData().get(SUB_WORKFLOW_ID);    //Backward compatibility
  }
  
  if(StringUtils.isEmpty(workflowId)) {
    return false;
  }
  
  Workflow subWorkflow = provider.getWorkflow(workflowId, false);
  WorkflowStatus subWorkflowStatus = subWorkflow.getStatus();
  if(!subWorkflowStatus.isTerminal()){
    return false;
  }
  task.getOutputData().putAll(subWorkflow.getOutput());
  if (subWorkflowStatus.isSuccessful()) {
    task.setStatus(Status.COMPLETED);
  } else {
    task.setReasonForIncompletion(subWorkflow.getReasonForIncompletion());
    task.setStatus(Status.FAILED);
  }
  return true;
}

代码示例来源:origin: Netflix/conductor

@VisibleForTesting
void checkForTimeout(TaskDef taskDef, Task task) {
  if (taskDef == null) {
    LOGGER.warn("missing task type " + task.getTaskDefName() + ", workflowId=" + task.getWorkflowInstanceId());
    return;
  }
  if (task.getStatus().isTerminal() || taskDef.getTimeoutSeconds() <= 0 || !task.getStatus().equals(IN_PROGRESS)) {
    return;
  }
  long timeout = 1000L * taskDef.getTimeoutSeconds();
  long now = System.currentTimeMillis();
  long elapsedTime = now - (task.getStartTime() + ((long) task.getStartDelayInSeconds() * 1000L));
  if (elapsedTime < timeout) {
    return;
  }
  String reason = "Task timed out after " + elapsedTime + " millisecond.  Timeout configured as " + timeout;
  Monitors.recordTaskTimeout(task.getTaskDefName());
  switch (taskDef.getTimeoutPolicy()) {
    case ALERT_ONLY:
      return;
    case RETRY:
      task.setStatus(TIMED_OUT);
      task.setReasonForIncompletion(reason);
      return;
    case TIME_OUT_WF:
      task.setStatus(TIMED_OUT);
      task.setReasonForIncompletion(reason);
      throw new TerminateWorkflowException(reason, WorkflowStatus.TIMED_OUT, task);
  }
}

代码示例来源:origin: Netflix/conductor

rescheduled.setInputData(new HashMap<>());
rescheduled.getInputData().putAll(task.getInputData());
rescheduled.setReasonForIncompletion(null);

代码示例来源:origin: Netflix/conductor

to.setWorkflowType( from.getWorkflowType() );
to.setTaskId( from.getTaskId() );
to.setReasonForIncompletion( from.getReasonForIncompletion() );
to.setCallbackAfterSeconds( from.getCallbackAfterSeconds() );
to.setWorkerId( from.getWorkerId() );

代码示例来源:origin: Netflix/conductor

@Test
public void indexTask() throws Exception {
  String correlationId = "some-correlation-id";
  Task task = new Task();
  task.setTaskId("some-task-id");
  task.setWorkflowInstanceId("some-workflow-instance-id");
  task.setTaskType("some-task-type");
  task.setStatus(Status.FAILED);
  task.setInputData(new HashMap<String, Object>() {{ put("input_key", "input_value"); }});
  task.setCorrelationId(correlationId);
  task.setTaskDefName("some-task-def-name");
  task.setReasonForIncompletion("some-failure-reason");
  indexDAO.indexTask(task);
  await()
      .atMost(5, TimeUnit.SECONDS)
      .untilAsserted(() -> {
        SearchResult<String> result = indexDAO
            .searchTasks("correlationId='" + correlationId + "'", "*", 0, 10000, null);
        assertTrue("should return 1 or more search results", result.getResults().size() > 0);
        assertEquals("taskId should match the indexed task", "some-task-id", result.getResults().get(0));
      });
}

代码示例来源:origin: Netflix/conductor

@Test
public void indexTask() throws Exception {
  String correlationId = "some-correlation-id";
  Task task = new Task();
  task.setTaskId("some-task-id");
  task.setWorkflowInstanceId("some-workflow-instance-id");
  task.setTaskType("some-task-type");
  task.setStatus(Status.FAILED);
  task.setInputData(new HashMap<String, Object>() {{ put("input_key", "input_value"); }});
  task.setCorrelationId(correlationId);
  task.setTaskDefName("some-task-def-name");
  task.setReasonForIncompletion("some-failure-reason");
  indexDAO.indexTask(task);
  await()
      .atMost(5, TimeUnit.SECONDS)
      .untilAsserted(() -> {
        SearchResult<String> result = indexDAO
            .searchTasks("correlationId='" + correlationId + "'", "*", 0, 10000, null);
        assertTrue("should return 1 or more search results", result.getResults().size() > 0);
        assertEquals("taskId should match the indexed task", "some-task-id", result.getResults().get(0));
      });
}

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);

代码示例来源:origin: Netflix/conductor

private void verify(String inputParam1, String wfid, String task1Op, boolean fail) {
  Task task = workflowExecutionService.poll("junit_task_2", "task2.junit.worker");
  assertNotNull(task);
  assertTrue(workflowExecutionService.ackTaskReceived(task.getTaskId()));
  String task2Input = (String) task.getInputData().get("tp2");
  assertNotNull(task2Input);
  assertEquals(task1Op, task2Input);
  task2Input = (String) task.getInputData().get("tp1");
  assertNotNull(task2Input);
  assertEquals(inputParam1, task2Input);
  if (fail) {
    task.setStatus(FAILED);
    task.setReasonForIncompletion("failure...0");
  } else {
    task.setStatus(COMPLETED);
  }
  workflowExecutionService.updateTask(task);
  Workflow es = workflowExecutionService.getExecutionStatus(wfid, false);
  assertNotNull(es);
  if (fail) {
    assertEquals(RUNNING, es.getStatus());
  } else {
    assertEquals(WorkflowStatus.COMPLETED, es.getStatus());
  }
}

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);
task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);

代码示例来源:origin: Netflix/conductor

task.setReasonForIncompletion("unit test failure");
workflowExecutionService.updateTask(task);

相关文章

Task类方法