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);
}
Aggregations