use of com.sequenceiq.periscope.api.model.LoadAlertResponse in project cloudbreak by hortonworks.
the class ClusterConverter method convert.
@Override
public AutoscaleClusterResponse convert(Cluster source) {
AutoscaleClusterResponse json = new AutoscaleClusterResponse(source.getHost(), source.getPort(), secretService.get(source.getClusterManagerUser()), source.getStackCrn(), source.isAutoscalingEnabled(), source.getState().name());
if (!source.getTimeAlerts().isEmpty()) {
List<TimeAlertResponse> timeAlertRequests = timeAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getTimeAlerts()));
json.setTimeAlerts(timeAlertRequests);
}
if (!source.getLoadAlerts().isEmpty()) {
List<LoadAlertResponse> loadAlertRequests = loadAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getLoadAlerts()));
json.setLoadAlerts(loadAlertRequests);
}
ScalingConfigurationRequest scalingConfig = new ScalingConfigurationRequest(source.getMinSize(), source.getMaxSize(), source.getCoolDown());
json.setScalingConfiguration(scalingConfig);
return json;
}
use of com.sequenceiq.periscope.api.model.LoadAlertResponse 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.LoadAlertResponse in project cloudbreak by hortonworks.
the class LoadAlertResponseConverter method convert.
@Override
public LoadAlertResponse convert(LoadAlert source) {
LoadAlertResponse json = new LoadAlertResponse();
json.setCrn(source.getAlertCrn());
json.setAlertName(source.getName());
json.setDescription(source.getDescription());
if (source.getLoadAlertConfiguration() != null) {
json.setLoadAlertConfiguration(loadAlertConfigurationResponseConverter.convert(source.getLoadAlertConfiguration()));
}
if (source.getScalingPolicy() != null) {
json.setScalingPolicy(scalingPolicyResponseConverter.convert(source.getScalingPolicy()));
}
return json;
}
use of com.sequenceiq.periscope.api.model.LoadAlertResponse in project cloudbreak by hortonworks.
the class LoadAlertResponseConverterTest method testConvertLoadAlertToLoadAlertResponse.
@Test
public void testConvertLoadAlertToLoadAlertResponse() {
LoadAlert req = new LoadAlert();
req.setName("loadalert");
req.setDescription("loadalertdesc");
req.setId(10L);
ScalingPolicy scalingPolicy = getScalingPolicy();
req.setScalingPolicy(scalingPolicy);
when(scalingPolicyResponseConverter.convert(any(ScalingPolicy.class))).thenCallRealMethod();
LoadAlertResponse loadAlertResponse = underTest.convert(req);
assertEquals("LoadAlert Name should match", loadAlertResponse.getAlertName(), "loadalert");
assertEquals("LoadAlert Desc should match", loadAlertResponse.getDescription(), "loadalertdesc");
assertEquals("LoadAlert Hostgroup should match", loadAlertResponse.getScalingPolicy().getHostGroup(), "compute");
assertEquals("LoadAlert Adjustment Type should match", loadAlertResponse.getScalingPolicy().getAdjustmentType(), NODE_COUNT);
assertEquals("LoadAlert Adjustment should match", loadAlertResponse.getScalingPolicy().getScalingAdjustment(), 10);
}
Aggregations