Search in sources :

Example 1 with TargetTrackingPolicyDescriptor

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

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

the class AutoScalingTestUtils method generateTargetPolicy.

public static ScalingPolicy generateTargetPolicy() {
    CustomizedMetricSpecification customizedMetricSpec = CustomizedMetricSpecification.newBuilder().addDimensions(MetricDimension.newBuilder().setName("testName").setValue("testValue").build()).setMetricName("testMetric").setNamespace("NFLX/EPIC").setStatistic(AlarmConfiguration.Statistic.Sum).setMetricName("peanuts").build();
    TargetTrackingPolicyDescriptor targetTrackingPolicyDescriptor = TargetTrackingPolicyDescriptor.newBuilder().setTargetValue(DoubleValue.newBuilder().setValue(ThreadLocalRandom.current().nextDouble()).build()).setScaleInCooldownSec(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build()).setScaleOutCooldownSec(Int32Value.newBuilder().setValue(ThreadLocalRandom.current().nextInt()).build()).setDisableScaleIn(BoolValue.newBuilder().setValue(false).build()).setCustomizedMetricSpecification(customizedMetricSpec).build();
    return ScalingPolicy.newBuilder().setTargetPolicyDescriptor(targetTrackingPolicyDescriptor).build();
}
Also used : CustomizedMetricSpecification(com.netflix.titus.grpc.protogen.CustomizedMetricSpecification) TargetTrackingPolicyDescriptor(com.netflix.titus.grpc.protogen.TargetTrackingPolicyDescriptor)

Example 3 with TargetTrackingPolicyDescriptor

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

the class AutoScalingTestUtils method generateUpdateTargetTrackingPolicyRequest.

public static UpdatePolicyRequest generateUpdateTargetTrackingPolicyRequest(String policyRefId, double targetValue) {
    ScalingPolicy scalingPolicy = generateTargetPolicy();
    TargetTrackingPolicyDescriptor targetPolicyDescriptor = scalingPolicy.getTargetPolicyDescriptor();
    TargetTrackingPolicyDescriptor targetPolicyWithUpdatedValue = targetPolicyDescriptor.toBuilder().setTargetValue(DoubleValue.newBuilder().setValue(targetValue).build()).build();
    ScalingPolicy scalingPolicyTobeUpdated = scalingPolicy.toBuilder().setTargetPolicyDescriptor(targetPolicyWithUpdatedValue).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) UpdatePolicyRequest(com.netflix.titus.grpc.protogen.UpdatePolicyRequest) TargetTrackingPolicyDescriptor(com.netflix.titus.grpc.protogen.TargetTrackingPolicyDescriptor)

Aggregations

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