use of com.sequenceiq.periscope.api.model.ScalingConfigurationRequest in project cloudbreak by hortonworks.
the class ClusterConverter method convert.
@Override
public AutoscaleClusterResponse convert(Cluster source) {
AutoscaleClusterResponse json = new AutoscaleClusterResponse(source.getHost(), source.getPort(), source.getAmbariUser(), source.getStackId(), source.isAutoscalingEnabled(), source.getId(), source.getState().name());
if (!source.getMetricAlerts().isEmpty()) {
List<MetricAlertResponse> metricAlerts = metricAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getMetricAlerts()));
json.setMetricAlerts(metricAlerts);
}
if (!source.getTimeAlerts().isEmpty()) {
List<TimeAlertResponse> timeAlertRequests = timeAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getTimeAlerts()));
json.setTimeAlerts(timeAlertRequests);
}
if (!source.getPrometheusAlerts().isEmpty()) {
List<PrometheusAlertResponse> prometheusAlertRequests = prometheusAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getPrometheusAlerts()));
json.setPrometheusAlerts(prometheusAlertRequests);
}
ScalingConfigurationRequest scalingConfig = new ScalingConfigurationRequest(source.getMinSize(), source.getMaxSize(), source.getCoolDown());
json.setScalingConfiguration(scalingConfig);
return json;
}
use of com.sequenceiq.periscope.api.model.ScalingConfigurationRequest in project cloudbreak by hortonworks.
the class ClusterRequestConverter method convert.
@Override
public Cluster convert(AutoscaleClusterRequest source) {
Cluster cluster = new Cluster();
cluster.setStackId(source.getStackId());
cluster.setAutoscalingEnabled(source.enableAutoscaling());
List<MetricAlertRequest> metricAlertResponses = source.getMetricAlerts();
if (metricAlertResponses != null && !metricAlertResponses.isEmpty()) {
Set<MetricAlert> alerts = metricAlertResponses.stream().map(metricAlertJson -> {
MetricAlert alert = metricAlertRequestConverter.convert(metricAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setMetricAlerts(alerts);
}
List<TimeAlertRequest> timeAlertRequests = source.getTimeAlerts();
if (timeAlertRequests != null && !timeAlertRequests.isEmpty()) {
Set<TimeAlert> alerts = timeAlertRequests.stream().map(timeAlertJson -> {
TimeAlert alert = timeAlertRequestConverter.convert(timeAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setTimeAlerts(alerts);
}
List<PrometheusAlertRequest> prometheusAlertRequests = source.getPrometheusAlerts();
if (prometheusAlertRequests != null && !prometheusAlertRequests.isEmpty()) {
Set<PrometheusAlert> alerts = prometheusAlertRequests.stream().map(prometheusAlertJson -> {
PrometheusAlert alert = prometheusAlertRequestConverter.convert(prometheusAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setPrometheusAlerts(alerts);
}
ScalingConfigurationRequest scalingConfiguration = source.getScalingConfiguration();
if (scalingConfiguration != null) {
cluster.setMinSize(scalingConfiguration.getMinSize());
cluster.setMaxSize(scalingConfiguration.getMaxSize());
cluster.setCoolDown(scalingConfiguration.getCoolDown());
}
return cluster;
}
use of com.sequenceiq.periscope.api.model.ScalingConfigurationRequest in project cloudbreak by hortonworks.
the class AutoscalingUtil method configureAutoScaling.
static void configureAutoScaling(AutoscaleClient autoscaleClient, Long clusterId, int cooldown, int clusterMinsize, int clusterMaxSize) {
ConfigurationEndpoint configurationEndpoint = autoscaleClient.configurationEndpoint();
ScalingConfigurationRequest scalingConfigurationRequest = new ScalingConfigurationRequest();
scalingConfigurationRequest.setCoolDown(cooldown);
scalingConfigurationRequest.setMinSize(clusterMinsize);
scalingConfigurationRequest.setMaxSize(clusterMaxSize);
configurationEndpoint.setScalingConfiguration(clusterId, scalingConfigurationRequest);
ScalingConfigurationRequest scalingConfigurationTest = configurationEndpoint.getScalingConfiguration(clusterId);
Assert.assertEquals(cooldown, scalingConfigurationTest.getCoolDown());
Assert.assertEquals(clusterMinsize, scalingConfigurationTest.getMinSize());
Assert.assertEquals(clusterMaxSize, scalingConfigurationTest.getMaxSize());
}
use of com.sequenceiq.periscope.api.model.ScalingConfigurationRequest in project cloudbreak by hortonworks.
the class ClusterService method getScalingConfiguration.
public ScalingConfigurationRequest getScalingConfiguration(Long clusterId) {
Cluster cluster = findOneById(clusterId);
ScalingConfigurationRequest configuration = new ScalingConfigurationRequest();
configuration.setCoolDown(cluster.getCoolDown());
configuration.setMaxSize(cluster.getMaxSize());
configuration.setMinSize(cluster.getMinSize());
return configuration;
}
Aggregations