Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS SDK 또는 CLI와 DescribeJobs
함께 사용
다음 코드 예시는 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
}
]
}
- Java
-
- SDK for Java 2.x
-
/**
* 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());
}