Search in sources :

Example 1 with StepScalingPolicy

use of com.netflix.titus.grpc.protogen.StepScalingPolicy in project titus-control-plane by Netflix.

the class AutoScalingTestUtils method generateStepPolicy.

/**
 * Builds a random scaling policy for use with tests.
 *
 * @return
 */
public static ScalingPolicy generateStepPolicy() {
    // TODO(Andrew L): Add target tracking support
    AlarmConfiguration alarmConfig = AlarmConfiguration.newBuilder().setActionsEnabled(BoolValue.newBuilder().setValue(ThreadLocalRandom.current().nextBoolean()).build()).setComparisonOperator(AlarmConfiguration.ComparisonOperator.GreaterThanThreshold).setEvaluationPeriods(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build()).setPeriodSec(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build()).setThreshold(DoubleValue.newBuilder().setValue(ThreadLocalRandom.current().nextDouble()).build()).setMetricNamespace("NFLX/EPIC").setMetricName("Metric-" + ThreadLocalRandom.current().nextInt()).setStatistic(AlarmConfiguration.Statistic.Sum).build();
    StepScalingPolicy stepScalingPolicy = StepScalingPolicy.newBuilder().setAdjustmentType(StepScalingPolicy.AdjustmentType.ChangeInCapacity).setCooldownSec(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build()).setMinAdjustmentMagnitude(Int64Value.newBuilder().setValue(ThreadLocalRandom.current().nextLong()).build()).setMetricAggregationType(StepScalingPolicy.MetricAggregationType.Maximum).addStepAdjustments(StepAdjustments.newBuilder().setMetricIntervalLowerBound(DoubleValue.newBuilder().setValue(ThreadLocalRandom.current().nextDouble()).build()).setMetricIntervalUpperBound(DoubleValue.newBuilder().setValue(ThreadLocalRandom.current().nextDouble()).build()).setScalingAdjustment(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build())).build();
    StepScalingPolicyDescriptor stepScalingPolicyDescriptor = StepScalingPolicyDescriptor.newBuilder().setAlarmConfig(alarmConfig).setScalingPolicy(stepScalingPolicy).build();
    return ScalingPolicy.newBuilder().setStepPolicyDescriptor(stepScalingPolicyDescriptor).build();
}
Also used : StepScalingPolicy(com.netflix.titus.grpc.protogen.StepScalingPolicy) StepScalingPolicyDescriptor(com.netflix.titus.grpc.protogen.StepScalingPolicyDescriptor) AlarmConfiguration(com.netflix.titus.grpc.protogen.AlarmConfiguration)

Example 2 with StepScalingPolicy

use of com.netflix.titus.grpc.protogen.StepScalingPolicy 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)

Aggregations

AlarmConfiguration (com.netflix.titus.grpc.protogen.AlarmConfiguration)2 StepScalingPolicy (com.netflix.titus.grpc.protogen.StepScalingPolicy)2 StepScalingPolicyDescriptor (com.netflix.titus.grpc.protogen.StepScalingPolicyDescriptor)2 AutoScalingPolicy (com.netflix.titus.api.appscale.model.AutoScalingPolicy)1 ScalingPolicy (com.netflix.titus.grpc.protogen.ScalingPolicy)1 TargetTrackingPolicyDescriptor (com.netflix.titus.grpc.protogen.TargetTrackingPolicyDescriptor)1