Search in sources :

Example 1 with ActionOnFailure

use of com.amazonaws.services.elasticmapreduce.model.ActionOnFailure in project herd by FINRAOS.

the class EmrPigStepHelper method getEmrStepConfig.

@Override
public StepConfig getEmrStepConfig(Object step) {
    EmrPigStep pigStep = (EmrPigStep) step;
    // Default ActionOnFailure is to cancel the execution and wait
    ActionOnFailure actionOnFailure = ActionOnFailure.CANCEL_AND_WAIT;
    if (pigStep.isContinueOnError() != null && pigStep.isContinueOnError()) {
        // Override based on user input
        actionOnFailure = ActionOnFailure.CONTINUE;
    }
    // If there are no arguments to hive script
    if (CollectionUtils.isEmpty(pigStep.getScriptArguments())) {
        // Just build the StepConfig object and return
        return new StepConfig().withName(pigStep.getStepName().trim()).withActionOnFailure(actionOnFailure).withHadoopJarStep(new StepFactory().newRunPigScriptStep(pigStep.getScriptLocation().trim()));
    } else // If there are arguments specified
    {
        return new StepConfig().withName(pigStep.getStepName().trim()).withActionOnFailure(actionOnFailure).withHadoopJarStep(new StepFactory().newRunPigScriptStep(pigStep.getScriptLocation().trim(), pigStep.getScriptArguments().toArray(new String[pigStep.getScriptArguments().size()])));
    }
}
Also used : ActionOnFailure(com.amazonaws.services.elasticmapreduce.model.ActionOnFailure) EmrPigStep(org.finra.herd.model.api.xml.EmrPigStep) StepConfig(com.amazonaws.services.elasticmapreduce.model.StepConfig) StepFactory(com.amazonaws.services.elasticmapreduce.util.StepFactory)

Example 2 with ActionOnFailure

use of com.amazonaws.services.elasticmapreduce.model.ActionOnFailure in project herd by FINRAOS.

the class EmrHiveStepHelper method getEmrStepConfig.

@Override
public StepConfig getEmrStepConfig(Object step) {
    EmrHiveStep emrHiveStep = (EmrHiveStep) step;
    // Default ActionOnFailure is to cancel the execution and wait
    ActionOnFailure actionOnFailure = ActionOnFailure.CANCEL_AND_WAIT;
    if (emrHiveStep.isContinueOnError() != null && emrHiveStep.isContinueOnError()) {
        // Override based on user input
        actionOnFailure = ActionOnFailure.CONTINUE;
    }
    // If there are no arguments to hive script
    if (CollectionUtils.isEmpty(emrHiveStep.getScriptArguments())) {
        // Just build the StepConfig object and return
        return new StepConfig().withName(emrHiveStep.getStepName().trim()).withActionOnFailure(actionOnFailure).withHadoopJarStep(new StepFactory().newRunHiveScriptStep(emrHiveStep.getScriptLocation().trim()));
    } else // If there are arguments specified
    {
        // For each argument, add "-d" option
        List<String> hiveArgs = new ArrayList<>();
        for (String hiveArg : emrHiveStep.getScriptArguments()) {
            hiveArgs.add("-d");
            hiveArgs.add(hiveArg);
        }
        // Return the StepConfig object
        return new StepConfig().withName(emrHiveStep.getStepName().trim()).withActionOnFailure(actionOnFailure).withHadoopJarStep(new StepFactory().newRunHiveScriptStep(emrHiveStep.getScriptLocation().trim(), hiveArgs.toArray(new String[hiveArgs.size()])));
    }
}
Also used : ActionOnFailure(com.amazonaws.services.elasticmapreduce.model.ActionOnFailure) ArrayList(java.util.ArrayList) StepConfig(com.amazonaws.services.elasticmapreduce.model.StepConfig) StepFactory(com.amazonaws.services.elasticmapreduce.util.StepFactory) EmrHiveStep(org.finra.herd.model.api.xml.EmrHiveStep)

Example 3 with ActionOnFailure

use of com.amazonaws.services.elasticmapreduce.model.ActionOnFailure in project herd by FINRAOS.

the class EmrShellStepHelper method getEmrStepConfig.

@Override
public StepConfig getEmrStepConfig(Object step) {
    EmrShellStep emrShellStep = (EmrShellStep) step;
    // Hadoop Jar provided by Amazon for running Shell Scripts
    String hadoopJarForShellScript = configurationHelper.getProperty(ConfigurationValue.EMR_SHELL_SCRIPT_JAR);
    // Default ActionOnFailure is to cancel the execution and wait
    ActionOnFailure actionOnFailure = ActionOnFailure.CANCEL_AND_WAIT;
    if (emrShellStep.isContinueOnError() != null && emrShellStep.isContinueOnError()) {
        // Override based on user input
        actionOnFailure = ActionOnFailure.CONTINUE;
    }
    // Add the script location
    List<String> argsList = new ArrayList<>();
    argsList.add(emrShellStep.getScriptLocation().trim());
    // Add the script arguments
    if (!CollectionUtils.isEmpty(emrShellStep.getScriptArguments())) {
        for (String argument : emrShellStep.getScriptArguments()) {
            argsList.add(argument.trim());
        }
    }
    // Return the StepConfig object
    HadoopJarStepConfig jarConfig = new HadoopJarStepConfig(hadoopJarForShellScript).withArgs(argsList);
    return new StepConfig().withName(emrShellStep.getStepName().trim()).withActionOnFailure(actionOnFailure).withHadoopJarStep(jarConfig);
}
Also used : HadoopJarStepConfig(com.amazonaws.services.elasticmapreduce.model.HadoopJarStepConfig) ActionOnFailure(com.amazonaws.services.elasticmapreduce.model.ActionOnFailure) EmrShellStep(org.finra.herd.model.api.xml.EmrShellStep) ArrayList(java.util.ArrayList) StepConfig(com.amazonaws.services.elasticmapreduce.model.StepConfig) HadoopJarStepConfig(com.amazonaws.services.elasticmapreduce.model.HadoopJarStepConfig)

Aggregations

ActionOnFailure (com.amazonaws.services.elasticmapreduce.model.ActionOnFailure)3 StepConfig (com.amazonaws.services.elasticmapreduce.model.StepConfig)3 StepFactory (com.amazonaws.services.elasticmapreduce.util.StepFactory)2 ArrayList (java.util.ArrayList)2 HadoopJarStepConfig (com.amazonaws.services.elasticmapreduce.model.HadoopJarStepConfig)1 EmrHiveStep (org.finra.herd.model.api.xml.EmrHiveStep)1 EmrPigStep (org.finra.herd.model.api.xml.EmrPigStep)1 EmrShellStep (org.finra.herd.model.api.xml.EmrShellStep)1