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

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

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

Task.getTaskId介绍

暂无

代码示例

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

private void validate(Task task) {
    Preconditions.checkNotNull(task, "task object cannot be null");
    Preconditions.checkNotNull(task.getTaskId(), "Task id cannot be null");
    Preconditions.checkNotNull(task.getWorkflowInstanceId(), "Workflow instance id cannot be null");
    Preconditions.checkNotNull(task.getReferenceTaskName(), "Task reference name cannot be null");
  }
}

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

@Override
public void cancel(Workflow workflow, Task task, WorkflowExecutor provider) {
  Message message = new Message(task.getTaskId(), null, task.getTaskId());
  getQueue(workflow, task).ack(Collections.singletonList(message));
}

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

@Override
public List<Task> getTasks(List<String> taskIds) {
  Preconditions.checkNotNull(taskIds);
  Preconditions.checkArgument(taskIds.size() > 0, "Task ids list cannot be empty");
  String workflowId = lookupWorkflowIdFromTaskId(taskIds.get(0));
  if (workflowId == null) {
    return null;
  }
  return getWorkflow(workflowId, true).getTasks().stream()
      .filter(task -> taskIds.contains(task.getTaskId()))
      .collect(Collectors.toList());
}

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

/**
   * Returns task back to conductor by calling updateTask API without any change to task for error scenarios where
   * worker can't work on the task due to ack failures,  {@code executorService.submit} throwing {@link RejectedExecutionException},
   * etc. This guarantees that task will be picked up by any worker again after task's {@code callbackAfterSeconds}.
   * This is critical especially for tasks without responseTimeoutSeconds setting in which case task will get stuck
   * in IN_PROGRESS status forever when these errors occur if task is not returned.
   */
  private void returnTask(Worker worker, Task task) {
    logger.warn("Returning task {} back to conductor", task.getTaskId());
    updateWithRetry(updateRetryCount, task, new TaskResult(task), worker);
  }
}

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

private void removeTaskLookup(Task task) {
  try {
    recordCassandraDaoRequests("removeTaskLookup", task.getTaskType(), task.getWorkflowType());
    session.execute(deleteTaskLookupStatement.bind(UUID.fromString(task.getTaskId())));
  } catch (Exception e) {
    Monitors.error(CLASS_NAME, "removeTaskLookup");
    String errorMsg = String.format("Failed to remove task lookup: %s", task.getTaskId());
    LOGGER.error(errorMsg, e);
    throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg);
  }
}

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

@Override
public void indexTask(Task task) {
  String taskId = task.getTaskId();
  TaskSummary summary = new TaskSummary(task);
  indexObject(indexName, TASK_DOC_TYPE, taskId, summary);
}

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

public void addTaskToQueue(Task task) {
  // put in queue
  String taskQueueName = QueueUtils.getQueueName(task);
  queueDAO.remove(taskQueueName, task.getTaskId());
  if (task.getCallbackAfterSeconds() > 0) {
    queueDAO.push(taskQueueName, task.getTaskId(), task.getCallbackAfterSeconds());
  } else {
    queueDAO.push(taskQueueName, task.getTaskId(), 0);
  }
  LOGGER.debug("Added task {} to queue {} with call back seconds {}", task, taskQueueName, task.getCallbackAfterSeconds());
}

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

private boolean requeue(Task pending) {
  long callback = pending.getCallbackAfterSeconds();
  if (callback < 0) {
    callback = 0;
  }
  queueDAO.remove(QueueUtils.getQueueName(pending), pending.getTaskId());
  long now = System.currentTimeMillis();
  callback = callback - ((now - pending.getUpdateTime())/1000);
  if(callback < 0) {
    callback = 0;
  }
  return queueDAO.pushIfNotExists(QueueUtils.getQueueName(pending), pending.getTaskId(), callback);
}

代码示例来源: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

private void removeTaskData(Connection connection, Task task) {
  String REMOVE_TASK = "DELETE FROM task WHERE task_id = ?";
  execute(connection, REMOVE_TASK, q -> q.addParameter(task.getTaskId()).executeDelete());
}

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

@VisibleForTesting
boolean addScheduledTask(Connection connection, Task task, String taskKey) {
  final String INSERT_IGNORE_SCHEDULED_TASK = "INSERT IGNORE INTO task_scheduled (workflow_id, task_key, task_id) VALUES (?, ?, ?)";
  int count = query(connection, INSERT_IGNORE_SCHEDULED_TASK, q -> q.addParameter(task.getWorkflowInstanceId())
      .addParameter(taskKey).addParameter(task.getTaskId()).executeUpdate());
  return count > 0;
}

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

private void insertOrUpdateTaskData(Connection connection, Task task) {
  String INSERT_TASK = "INSERT INTO task (task_id, json_data, modified_on) VALUES (?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE json_data=VALUES(json_data), modified_on=VALUES(modified_on)";
  execute(connection, INSERT_TASK, q -> q.addParameter(task.getTaskId()).addJsonParameter(task).executeUpdate());
}

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

private void removeTaskInProgress(Connection connection, Task task) {
  String REMOVE_IN_PROGRESS_TASK = "DELETE FROM task_in_progress WHERE task_def_name = ? AND task_id = ?";
  execute(connection, REMOVE_IN_PROGRESS_TASK,
      q -> q.addParameter(task.getTaskDefName()).addParameter(task.getTaskId()).executeUpdate());
}

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

private void removeWorkflowToTaskMapping(Connection connection, Task task) {
  String REMOVE_WORKFLOW_TO_TASK = "DELETE FROM workflow_to_task WHERE workflow_id = ? AND task_id = ?";
  execute(connection, REMOVE_WORKFLOW_TO_TASK,
      q -> q.addParameter(task.getWorkflowInstanceId()).addParameter(task.getTaskId()).executeDelete());
}

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

private void addWorkflowToTaskMapping(Connection connection, Task task) {
  String INSERT_WORKFLOW_TO_TASK = "INSERT IGNORE INTO workflow_to_task (workflow_id, task_id) VALUES (?, ?)";
  execute(connection, INSERT_WORKFLOW_TO_TASK,
      q -> q.addParameter(task.getWorkflowInstanceId()).addParameter(task.getTaskId()).executeUpdate());
}

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

private void addTaskInProgress(Connection connection, Task task) {
  String EXISTS_IN_PROGRESS_TASK = "SELECT EXISTS(SELECT 1 FROM task_in_progress WHERE task_def_name = ? AND task_id = ?)";
  boolean exist = query(connection, EXISTS_IN_PROGRESS_TASK,
      q -> q.addParameter(task.getTaskDefName()).addParameter(task.getTaskId()).exists());
  if (!exist) {
    String INSERT_IN_PROGRESS_TASK = "INSERT INTO task_in_progress (task_def_name, task_id, workflow_id) VALUES (?, ?, ?)";
    execute(connection, INSERT_IN_PROGRESS_TASK, q -> q.addParameter(task.getTaskDefName())
        .addParameter(task.getTaskId()).addParameter(task.getWorkflowInstanceId()).executeUpdate());
  }
}

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

private void updateInProgressStatus(Connection connection, Task task, boolean inProgress) {
  String UPDATE_IN_PROGRESS_TASK_STATUS = "UPDATE task_in_progress SET in_progress_status = ?, modified_on = CURRENT_TIMESTAMP "
      + "WHERE task_def_name = ? AND task_id = ?";
  execute(connection, UPDATE_IN_PROGRESS_TASK_STATUS, q -> q.addParameter(inProgress)
      .addParameter(task.getTaskDefName()).addParameter(task.getTaskId()).executeUpdate());
}

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

private void printTaskStatuses(Workflow wf, String message) {
    if (printWFTaskDetails) {
      System.out.println(message + " >>> Workflow status " + wf.getStatus().name());
      wf.getTasks().forEach(t -> {
        System.out.println("Task " + String.format("%-15s", t.getTaskType()) + "\t" + String.format("%-15s", t.getReferenceTaskName()) + "\t" + String.format("%-15s", t.getWorkflowTask().getType()) + "\t" + t.getSeq() + "\t" + t.getStatus() + "\t" + t.getTaskId());
      });
      System.out.println();
    }
  }
}

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

public TaskResult(Task task) {
  this.workflowInstanceId = task.getWorkflowInstanceId();
  this.taskId = task.getTaskId();
  this.reasonForIncompletion = task.getReasonForIncompletion();
  this.callbackAfterSeconds = task.getCallbackAfterSeconds();
  this.status = Status.valueOf(task.getStatus().name());
  this.workerId = task.getWorkerId();
  this.outputData = task.getOutputData();
  this.externalOutputPayloadStoragePath = task.getExternalOutputPayloadStoragePath();
}

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

@Override
  public int hashCode() {
    return Objects.hash(getTaskType(), getStatus(), getInputData(), getReferenceTaskName(), getRetryCount(), getSeq(), getCorrelationId(), getPollCount(), getTaskDefName(), getScheduledTime(), getStartTime(), getEndTime(), getUpdateTime(), getStartDelayInSeconds(), getRetriedTaskId(), isRetried(), isExecuted(), isCallbackFromWorker(), getResponseTimeoutSeconds(), getWorkflowInstanceId(), getWorkflowType(), getTaskId(), getReasonForIncompletion(), getCallbackAfterSeconds(), getWorkerId(), getOutputData(), getWorkflowTask(), getDomain(), getInputMessage(), getOutputMessage(), getRateLimitPerFrequency(), getRateLimitFrequencyInSeconds(), getExternalInputPayloadStoragePath(), getExternalOutputPayloadStoragePath());
  }
}

相关文章

Task类方法