Search in sources :

Example 1 with StepAdjustment

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;
}
Also used : AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) StepAdjustment(com.netflix.titus.api.appscale.model.StepAdjustment) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration)

Example 2 with StepAdjustment

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;
}
Also used : AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) StepAdjustment(com.netflix.titus.api.appscale.model.StepAdjustment) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration)

Example 3 with StepAdjustment

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));
}
Also used : Arrays(java.util.Arrays) StepAdjustmentType(com.netflix.titus.api.appscale.model.StepAdjustmentType) Row(com.datastax.driver.core.Row) LoggerFactory(org.slf4j.LoggerFactory) ComparisonOperator(com.netflix.titus.api.appscale.model.ComparisonOperator) CassandraCQLUnit(org.cassandraunit.CassandraCQLUnit) Observable(rx.Observable) PreparedStatement(com.datastax.driver.core.PreparedStatement) ResultSet(com.datastax.driver.core.ResultSet) BoundStatement(com.datastax.driver.core.BoundStatement) AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) Session(com.datastax.driver.core.Session) ClassPathCQLDataSet(org.cassandraunit.dataset.cql.ClassPathCQLDataSet) Assertions(org.assertj.core.api.Assertions) PolicyStatus(com.netflix.titus.api.appscale.model.PolicyStatus) Before(org.junit.Before) AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) MetricAggregationType(com.netflix.titus.api.appscale.model.MetricAggregationType) Logger(org.slf4j.Logger) Test(org.junit.Test) UUID(java.util.UUID) Mockito.when(org.mockito.Mockito.when) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) PolicyType(com.netflix.titus.api.appscale.model.PolicyType) StepScalingPolicyConfiguration(com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration) Statistic(com.netflix.titus.api.appscale.model.Statistic) List(java.util.List) StepAdjustment(com.netflix.titus.api.appscale.model.StepAdjustment) ObjectMappers(com.netflix.titus.api.json.ObjectMappers) Rule(org.junit.Rule) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Optional(java.util.Optional) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest) Mockito.mock(org.mockito.Mockito.mock) AutoScalingPolicy(com.netflix.titus.api.appscale.model.AutoScalingPolicy) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) StepAdjustment(com.netflix.titus.api.appscale.model.StepAdjustment) Session(com.datastax.driver.core.Session) Test(org.junit.Test) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)

Aggregations

AlarmConfiguration (com.netflix.titus.api.appscale.model.AlarmConfiguration)3 AutoScalingPolicy (com.netflix.titus.api.appscale.model.AutoScalingPolicy)3 PolicyConfiguration (com.netflix.titus.api.appscale.model.PolicyConfiguration)3 StepAdjustment (com.netflix.titus.api.appscale.model.StepAdjustment)3 StepScalingPolicyConfiguration (com.netflix.titus.api.appscale.model.StepScalingPolicyConfiguration)3 BoundStatement (com.datastax.driver.core.BoundStatement)1 PreparedStatement (com.datastax.driver.core.PreparedStatement)1 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 Session (com.datastax.driver.core.Session)1 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)1 ComparisonOperator (com.netflix.titus.api.appscale.model.ComparisonOperator)1 MetricAggregationType (com.netflix.titus.api.appscale.model.MetricAggregationType)1 PolicyStatus (com.netflix.titus.api.appscale.model.PolicyStatus)1 PolicyType (com.netflix.titus.api.appscale.model.PolicyType)1 Statistic (com.netflix.titus.api.appscale.model.Statistic)1 StepAdjustmentType (com.netflix.titus.api.appscale.model.StepAdjustmentType)1 ObjectMappers (com.netflix.titus.api.json.ObjectMappers)1 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)1 Arrays (java.util.Arrays)1