本文整理了Java中com.netflix.conductor.common.metadata.tasks.Task.getTaskDefName()
方法的一些代码示例,展示了Task.getTaskDefName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getTaskDefName()
方法的具体详情如下:
包路径:com.netflix.conductor.common.metadata.tasks.Task
类名称:Task
方法名:getTaskDefName
暂无
代码示例来源: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
@Override
public boolean exceedsInProgressLimit(Task task) {
Optional<TaskDef> taskDefinition = task.getTaskDefinition();
if (!taskDefinition.isPresent()) {
return false;
}
TaskDef taskDef = taskDefinition.get();
int limit = taskDef.concurrencyLimit();
if (limit <= 0) {
return false;
}
long current = getInProgressTaskCount(task.getTaskDefName());
if (current >= limit) {
Monitors.recordTaskConcurrentExecutionLimited(task.getTaskDefName(), limit);
return true;
}
logger.info("Task execution count for {}: limit={}, current={}", task.getTaskDefName(), limit,
getInProgressTaskCount(task.getTaskDefName()));
String taskId = task.getTaskId();
List<String> tasksInProgressInOrderOfArrival = findAllTasksInProgressInOrderOfArrival(task, limit);
boolean rateLimited = !tasksInProgressInOrderOfArrival.contains(taskId);
if (rateLimited) {
logger.info("Task execution count limited. {}, limit {}, current {}", task.getTaskDefName(), limit,
getInProgressTaskCount(task.getTaskDefName()));
Monitors.recordTaskConcurrentExecutionLimited(task.getTaskDefName(), limit);
}
return rateLimited;
}
代码示例来源: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
long current = getInProgressTaskCount(task.getTaskDefName());
if(current >= limit) {
logger.info("Task execution count limited. task - {}:{}, limit: {}, current: {}", task.getTaskId(), task.getTaskDefName(), limit, current);
Monitors.recordTaskConcurrentExecutionLimited(task.getTaskDefName(), limit);
return true;
String rateLimitKey = nsKey(TASK_LIMIT_BUCKET, task.getTaskDefName());
double score = System.currentTimeMillis();
String taskId = task.getTaskId();
boolean rateLimited = !ids.contains(taskId);
if(rateLimited) {
logger.info("Task execution count limited. task - {}:{}, limit: {}, current: {}", task.getTaskId(), task.getTaskDefName(), limit, current);
String inProgressKey = nsKey(TASKS_IN_PROGRESS_STATUS, task.getTaskDefName());
Monitors.recordTaskRateLimited(task.getTaskDefName(), limit);
代码示例来源:origin: Netflix/conductor
private List<String> findAllTasksInProgressInOrderOfArrival(Task task, int limit) {
String GET_IN_PROGRESS_TASKS_WITH_LIMIT = "SELECT task_id FROM task_in_progress WHERE task_def_name = ? ORDER BY id LIMIT ?";
return queryWithTransaction(GET_IN_PROGRESS_TASKS_WITH_LIMIT,
q -> q.addParameter(task.getTaskDefName()).addParameter(limit).executeScalarList(String.class));
}
代码示例来源:origin: Netflix/conductor
private void updateWithRetry(int count, Task task, TaskResult result, Worker worker) {
try {
String description = String.format("Retry updating task result: %s for task: %s in worker: %s", result.toString(), task.getTaskDefName(), worker.getIdentity());
String methodName = "updateWithRetry";
new RetryUtil<>().retryOnException(() ->
{
taskClient.updateTask(result, task.getTaskType());
return null;
}, null, null, count, description, methodName);
} catch (Exception e) {
worker.onErrorUpdate(task);
WorkflowTaskMetrics.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);
}
}
代码示例来源: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
this.taskDefName = task.getTaskDefName();
this.taskType = task.getTaskType();
this.workflowId = task.getWorkflowInstanceId();
代码示例来源:origin: Netflix/conductor
/**
* Populates the task input from external payload storage if the external storage path is specified.
*
* @param task the task for which the input is to be populated.
*/
private void populateTaskInput(Task task) {
if (StringUtils.isNotBlank(task.getExternalInputPayloadStoragePath())) {
WorkflowTaskMetrics.incrementExternalPayloadUsedCount(task.getTaskDefName(), ExternalPayloadStorage.Operation.READ.name(), ExternalPayloadStorage.PayloadType.TASK_INPUT.name());
task.setInputData(downloadFromExternalStorage(ExternalPayloadStorage.PayloadType.TASK_INPUT, task.getExternalInputPayloadStoragePath()));
task.setExternalInputPayloadStoragePath(null);
}
}
代码示例来源:origin: Netflix/conductor
/**
* Updates the workflow output.
*
* @param workflow the workflow instance
* @param task if not null, the output of this task will be copied to workflow output if no output parameters are specified in the workflow defintion
* if null, the output of the last task in the workflow will be copied to workflow output of no output parameters are specified in the workflow definition
*/
void updateWorkflowOutput(final Workflow workflow, @Nullable Task task) {
List<Task> allTasks = workflow.getTasks();
if (allTasks.isEmpty()) {
return;
}
Task last = Optional.ofNullable(task).orElse(allTasks.get(allTasks.size() - 1));
WorkflowDef workflowDef = workflow.getWorkflowDefinition();
Map<String, Object> output;
if (workflowDef.getOutputParameters() != null && !workflowDef.getOutputParameters().isEmpty()) {
Workflow workflowInstance = populateWorkflowAndTaskData(workflow);
output = parametersUtils.getTaskInput(workflowDef.getOutputParameters(), workflowInstance, null, null);
} else if (StringUtils.isNotBlank(last.getExternalOutputPayloadStoragePath())) {
output = externalPayloadStorageUtils.downloadPayload(last.getExternalOutputPayloadStoragePath());
Monitors.recordExternalPayloadStorageUsage(last.getTaskDefName(), ExternalPayloadStorage.Operation.READ.toString(), ExternalPayloadStorage.PayloadType.TASK_OUTPUT.toString());
} else {
output = last.getOutputData();
}
workflow.setOutput(output);
externalPayloadStorageUtils.verifyAndUpload(workflow, ExternalPayloadStorage.PayloadType.WORKFLOW_OUTPUT);
}
代码示例来源:origin: Netflix/conductor
@VisibleForTesting
boolean isResponseTimedOut(TaskDef taskDefinition, Task task) {
if (taskDefinition == null) {
LOGGER.warn("missing task type : {}, workflowId= {}", task.getTaskDefName(), task.getWorkflowInstanceId());
return false;
}
if (task.getStatus().isTerminal() || !task.getStatus().equals(IN_PROGRESS) || taskDefinition.getResponseTimeoutSeconds() == 0) {
return false;
}
if (!task.getStatus().equals(IN_PROGRESS) || taskDefinition.getResponseTimeoutSeconds() == 0) {
return false;
}
if (queueDAO.exists(QueueUtils.getQueueName(task), task.getTaskId())) {
// this task is present in the queue
// this means that it has been updated with callbackAfterSeconds and is not being executed in a worker
return false;
}
LOGGER.debug("Evaluating responseTimeOut for Task: {}, with Task Definition: {} ", task, taskDefinition);
long responseTimeout = 1000L * taskDefinition.getResponseTimeoutSeconds();
long now = System.currentTimeMillis();
long noResponseTime = now - task.getUpdateTime();
if (noResponseTime < responseTimeout) {
LOGGER.debug("Current responseTime: {} has not exceeded the configured responseTimeout of {} " +
"for the Task: {} with Task Definition: {}", noResponseTime, responseTimeout, task, taskDefinition);
return false;
}
Monitors.recordTaskResponseTimeout(task.getTaskDefName());
return true;
}
代码示例来源: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
@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
if (StringUtils.isNotBlank(task.getExternalOutputPayloadStoragePath())) {
task.setOutputData(externalPayloadStorageUtils.downloadPayload(task.getExternalOutputPayloadStoragePath()));
Monitors.recordExternalPayloadStorageUsage(task.getTaskDefName(), ExternalPayloadStorage.Operation.READ.toString(), ExternalPayloadStorage.PayloadType.TASK_OUTPUT.toString());
task.setExternalOutputPayloadStoragePath(null);
Monitors.recordExternalPayloadStorageUsage(task.getTaskDefName(), ExternalPayloadStorage.Operation.READ.toString(), ExternalPayloadStorage.PayloadType.TASK_INPUT.toString());
task.setExternalInputPayloadStoragePath(null);
代码示例来源: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 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
@Test
public void testWorkflowWithNoTasks() throws Exception {
InputStream stream = TestDeciderOutcomes.class.getResourceAsStream("/conditional_flow.json");
WorkflowDef def = objectMapper.readValue(stream, WorkflowDef.class);
assertNotNull(def);
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(def);
workflow.setStartTime(0);
workflow.getInput().put("param1", "nested");
workflow.getInput().put("param2", "one");
DeciderOutcome outcome = deciderService.decide(workflow);
assertNotNull(outcome);
assertFalse(outcome.isComplete);
assertTrue(outcome.tasksToBeUpdated.isEmpty());
assertEquals(3, outcome.tasksToBeScheduled.size());
System.out.println(outcome.tasksToBeScheduled);
outcome.tasksToBeScheduled.forEach(t -> t.setStatus(Status.COMPLETED));
workflow.getTasks().addAll(outcome.tasksToBeScheduled);
outcome = deciderService.decide(workflow);
assertFalse(outcome.isComplete);
assertEquals(outcome.tasksToBeUpdated.toString(), 3, outcome.tasksToBeUpdated.size());
assertEquals(1, outcome.tasksToBeScheduled.size());
assertEquals("junit_task_3", outcome.tasksToBeScheduled.get(0).getTaskDefName());
System.out.println(outcome.tasksToBeScheduled);
}
代码示例来源:origin: Netflix/conductor
if (task.getStartTime() == 0) {
task.setStartTime(System.currentTimeMillis());
Monitors.recordQueueWaitTime(task.getTaskDefName(), task.getQueueWaitTime());
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!