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