Example usage for com.amazonaws.services.autoscaling.model ScalingPolicy getScalingAdjustment

List of usage examples for com.amazonaws.services.autoscaling.model ScalingPolicy getScalingAdjustment

Introduction

In this page you can find the example usage for com.amazonaws.services.autoscaling.model ScalingPolicy getScalingAdjustment.

Prototype


public Integer getScalingAdjustment() 

Source Link

Document

The amount by which to scale, based on the specified adjustment type.

Usage

From source file:com.pinterest.arcee.autoscaling.AwsAutoScaleGroupManager.java

License:Apache License

@Override
public Map<String, ScalingPolicyBean> getScalingPoliciesForGroup(String groupName) throws Exception {
    Map<String, ScalingPolicyBean> policyBeans = new HashMap<>();
    try {/*from w  w  w  .  j  ava 2 s  . c  om*/
        DescribePoliciesRequest request = new DescribePoliciesRequest();
        request.setAutoScalingGroupName(groupName);
        DescribePoliciesResult result = aasClient.describePolicies(request);
        List<ScalingPolicy> policySet = result.getScalingPolicies();
        for (ScalingPolicy policy : policySet) {
            ScalingPolicyBean bean = new ScalingPolicyBean();
            bean.setCoolDownTime(policy.getCooldown() / 60);
            bean.setScalingType(policy.getAdjustmentType());
            bean.setPolicyName(policy.getPolicyName());
            bean.setScaleSize(policy.getScalingAdjustment());
            bean.setARN(policy.getPolicyARN());
            policyBeans.put(bean.getPolicyName(), bean);
        }
        return policyBeans;
    } catch (com.amazonaws.AmazonServiceException e) {
        return policyBeans;
    }
}

From source file:com.pinterest.arcee.autoscaling.AwsAutoScalingManager.java

License:Apache License

@Override
public Map<String, ScalingPolicyBean> getScalingPoliciesForGroup(String groupName) throws Exception {
    Map<String, ScalingPolicyBean> policyBeans = new HashMap<>();
    try {/*from   w  w w . j ava2s  .  c o m*/
        DescribePoliciesRequest request = new DescribePoliciesRequest();
        request.setAutoScalingGroupName(groupName);
        DescribePoliciesResult result = aasClient.describePolicies(request);
        List<ScalingPolicy> policySet = result.getScalingPolicies();
        for (ScalingPolicy policy : policySet) {
            ScalingPolicyBean bean = new ScalingPolicyBean();
            bean.setCoolDownTime(policy.getCooldown() / 60);
            bean.setScalingType(policy.getAdjustmentType());
            bean.setScaleSize(policy.getScalingAdjustment());
            if (policy.getScalingAdjustment() > 0) {
                bean.setPolicyType(PolicyType.SCALEUP.toString());
            } else {
                bean.setPolicyType(PolicyType.SCALEDOWN.toString());
            }
            bean.setARN(policy.getPolicyARN());
            policyBeans.put(bean.getPolicyType(), bean);
        }
        return policyBeans;
    } catch (com.amazonaws.AmazonServiceException e) {
        return policyBeans;
    }
}