Class JobQueue

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.batch.JobQueue
All Implemented Interfaces:
IResource, IJobQueue, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-09-11T18:01:12.060Z") @Stability(Stable) public class JobQueue extends Resource implements IJobQueue
JobQueues can receive Jobs, which are removed from the queue when sent to the linked ComputeEnvironment(s) to be executed.

Jobs exit the queue in FIFO order unless a SchedulingPolicy is linked.

Example:

 IVpc vpc;
 EcsJobDefinition ecsJob = EcsJobDefinition.Builder.create(this, "JobDefn")
         .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                 .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                 .memory(Size.mebibytes(2048))
                 .cpu(256)
                 .build())
         .build();
 JobQueue queue = JobQueue.Builder.create(this, "JobQueue")
         .computeEnvironments(List.of(OrderedComputeEnvironment.builder()
                 .computeEnvironment(ManagedEc2EcsComputeEnvironment.Builder.create(this, "managedEc2CE")
                         .vpc(vpc)
                         .build())
                 .order(1)
                 .build()))
         .priority(10)
         .build();
 User user = new User(this, "MyUser");
 ecsJob.grantSubmitJob(user, queue);
 
  • Constructor Details

    • JobQueue

      protected JobQueue(software.amazon.jsii.JsiiObjectRef objRef)
    • JobQueue

      protected JobQueue(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • JobQueue

      @Stability(Stable) public JobQueue(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable JobQueueProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • JobQueue

      @Stability(Stable) public JobQueue(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • fromJobQueueArn

      @Stability(Stable) @NotNull public static IJobQueue fromJobQueueArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String jobQueueArn)
      refer to an existing JobQueue by its arn.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      jobQueueArn - This parameter is required.
    • addComputeEnvironment

      @Stability(Stable) public void addComputeEnvironment(@NotNull IComputeEnvironment computeEnvironment, @NotNull Number order)
      Add a ComputeEnvironment to this Queue.

      The Queue will prefer lower-order ComputeEnvironments.

      Specified by:
      addComputeEnvironment in interface IJobQueue
      Parameters:
      computeEnvironment - This parameter is required.
      order - This parameter is required.
    • getComputeEnvironments

      @Stability(Stable) @NotNull public List<OrderedComputeEnvironment> getComputeEnvironments()
      The set of compute environments mapped to a job queue and their order relative to each other.

      The job scheduler uses this parameter to determine which compute environment runs a specific job. Compute environments must be in the VALID state before you can associate them with a job queue. You can associate up to three compute environments with a job queue. All of the compute environments must be either EC2 (EC2 or SPOT) or Fargate (FARGATE or FARGATE_SPOT); EC2 and Fargate compute environments can't be mixed.

      Note: All compute environments that are associated with a job queue must share the same architecture. AWS Batch doesn't support mixing compute environment architecture types in a single job queue.

      Specified by:
      getComputeEnvironments in interface IJobQueue
    • getJobQueueArn

      @Stability(Stable) @NotNull public String getJobQueueArn()
      The ARN of this job queue.
      Specified by:
      getJobQueueArn in interface IJobQueue
    • getJobQueueName

      @Stability(Stable) @NotNull public String getJobQueueName()
      The name of the job queue.

      It can be up to 128 letters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_)

      Specified by:
      getJobQueueName in interface IJobQueue
    • getPriority

      @Stability(Stable) @NotNull public Number getPriority()
      The priority of the job queue.

      Job queues with a higher priority are evaluated first when associated with the same compute environment. Priority is determined in descending order. For example, a job queue with a priority value of 10 is given scheduling preference over a job queue with a priority value of 1.

      Specified by:
      getPriority in interface IJobQueue
    • getEnabled

      @Stability(Stable) @Nullable public Boolean getEnabled()
      If the job queue is enabled, it is able to accept jobs.

      Otherwise, new jobs can't be added to the queue, but jobs already in the queue can finish.

      Specified by:
      getEnabled in interface IJobQueue
    • getSchedulingPolicy

      @Stability(Stable) @Nullable public ISchedulingPolicy getSchedulingPolicy()
      The SchedulingPolicy for this JobQueue.

      Instructs the Scheduler how to schedule different jobs.

      Specified by:
      getSchedulingPolicy in interface IJobQueue