Search in sources :

Example 1 with LoadAlertConfiguration

use of com.sequenceiq.periscope.domain.LoadAlertConfiguration in project cloudbreak by hortonworks.

the class ClusterRepositoryTest method getAClusterWithLoadAlerts.

private Cluster getAClusterWithLoadAlerts() {
    Cluster cluster = new Cluster();
    cluster.setStackCrn(CLOUDBREAK_STACK_CRN_1);
    cluster.setState(ClusterState.RUNNING);
    cluster.setAutoscalingEnabled(Boolean.TRUE);
    cluster.setStackType(StackType.WORKLOAD);
    ClusterPertain clusterPertain = new ClusterPertain();
    clusterPertain.setTenant(TEST_TENANT);
    cluster.setClusterPertain(clusterPertain);
    ScalingPolicy scalingPolicy = new ScalingPolicy();
    scalingPolicy.setAdjustmentType(AdjustmentType.LOAD_BASED);
    scalingPolicy.setHostGroup("compute");
    LoadAlertConfiguration alertConfiguration = new LoadAlertConfiguration();
    alertConfiguration.setCoolDownMinutes(10);
    alertConfiguration.setMaxResourceValue(TEST_HOSTGROUP_MAX_SIZE);
    alertConfiguration.setMinResourceValue(TEST_HOSTGROUP_MIN_SIZE);
    LoadAlert loadAlert = new LoadAlert();
    loadAlert.setScalingPolicy(scalingPolicy);
    loadAlert.setLoadAlertConfiguration(alertConfiguration);
    loadAlert.setCluster(cluster);
    cluster.setLoadAlerts(Set.of(loadAlert));
    cluster.setLastScalingActivity(Instant.now().minus(45, ChronoUnit.MINUTES).toEpochMilli());
    return cluster;
}
Also used : ClusterPertain(com.sequenceiq.periscope.domain.ClusterPertain) ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) Cluster(com.sequenceiq.periscope.domain.Cluster) LoadAlert(com.sequenceiq.periscope.domain.LoadAlert) LoadAlertConfiguration(com.sequenceiq.periscope.domain.LoadAlertConfiguration)

Example 2 with LoadAlertConfiguration

use of com.sequenceiq.periscope.domain.LoadAlertConfiguration in project cloudbreak by hortonworks.

the class YarnLoadEvaluatorTest method getARunningCluster.

private Cluster getARunningCluster() {
    Cluster cluster = new Cluster();
    cluster.setId(AUTOSCALE_CLUSTER_ID);
    cluster.setStackCrn(CLOUDBREAK_STACK_CRN);
    cluster.setState(ClusterState.RUNNING);
    ClusterPertain clusterPertain = new ClusterPertain();
    clusterPertain.setTenant("testtenant");
    cluster.setClusterPertain(clusterPertain);
    ScalingPolicy scalingPolicy = new ScalingPolicy();
    scalingPolicy.setAdjustmentType(AdjustmentType.LOAD_BASED);
    scalingPolicy.setHostGroup("compute");
    LoadAlertConfiguration alertConfiguration = new LoadAlertConfiguration();
    alertConfiguration.setCoolDownMinutes(10);
    alertConfiguration.setMaxResourceValue(TEST_HOSTGROUP_MAX_SIZE);
    alertConfiguration.setMinResourceValue(TEST_HOSTGROUP_MIN_SIZE);
    LoadAlert loadAlert = new LoadAlert();
    loadAlert.setScalingPolicy(scalingPolicy);
    loadAlert.setLoadAlertConfiguration(alertConfiguration);
    cluster.setLoadAlerts(Set.of(loadAlert));
    cluster.setLastScalingActivity(Instant.now().minus(45, ChronoUnit.MINUTES).toEpochMilli());
    cluster.setMachineUserCrn(MACHINE_USER_CNR);
    return cluster;
}
Also used : ClusterPertain(com.sequenceiq.periscope.domain.ClusterPertain) ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) Cluster(com.sequenceiq.periscope.domain.Cluster) LoadAlert(com.sequenceiq.periscope.domain.LoadAlert) LoadAlertConfiguration(com.sequenceiq.periscope.domain.LoadAlertConfiguration)

Example 3 with LoadAlertConfiguration

use of com.sequenceiq.periscope.domain.LoadAlertConfiguration in project cloudbreak by hortonworks.

the class UsageReportingServiceTest method testReportLoadBasedAutoscalingTriggered.

@Test
public void testReportLoadBasedAutoscalingTriggered() {
    LoadAlert alert = new LoadAlert();
    alert.setName("testAlert");
    LoadAlertConfiguration la = new LoadAlertConfiguration();
    la.setMaxResourceValue(100);
    la.setMinResourceValue(10);
    la.setCoolDownMinutes(5);
    alert.setLoadAlertConfiguration(la);
    ScalingPolicy scalingPolicy = new ScalingPolicy();
    scalingPolicy.setHostGroup("compute");
    alert.setScalingPolicy(scalingPolicy);
    Cluster cluster = mock(Cluster.class);
    ClusterPertain clusterPertain = mock(ClusterPertain.class);
    when(cluster.getClusterPertain()).thenReturn(clusterPertain);
    when(clusterPertain.getTenant()).thenReturn("testTenant");
    when(cluster.getStackCrn()).thenReturn("testStackCrn");
    when(cluster.getStackName()).thenReturn("testStackName");
    underTest.reportAutoscalingTriggered(10, 20, ScalingStatus.SUCCESS, "Scaling was triggered", alert, cluster);
    ArgumentCaptor<UsageProto.CDPDatahubAutoscaleTriggered> captor = ArgumentCaptor.forClass(UsageProto.CDPDatahubAutoscaleTriggered.class);
    verify(usageReporter, times(1)).cdpDatahubAutoscaleTriggered(captor.capture());
    UsageProto.CDPDatahubAutoscaleTriggered actual = captor.getValue();
    assertEquals("Tenant should match", "testTenant", actual.getAutoscaleTriggerDetails().getAccountId());
    assertEquals("Cluster crn should match", "testStackCrn", actual.getAutoscaleTriggerDetails().getClusterCrn());
    assertEquals("Scaling Action should match", "Scaling was triggered", actual.getAutoscaleTriggerDetails().getAutoscalingAction());
    assertEquals("Original Node Count should match", 20, actual.getAutoscaleTriggerDetails().getOriginalHostGroupNodeCount());
    assertEquals("Desired Node Count should match", 30, actual.getAutoscaleTriggerDetails().getDesiredHostGroupNodeCount());
    assertEquals("Alert Policy Type should match", "LOAD_BASED", actual.getAutoscaleTriggerDetails().getAutoscalingPolicyDefinition().getAutoscalePolicyType().name());
    assertEquals("Alert Policy Parameters should match", "{parameters=LoadAlertConfiguration{minResourceValue=10, maxResourceValue=100, coolDownMinutes=5, scaleUpCoolDownMinutes=null," + " scaleDownCoolDownMinutes=null, maxScaleDownStepSize=100, maxScaleUpStepSize=100}}", actual.getAutoscaleTriggerDetails().getAutoscalingPolicyDefinition().getAutoscalePolicyParameters());
}
Also used : ClusterPertain(com.sequenceiq.periscope.domain.ClusterPertain) ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) Cluster(com.sequenceiq.periscope.domain.Cluster) LoadAlert(com.sequenceiq.periscope.domain.LoadAlert) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) LoadAlertConfiguration(com.sequenceiq.periscope.domain.LoadAlertConfiguration) Test(org.junit.Test)

Example 4 with LoadAlertConfiguration

use of com.sequenceiq.periscope.domain.LoadAlertConfiguration in project cloudbreak by hortonworks.

the class LoadAlertConfigurationRequestConverter method convert.

@Override
public LoadAlertConfiguration convert(LoadAlertConfigurationRequest source) {
    LoadAlertConfiguration loadAlertConfiguration = new LoadAlertConfiguration();
    loadAlertConfiguration.setMaxResourceValue(source.getMaxResourceValue());
    loadAlertConfiguration.setMinResourceValue(source.getMinResourceValue());
    loadAlertConfiguration.setMaxScaleUpStepSize(source.getMaxScaleUpStepSize());
    loadAlertConfiguration.setMaxScaleDownStepSize(source.getMaxScaleDownStepSize());
    loadAlertConfiguration.setCoolDownMinutes(source.getCoolDownMinutes());
    loadAlertConfiguration.setScaleUpCoolDownMinutes(source.getScaleUpCoolDownMinutes());
    loadAlertConfiguration.setScaleDownCoolDownMinutes(source.getScaleDownCoolDownMinutes());
    return loadAlertConfiguration;
}
Also used : LoadAlertConfiguration(com.sequenceiq.periscope.domain.LoadAlertConfiguration)

Aggregations

LoadAlertConfiguration (com.sequenceiq.periscope.domain.LoadAlertConfiguration)4 Cluster (com.sequenceiq.periscope.domain.Cluster)3 ClusterPertain (com.sequenceiq.periscope.domain.ClusterPertain)3 LoadAlert (com.sequenceiq.periscope.domain.LoadAlert)3 ScalingPolicy (com.sequenceiq.periscope.domain.ScalingPolicy)3 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 Test (org.junit.Test)1