@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAutoScalingGroupName() == null) ? 0 : getAutoScalingGroupName().hashCode()); hashCode = prime * hashCode + ((getDesiredCapacity() == null) ? 0 : getDesiredCapacity().hashCode()); hashCode = prime * hashCode + ((getHonorCooldown() == null) ? 0 : getHonorCooldown().hashCode()); return hashCode; }
/** * <p> * The name of the Auto Scaling group. * </p> * * @param autoScalingGroupName * The name of the Auto Scaling group. * @return Returns a reference to this object so that method calls can be chained together. */ public SetDesiredCapacityRequest withAutoScalingGroupName(String autoScalingGroupName) { setAutoScalingGroupName(autoScalingGroupName); return this; }
/** * <p> * The number of EC2 instances that should be running in the Auto Scaling group. * </p> * * @param desiredCapacity * The number of EC2 instances that should be running in the Auto Scaling group. * @return Returns a reference to this object so that method calls can be chained together. */ public SetDesiredCapacityRequest withDesiredCapacity(Integer desiredCapacity) { setDesiredCapacity(desiredCapacity); return this; }
/** * Updates the Auto Scaling group size by setting the desired capacity only. */ private void setDesiredSize() { SetDesiredCapacityRequest request = new SetDesiredCapacityRequest() .withAutoScalingGroupName(this.autoScalingGroup).withDesiredCapacity(this.desiredCapacity) .withHonorCooldown(false); getClient().getApi().setDesiredCapacity(request); } }
@Override public void scaleTo(int desiredCapacity, String autoScalingGroup) throws ECSException { logger.info("Scaling to capacity: {} in ASG: {}", desiredCapacity, autoScalingGroup); try { AmazonAutoScaling asClient = AmazonAutoScalingClientBuilder.defaultClient(); asClient.setDesiredCapacity(new SetDesiredCapacityRequest() .withDesiredCapacity(desiredCapacity) .withAutoScalingGroupName(autoScalingGroup) ); } catch (Exception e) { throw new ECSException(e); } }
public void setDesiredCapacity(AutoScalingGroup autoScalingGroup, Integer capacity) { log.info("Setting desired capacity to : " + capacity); try { awsAsClient.setDesiredCapacity(new SetDesiredCapacityRequest() .withAutoScalingGroupName(autoScalingGroup.getAutoScalingGroupName()) .withDesiredCapacity(capacity) .withHonorCooldown(false)); } catch (AmazonClientException e) { log.error(e.getMessage(), e); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SetDesiredCapacityRequest == false) return false; SetDesiredCapacityRequest other = (SetDesiredCapacityRequest) obj; if (other.getAutoScalingGroupName() == null ^ this.getAutoScalingGroupName() == null) return false; if (other.getAutoScalingGroupName() != null && other.getAutoScalingGroupName().equals(this.getAutoScalingGroupName()) == false) return false; if (other.getDesiredCapacity() == null ^ this.getDesiredCapacity() == null) return false; if (other.getDesiredCapacity() != null && other.getDesiredCapacity().equals(this.getDesiredCapacity()) == false) return false; if (other.getHonorCooldown() == null ^ this.getHonorCooldown() == null) return false; if (other.getHonorCooldown() != null && other.getHonorCooldown().equals(this.getHonorCooldown()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAutoScalingGroupName() != null) sb.append("AutoScalingGroupName: ").append(getAutoScalingGroupName()).append(","); if (getDesiredCapacity() != null) sb.append("DesiredCapacity: ").append(getDesiredCapacity()).append(","); if (getHonorCooldown() != null) sb.append("HonorCooldown: ").append(getHonorCooldown()); sb.append("}"); return sb.toString(); }
public Request<SetDesiredCapacityRequest> marshall(SetDesiredCapacityRequest setDesiredCapacityRequest) { if (setDesiredCapacityRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<SetDesiredCapacityRequest> request = new DefaultRequest<SetDesiredCapacityRequest>(setDesiredCapacityRequest, "AmazonAutoScaling"); request.addParameter("Action", "SetDesiredCapacity"); request.addParameter("Version", "2011-01-01"); request.setHttpMethod(HttpMethodName.POST); if (setDesiredCapacityRequest.getAutoScalingGroupName() != null) { request.addParameter("AutoScalingGroupName", StringUtils.fromString(setDesiredCapacityRequest.getAutoScalingGroupName())); } if (setDesiredCapacityRequest.getDesiredCapacity() != null) { request.addParameter("DesiredCapacity", StringUtils.fromInteger(setDesiredCapacityRequest.getDesiredCapacity())); } if (setDesiredCapacityRequest.getHonorCooldown() != null) { request.addParameter("HonorCooldown", StringUtils.fromBoolean(setDesiredCapacityRequest.getHonorCooldown())); } return request; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAutoScalingGroupName() == null) ? 0 : getAutoScalingGroupName().hashCode()); hashCode = prime * hashCode + ((getDesiredCapacity() == null) ? 0 : getDesiredCapacity().hashCode()); hashCode = prime * hashCode + ((getHonorCooldown() == null) ? 0 : getHonorCooldown().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SetDesiredCapacityRequest == false) return false; SetDesiredCapacityRequest other = (SetDesiredCapacityRequest) obj; if (other.getAutoScalingGroupName() == null ^ this.getAutoScalingGroupName() == null) return false; if (other.getAutoScalingGroupName() != null && other.getAutoScalingGroupName().equals(this.getAutoScalingGroupName()) == false) return false; if (other.getDesiredCapacity() == null ^ this.getDesiredCapacity() == null) return false; if (other.getDesiredCapacity() != null && other.getDesiredCapacity().equals(this.getDesiredCapacity()) == false) return false; if (other.getHonorCooldown() == null ^ this.getHonorCooldown() == null) return false; if (other.getHonorCooldown() != null && other.getHonorCooldown().equals(this.getHonorCooldown()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAutoScalingGroupName() != null) sb.append("AutoScalingGroupName: " + getAutoScalingGroupName() + ","); if (getDesiredCapacity() != null) sb.append("DesiredCapacity: " + getDesiredCapacity() + ","); if (getHonorCooldown() != null) sb.append("HonorCooldown: " + getHonorCooldown()); sb.append("}"); return sb.toString(); }
if (setDesiredCapacityRequest.getAutoScalingGroupName() != null) { prefix = "AutoScalingGroupName"; String autoScalingGroupName = setDesiredCapacityRequest.getAutoScalingGroupName(); request.addParameter(prefix, StringUtils.fromString(autoScalingGroupName)); if (setDesiredCapacityRequest.getDesiredCapacity() != null) { prefix = "DesiredCapacity"; Integer desiredCapacity = setDesiredCapacityRequest.getDesiredCapacity(); request.addParameter(prefix, StringUtils.fromInteger(desiredCapacity)); if (setDesiredCapacityRequest.getHonorCooldown() != null) { prefix = "HonorCooldown"; Boolean honorCooldown = setDesiredCapacityRequest.getHonorCooldown(); request.addParameter(prefix, StringUtils.fromBoolean(honorCooldown));