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

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

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

Task.getWorkflowType介绍

暂无

代码示例

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

@Override
public List<Task> getTasks(List<String> taskIds) {
  return taskIds.stream()
      .map(taskId -> nsKey(TASK, taskId))
      .map(dynoClient::get)
      .filter(Objects::nonNull)
      .map(jsonString -> {
        Task task = readValue(jsonString, Task.class);
        recordRedisDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
        recordRedisDaoPayloadSize("getTask", jsonString.length(), task.getTaskType(), task.getWorkflowType());
        return task;
      })
      .collect(Collectors.toList());
}

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

@Override
public Task getTask(String taskId) {
  Preconditions.checkNotNull(taskId, "taskId cannot be null");
  return Optional.ofNullable(dynoClient.get(nsKey(TASK, taskId)))
      .map(json -> {
        Task task = readValue(json, Task.class);
        recordRedisDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
        recordRedisDaoPayloadSize("getTask", toJson(task).length(), task.getTaskType(), task.getWorkflowType());
        return task;
      })
      .orElse(null);
}

代码示例来源: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 Task getTask(String taskId) {
  try {
    String workflowId = lookupWorkflowIdFromTaskId(taskId);
    if (workflowId == null) {
      return null;
    }
    // TODO: implement for query against multiple shards
    ResultSet resultSet = session.execute(selectTaskStatement.bind(UUID.fromString(workflowId), DEFAULT_SHARD_ID, taskId));
    return Optional.ofNullable(resultSet.one())
        .map(row -> {
          Task task = readValue(row.getString(PAYLOAD_KEY), Task.class);
          recordCassandraDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
          recordCassandraDaoPayloadSize("getTask", toJson(task).length(), task.getTaskType(), task.getWorkflowType());
          return task;
        })
        .orElse(null);
  } catch (Exception e) {
    Monitors.error(CLASS_NAME, "getTask");
    String errorMsg = String.format("Error getting task by id: %s", taskId);
    LOGGER.error(errorMsg, e);
    throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg);
  }
}

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

@Override
public void updateTask(Task task) {
  try {
    task.setUpdateTime(System.currentTimeMillis());
    if (task.getStatus().isTerminal() && task.getEndTime() == 0) {
      task.setEndTime(System.currentTimeMillis());
    }
    // TODO: calculate the shard number the task belongs to
    String taskPayload = toJson(task);
    recordCassandraDaoRequests("updateTask", task.getTaskType(), task.getWorkflowType());
    recordCassandraDaoPayloadSize("updateTask", taskPayload.length(), task.getTaskType(), task.getWorkflowType());
    session.execute(insertTaskStatement.bind(UUID.fromString(task.getWorkflowInstanceId()), DEFAULT_SHARD_ID, task.getTaskId(), taskPayload));
  } catch (Exception e) {
    Monitors.error(CLASS_NAME, "updateTask");
    String errorMsg = String.format("Error updating task: %s in workflow: %s", task.getTaskId(), task.getWorkflowInstanceId());
    LOGGER.error(errorMsg, e);
    throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg, e);
  }
}

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

String taskPayload = toJson(task);
  batchStatement.add(insertTaskStatement.bind(UUID.fromString(workflowId), DEFAULT_SHARD_ID, task.getTaskId(), taskPayload));
  recordCassandraDaoRequests("createTask", task.getTaskType(), task.getWorkflowType());
  recordCassandraDaoPayloadSize("createTask", taskPayload.length(), task.getTaskType(), task.getWorkflowType());
});
batchStatement.add(updateTotalTasksStatement.bind(totalTasks, UUID.fromString(workflowId), DEFAULT_SHARD_ID));

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

this.taskType = task.getTaskType();
this.workflowId = task.getWorkflowInstanceId();
this.workflowType = task.getWorkflowType();
this.correlationId = task.getCorrelationId();
this.scheduledTime = sdf.format(new Date(task.getScheduledTime()));

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

private boolean removeTask(Task task) {
  // TODO: calculate shard number based on seq and maxTasksPerShard
  try {
    // get total tasks for this workflow
    WorkflowMetadata workflowMetadata = getWorkflowMetadata(task.getWorkflowInstanceId());
    int totalTasks = workflowMetadata.getTotalTasks();
    // remove from task_lookup table
    removeTaskLookup(task);
    recordCassandraDaoRequests("removeTask", task.getTaskType(), task.getWorkflowType());
    // delete task from workflows table and decrement total tasks by 1
    BatchStatement batchStatement = new BatchStatement();
    batchStatement.add(deleteTaskStatement.bind(UUID.fromString(task.getWorkflowInstanceId()), DEFAULT_SHARD_ID, task.getTaskId()));
    batchStatement.add(updateTotalTasksStatement.bind(totalTasks - 1, UUID.fromString(task.getWorkflowInstanceId()), DEFAULT_SHARD_ID));
    ResultSet resultSet = session.execute(batchStatement);
    return resultSet.wasApplied();
  } catch (Exception e) {
    Monitors.error(CLASS_NAME, "removeTask");
    String errorMsg = String.format("Failed to remove task: %s", task.getTaskId());
    LOGGER.error(errorMsg, e);
    throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg);
  }
}

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

String taskId = task.getTaskId();
dynoClient.zaddnx(rateLimitKey, score, taskId);
recordRedisDaoRequests("checkTaskRateLimiting", task.getTaskType(), task.getWorkflowType());

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

Objects.equals(getRetriedTaskId(), task.getRetriedTaskId()) &&
Objects.equals(getWorkflowInstanceId(), task.getWorkflowInstanceId()) &&
Objects.equals(getWorkflowType(), task.getWorkflowType()) &&
Objects.equals(getTaskId(), task.getTaskId()) &&
Objects.equals(getReasonForIncompletion(), task.getReasonForIncompletion()) &&

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

@Override
public List<Task> createTasks(List<Task> tasks) {
  List<Task> tasksCreated = new LinkedList<>();
  for (Task task : tasks) {
    validate(task);
    recordRedisDaoRequests("createTask", task.getTaskType(), task.getWorkflowType());
    String taskKey = task.getReferenceTaskName() + "" + task.getRetryCount();
    Long added = dynoClient.hset(nsKey(SCHEDULED_TASKS, task.getWorkflowInstanceId()), taskKey, task.getTaskId());
    if (added < 1) {
      logger.debug("Task already scheduled, skipping the run " + task.getTaskId() + ", ref=" + task.getReferenceTaskName() + ", key=" + taskKey);
      continue;
    }
    task.setScheduledTime(System.currentTimeMillis());
    correlateTaskToWorkflowInDS(task.getTaskId(), task.getWorkflowInstanceId());
    logger.debug("Scheduled task added to WORKFLOW_TO_TASKS workflowId: {}, taskId: {}, taskType: {} during createTasks",
        task.getWorkflowInstanceId(), task.getTaskId(), task.getTaskType());
    String inProgressTaskKey = nsKey(IN_PROGRESS_TASKS, task.getTaskDefName());
    dynoClient.sadd(inProgressTaskKey, task.getTaskId());
    logger.debug("Scheduled task added to IN_PROGRESS_TASKS with inProgressTaskKey: {}, workflowId: {}, taskId: {}, taskType: {} during createTasks",
        inProgressTaskKey, task.getWorkflowInstanceId(), task.getTaskId(), task.getTaskType());
    updateTask(task);
    tasksCreated.add(task);
  }
  return tasksCreated;
}

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

recordRedisDaoPayloadSize("updateTask", payload.length(), taskDefinition
    .map(TaskDef::getName)
    .orElse("n/a"), task.getWorkflowType());
recordRedisDaoRequests("updateTask", task.getTaskType(), task.getWorkflowType());
dynoClient.set(nsKey(TASK, task.getTaskId()), payload);
logger.debug("Workflow task payload saved to TASK with taskKey: {}, workflowId: {}, taskId: {}, taskType: {} during updateTask",

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

@Override
public boolean removeTask(String taskId) {
  Task task = getTask(taskId);
  if(task == null) {
    logger.warn("No such task found by id {}", taskId);
    return false;
  }
  String taskKey = task.getReferenceTaskName() + "" + task.getRetryCount();
  dynoClient.hdel(nsKey(SCHEDULED_TASKS, task.getWorkflowInstanceId()), taskKey);
  dynoClient.srem(nsKey(IN_PROGRESS_TASKS, task.getTaskDefName()), task.getTaskId());
  dynoClient.srem(nsKey(WORKFLOW_TO_TASKS, task.getWorkflowInstanceId()), task.getTaskId());
  dynoClient.srem(nsKey(TASKS_IN_PROGRESS_STATUS, task.getTaskDefName()), task.getTaskId());
  dynoClient.del(nsKey(TASK, task.getTaskId()));
  dynoClient.zrem(nsKey(TASK_LIMIT_BUCKET, task.getTaskDefName()), task.getTaskId());
  recordRedisDaoRequests("removeTask", task.getTaskType(), task.getWorkflowType());
  return true;
}

代码示例来源: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());
  }
}

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

to.setWorkflowInstanceId( from.getWorkflowInstanceId() );
if (from.getWorkflowType() != null) {
  to.setWorkflowType( from.getWorkflowType() );

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public List<Task> getTasks(List<String> taskIds) {
  return taskIds.stream()
      .map(taskId -> nsKey(TASK, taskId))
      .map(dynoClient::get)
      .filter(Objects::nonNull)
      .map(jsonString -> {
        Task task = readValue(jsonString, Task.class);
        recordRedisDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
        recordRedisDaoPayloadSize("getTask", jsonString.length(), task.getTaskType(), task.getWorkflowType());
        return task;
      })
      .collect(Collectors.toList());
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public Task getTask(String taskId) {
  Preconditions.checkNotNull(taskId, "taskId cannot be null");
  return Optional.ofNullable(dynoClient.get(nsKey(TASK, taskId)))
      .map(json -> {
        Task task = readValue(json, Task.class);
        recordRedisDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
        recordRedisDaoPayloadSize("getTask", toJson(task).length(), task.getTaskType(), task.getWorkflowType());
        return task;
      })
      .orElse(null);
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public List<Task> createTasks(List<Task> tasks) {
  List<Task> tasksCreated = new LinkedList<>();
  for (Task task : tasks) {
    validate(task);
    recordRedisDaoRequests("createTask", task.getTaskType(), task.getWorkflowType());
    String taskKey = task.getReferenceTaskName() + "" + task.getRetryCount();
    Long added = dynoClient.hset(nsKey(SCHEDULED_TASKS, task.getWorkflowInstanceId()), taskKey, task.getTaskId());
    if (added < 1) {
      logger.debug("Task already scheduled, skipping the run " + task.getTaskId() + ", ref=" + task.getReferenceTaskName() + ", key=" + taskKey);
      continue;
    }
    task.setScheduledTime(System.currentTimeMillis());
    correlateTaskToWorkflowInDS(task.getTaskId(), task.getWorkflowInstanceId());
    logger.debug("Scheduled task added to WORKFLOW_TO_TASKS workflowId: {}, taskId: {}, taskType: {} during createTasks",
        task.getWorkflowInstanceId(), task.getTaskId(), task.getTaskType());
    String inProgressTaskKey = nsKey(IN_PROGRESS_TASKS, task.getTaskDefName());
    dynoClient.sadd(inProgressTaskKey, task.getTaskId());
    logger.debug("Scheduled task added to IN_PROGRESS_TASKS with inProgressTaskKey: {}, workflowId: {}, taskId: {}, taskType: {} during createTasks",
        inProgressTaskKey, task.getWorkflowInstanceId(), task.getTaskId(), task.getTaskType());
    updateTask(task);
    tasksCreated.add(task);
  }
  return tasksCreated;
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public boolean removeTask(String taskId) {
  Task task = getTask(taskId);
  if(task == null) {
    logger.warn("No such task found by id {}", taskId);
    return false;
  }
  String taskKey = task.getReferenceTaskName() + "" + task.getRetryCount();
  dynoClient.hdel(nsKey(SCHEDULED_TASKS, task.getWorkflowInstanceId()), taskKey);
  dynoClient.srem(nsKey(IN_PROGRESS_TASKS, task.getTaskDefName()), task.getTaskId());
  dynoClient.srem(nsKey(WORKFLOW_TO_TASKS, task.getWorkflowInstanceId()), task.getTaskId());
  dynoClient.srem(nsKey(TASKS_IN_PROGRESS_STATUS, task.getTaskDefName()), task.getTaskId());
  dynoClient.del(nsKey(TASK, task.getTaskId()));
  dynoClient.zrem(nsKey(TASK_LIMIT_BUCKET, task.getTaskDefName()), task.getTaskId());
  recordRedisDaoRequests("removeTask", task.getTaskType(), task.getWorkflowType());
  return true;
}

代码示例来源:origin: com.netflix.conductor/conductor-common

@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类方法