Search in sources :

Example 1 with DistroXAutoscaleClusterResponse

use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method testEnableStopStartScalingForClusterCrn.

@Test
public void testEnableStopStartScalingForClusterCrn() {
    DistroXAutoscaleClusterResponse clusterResponse = distroXAutoScaleClusterV1Endpoint.enableAutoscaleForClusterCrn(TEST_CLUSTER_CRN, AutoscaleClusterState.enableStopStart());
    assertTrue("StopStart scaling should be enabled", clusterResponse.isStopStartScalingEnabled());
    clusterResponse = distroXAutoScaleClusterV1Endpoint.enableAutoscaleForClusterCrn(TEST_CLUSTER_CRN, AutoscaleClusterState.disableStopStart());
    assertFalse("StopStart scaling should be disabled", clusterResponse.isStopStartScalingEnabled());
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 2 with DistroXAutoscaleClusterResponse

use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse in project cloudbreak by hortonworks.

the class HttpNotificationSender method sendConfigUpdateNotification.

public void sendConfigUpdateNotification(Cluster configUpdate) {
    Notification configUpdateNotification = new Notification();
    configUpdateNotification.setTenantName(configUpdate.getClusterPertain().getTenant());
    configUpdateNotification.setEventType(NotificationType.AUTOSCALE_CONFIG_UPDATE.name());
    configUpdateNotification.setEventTimestamp(Instant.now().toEpochMilli());
    configUpdateNotification.setEventMessage(messagesService.getMessage(MessageCode.NOTIFICATION_AS_CONFIG_UPDATE));
    DistroXAutoscaleClusterResponse asResponse = autoscaleClusterResponseConverter.convert(configUpdate);
    configUpdateNotification.setPayload(asResponse);
    configUpdateNotification.setPayloadType(asResponse.getClass().getSimpleName());
    send(configUpdateNotification);
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse)

Example 3 with DistroXAutoscaleClusterResponse

use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse in project cloudbreak by hortonworks.

the class DistroXAutoscaleClusterResponseConverter method convert.

@Override
public DistroXAutoscaleClusterResponse convert(Cluster source) {
    DistroXAutoscaleClusterResponse json = new DistroXAutoscaleClusterResponse(source.getStackCrn(), source.getStackName(), source.isAutoscalingEnabled(), source.getState());
    json.setStackType(source.getStackType());
    json.setStopStartScalingEnabled(source.isStopStartScalingEnabled());
    List<TimeAlertResponse> timeAlertRequests = timeAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getTimeAlerts()));
    json.setTimeAlerts(timeAlertRequests);
    List<LoadAlertResponse> loadAlertRequests = loadAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getLoadAlerts()));
    json.setLoadAlerts(loadAlertRequests);
    return json;
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) TimeAlertResponse(com.sequenceiq.periscope.api.model.TimeAlertResponse) LoadAlertResponse(com.sequenceiq.periscope.api.model.LoadAlertResponse)

Example 4 with DistroXAutoscaleClusterResponse

use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method testEnableStopStartScalingForClusterName.

@Test
public void testEnableStopStartScalingForClusterName() {
    DistroXAutoscaleClusterResponse clusterResponse = distroXAutoScaleClusterV1Endpoint.enableAutoscaleForClusterName(TEST_CLUSTER_NAME, AutoscaleClusterState.enableStopStart());
    assertTrue("StopStart scaling should be enabled", clusterResponse.isStopStartScalingEnabled());
    clusterResponse = distroXAutoScaleClusterV1Endpoint.enableAutoscaleForClusterName(TEST_CLUSTER_NAME, AutoscaleClusterState.disableStopStart());
    assertFalse("StopStart scaling should be disabled", clusterResponse.isStopStartScalingEnabled());
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 5 with DistroXAutoscaleClusterResponse

use of com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse in project cloudbreak by hortonworks.

the class DistroXAutoScaleClusterV1EndpointTest method testUpdateAutoscaleConfigByClusterNameForLoadAlerts.

@Test
public void testUpdateAutoscaleConfigByClusterNameForLoadAlerts() {
    List<LoadAlertRequest> loadAlertRequests = getLoadAlertRequests(1, List.of("compute"));
    DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest = new DistroXAutoscaleClusterRequest();
    distroXAutoscaleClusterRequest.setLoadAlertRequests(loadAlertRequests);
    distroXAutoscaleClusterRequest.setEnableAutoscaling(true);
    DistroXAutoscaleClusterResponse xAutoscaleClusterResponse = distroXAutoScaleClusterV1Endpoint.updateAutoscaleConfigByClusterName(TEST_CLUSTER_NAME, distroXAutoscaleClusterRequest);
    assertEquals("Retrieved Alerts Size Should Match", 1, xAutoscaleClusterResponse.getLoadAlerts().size());
    assertTrue("Autoscaling should be enabled", xAutoscaleClusterResponse.isAutoscalingEnabled());
    xAutoscaleClusterResponse.getLoadAlerts().stream().forEach(this::validateLoadAlertResponse);
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) LoadAlertRequest(com.sequenceiq.periscope.api.model.LoadAlertRequest) DistroXAutoscaleClusterRequest(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

DistroXAutoscaleClusterResponse (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse)14 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 DistroXAutoscaleClusterRequest (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterRequest)8 LoadAlertRequest (com.sequenceiq.periscope.api.model.LoadAlertRequest)3 TimeAlertRequest (com.sequenceiq.periscope.api.model.TimeAlertRequest)3 LoadAlertResponse (com.sequenceiq.periscope.api.model.LoadAlertResponse)1 TimeAlertResponse (com.sequenceiq.periscope.api.model.TimeAlertResponse)1