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);
}
}
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);
}
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);
}
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);
}
}
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;
}
Aggregations