Search in sources :

Example 1 with ScalingPolicyResponse

use of com.sequenceiq.periscope.api.model.ScalingPolicyResponse 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 2 with ScalingPolicyResponse

use of com.sequenceiq.periscope.api.model.ScalingPolicyResponse in project cloudbreak by hortonworks.

the class AutoscalingUtil method createPolicy.

static void createPolicy(AutoscaleClient autoscaleClient, String policyName, Long clusterId, Long alertId, String hostGroup, int scalingAdjustment) {
    Boolean policyCreated = Boolean.FALSE;
    ScalingPolicyRequest scalingPolicyRequest = new ScalingPolicyRequest();
    scalingPolicyRequest.setName(policyName);
    scalingPolicyRequest.setAdjustmentType(AdjustmentType.NODE_COUNT);
    scalingPolicyRequest.setAlertId(alertId);
    scalingPolicyRequest.setScalingAdjustment(scalingAdjustment);
    scalingPolicyRequest.setHostGroup(hostGroup);
    PolicyEndpoint policyEndpoint = autoscaleClient.policyEndpoint();
    policyEndpoint.addScalingPolicy(clusterId, scalingPolicyRequest);
    List<ScalingPolicyResponse> policies = policyEndpoint.getScalingPolicies(clusterId);
    for (ScalingPolicyResponse policy : policies) {
        if (policy.getAlertId() == alertId) {
            policyCreated = Boolean.TRUE;
        }
    }
    Assert.assertTrue(policyCreated);
}
Also used : ScalingPolicyRequest(com.sequenceiq.periscope.api.model.ScalingPolicyRequest) PolicyEndpoint(com.sequenceiq.periscope.api.endpoint.v1.PolicyEndpoint) ScalingPolicyResponse(com.sequenceiq.periscope.api.model.ScalingPolicyResponse)

Aggregations

ScalingPolicyResponse (com.sequenceiq.periscope.api.model.ScalingPolicyResponse)2 PolicyEndpoint (com.sequenceiq.periscope.api.endpoint.v1.PolicyEndpoint)1 ScalingPolicyRequest (com.sequenceiq.periscope.api.model.ScalingPolicyRequest)1 BaseAlert (com.sequenceiq.periscope.domain.BaseAlert)1