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();
}
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();
}
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;
}
Aggregations