Search in sources :

Example 46 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class RedisExecutionDAO method updateEventExecution.

@Override
public void updateEventExecution(EventExecution eventExecution) {
    try {
        String key = nsKey(EVENT_EXECUTION, eventExecution.getName(), eventExecution.getEvent(), eventExecution.getMessageId());
        String json = objectMapper.writeValueAsString(eventExecution);
        logger.info("updating event execution {}", key);
        dynoClient.hset(key, eventExecution.getId(), json);
        recordRedisDaoEventRequests("updateEventExecution", eventExecution.getEvent());
        recordRedisDaoPayloadSize("updateEventExecution", json.length(), eventExecution.getEvent(), "n/a");
    } catch (Exception e) {
        throw new ApplicationException(Code.BACKEND_ERROR, "Unable to update event execution for " + eventExecution.getId(), e);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 47 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class ExecutionService method removeTaskfromQueue.

public void removeTaskfromQueue(String taskId) {
    Task task = executionDAOFacade.getTaskById(taskId);
    if (task == null) {
        throw new ApplicationException(ApplicationException.Code.NOT_FOUND, String.format("No such task found by taskId: %s", taskId));
    }
    queueDAO.remove(QueueUtils.getQueueName(task), taskId);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 48 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException 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);
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Service(com.netflix.conductor.annotations.Service)

Example 49 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class SetVariable method validateVariablesSize.

private boolean validateVariablesSize(Workflow workflow, Task task, Map<String, Object> variables) {
    String workflowId = workflow.getWorkflowId();
    long maxThreshold = configuration.getMaxWorkflowVariablesPayloadSizeThresholdKB();
    try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
        this.objectMapper.writeValue(byteArrayOutputStream, variables);
        byte[] payloadBytes = byteArrayOutputStream.toByteArray();
        long payloadSize = payloadBytes.length;
        if (payloadSize > maxThreshold * 1024) {
            String errorMsg = String.format("The variables payload size: %dB of workflow: %s is greater than the permissible limit: %dKB", payloadSize, workflowId, maxThreshold);
            LOGGER.error(errorMsg);
            task.setReasonForIncompletion(errorMsg);
            return false;
        }
        return true;
    } catch (IOException e) {
        LOGGER.error("Unable to validate variables payload size of workflow: {}", workflowId, e);
        throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, e);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 50 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class MetadataMapperService method lookupForWorkflowDefinition.

public WorkflowDef lookupForWorkflowDefinition(String name, Integer version) {
    Optional<WorkflowDef> potentialDef = version == null ? lookupLatestWorkflowDefinition(name) : lookupWorkflowDefinition(name, version);
    // Check if the workflow definition is valid
    WorkflowDef workflowDefinition = potentialDef.orElseThrow(() -> {
        logger.error("There is no workflow defined with name {} and version {}", name, version);
        return new ApplicationException(ApplicationException.Code.NOT_FOUND, String.format("No such workflow defined. name=%s, version=%s", name, version));
    });
    return workflowDefinition;
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef)

Aggregations

ApplicationException (com.netflix.conductor.core.execution.ApplicationException)93 Task (com.netflix.conductor.common.metadata.tasks.Task)22 Workflow (com.netflix.conductor.common.run.Workflow)22 HashMap (java.util.HashMap)19 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)16 IOException (java.io.IOException)16 Map (java.util.Map)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Inject (javax.inject.Inject)14 Singleton (javax.inject.Singleton)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Trace (com.netflix.conductor.annotations.Trace)13 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)13 Monitors (com.netflix.conductor.metrics.Monitors)13 Collectors (java.util.stream.Collectors)13 ResultSet (com.datastax.driver.core.ResultSet)12 EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)12 TimeUnit (java.util.concurrent.TimeUnit)12