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

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

Introduction

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

Prototype


public Integer getCooldown() 

Source Link

Document

The amount of time, in seconds, after a scaling activity completes before any further dynamic scaling activities can start.

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  ava2s.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  w  w w  .  j  a  v  a 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;
    }
}