Search in sources :

Example 1 with BaseAlert

use of com.sequenceiq.periscope.domain.BaseAlert in project cloudbreak by hortonworks.

the class ScalingPolicyRequestConverter method convert.

@Override
public ScalingPolicyRequest convert(ScalingPolicy source) {
    ScalingPolicyRequest json = new ScalingPolicyRequest();
    json.setAdjustmentType(source.getAdjustmentType());
    BaseAlert alert = source.getAlert();
    if (alert != null) {
        json.setAlertId(alert.getId());
    }
    json.setName(source.getName());
    json.setScalingAdjustment(source.getScalingAdjustment());
    json.setHostGroup(source.getHostGroup());
    return json;
}
Also used : ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) BaseAlert(com.sequenceiq.periscope.domain.BaseAlert)

Example 2 with BaseAlert

use of com.sequenceiq.periscope.domain.BaseAlert in project cloudbreak by hortonworks.

the class ScalingPolicyResponseConverter method convert.

@Override
public ScalingPolicyResponse convert(ScalingPolicy source) {
    ScalingPolicyResponse json = new ScalingPolicyResponse();
    json.setId(source.getId());
    json.setAdjustmentType(source.getAdjustmentType());
    BaseAlert alert = source.getAlert();
    if (alert != null) {
        json.setAlertId(alert.getId());
    }
    json.setName(source.getName());
    json.setScalingAdjustment(source.getScalingAdjustment());
    json.setHostGroup(source.getHostGroup());
    return json;
}
Also used : BaseAlert(com.sequenceiq.periscope.domain.BaseAlert) ScalingPolicyResponse(com.sequenceiq.periscope.api.model.ScalingPolicyResponse)

Example 3 with BaseAlert

use of com.sequenceiq.periscope.domain.BaseAlert in project cloudbreak by hortonworks.

the class ScalingHandler method onApplicationEvent.

@Override
public void onApplicationEvent(ScalingEvent event) {
    BaseAlert alert = event.getAlert();
    Cluster cluster = clusterService.find(alert.getCluster().getId());
    MDCBuilder.buildMdcContext(cluster);
    scale(cluster, alert.getScalingPolicy());
}
Also used : BaseAlert(com.sequenceiq.periscope.domain.BaseAlert) Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 4 with BaseAlert

use of com.sequenceiq.periscope.domain.BaseAlert 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;
}
Also used : ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) BaseAlert(com.sequenceiq.periscope.domain.BaseAlert)

Example 5 with BaseAlert

use of com.sequenceiq.periscope.domain.BaseAlert 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);
}
Also used : ScalingPolicy(com.sequenceiq.periscope.domain.ScalingPolicy) BaseAlert(com.sequenceiq.periscope.domain.BaseAlert)

Aggregations

BaseAlert (com.sequenceiq.periscope.domain.BaseAlert)5 ScalingPolicy (com.sequenceiq.periscope.domain.ScalingPolicy)2 ScalingPolicyRequest (com.sequenceiq.periscope.api.model.ScalingPolicyRequest)1 ScalingPolicyResponse (com.sequenceiq.periscope.api.model.ScalingPolicyResponse)1 Cluster (com.sequenceiq.periscope.domain.Cluster)1