software.amazon.awscdk.services.gamelift.alpha.AutoScalingPolicy Maven / Gradle / Ivy
Show all versions of gamelift-alpha Show documentation
package software.amazon.awscdk.services.gamelift.alpha;
/**
* (experimental) Configuration settings for intelligent automatic scaling that uses target tracking.
*
* After the Auto Scaling group is created, all updates to Auto Scaling policies, including changing this policy and adding or removing other policies, is done directly on the Auto Scaling group.
*
* Example:
*
*
* ILaunchTemplate launchTemplate;
* IVpc vpc;
* GameServerGroup.Builder.create(this, "Game server group")
* .gameServerGroupName("sample-gameservergroup-name")
* .instanceDefinitions(List.of(InstanceDefinition.builder()
* .instanceType(InstanceType.of(InstanceClass.C5, InstanceSize.LARGE))
* .build(), InstanceDefinition.builder()
* .instanceType(InstanceType.of(InstanceClass.C4, InstanceSize.LARGE))
* .build()))
* .launchTemplate(launchTemplate)
* .vpc(vpc)
* .autoScalingPolicy(AutoScalingPolicy.builder()
* .estimatedInstanceWarmup(Duration.minutes(5))
* .targetTrackingConfiguration(5)
* .build())
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.104.0 (build e79254c)", date = "2024-12-27T17:02:12.090Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.gamelift.alpha.$Module.class, fqn = "@aws-cdk/aws-gamelift-alpha.AutoScalingPolicy")
@software.amazon.jsii.Jsii.Proxy(AutoScalingPolicy.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface AutoScalingPolicy extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) Settings for a target-based scaling policy applied to Auto Scaling group.
*
* These settings are used to create a target-based policy that tracks the GameLift FleetIQ metric PercentUtilizedGameServers
and specifies a target value for the metric.
*
* As player usage changes, the policy triggers to adjust the game server group capacity so that the metric returns to the target value.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull java.lang.Number getTargetTrackingConfiguration();
/**
* (experimental) Length of time, it takes for a new instance to start new game server processes and register with GameLift FleetIQ.
*
* Specifying a warm-up time can be useful, particularly with game servers that take a long time to start up, because it avoids prematurely starting new instances.
*
* Default: no instance warmup duration settled
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.Duration getEstimatedInstanceWarmup() {
return null;
}
/**
* @return a {@link Builder} of {@link AutoScalingPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link AutoScalingPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.Number targetTrackingConfiguration;
software.amazon.awscdk.Duration estimatedInstanceWarmup;
/**
* Sets the value of {@link AutoScalingPolicy#getTargetTrackingConfiguration}
* @param targetTrackingConfiguration Settings for a target-based scaling policy applied to Auto Scaling group. This parameter is required.
* These settings are used to create a target-based policy that tracks the GameLift FleetIQ metric PercentUtilizedGameServers
and specifies a target value for the metric.
*
* As player usage changes, the policy triggers to adjust the game server group capacity so that the metric returns to the target value.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder targetTrackingConfiguration(java.lang.Number targetTrackingConfiguration) {
this.targetTrackingConfiguration = targetTrackingConfiguration;
return this;
}
/**
* Sets the value of {@link AutoScalingPolicy#getEstimatedInstanceWarmup}
* @param estimatedInstanceWarmup Length of time, it takes for a new instance to start new game server processes and register with GameLift FleetIQ.
* Specifying a warm-up time can be useful, particularly with game servers that take a long time to start up, because it avoids prematurely starting new instances.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder estimatedInstanceWarmup(software.amazon.awscdk.Duration estimatedInstanceWarmup) {
this.estimatedInstanceWarmup = estimatedInstanceWarmup;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link AutoScalingPolicy}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public AutoScalingPolicy build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link AutoScalingPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements AutoScalingPolicy {
private final java.lang.Number targetTrackingConfiguration;
private final software.amazon.awscdk.Duration estimatedInstanceWarmup;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.targetTrackingConfiguration = software.amazon.jsii.Kernel.get(this, "targetTrackingConfiguration", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
this.estimatedInstanceWarmup = software.amazon.jsii.Kernel.get(this, "estimatedInstanceWarmup", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.Duration.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.targetTrackingConfiguration = java.util.Objects.requireNonNull(builder.targetTrackingConfiguration, "targetTrackingConfiguration is required");
this.estimatedInstanceWarmup = builder.estimatedInstanceWarmup;
}
@Override
public final java.lang.Number getTargetTrackingConfiguration() {
return this.targetTrackingConfiguration;
}
@Override
public final software.amazon.awscdk.Duration getEstimatedInstanceWarmup() {
return this.estimatedInstanceWarmup;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("targetTrackingConfiguration", om.valueToTree(this.getTargetTrackingConfiguration()));
if (this.getEstimatedInstanceWarmup() != null) {
data.set("estimatedInstanceWarmup", om.valueToTree(this.getEstimatedInstanceWarmup()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-gamelift-alpha.AutoScalingPolicy"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AutoScalingPolicy.Jsii$Proxy that = (AutoScalingPolicy.Jsii$Proxy) o;
if (!targetTrackingConfiguration.equals(that.targetTrackingConfiguration)) return false;
return this.estimatedInstanceWarmup != null ? this.estimatedInstanceWarmup.equals(that.estimatedInstanceWarmup) : that.estimatedInstanceWarmup == null;
}
@Override
public final int hashCode() {
int result = this.targetTrackingConfiguration.hashCode();
result = 31 * result + (this.estimatedInstanceWarmup != null ? this.estimatedInstanceWarmup.hashCode() : 0);
return result;
}
}
}