Search code examples
amazon-web-servicesemrhadoop2

Is there a way to add multiple jobs using HadoopJarStepConfig jarConfig = new HadoopJarStepConfig(HADOOP_JAR);


I have written a AWS SWF workflow and the first action is to boot cluster and run a mapreduce program. This action also has like 2 other mapreduce jars to be executed depending upon the first jar's output. I am using this to add the jars

    HadoopJarStepConfig jarConfig = new HadoopJarStepConfig(S3N_HADOOP_JAR);
    jarConfig.setArgs(ARGS_AS_LIST);
    HadoopJarStepConfig jarConfig1 = new HadoopJarStepConfig(S3N_HADOOP_JAR);
    jarConfig1.setArgs(ARGS_AS_LIST1);
    try {
        StepConfig enableDebugging = new StepConfig()
                .withName("Enable debugging")
                .withActionOnFailure("TERMINATE_JOB_FLOW")
                .withHadoopJarStep(new StepFactory().newEnableDebuggingStep());
        StepConfig runJar = new StepConfig(HADOOP_JAR, jarConfig);
        StepConfig runJar1 = new StepConfig(HADOOP_JAR, jarConfig1);
        request.setSteps(Arrays.asList(new StepConfig[]{enableDebugging, runJar, runJar1}));
        RunJobFlowResult result = emr.runJobFlow(request);

Is this the correct way to add multiple jars. Thanks.


Solution

  • Use:

    request.withSteps(enableDebugging, runJar, runJar1);

    Don't Use:

    new StepConfig[]{enableDebugging, runJar, runJar1})); is wrong, you dont need a SpetConfig again here..