Search in sources :

Example 1 with PolicyEndpoint

use of com.sequenceiq.periscope.api.endpoint.v1.PolicyEndpoint 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

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