Search in sources :

Example 1 with AlarmConfiguration

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

use of com.netflix.titus.grpc.protogen.AlarmConfiguration 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 3 with AlarmConfiguration

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

the class AutoScalingTestUtils method generateUpdateStepScalingPolicyRequest.

public static UpdatePolicyRequest generateUpdateStepScalingPolicyRequest(String policyRefId, double threshold) {
    ScalingPolicy scalingPolicy = generateStepPolicy();
    AlarmConfiguration alarmConfig = scalingPolicy.getStepPolicyDescriptor().getAlarmConfig().toBuilder().setThreshold(DoubleValue.newBuilder().setValue(threshold).build()).build();
    StepScalingPolicyDescriptor stepScalingPolicyDescriptor = scalingPolicy.getStepPolicyDescriptor().toBuilder().setAlarmConfig(alarmConfig).build();
    ScalingPolicy scalingPolicyToBeUpdated = scalingPolicy.toBuilder().setStepPolicyDescriptor(stepScalingPolicyDescriptor).build();
    UpdatePolicyRequest updatePolicyRequest = UpdatePolicyRequest.newBuilder().setPolicyId(ScalingPolicyID.newBuilder().setId(policyRefId).build()).setScalingPolicy(scalingPolicyToBeUpdated).build();
    return updatePolicyRequest;
}
Also used : ScalingPolicy(com.netflix.titus.grpc.protogen.ScalingPolicy) StepScalingPolicy(com.netflix.titus.grpc.protogen.StepScalingPolicy) StepScalingPolicyDescriptor(com.netflix.titus.grpc.protogen.StepScalingPolicyDescriptor) UpdatePolicyRequest(com.netflix.titus.grpc.protogen.UpdatePolicyRequest) AlarmConfiguration(com.netflix.titus.grpc.protogen.AlarmConfiguration)

Aggregations

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