Search in sources :

Example 6 with AutoScalingPolicy

use of com.netflix.titus.api.appscale.model.AutoScalingPolicy in project titus-control-plane by Netflix.

the class GrpcModelConverters method toScalingPolicy.

private static ScalingPolicy toScalingPolicy(AutoScalingPolicy autoScalingPolicy) {
    ScalingPolicy.Builder scalingPolicyBuilder = ScalingPolicy.newBuilder();
    if (autoScalingPolicy.getPolicyConfiguration().getPolicyType() == StepScaling) {
        AlarmConfiguration alarmConfiguration = toAlarmConfiguration(autoScalingPolicy.getPolicyConfiguration().getAlarmConfiguration());
        StepScalingPolicy stepScalingPolicy = toStepScalingPolicy(autoScalingPolicy.getPolicyConfiguration().getStepScalingPolicyConfiguration());
        StepScalingPolicyDescriptor stepScalingPolicyDescriptor = StepScalingPolicyDescriptor.newBuilder().setAlarmConfig(alarmConfiguration).setScalingPolicy(stepScalingPolicy).build();
        scalingPolicyBuilder.setStepPolicyDescriptor(stepScalingPolicyDescriptor);
    } else if (autoScalingPolicy.getPolicyConfiguration().getPolicyType() == TargetTrackingScaling) {
        TargetTrackingPolicyDescriptor targetTrackingPolicyDesc = toTargetTrackingPolicyDescriptor(autoScalingPolicy.getPolicyConfiguration().getTargetTrackingPolicy());
        scalingPolicyBuilder.setTargetPolicyDescriptor(targetTrackingPolicyDesc);
    } else {
        throw new IllegalArgumentException("Invalid AutoScalingPolicyType value " + autoScalingPolicy.getPolicyConfiguration().getPolicyType());
    }
    return scalingPolicyBuilder.build();
}
Also used : StepScalingPolicy(com.netflix.titus.grpc.protogen.StepScalingPolicy) ScalingPolicy(com.netflix.titus.grpc.protogen.ScalingPolicy) AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) StepScalingPolicy(com.netflix.titus.grpc.protogen.StepScalingPolicy) StepScalingPolicyDescriptor(com.netflix.titus.grpc.protogen.StepScalingPolicyDescriptor) AlarmConfiguration(com.netflix.titus.grpc.protogen.AlarmConfiguration) TargetTrackingPolicyDescriptor(com.netflix.titus.grpc.protogen.TargetTrackingPolicyDescriptor)

Example 7 with AutoScalingPolicy

use of com.netflix.titus.api.appscale.model.AutoScalingPolicy in project titus-control-plane by Netflix.

the class GrpcModelConverters method toScalingPolicyResult.

public static ScalingPolicyResult toScalingPolicyResult(AutoScalingPolicy autoScalingPolicy) {
    ScalingPolicy scalingPolicy = toScalingPolicy(autoScalingPolicy);
    ScalingPolicyStatus scalingPolicyStatus = toScalingPolicyStatus(autoScalingPolicy.getStatus(), autoScalingPolicy.getStatusMessage());
    return ScalingPolicyResult.newBuilder().setJobId(autoScalingPolicy.getJobId()).setId(ScalingPolicyID.newBuilder().setId(autoScalingPolicy.getRefId()).build()).setPolicyState(scalingPolicyStatus).setScalingPolicy(scalingPolicy).build();
}
Also used : ScalingPolicy(com.netflix.titus.grpc.protogen.ScalingPolicy) AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) StepScalingPolicy(com.netflix.titus.grpc.protogen.StepScalingPolicy) ScalingPolicyStatus(com.netflix.titus.grpc.protogen.ScalingPolicyStatus)

Example 8 with AutoScalingPolicy

use of com.netflix.titus.api.appscale.model.AutoScalingPolicy in project titus-control-plane by Netflix.

the class ScalingPolicyModelSanitizationTest method testInvalidScalingConfigurationWithBothPolicies.

@Test
public void testInvalidScalingConfigurationWithBothPolicies() {
    PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withStepScalingPolicyConfiguration(mock(StepScalingPolicyConfiguration.class)).withAlarmConfiguration(mock(AlarmConfiguration.class)).withTargetTrackingPolicy(mock(TargetTrackingPolicy.class)).build();
    AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).build();
    Set<ValidationError> validationErrors = newScalingPolicySanitizer().validate(autoScalingPolicy);
    assertThat(validationErrors).hasSize(1);
    assertThat(CollectionsExt.first(validationErrors).getDescription()).isEqualTo("exactly one scaling policy should be set");
}
Also used : AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 9 with AutoScalingPolicy

use of com.netflix.titus.api.appscale.model.AutoScalingPolicy in project titus-control-plane by Netflix.

the class AutoScalingPolicyTests method buildStepScalingPolicy.

public static AutoScalingPolicy buildStepScalingPolicy(String jobId) {
    AlarmConfiguration alarmConfiguration = AlarmConfiguration.newBuilder().withActionsEnabled(true).withComparisonOperator(ComparisonOperator.GreaterThanThreshold).withEvaluationPeriods(1).withPeriodSec(60).withMetricName("CPUUtilization").withMetricNamespace("AWS/EC2").withName(jobId).withStatistic(Statistic.Average).build();
    StepAdjustment stepAdjustment = StepAdjustment.newBuilder().withMetricIntervalLowerBound(0).withScalingAdjustment(1).build();
    StepScalingPolicyConfiguration stepScalingPolicyConfiguration = StepScalingPolicyConfiguration.newBuilder().withAdjustmentType(StepAdjustmentType.ChangeInCapacity).withCoolDownSec(60).withMetricAggregatorType(MetricAggregationType.Average).withMinAdjustmentMagnitude(1).withSteps(Arrays.asList(stepAdjustment)).build();
    PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withAlarmConfiguration(alarmConfiguration).withStepScalingPolicyConfiguration(stepScalingPolicyConfiguration).withPolicyType(PolicyType.StepScaling).withName(jobId).build();
    AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).withStatus(PolicyStatus.Pending).withStatusMessage("ICE-ed by AWS").withJobId(jobId).build();
    return autoScalingPolicy;
}
Also used : AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) StepAdjustment(com.netflix.titus.api.appscale.model.StepAdjustment) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration)

Example 10 with AutoScalingPolicy

use of com.netflix.titus.api.appscale.model.AutoScalingPolicy in project titus-control-plane by Netflix.

the class AutoScalingPolicyTests method buildTargetTrackingPolicy.

public static AutoScalingPolicy buildTargetTrackingPolicy(String jobId) {
    CustomizedMetricSpecification customizedMetricSpec = CustomizedMetricSpecification.newBuilder().withNamespace("foobar").withNamespace("NFLX/EPIC").withStatistic(Statistic.Sum).withUnit("Seconds").build();
    TargetTrackingPolicy targetTrackingPolicy = TargetTrackingPolicy.newBuilder().withDisableScaleIn(false).withScaleInCooldownSec(10).withScaleOutCooldownSec(5).withCustomizedMetricSpecification(customizedMetricSpec).build();
    PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withTargetTrackingPolicy(targetTrackingPolicy).withPolicyType(PolicyType.TargetTrackingScaling).build();
    AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).withStatus(PolicyStatus.Pending).withStatusMessage("ICE-ed by AWS").withJobId(jobId).build();
    return autoScalingPolicy;
}
Also used : TargetTrackingPolicy(com.netflix.titus.api.appscale.model.TargetTrackingPolicy) AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) CustomizedMetricSpecification(com.netflix.titus.api.appscale.model.CustomizedMetricSpecification) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration)

Aggregations

AutoScalingPolicy (com.netflix.titus.api.appscale.model.AutoScalingPolicy)21 PolicyConfiguration (com.netflix.titus.api.appscale.model.PolicyConfiguration)8 StepScalingPolicyConfiguration (com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration)8 Test (org.junit.Test)7 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)6 AlarmConfiguration (com.netflix.titus.api.appscale.model.AlarmConfiguration)6 StepAdjustment (com.netflix.titus.api.appscale.model.StepAdjustment)4 BoundStatement (com.datastax.driver.core.BoundStatement)3 ResultSet (com.datastax.driver.core.ResultSet)3 Row (com.datastax.driver.core.Row)3 Session (com.datastax.driver.core.Session)3 PolicyStatus (com.netflix.titus.api.appscale.model.PolicyStatus)3 PolicyType (com.netflix.titus.api.appscale.model.PolicyType)3 V3JobOperations (com.netflix.titus.api.jobmanager.service.V3JobOperations)3 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)3 InMemoryPolicyStore (com.netflix.titus.runtime.store.v3.memory.InMemoryPolicyStore)3 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)3 List (java.util.List)3 Optional (java.util.Optional)3 UUID (java.util.UUID)3