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

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

Introduction

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

Prototype


public String getPolicyARN() 

Source Link

Document

The Amazon Resource Name (ARN) of the policy.

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 .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 {/*  w  w  w. j  a  va 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.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;
    }
}