StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInstanceId() != null) sb.append("InstanceId: ").append(getInstanceId()).append(","); if (getAutoScalingGroupName() != null) sb.append("AutoScalingGroupName: ").append(getAutoScalingGroupName()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getAutoScalingGroupName() == null) ? 0 : getAutoScalingGroupName().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getLifecycleState() == null) ? 0 : getLifecycleState().hashCode()); hashCode = prime * hashCode + ((getHealthStatus() == null) ? 0 : getHealthStatus().hashCode()); hashCode = prime * hashCode + ((getLaunchConfigurationName() == null) ? 0 : getLaunchConfigurationName().hashCode()); hashCode = prime * hashCode + ((getLaunchTemplate() == null) ? 0 : getLaunchTemplate().hashCode()); hashCode = prime * hashCode + ((getProtectedFromScaleIn() == null) ? 0 : getProtectedFromScaleIn().hashCode()); return hashCode; }
return false; AutoScalingInstanceDetails other = (AutoScalingInstanceDetails) obj; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; if (other.getAutoScalingGroupName() == null ^ this.getAutoScalingGroupName() == null)
/** * 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 (getInstanceId() != null) sb.append("InstanceId: " + getInstanceId() + ","); if (getAutoScalingGroupName() != null) sb.append("AutoScalingGroupName: " + getAutoScalingGroupName() + ","); if (getAvailabilityZone() != null) sb.append("AvailabilityZone: " + getAvailabilityZone() + ","); if (getLifecycleState() != null) sb.append("LifecycleState: " + getLifecycleState() + ","); if (getHealthStatus() != null) sb.append("HealthStatus: " + getHealthStatus() + ","); if (getLaunchConfigurationName() != null) sb.append("LaunchConfigurationName: " + getLaunchConfigurationName() + ","); if (getLaunchTemplate() != null) sb.append("LaunchTemplate: " + getLaunchTemplate() + ","); if (getProtectedFromScaleIn() != null) sb.append("ProtectedFromScaleIn: " + getProtectedFromScaleIn()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getAutoScalingGroupName() == null) ? 0 : getAutoScalingGroupName().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getLifecycleState() == null) ? 0 : getLifecycleState().hashCode()); hashCode = prime * hashCode + ((getHealthStatus() == null) ? 0 : getHealthStatus().hashCode()); hashCode = prime * hashCode + ((getLaunchConfigurationName() == null) ? 0 : getLaunchConfigurationName() .hashCode()); hashCode = prime * hashCode + ((getLaunchTemplate() == null) ? 0 : getLaunchTemplate().hashCode()); hashCode = prime * hashCode + ((getProtectedFromScaleIn() == null) ? 0 : getProtectedFromScaleIn().hashCode()); return hashCode; }
AutoScalingInstanceDetails other = (AutoScalingInstanceDetails) obj; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; if (other.getAutoScalingGroupName() == null ^ this.getAutoScalingGroupName() == null)
public void marshall(AutoScalingInstanceDetails _autoScalingInstanceDetails, Request<?> request, String _prefix) { String prefix; if (_autoScalingInstanceDetails.getInstanceId() != null) { prefix = _prefix + "InstanceId"; String instanceId = _autoScalingInstanceDetails.getInstanceId(); request.addParameter(prefix, StringUtils.fromString(instanceId));
public Observable<AwsState> pollForInstanceState() { try { return Observable.from(asyncClient.describeAutoScalingInstancesAsync(new DescribeAutoScalingInstancesRequest().withInstanceIds(instanceId))) .flatMap(result -> { Optional<String> optState = result.getAutoScalingInstances().stream().filter(i -> i.getInstanceId().equals(instanceId)).map(AutoScalingInstanceDetails::getLifecycleState).findFirst(); return just(optState.map(AwsState::map).orElse(AwsState.UNKNOWN)); }); } catch (AmazonClientException e) { LOG.error(LogConstants.ERROR_EXECUTING_REQUEST, e); throw new AwsException(e); } }
private Optional<AutoScalingInstanceDetails> describeInstance() { try { DescribeAutoScalingInstancesResult result = asyncClient.describeAutoScalingInstances(new DescribeAutoScalingInstancesRequest().withInstanceIds(Collections.singletonList(instanceId))); return result.getAutoScalingInstances().stream().filter(a -> a.getInstanceId().equals(instanceId)).findFirst(); } catch (AmazonAutoScalingException e) { if (e.getStatusCode() == 403) { LOG.error("Looks like the instance role is not correctly authorized, please see : https://github.com/msoute/vertx-deploy-tools#aws-iam-policy"); } LOG.error(e.getMessage(), e); throw e; } }
String getAutoscalingGroup(final String instanceId) { final DescribeAutoScalingInstancesRequest describeRequest = new DescribeAutoScalingInstancesRequest().withInstanceIds(Collections.singleton(instanceId)); final DescribeAutoScalingInstancesResult result = autoScalingClient.describeAutoScalingInstances(describeRequest); for (AutoScalingInstanceDetails details : result.getAutoScalingInstances()) { if (StringUtils.equals(instanceId, details.getInstanceId())) { return details.getAutoScalingGroupName(); } } return null; }
public boolean enterStandby(final String groupId, boolean decrementDesiredCapacity) { try { DescribeAutoScalingInstancesResult result = asyncClient.describeAutoScalingInstances(new DescribeAutoScalingInstancesRequest().withMaxRecords(1).withInstanceIds(instanceId)); Optional<AutoScalingInstanceDetails> state = result.getAutoScalingInstances() .stream() .filter(asi -> asi.getInstanceId().equals(instanceId)).findFirst(); state.ifPresent(s -> LOG.trace("enterStandby() instance {} current state : {}", instanceId, s.getLifecycleState())); if (state.isPresent() && state.get().getLifecycleState().equalsIgnoreCase(AwsState.STANDBY.name())) { return true; } else { asyncClient.enterStandby(new EnterStandbyRequest().withAutoScalingGroupName(groupId).withInstanceIds(instanceId).withShouldDecrementDesiredCapacity(decrementDesiredCapacity)); return true; } } catch (AmazonClientException e) { LOG.error(LogConstants.ERROR_EXECUTING_REQUEST, e); return false; } }