use of com.sequenceiq.periscope.api.model.ScalingPolicyRequest 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;
}
use of com.sequenceiq.periscope.api.model.ScalingPolicyRequest 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