List of usage examples for com.amazonaws.services.autoscaling.model UpdateAutoScalingGroupRequest setMaxSize
public void setMaxSize(Integer maxSize)
The maximum size of the Auto Scaling group.
From source file:com.netflix.dynomitemanager.sidecore.aws.AWSMembership.java
License:Apache License
@Override public void expandRacMembership(int count) { AmazonAutoScaling client = null;/*from www .j a v a 2s.com*/ try { client = getAutoScalingClient(); DescribeAutoScalingGroupsRequest asgReq = new DescribeAutoScalingGroupsRequest() .withAutoScalingGroupNames(config.getASGName()); DescribeAutoScalingGroupsResult res = client.describeAutoScalingGroups(asgReq); AutoScalingGroup asg = res.getAutoScalingGroups().get(0); UpdateAutoScalingGroupRequest ureq = new UpdateAutoScalingGroupRequest(); ureq.setAutoScalingGroupName(asg.getAutoScalingGroupName()); ureq.setMinSize(asg.getMinSize() + 1); ureq.setMaxSize(asg.getMinSize() + 1); ureq.setDesiredCapacity(asg.getMinSize() + 1); client.updateAutoScalingGroup(ureq); } finally { if (client != null) client.shutdown(); } }
From source file:com.pinterest.arcee.autoscaling.AwsAutoScaleGroupManager.java
License:Apache License
@Override public void increaseASGDesiredCapacityBySize(String groupName, int instanceCnt) throws Exception { DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest(); request.setAutoScalingGroupNames(Arrays.asList(groupName)); DescribeAutoScalingGroupsResult result = aasClient.describeAutoScalingGroups(request); List<AutoScalingGroup> groups = result.getAutoScalingGroups(); if (groups.isEmpty()) { return;//from w ww.j a va 2 s . c om } AutoScalingGroup group = groups.get(0); int curCapacity = group.getDesiredCapacity(); UpdateAutoScalingGroupRequest updateRequest = new UpdateAutoScalingGroupRequest(); updateRequest.setAutoScalingGroupName(groupName); updateRequest.setDesiredCapacity(curCapacity + instanceCnt); updateRequest.setMaxSize(Math.max(group.getMaxSize(), curCapacity + instanceCnt)); aasClient.updateAutoScalingGroup(updateRequest); }
From source file:com.pinterest.arcee.autoscaling.AwsAutoScalingManager.java
License:Apache License
@Override public void updateAutoScalingGroup(String groupName, AwsVmBean request) throws Exception { UpdateAutoScalingGroupRequest updateAutoScalingGroupRequest = new UpdateAutoScalingGroupRequest(); updateAutoScalingGroupRequest.setAutoScalingGroupName(groupName); if (!StringUtils.isEmpty(request.getLaunchConfigId())) { updateAutoScalingGroupRequest.setLaunchConfigurationName(request.getLaunchConfigId()); }//ww w . j a v a2s.c o m if (!StringUtils.isEmpty(request.getSubnet())) { updateAutoScalingGroupRequest.setVPCZoneIdentifier(request.getSubnet()); } if (!StringUtils.isEmpty(request.getTerminationPolicy())) { updateAutoScalingGroupRequest .setTerminationPolicies(Collections.singletonList(request.getTerminationPolicy())); } if (request.getMinSize() != null) { updateAutoScalingGroupRequest.setMinSize(request.getMinSize()); } if (request.getMaxSize() != null) { updateAutoScalingGroupRequest.setMaxSize(request.getMaxSize()); } aasClient.updateAutoScalingGroup(updateAutoScalingGroupRequest); }
From source file:com.pinterest.arcee.autoscaling.AwsAutoScalingManager.java
License:Apache License
private void changeGroupCapacity(String groupName, int size, boolean increment) throws Exception { AutoScalingGroup group = getAutoScalingGroup(groupName); if (group == null) { return;// www . j a v a 2 s . com } int currCapacity = group.getDesiredCapacity(); int currMinSize = group.getMinSize(); int currMaxSize = group.getMaxSize(); if (increment) { currCapacity += size; if (currMaxSize == currMinSize) { currMinSize = currCapacity; currMaxSize = currCapacity; } else { currMaxSize = Math.max(currMaxSize, currCapacity); } } else { currCapacity = Math.max(currCapacity - size, 0); if (currMaxSize == currMinSize) { currMinSize = currCapacity; currMaxSize = currCapacity; } else { currMinSize = Math.min(currMinSize, currCapacity); } } UpdateAutoScalingGroupRequest updateRequest = new UpdateAutoScalingGroupRequest(); updateRequest.setAutoScalingGroupName(groupName); updateRequest.setDesiredCapacity(currCapacity); updateRequest.setMaxSize(currMaxSize); updateRequest.setMinSize(currMinSize); aasClient.updateAutoScalingGroup(updateRequest); }
From source file:com.pinterest.clusterservice.cm.AwsVmManager.java
License:Apache License
@Override public void launchHosts(String clusterName, int num) throws Exception { AutoScalingGroup group = getAutoScalingGroup(clusterName); if (group == null) { LOG.error(String.format("Failed to launch hosts: auto scaling group %s does not exist", clusterName)); throw new Exception( String.format("Failed to launch hosts: auto scaling group %s does not exist", clusterName)); }//from w w w. j av a 2s. c o m try { UpdateAutoScalingGroupRequest updateRequest = new UpdateAutoScalingGroupRequest(); updateRequest.setAutoScalingGroupName(clusterName); updateRequest.setDesiredCapacity(group.getDesiredCapacity() + num); updateRequest.setMaxSize(Math.max(group.getDesiredCapacity(), group.getDesiredCapacity() + num)); aasClient.updateAutoScalingGroup(updateRequest); } catch (AmazonClientException e) { LOG.error(String.format("Failed to launch %d hosts to auto scaling group %s: %s", num, clusterName, e.getMessage())); throw new Exception(String.format("Failed to launch %d hosts to auto scaling group %s: %s", num, clusterName, e.getMessage())); } }
From source file:com.pinterest.clusterservice.cm.AwsVmManager.java
License:Apache License
private void updateAutoScalingGroup(String clusterName, AwsVmBean newBean) throws Exception { try {/*from w ww . j ava 2 s .c om*/ UpdateAutoScalingGroupRequest updateAsgRequest = new UpdateAutoScalingGroupRequest(); updateAsgRequest.setAutoScalingGroupName(clusterName); if (newBean.getSubnet() != null) { updateAsgRequest.setVPCZoneIdentifier(newBean.getSubnet()); } if (newBean.getMinSize() != null) { updateAsgRequest.setMinSize(newBean.getMinSize()); } if (newBean.getMaxSize() != null) { updateAsgRequest.setMaxSize(newBean.getMaxSize()); } if (newBean.getLaunchConfigId() != null) { updateAsgRequest.setLaunchConfigurationName(newBean.getLaunchConfigId()); } aasClient.updateAutoScalingGroup(updateAsgRequest); } catch (AmazonClientException e) { LOG.error(String.format("Failed to update auto scaling group %s: %s", clusterName, e.getMessage())); throw new Exception( String.format("Failed to update auto scaling group %s: %s", clusterName, e.getMessage())); } }
From source file:tools.descartes.bungee.cloud.aws.AWSImpl.java
License:Apache License
public boolean setScalingBounds(String hostName, Bounds bounds) { boolean success = false; AutoScalingGroup group = getAutoScaleGroupForHostName(hostName); if (group != null) { UpdateAutoScalingGroupRequest request = new UpdateAutoScalingGroupRequest() .withAutoScalingGroupName(group.getAutoScalingGroupName()); request.setMinSize(bounds.getMin()); request.setMaxSize(bounds.getMax()); autoScale.updateAutoScalingGroup(request); success = bounds.equals(getScalingBounds(hostName)); }//from ww w . j a v a 2 s . c om return success; }