use of com.netflix.titus.api.appscale.model.StepAdjustment in project titus-control-plane by Netflix.
the class CassAppScalePolicyStoreTest method buildAutoScalingPolicy.
private AutoScalingPolicy buildAutoScalingPolicy(String jobId) {
AlarmConfiguration alarmConfiguration = AlarmConfiguration.newBuilder().withActionsEnabled(true).withComparisonOperator(ComparisonOperator.GreaterThanThreshold).withEvaluationPeriods(1).withPeriodSec(60).withMetricName("CPUUtilization").withMetricNamespace("AWS/EC2").withName(jobId).withStatistic(Statistic.Average).build();
StepAdjustment stepAdjustment = StepAdjustment.newBuilder().withMetricIntervalLowerBound(0).withScalingAdjustment(1).build();
StepScalingPolicyConfiguration stepScalingPolicyConfiguration = StepScalingPolicyConfiguration.newBuilder().withAdjustmentType(StepAdjustmentType.ChangeInCapacity).withCoolDownSec(60).withMetricAggregatorType(MetricAggregationType.Average).withMinAdjustmentMagnitude(1).withSteps(Arrays.asList(stepAdjustment)).build();
PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withAlarmConfiguration(alarmConfiguration).withStepScalingPolicyConfiguration(stepScalingPolicyConfiguration).withPolicyType(PolicyType.StepScaling).withName(jobId).build();
AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).withStatus(PolicyStatus.Pending).withStatusMessage("ICE-ed by AWS").withJobId(jobId).build();
return autoScalingPolicy;
}
use of com.netflix.titus.api.appscale.model.StepAdjustment in project titus-control-plane by Netflix.
the class AutoScalingPolicyTests method buildStepScalingPolicy.
public static AutoScalingPolicy buildStepScalingPolicy(String jobId) {
AlarmConfiguration alarmConfiguration = AlarmConfiguration.newBuilder().withActionsEnabled(true).withComparisonOperator(ComparisonOperator.GreaterThanThreshold).withEvaluationPeriods(1).withPeriodSec(60).withMetricName("CPUUtilization").withMetricNamespace("AWS/EC2").withName(jobId).withStatistic(Statistic.Average).build();
StepAdjustment stepAdjustment = StepAdjustment.newBuilder().withMetricIntervalLowerBound(0).withScalingAdjustment(1).build();
StepScalingPolicyConfiguration stepScalingPolicyConfiguration = StepScalingPolicyConfiguration.newBuilder().withAdjustmentType(StepAdjustmentType.ChangeInCapacity).withCoolDownSec(60).withMetricAggregatorType(MetricAggregationType.Average).withMinAdjustmentMagnitude(1).withSteps(Arrays.asList(stepAdjustment)).build();
PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withAlarmConfiguration(alarmConfiguration).withStepScalingPolicyConfiguration(stepScalingPolicyConfiguration).withPolicyType(PolicyType.StepScaling).withName(jobId).build();
AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).withStatus(PolicyStatus.Pending).withStatusMessage("ICE-ed by AWS").withJobId(jobId).build();
return autoScalingPolicy;
}
use of com.netflix.titus.api.appscale.model.StepAdjustment in project titus-control-plane by Netflix.
the class CassAppScalePolicyStoreTest method verifyStoreInit.
@Test
public void verifyStoreInit() throws Exception {
Session session = cassandraCQLUnit.getSession();
loadTestData();
CassAppScalePolicyStore store = new CassAppScalePolicyStore(session, configuration, new DefaultRegistry());
store.init().await();
List<AutoScalingPolicy> allPolicies = store.retrievePolicies(false).toList().toBlocking().first();
Assertions.assertThat(allPolicies.size()).isEqualTo(3);
List<AutoScalingPolicy> jobOnePolicies = store.retrievePoliciesForJob("job-1").toList().toBlocking().first();
Assertions.assertThat(jobOnePolicies.size()).isEqualTo(2);
List<String> refIdList = jobOnePolicies.stream().map(as -> as.getRefId()).collect(Collectors.toList());
Assertions.assertThat(refIdList).containsOnly(POLICY_1_ID, POLICY_3_ID);
List<AutoScalingPolicy> jobTwoPolicies = store.retrievePoliciesForJob("job-2").toList().toBlocking().first();
Assertions.assertThat(jobTwoPolicies.size()).isEqualTo(1);
List<String> jobTwoRefIdList = jobTwoPolicies.stream().map(as -> as.getRefId()).collect(Collectors.toList());
Assertions.assertThat(jobTwoRefIdList).isEqualTo(Arrays.asList(POLICY_2_ID));
// verify metric lower/upper bounds
List<StepAdjustment> stepAdjustments = jobTwoPolicies.stream().flatMap(as -> as.getPolicyConfiguration().getStepScalingPolicyConfiguration().getSteps().stream()).collect(Collectors.toList());
Assertions.assertThat(stepAdjustments.size()).isEqualTo(1);
Assertions.assertThat(stepAdjustments.get(0).getMetricIntervalUpperBound()).isEqualTo(Optional.empty());
Assertions.assertThat(stepAdjustments.get(0).getMetricIntervalLowerBound().get()).isEqualTo(Double.valueOf(0));
}
Aggregations