文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DescribeJobs
与 AWS SDK 或 CLI 配合使用
以下代码示例演示如何使用 DescribeJobs
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- CLI
-
- AWS CLI
-
描述任务
以下
describe-jobs
示例描述具有指定作业 ID 的作业。aws batch describe-jobs \ --jobs
bcf0b186-a532-4122-842e-2ccab8d54efb
输出:
{ "jobs": [ { "status": "SUBMITTED", "container": { "mountPoints": [], "image": "busybox", "environment": [], "vcpus": 1, "command": [ "sleep", "60" ], "volumes": [], "memory": 128, "ulimits": [] }, "parameters": {}, "jobDefinition": "arn:aws:batch:us-east-1:012345678910:job-definition/sleep60:1", "jobQueue": "arn:aws:batch:us-east-1:012345678910:job-queue/HighPriority", "jobId": "bcf0b186-a532-4122-842e-2ccab8d54efb", "dependsOn": [], "jobName": "example", "createdAt": 1480483387803 } ] }
-
有关 API 的详细信息,请参阅AWS CLI 命令参考DescribeJobs
中的。
-
- Java
-
- 适用于 Java 的 SDK 2.x
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /** * Asynchronously retrieves the status of a specific job. * * @param jobId the ID of the job to retrieve the status for * @return a CompletableFuture that completes with the job status */ public CompletableFuture<String> describeJobAsync(String jobId) { DescribeJobsRequest describeJobsRequest = DescribeJobsRequest.builder() .jobs(jobId) .build(); CompletableFuture<DescribeJobsResponse> responseFuture = getAsyncClient().describeJobs(describeJobsRequest); return responseFuture.whenComplete((response, ex) -> { if (ex != null) { throw new RuntimeException("Unexpected error occurred: " + ex.getMessage(), ex); } }).thenApply(response -> response.jobs().get(0).status().toString()); }
-
有关 API 的详细信息,请参阅 AWS SDK for Java 2.x API 参考DescribeJobs中的。
-
DescribeJobQueues
ListJobsPaginator