use of com.sequenceiq.periscope.api.model.MetricAlertRequest in project cloudbreak by hortonworks.
the class MetricAlertRequestConverter method convert.
@Override
public MetricAlertRequest convert(MetricAlert source) {
MetricAlertRequest json = new MetricAlertRequest();
json.setAlertName(source.getName());
json.setDescription(source.getDescription());
json.setPeriod(source.getPeriod());
json.setAlertDefinition(source.getDefinitionName());
json.setAlertState(source.getAlertState());
return json;
}
use of com.sequenceiq.periscope.api.model.MetricAlertRequest 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;
}
Aggregations