use of com.netflix.conductor.annotations.Service in project conductor by Netflix.
the class MetadataServiceImpl method registerTaskDef.
/**
* @param taskDefinitions Task Definitions to register
*/
@Service
public void registerTaskDef(List<TaskDef> taskDefinitions) {
for (TaskDef taskDefinition : taskDefinitions) {
taskDefinition.setCreatedBy(WorkflowContext.get().getClientApp());
taskDefinition.setCreateTime(System.currentTimeMillis());
taskDefinition.setUpdatedBy(null);
taskDefinition.setUpdateTime(null);
metadataDAO.createTaskDef(taskDefinition);
}
}
use of com.netflix.conductor.annotations.Service in project conductor by Netflix.
the class TaskServiceImpl method ackTaskReceived.
/**
* Ack Task is received.
*
* @param taskId Id of the task
* @return `true|false` if task if received or not
*/
@Service
public boolean ackTaskReceived(String taskId) {
LOGGER.debug("Ack received for task: {}", taskId);
String ackTaskDesc = "Ack Task with taskId: " + taskId;
String ackTaskOperation = "ackTaskReceived";
AtomicBoolean ackResult = new AtomicBoolean(false);
try {
new RetryUtil<>().retryOnException(() -> {
ackResult.set(executionService.ackTaskReceived(taskId));
return null;
}, null, null, 3, ackTaskDesc, ackTaskOperation);
} catch (Exception e) {
// Fail the task and let decide reevaluate the workflow, thereby preventing workflow being stuck from transient ack errors.
String errorMsg = String.format("Error when trying to ack task %s", taskId);
LOGGER.error(errorMsg, e);
Task task = executionService.getTask(taskId);
Monitors.recordAckTaskError(task.getTaskType());
failTask(task, errorMsg);
ackResult.set(false);
}
return ackResult.get();
}
use of com.netflix.conductor.annotations.Service in project conductor by Netflix.
the class MetadataServiceImpl method updateWorkflowDef.
/**
* @param workflowDefList Workflow definitions to be updated.
*/
@Service
public void updateWorkflowDef(List<WorkflowDef> workflowDefList) {
for (WorkflowDef workflowDef : workflowDefList) {
workflowDef.setUpdateTime(System.currentTimeMillis());
metadataDAO.updateWorkflowDef(workflowDef);
}
}
use of com.netflix.conductor.annotations.Service in project conductor by Netflix.
the class MetadataServiceImpl method updateTaskDef.
/*
* @param taskDefinition Task Definition to be updated
*/
@Service
public void updateTaskDef(TaskDef taskDefinition) {
TaskDef existing = metadataDAO.getTaskDef(taskDefinition.getName());
if (existing == null) {
throw new ApplicationException(Code.NOT_FOUND, "No such task by name " + taskDefinition.getName());
}
taskDefinition.setUpdatedBy(WorkflowContext.get().getClientApp());
taskDefinition.setUpdateTime(System.currentTimeMillis());
metadataDAO.updateTaskDef(taskDefinition);
}
use of com.netflix.conductor.annotations.Service in project conductor by Netflix.
the class TaskServiceImpl method poll.
/**
* Poll for a task of a certain type.
*
* @param taskType Task name
* @param workerId Id of the workflow
* @param domain Domain of the workflow
* @return polled {@link Task}
*/
@Service
public Task poll(String taskType, String workerId, String domain) {
LOGGER.debug("Task being polled: /tasks/poll/{}?{}&{}", taskType, workerId, domain);
Task task = executionService.getLastPollTask(taskType, workerId, domain);
if (task != null) {
LOGGER.debug("The Task {} being returned for /tasks/poll/{}?{}&{}", task, taskType, workerId, domain);
}
Monitors.recordTaskPollCount(taskType, domain, 1);
return task;
}
Aggregations