以编程方式获取 'newly-launched' EMR 集群的状态
Get status of 'newly-launched' EMR cluster programmatically
我正在跟随 official docs guide 编写一个 Scala 脚本以使用 AWS Java SDK 启动 EMR 集群。我能够确定这里需要的 3 个主要步骤:
- 实例化 EMR 客户端
我使用 AmazonElasticMapReduceClientBuilder.defaultClient()
- 正在创建 JobFlowRequest
我创建了一个 RunJobFlowRequest
对象并为其提供了 JobFlowInstancesConfig
(这两个对象都根据需要提供了适当的参数)
- 运行 JobFlowRequest
这是通过调用 emrClient.runJobFlow(runJobFlowRequest)
完成的,其中 returns 一个 RunJobFlowResult
对象
但是 RunJobFlowResult 对象没有提供任何关于集群是否成功启动的线索(使用所有给定的配置)
现在我知道 listClusters() method of the emrClient
can be used to get cluster id of the newly-launched cluster through which we can query the state of the cluster using describeCluster() 来电了。但是,由于我使用 Scala 脚本来执行所有这些操作,因此我需要将过程自动化(这里在 getClusters()
的结果中查找集群 ID 必须手动完成)
有什么方法可以实现吗?
你有所有的部分,但还没有完全拼接在一起。
集群的 ID 可以从 RunJobFlowResult.getJobFlowId() 中检索。 (是"j-"开头的字符串。)然后可以将这个jobFlowId传给DescribeCluster。
不过,我不会因为您的混淆而责怪您,因为它在某些方法(主要是较旧的 API 方法)中称为 "jobFlowId",而在其他方法中称为 "clusterId"。不过它们真的是一回事。
我正在跟随 official docs guide 编写一个 Scala 脚本以使用 AWS Java SDK 启动 EMR 集群。我能够确定这里需要的 3 个主要步骤:
- 实例化 EMR 客户端
我使用
AmazonElasticMapReduceClientBuilder.defaultClient()
- 正在创建 JobFlowRequest
我创建了一个
RunJobFlowRequest
对象并为其提供了JobFlowInstancesConfig
(这两个对象都根据需要提供了适当的参数) - 运行 JobFlowRequest
这是通过调用
emrClient.runJobFlow(runJobFlowRequest)
完成的,其中 returns 一个RunJobFlowResult
对象
但是 RunJobFlowResult 对象没有提供任何关于集群是否成功启动的线索(使用所有给定的配置)
现在我知道 listClusters() method of the emrClient
can be used to get cluster id of the newly-launched cluster through which we can query the state of the cluster using describeCluster() 来电了。但是,由于我使用 Scala 脚本来执行所有这些操作,因此我需要将过程自动化(这里在 getClusters()
的结果中查找集群 ID 必须手动完成)
有什么方法可以实现吗?
你有所有的部分,但还没有完全拼接在一起。
集群的 ID 可以从 RunJobFlowResult.getJobFlowId() 中检索。 (是"j-"开头的字符串。)然后可以将这个jobFlowId传给DescribeCluster。
不过,我不会因为您的混淆而责怪您,因为它在某些方法(主要是较旧的 API 方法)中称为 "jobFlowId",而在其他方法中称为 "clusterId"。不过它们真的是一回事。