Class FairshareSchedulingPolicy

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

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-17T05:10:06.481Z") @Stability(Stable) public class FairshareSchedulingPolicy extends Resource implements IFairshareSchedulingPolicy, ISchedulingPolicy
Represents a Fairshare Scheduling Policy. Instructs the scheduler to allocate ComputeEnvironment vCPUs based on Job shareIdentifiers.

The Faireshare Scheduling Policy ensures that each share gets a certain amount of vCPUs. The scheduler does this by deciding how many Jobs of each share to schedule relative to how many jobs of each share are currently being executed by the ComputeEnvironment. The weight factors associated with each share determine the ratio of vCPUs allocated; see the readme for a more in-depth discussion of fairshare policies.

Example:

 FairshareSchedulingPolicy fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy");
 fairsharePolicy.addShare(Share.builder()
         .shareIdentifier("A")
         .weightFactor(1)
         .build());
 fairsharePolicy.addShare(Share.builder()
         .shareIdentifier("B")
         .weightFactor(1)
         .build());
 JobQueue.Builder.create(this, "JobQueue")
         .schedulingPolicy(fairsharePolicy)
         .build();
 
  • Constructor Details

    • FairshareSchedulingPolicy

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

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

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

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

    • fromFairshareSchedulingPolicyArn

      @Stability(Stable) @NotNull public static IFairshareSchedulingPolicy fromFairshareSchedulingPolicyArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String fairshareSchedulingPolicyArn)
      Reference an exisiting Scheduling Policy by its ARN.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      fairshareSchedulingPolicyArn - This parameter is required.
    • addShare

      @Stability(Stable) public void addShare(@NotNull Share share)
      Add a share this to this Fairshare SchedulingPolicy.

      Parameters:
      share - This parameter is required.
    • getSchedulingPolicyArn

      @Stability(Stable) @NotNull public String getSchedulingPolicyArn()
      The arn of this scheduling policy.
      Specified by:
      getSchedulingPolicyArn in interface ISchedulingPolicy
    • getSchedulingPolicyName

      @Stability(Stable) @NotNull public String getSchedulingPolicyName()
      The name of this scheduling policy.
      Specified by:
      getSchedulingPolicyName in interface ISchedulingPolicy
    • getShares

      @Stability(Stable) @NotNull public List<Share> getShares()
      The shares that this Scheduling Policy applies to.

      Note: It is possible to submit Jobs to the queue with Share Identifiers that are not recognized by the Scheduling Policy.

      Specified by:
      getShares in interface IFairshareSchedulingPolicy
    • getComputeReservation

      @Stability(Stable) @Nullable public Number getComputeReservation()
      Used to calculate the percentage of the maximum available vCPU to reserve for share identifiers not present in the Queue.

      The percentage reserved is defined by the Scheduler as: (computeReservation/100)^ActiveFairShares where ActiveFairShares is the number of active fair share identifiers.

      For example, a computeReservation value of 50 indicates that AWS Batch reserves 50% of the maximum available vCPU if there's only one fair share identifier. It reserves 25% if there are two fair share identifiers. It reserves 12.5% if there are three fair share identifiers.

      A computeReservation value of 25 indicates that AWS Batch should reserve 25% of the maximum available vCPU if there's only one fair share identifier, 6.25% if there are two fair share identifiers, and 1.56% if there are three fair share identifiers.

      Specified by:
      getComputeReservation in interface IFairshareSchedulingPolicy
    • getShareDecay

      @Stability(Stable) @Nullable public Duration getShareDecay()
      The amount of time to use to measure the usage of each job.

      The usage is used to calculate a fair share percentage for each fair share identifier currently in the Queue. A value of zero (0) indicates that only current usage is measured. The decay is linear and gives preference to newer jobs.

      The maximum supported value is 604800 seconds (1 week).

      Specified by:
      getShareDecay in interface IFairshareSchedulingPolicy