Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DescribeJobQueues
dengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanDescribeJobQueues
.
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 antrian pekerjaan
Contoh ini menjelaskan antrian HighPriority pekerjaan.
Perintah:
aws batch describe-job-queues --job-queues
HighPriority
Output:
{ "jobQueues": [ { "status": "VALID", "jobQueueArn": "arn:aws:batch:us-east-1:012345678910:job-queue/HighPriority", "computeEnvironmentOrder": [ { "computeEnvironment": "arn:aws:batch:us-east-1:012345678910:compute-environment/C4OnDemand", "order": 1 } ], "statusReason": "JobQueue Healthy", "priority": 1, "state": "ENABLED", "jobQueueName": "HighPriority" } ] }
-
Untuk API detailnya, lihat DescribeJobQueues
di Referensi AWS CLI Perintah.
-
- Java
-
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /** * Asynchronously describes the job queue associated with the specified compute environment. * * @param computeEnvironmentName the name of the compute environment to find the associated job queue for * @return a {@link CompletableFuture} that, when completed, contains the job queue ARN associated with the specified compute environment * @throws RuntimeException if the job queue description fails */ public CompletableFuture<String> describeJobQueueAsync(String computeEnvironmentName) { DescribeJobQueuesRequest describeJobQueuesRequest = DescribeJobQueuesRequest.builder() .build(); CompletableFuture<DescribeJobQueuesResponse> responseFuture = getAsyncClient().describeJobQueues(describeJobQueuesRequest); return responseFuture.whenComplete((describeJobQueuesResponse, ex) -> { if (describeJobQueuesResponse != null) { String jobQueueARN; for (JobQueueDetail jobQueueDetail : describeJobQueuesResponse.jobQueues()) { for (ComputeEnvironmentOrder computeEnvironmentOrder : jobQueueDetail.computeEnvironmentOrder()) { String computeEnvironment = computeEnvironmentOrder.computeEnvironment(); String name = getComputeEnvironmentName(computeEnvironment); if (name.equals(computeEnvironmentName)) { jobQueueARN = jobQueueDetail.jobQueueArn(); logger.info("Job queue ARN associated with the compute environment: " + jobQueueARN); } } } } else { throw new RuntimeException("Failed to describe job queue: " + ex.getMessage(), ex); } }).thenApply(describeJobQueuesResponse -> { String jobQueueARN = ""; for (JobQueueDetail jobQueueDetail : describeJobQueuesResponse.jobQueues()) { for (ComputeEnvironmentOrder computeEnvironmentOrder : jobQueueDetail.computeEnvironmentOrder()) { String computeEnvironment = computeEnvironmentOrder.computeEnvironment(); String name = getComputeEnvironmentName(computeEnvironment); if (name.equals(computeEnvironmentName)) { jobQueueARN = jobQueueDetail.jobQueueArn(); } } } return jobQueueARN; }); }
-
Untuk API detailnya, lihat DescribeJobQueuesdi AWS SDK for Java 2.x APIReferensi.
-