Search in sources :

Example 1 with LoadAlertResponse

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;
}
Also used : AutoscaleClusterResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterResponse) ScalingConfigurationRequest(com.sequenceiq.periscope.api.model.ScalingConfigurationRequest) TimeAlertResponse(com.sequenceiq.periscope.api.model.TimeAlertResponse) LoadAlertResponse(com.sequenceiq.periscope.api.model.LoadAlertResponse)

Example 2 with LoadAlertResponse

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;
}
Also used : DistroXAutoscaleClusterResponse(com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse) TimeAlertResponse(com.sequenceiq.periscope.api.model.TimeAlertResponse) LoadAlertResponse(com.sequenceiq.periscope.api.model.LoadAlertResponse)

Example 3 with LoadAlertResponse

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;
}
Also used : LoadAlertResponse(com.sequenceiq.periscope.api.model.LoadAlertResponse)

Example 4 with LoadAlertResponse

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);
}
Also used : ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) LoadAlertResponse(com.sequenceiq.periscope.api.model.LoadAlertResponse) LoadAlert(com.sequenceiq.periscope.domain.LoadAlert) Test(org.junit.Test)

Aggregations

LoadAlertResponse (com.sequenceiq.periscope.api.model.LoadAlertResponse)4 TimeAlertResponse (com.sequenceiq.periscope.api.model.TimeAlertResponse)2 AutoscaleClusterResponse (com.sequenceiq.periscope.api.model.AutoscaleClusterResponse)1 DistroXAutoscaleClusterResponse (com.sequenceiq.periscope.api.model.DistroXAutoscaleClusterResponse)1 ScalingConfigurationRequest (com.sequenceiq.periscope.api.model.ScalingConfigurationRequest)1 LoadAlert (com.sequenceiq.periscope.domain.LoadAlert)1 ScalingPolicy (com.sequenceiq.periscope.domain.ScalingPolicy)1 Test (org.junit.Test)1