use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class FedExWorker method execute.
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
result.setStatus(TaskResult.Status.COMPLETED);
return result;
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class ImageConvertResizeWorker method execute.
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
try {
String fileLocation = (String) task.getInputData().get("fileLocation");
Integer width = (Integer) task.getInputData().get("outputWidth");
Integer height = (Integer) task.getInputData().get("outputHeight");
String outputFormat = (String) task.getInputData().get("outputFormat");
String outputFileName = "/tmp/" + UUID.randomUUID().toString() + "." + outputFormat;
String s3BucketName = "image-processing-orkes";
resizeImage(fileLocation, width, height, outputFileName);
String url = S3Utils.uploadToS3(outputFileName, Regions.US_EAST_1, s3BucketName);
result.setStatus(TaskResult.Status.COMPLETED);
result.addOutputData("fileLocation", url);
result.addOutputData("outputWidth", width);
result.addOutputData("outputHeight", height);
result.addOutputData("outputFormat", outputFormat);
} catch (Exception e) {
e.printStackTrace();
result.setStatus(TaskResult.Status.FAILED);
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
e.printStackTrace(pw);
result.log(sw.getBuffer().toString());
}
return result;
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class ImageEffectWorker method execute.
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
try {
String fileLocation = (String) task.getInputData().get("fileLocation");
String recipeName = ((String) task.getInputData().get("recipe")).toLowerCase();
RECIPE recipe = validateRecipeNames(recipeName);
Map<String, Object> recipeParameters = (Map<String, Object>) task.getInputData().get("recipeParameters");
String fileExtension = Files.getFileExtension(fileLocation);
String outputFileName = "/tmp/" + UUID.randomUUID().toString() + "-" + recipe.name() + "." + fileExtension;
if (recipe == RECIPE.SEPIA) {
Integer sepiaIntensityThreshold = ((Integer) recipeParameters.get("sepiaIntensityThreshold"));
sepia(fileLocation, sepiaIntensityThreshold, outputFileName);
} else if (recipe == RECIPE.VIBRANT) {
Integer vibrance = ((Integer) recipeParameters.get("vibrance"));
vibrant(fileLocation, vibrance, outputFileName);
}
String s3BucketName = "image-processing-orkes";
String url = S3Utils.uploadToS3(outputFileName, Regions.US_EAST_1, s3BucketName);
result.setStatus(TaskResult.Status.COMPLETED);
result.addOutputData("fileLocation", url);
result.addOutputData("recipe", recipe);
result.addOutputData("recipeParameters", recipeParameters);
} catch (Exception e) {
e.printStackTrace();
result.setStatus(TaskResult.Status.FAILED);
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
e.printStackTrace(pw);
result.log(sw.getBuffer().toString());
}
return result;
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class TaskCallbackWorker method execute.
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
result.addOutputData("result" + runCount.incrementAndGet(), "Run Count: " + runCount.get());
result.log("Running for " + runCount.get());
if (runCount.get() % 5 == 0) {
// Check DB if things are completed
result.setStatus(TaskResult.Status.COMPLETED);
} else {
// If still running then post updates
result.setStatus(TaskResult.Status.IN_PROGRESS);
result.setCallbackAfterSeconds(3);
}
return result;
}
use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class UPSWorker method execute.
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
result.setStatus(TaskResult.Status.COMPLETED);
return result;
}
Aggregations