Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc. GitHub
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DescribeJobs
dengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanDescribeJobs
.
Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:
- CLI
-
- AWS CLI
-
Untuk menggambarkan pekerjaan
describe-jobs
Contoh berikut menjelaskan pekerjaan dengan ID pekerjaan yang ditentukan.
aws batch describe-jobs \
--jobs bcf0b186-a532-4122-842e-2ccab8d54efb
Output:
{
"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 untuk Java 2.x
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode 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());
}