简体   繁体   English

适用于AWS EMR的Java客户端,listSteps未显示最新步骤

[英]Java Client for AWS EMR, listSteps doesn't show the latest step

I'm running a Java job that start AWS EMR and run steps on it. 我正在运行一个Java作业,该作业启动AWS EMR并在其上运行步骤。 After I add a step to the EMR I call the listSteps function to get the status of the steps and wait until they all done/failed. 在将步骤添加到EMR之后,我调用listSteps函数以获取步骤的状态并等待它们全部完成/失败。

I noticed that sometimes the function listSteps doesn't included the last step I added if I call it right after I added it. 我注意到有时函数listSteps不包含我添加后的最后一步,如果我在添加它后立即调用它的话。 Which makes me think that all the steps are done while actually the latest step didn't even started. 这让我认为所有步骤都已完成,而实际上最新步骤甚至还没有开始。

  1. Is that a known issue or am I missing anything here? 这是一个已知问题,还是我在这里错过了任何东西?
  2. Is there a "best practice" to avoid this except "sleeping" before calling listSteps ? 有没有“最佳实践”以避免在调用listSteps之前“睡眠”以外的listSteps

I'm use the "AmazonElasticMapReduceClient" class from Amazon SDK. 我正在使用Amazon SDK中的“ AmazonElasticMapReduceClient”类。

I don't think there is a magic workaround for this kind of problem. 对于这种问题,我认为没有神奇的解决方法。 Many of AWS calls are asynchronous. 许多AWS调用都是异步的。 For example, launching an EC2 machine will return right away, and then you must poll to see if the instance is up yet. 例如,启动EC2计算机将立即返回,然后您必须轮询以查看实例是否启动。 I think with a bit of design, it won't be much of an issue. 我认为只要进行一些设计,就不会有太大的问题。 I see several options: 我看到几个选择:

When you create the cluster and add the job steps, you know how many job steps, and which job steps you're adding to the cluster, so you can start a new thread and monitor the cluster for all steps being added (in psuedocode): 创建集群并添加作业步骤时,您知道要向集群添加多少作业步骤以及要添加的作业步骤,因此可以启动新线程并监视群集中所有要添加的步骤(以psuedocode表示) :

function createCluster(steps, callback):
    aws.runJobFlow(...)
    on new thread:
        while(steps != aws.listSteps(...)):
            sleep()
        callback()

Then all you have to do in your status check (to see if job has finished) is to call listSteps() and check the status. 然后,状态检查(以查看作业是否完成)中listSteps()就是调用listSteps()并检查状态。 That's probably the simplest solution to the problem. 那可能是最简单的解决方案。

The other design option is that you have a job step that notifies your software of progress or successful completion of the job. 另一个设计选项是您有一个作业步骤,通知您软件进度或作业成功完成。 This design option would be asynchronous and wouldn't require polling. 此设计选项将是异步的,并且不需要轮询。 For example, create a job step called notify . 例如,创建一个名为notify的作业步骤。 Then you run your steps like 然后,您可以像

  1. JobStep1 JobStep1
  2. Notify 通知
  3. JobStep2 JobStep2
  4. Notify 通知

Each notify step can listSteps() on the job flow to see the result of the previous steps and update a database, send a message to a service, or update a cache with the progress of the job. 每个通知步骤可以在作业流上列出listSteps(),以查看先前步骤的结果并更新数据库,向服务发送消息或根据作业的进度更新缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM