本文整理了Java中com.netflix.conductor.common.metadata.tasks.Task.getReferenceTaskName()
方法的一些代码示例,展示了Task.getReferenceTaskName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getReferenceTaskName()
方法的具体详情如下:
包路径:com.netflix.conductor.common.metadata.tasks.Task
类名称:Task
方法名:getReferenceTaskName
暂无
代码示例来源:origin: Netflix/conductor
public Task getPendingTaskByWorkflow(String taskReferenceName, String workflowId) {
return executionDAOFacade.getTasksForWorkflow(workflowId).stream()
.filter(isNonTerminalTask)
.filter(task -> task.getReferenceTaskName().equals(taskReferenceName))
.findFirst() // There can only be one task by a given reference name running at a time.
.orElse(null);
}
代码示例来源:origin: Netflix/conductor
private static String taskKey(Task task) {
return task.getReferenceTaskName() + "_" + task.getRetryCount();
}
代码示例来源: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
@VisibleForTesting
List<Task> dedupAndAddTasks(Workflow workflow, List<Task> tasks) {
List<String> tasksInWorkflow = workflow.getTasks().stream()
.map(task -> task.getReferenceTaskName() + "_" + task.getRetryCount())
.collect(Collectors.toList());
List<Task> dedupedTasks = tasks.stream()
.filter(task -> !tasksInWorkflow.contains(task.getReferenceTaskName() + "_" + task.getRetryCount()))
.collect(Collectors.toList());
workflow.getTasks().addAll(dedupedTasks);
return dedupedTasks;
}
代码示例来源:origin: Netflix/conductor
public Task getTaskByRefName(String refName) {
if (refName == null) {
throw new RuntimeException("refName passed is null. Check the workflow execution. For dynamic tasks, make sure referenceTaskName is set to a not null value");
}
LinkedList<Task> found = new LinkedList<>();
for (Task t : tasks) {
if (t.getReferenceTaskName() == null) {
throw new RuntimeException("Task " + t.getTaskDefName() + ", seq=" + t.getSeq() + " does not have reference name specified.");
}
if (t.getReferenceTaskName().equals(refName)) {
found.add(t);
}
}
if (found.isEmpty()) {
return null;
}
return found.getLast();
}
代码示例来源:origin: Netflix/conductor
/**
*
* @param task
* @throws ApplicationException
*/
private void validate(Task task) {
try {
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");
} catch (NullPointerException npe){
throw new ApplicationException(Code.INVALID_INPUT, npe.getMessage(), npe);
}
}
}
代码示例来源:origin: Netflix/conductor
@VisibleForTesting
void validateTasks(List<Task> tasks) {
Preconditions.checkNotNull(tasks, "Tasks object cannot be null");
Preconditions.checkArgument(!tasks.isEmpty(), "Tasks object cannot be empty");
tasks.forEach(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");
});
String workflowId = tasks.get(0).getWorkflowInstanceId();
Optional<Task> optionalTask = tasks.stream()
.filter(task -> !workflowId.equals(task.getWorkflowInstanceId()))
.findAny();
if (optionalTask.isPresent()) {
throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, "Tasks of multiple workflows cannot be created/updated simultaneously");
}
}
代码示例来源:origin: Netflix/conductor
private boolean checkForWorkflowCompletion(final Workflow workflow) throws TerminateWorkflowException {
List<Task> allTasks = workflow.getTasks();
if (allTasks.isEmpty()) {
return false;
}
Map<String, Status> taskStatusMap = new HashMap<>();
workflow.getTasks().forEach(task -> taskStatusMap.put(task.getReferenceTaskName(), task.getStatus()));
List<WorkflowTask> workflowTasks = workflow.getWorkflowDefinition().getTasks();
boolean allCompletedSuccessfully = workflowTasks.stream().parallel().allMatch(wftask -> {
Status status = taskStatusMap.get(wftask.getTaskReferenceName());
return status != null && status.isSuccessful() && status.isTerminal();
});
boolean noPendingTasks = taskStatusMap.values()
.stream()
.allMatch(Status::isTerminal);
boolean noPendingSchedule = workflow.getTasks().stream().parallel().filter(wftask -> {
String next = getNextTasksToBeScheduled(workflow, wftask);
return next != null && !taskStatusMap.containsKey(next);
}).collect(Collectors.toList()).isEmpty();
return allCompletedSuccessfully && noPendingTasks && noPendingSchedule;
}
代码示例来源:origin: Netflix/conductor
@VisibleForTesting
List<Task> getNextTask(Workflow workflow, Task task) {
final WorkflowDef workflowDef = workflow.getWorkflowDefinition();
// Get the following task after the last completed task
if (SystemTaskType.is(task.getTaskType()) && SystemTaskType.DECISION.name().equals(task.getTaskType())) {
if (task.getInputData().get("hasChildren") != null) {
return Collections.emptyList();
}
}
String taskReferenceName = task.getReferenceTaskName();
WorkflowTask taskToSchedule = workflowDef.getNextTask(taskReferenceName);
while (isTaskSkipped(taskToSchedule, workflow)) {
taskToSchedule = workflowDef.getNextTask(taskToSchedule.getTaskReferenceName());
}
if (taskToSchedule != null) {
return getTasksToBeScheduled(workflow, taskToSchedule, 0);
}
return Collections.emptyList();
}
代码示例来源:origin: Netflix/conductor
queueName = sinkValue + ":" + workflow.getWorkflowName() + ":" + task.getReferenceTaskName();
} else if(sinkValue.startsWith("conductor:")) {
queueName = sinkValue.replaceAll("conductor:", "");
代码示例来源:origin: Netflix/conductor
@Override
public List<Task> createTasks(List<Task> tasks) {
List<Task> created = Lists.newArrayListWithCapacity(tasks.size());
withTransaction(connection -> {
for (Task task : tasks) {
validate(task);
task.setScheduledTime(System.currentTimeMillis());
final String taskKey = taskKey(task);
boolean scheduledTaskAdded = addScheduledTask(connection, task, taskKey);
if (!scheduledTaskAdded) {
logger.trace("Task already scheduled, skipping the run " + task.getTaskId() + ", ref="
+ task.getReferenceTaskName() + ", key=" + taskKey);
continue;
}
insertOrUpdateTaskData(connection, task);
addWorkflowToTaskMapping(connection, task);
addTaskInProgress(connection, task);
updateTask(connection, task);
created.add(task);
}
});
return created;
}
代码示例来源:origin: Netflix/conductor
private String getNextTasksToBeScheduled(Workflow workflow, Task task) {
final WorkflowDef def = workflow.getWorkflowDefinition();
String taskReferenceName = task.getReferenceTaskName();
WorkflowTask taskToSchedule = def.getNextTask(taskReferenceName);
while (isTaskSkipped(taskToSchedule, workflow)) {
taskToSchedule = def.getNextTask(taskToSchedule.getTaskReferenceName());
}
return taskToSchedule == null ? null : taskToSchedule.getTaskReferenceName();
}
代码示例来源: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
.filter(task -> !inProgressTasks.contains(task.getReferenceTaskName()))
.collect(Collectors.toList());
tasks.forEach(task -> externalPayloadStorageUtils.verifyAndUpload(task, ExternalPayloadStorage.PayloadType.TASK_INPUT));
代码示例来源: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
Workflow workflow = workflowExecutionService.getExecutionStatus(wfid, true);
for (Task x : workflow.getTasks()) {
System.out.println(x.getTaskType() + "/" + x.getReferenceTaskName());
代码示例来源:origin: Netflix/conductor
@Test
public void testGetTasksToBeScheduled() {
WorkflowDef workflowDef = createLinearWorkflow();
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(workflowDef);
workflow.setStatus(WorkflowStatus.RUNNING);
WorkflowTask workflowTask1 = new WorkflowTask();
workflowTask1.setName("s1");
workflowTask1.setTaskReferenceName("s1");
workflowTask1.setType(TaskType.SIMPLE.name());
workflowTask1.setTaskDefinition(new TaskDef("s1"));
List<Task> tasksToBeScheduled = deciderService.getTasksToBeScheduled(workflow, workflowTask1, 0, null);
assertNotNull(tasksToBeScheduled);
assertEquals(1, tasksToBeScheduled.size());
assertEquals("s1", tasksToBeScheduled.get(0).getReferenceTaskName());
WorkflowTask workflowTask2 = new WorkflowTask();
workflowTask2.setName("s2");
workflowTask2.setTaskReferenceName("s2");
workflowTask2.setType(TaskType.SIMPLE.name());
workflowTask2.setTaskDefinition(new TaskDef("s2"));
tasksToBeScheduled = deciderService.getTasksToBeScheduled(workflow, workflowTask2, 0, null);
assertNotNull(tasksToBeScheduled);
assertEquals(1, tasksToBeScheduled.size());
assertEquals("s2", tasksToBeScheduled.get(0).getReferenceTaskName());
}
代码示例来源: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
@Test
public void testDecideFailedTask() {
WorkflowDef workflowDef = createLinearWorkflow();
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(workflowDef);
workflow.setStatus(WorkflowStatus.RUNNING);
Task task = new Task();
task.setTaskType("junit_task_l1");
task.setReferenceTaskName("s1");
task.setSeq(1);
task.setRetried(false);
task.setExecuted(false);
task.setStatus(Status.FAILED);
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setTaskReferenceName("s1");
workflowTask.setName("junit_task_l1");
workflowTask.setTaskDefinition(new TaskDef("junit_task_l1"));
task.setWorkflowTask(workflowTask);
workflow.getTasks().add(task);
DeciderOutcome deciderOutcome = deciderService.decide(workflow);
assertNotNull(deciderOutcome);
assertFalse(workflow.getTaskByRefName("s1").isExecuted());
assertTrue(workflow.getTaskByRefName("s1").isRetried());
assertEquals(1, deciderOutcome.tasksToBeUpdated.size());
assertEquals("s1", deciderOutcome.tasksToBeUpdated.get(0).getReferenceTaskName());
assertEquals(1, deciderOutcome.tasksToBeScheduled.size());
assertEquals("s1", deciderOutcome.tasksToBeScheduled.get(0).getReferenceTaskName());
assertEquals(0, deciderOutcome.tasksToBeRequeued.size());
assertFalse(deciderOutcome.isComplete);
}
内容来源于网络,如有侵权,请联系作者删除!