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

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

Introduction

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

Prototype


public String getAdjustmentType() 

Source Link

Document

The adjustment type, which specifies how ScalingAdjustment is interpreted.

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 a  v  a  2s .  co 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.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   ww w .j av  a 2  s  .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;
    }
}