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