use of com.sequenceiq.periscope.domain.ScalingPolicy in project cloudbreak by hortonworks.
the class PrometheusAlertResponseConverter method convert.
@Override
public PrometheusAlert convert(PrometheusAlertResponse source) {
PrometheusAlert alert = new PrometheusAlert();
alert.setName(source.getAlertName());
alert.setDescription(source.getDescription());
alert.setPeriod(source.getPeriod());
alert.setAlertState(source.getAlertState() != null ? source.getAlertState() : CRITICAL);
double threshold = source.getThreshold();
String alertRuleName = source.getAlertRuleName();
try {
AlertOperator alertOperator = source.getAlertOperator() != null ? source.getAlertOperator() : AlertOperator.MORE_THAN;
String operator = alertOperator.getOperator();
String alertRule = templateService.createAlert(alertRuleName, alert.getName(), String.valueOf(threshold), alert.getPeriod(), operator);
alert.setAlertRule(alertRule);
alert.setParameters(createParametersFrom(threshold, alertOperator));
if (source.getScalingPolicy() != null) {
ScalingPolicy scalingPolicy = scalingPolicyRequestConverter.convert(source.getScalingPolicy());
scalingPolicy.setAlert(alert);
alert.setScalingPolicy(scalingPolicy);
}
} catch (Exception e) {
throw new ConversionFailedException(TypeDescriptor.valueOf(PrometheusAlertRequest.class), TypeDescriptor.valueOf(PrometheusAlert.class), source.toString(), e);
}
return alert;
}
use of com.sequenceiq.periscope.domain.ScalingPolicy in project cloudbreak by hortonworks.
the class ScalingPolicyRequestConverter method convert.
@Override
public ScalingPolicy convert(ScalingPolicyRequest source) {
ScalingPolicy policy = new ScalingPolicy();
policy.setAdjustmentType(source.getAdjustmentType());
policy.setName(source.getName());
policy.setScalingAdjustment(source.getScalingAdjustment());
policy.setHostGroup(source.getHostGroup());
return policy;
}
use of com.sequenceiq.periscope.domain.ScalingPolicy in project cloudbreak by hortonworks.
the class ScalingService method createPolicy.
public ScalingPolicy createPolicy(Long clusterId, Long alertId, ScalingPolicy policy) {
BaseAlert alert = alertService.getBaseAlert(clusterId, alertId);
policy.setAlert(alert);
ScalingPolicy scalingPolicy = policyRepository.save(policy);
alert.setScalingPolicy(scalingPolicy);
alertService.save(alert);
return scalingPolicy;
}
use of com.sequenceiq.periscope.domain.ScalingPolicy in project cloudbreak by hortonworks.
the class ScalingService method updatePolicy.
public ScalingPolicy updatePolicy(Long clusterId, Long policyId, ScalingPolicy scalingPolicy) {
ScalingPolicy policy = getScalingPolicy(clusterId, policyId);
policy.setName(scalingPolicy.getName());
policy.setHostGroup(scalingPolicy.getHostGroup());
policy.setAdjustmentType(scalingPolicy.getAdjustmentType());
policy.setScalingAdjustment(scalingPolicy.getScalingAdjustment());
return policyRepository.save(policy);
}
use of com.sequenceiq.periscope.domain.ScalingPolicy in project cloudbreak by hortonworks.
the class ScalingService method deletePolicy.
public void deletePolicy(Long clusterId, Long policyId) {
ScalingPolicy policy = getScalingPolicy(clusterId, policyId);
BaseAlert alert = policy.getAlert();
alert.setScalingPolicy(null);
policy.setAlert(null);
policyRepository.delete(policy);
alertService.save(alert);
}
Aggregations