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