【问题标题】:Submit spark job to AWS EMR with java code and wait for the execution and get final status使用 java 代码将 spark 作业提交到 AWS EMR 并等待执行并获得最终状态
【发布时间】:2018-01-04 18:40:24
【问题描述】:

我正在尝试通过 AWS EMR 开发工具包 API 向 AWS EMR 提交 Spark 作业。 我希望进程提交作业,然后等待作业完成/失败并获得相应的状态。

代码:

    AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonElasticMapReduce emr =
        AmazonElasticMapReduceClientBuilder
                .standard()
                .withCredentials(new AWSStaticCredentialsProvider(credentials))
                .build();

HadoopJarStepConfig sparkStepConf =
        new HadoopJarStepConfig()
                .withJar("command-runner.jar")
                .withArgs("spark-submit")
                .withArgs("--master", "yarn")
                .withArgs(sparkJarPath)
                .withArgs(args);

StepConfig sparkStep =
        new StepConfig().withName("Spark Step").withActionOnFailure(ActionOnFailure.CONTINUE).withHadoopJarStep(
                sparkStepConf);

AddJobFlowStepsRequest req =
        new AddJobFlowStepsRequest().withJobFlowId(clusterId).withSteps(Collections.singletonList(sparkStep));
emr.addJobFlowSteps(req);

找不到东西来获取已提交作业的状态

【问题讨论】:

    标签: java apache-spark amazon-emr


    【解决方案1】:

    这是一个示例(请检查某些代码区域是否为空):

    ListStepsResult stepsResult = emr.listSteps(new ListStepsRequest().withClusterId(clusterId).withStepIds(req.getStepIds()));
    List<StepSummary> stepsList = stepsResult.getSteps();
    StepSummary stepSummary = stepsList.get(0);
    StepStatus stepSummaryStatus = stepSummary.getStatus();
    String stepStatus = stepSummaryStatus.getState();
    StepExecutionState stepState = StepExecutionState.valueOf(stepStatus);
    

    stepState 会有你想要的。

    【讨论】:

      猜你喜欢
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 2018-11-13
      • 2019-07-03
      • 2020-11-08
      • 2013-10-21
      • 1970-01-01
      • 2016-11-16
      相关资源
      最近更新 更多