io.cloudshiftdev.awscdk.services.batch.FairshareSchedulingPolicyProps.kt Maven / Gradle / Ivy
The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.batch
import io.cloudshiftdev.awscdk.Duration
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Number
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
/**
* Fairshare SchedulingPolicy configuration.
*
* Example:
*
* ```
* FairshareSchedulingPolicy fairsharePolicy = FairshareSchedulingPolicy.Builder.create(this,
* "myFairsharePolicy")
* .shareDecay(Duration.minutes(5))
* .build();
* ```
*/
public interface FairshareSchedulingPolicyProps {
/**
* 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.
*
* Default: - no vCPU is reserved
*/
public fun computeReservation(): Number? = unwrap(this).getComputeReservation()
/**
* The name of this SchedulingPolicy.
*
* Default: - generated by CloudFormation
*/
public fun schedulingPolicyName(): String? = unwrap(this).getSchedulingPolicyName()
/**
* 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).
*
* Default: - 0: only the current job usage is considered
*/
public fun shareDecay(): Duration? = unwrap(this).getShareDecay()?.let(Duration::wrap)
/**
* 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.
*
* Default: - no shares
*/
public fun shares(): List = unwrap(this).getShares()?.map(Share::wrap) ?: emptyList()
/**
* A builder for [FairshareSchedulingPolicyProps]
*/
@CdkDslMarker
public interface Builder {
/**
* @param computeReservation 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.
*/
public fun computeReservation(computeReservation: Number)
/**
* @param schedulingPolicyName The name of this SchedulingPolicy.
*/
public fun schedulingPolicyName(schedulingPolicyName: String)
/**
* @param shareDecay 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).
*/
public fun shareDecay(shareDecay: Duration)
/**
* @param shares 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.
*/
public fun shares(shares: List)
/**
* @param shares 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.
*/
public fun shares(vararg shares: Share)
}
private class BuilderImpl : Builder {
private val cdkBuilder:
software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps.Builder =
software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps.builder()
/**
* @param computeReservation 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.
*/
override fun computeReservation(computeReservation: Number) {
cdkBuilder.computeReservation(computeReservation)
}
/**
* @param schedulingPolicyName The name of this SchedulingPolicy.
*/
override fun schedulingPolicyName(schedulingPolicyName: String) {
cdkBuilder.schedulingPolicyName(schedulingPolicyName)
}
/**
* @param shareDecay 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).
*/
override fun shareDecay(shareDecay: Duration) {
cdkBuilder.shareDecay(shareDecay.let(Duration.Companion::unwrap))
}
/**
* @param shares 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.
*/
override fun shares(shares: List) {
cdkBuilder.shares(shares.map(Share.Companion::unwrap))
}
/**
* @param shares 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.
*/
override fun shares(vararg shares: Share): Unit = shares(shares.toList())
public fun build(): software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps =
cdkBuilder.build()
}
private class Wrapper(
cdkObject: software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps,
) : CdkObject(cdkObject),
FairshareSchedulingPolicyProps {
/**
* 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.
*
* Default: - no vCPU is reserved
*/
override fun computeReservation(): Number? = unwrap(this).getComputeReservation()
/**
* The name of this SchedulingPolicy.
*
* Default: - generated by CloudFormation
*/
override fun schedulingPolicyName(): String? = unwrap(this).getSchedulingPolicyName()
/**
* 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).
*
* Default: - 0: only the current job usage is considered
*/
override fun shareDecay(): Duration? = unwrap(this).getShareDecay()?.let(Duration::wrap)
/**
* 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.
*
* Default: - no shares
*/
override fun shares(): List = unwrap(this).getShares()?.map(Share::wrap) ?: emptyList()
}
public companion object {
public operator fun invoke(block: Builder.() -> Unit = {}): FairshareSchedulingPolicyProps {
val builderImpl = BuilderImpl()
return Wrapper(builderImpl.apply(block).build())
}
internal
fun wrap(cdkObject: software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps):
FairshareSchedulingPolicyProps = CdkObjectWrappers.wrap(cdkObject) as?
FairshareSchedulingPolicyProps ?: Wrapper(cdkObject)
internal fun unwrap(wrapped: FairshareSchedulingPolicyProps):
software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps = (wrapped as
CdkObject).cdkObject as software.amazon.awscdk.services.batch.FairshareSchedulingPolicyProps
}
}