@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeInstanceHealthResult == false) return false; DescribeInstanceHealthResult other = (DescribeInstanceHealthResult) obj; if (other.getInstanceStates() == null ^ this.getInstanceStates() == null) return false; if (other.getInstanceStates() != null && other.getInstanceStates().equals(this.getInstanceStates()) == false) return false; return true; }
public DescribeInstanceHealthResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeInstanceHealthResult describeInstanceHealthResult = new DescribeInstanceHealthResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeInstanceHealthResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("InstanceStates", targetDepth)) { describeInstanceHealthResult.withInstanceStates(new ArrayList<InstanceState>()); continue; } if (context.testExpression("InstanceStates/member", targetDepth)) { describeInstanceHealthResult.withInstanceStates(InstanceStateStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeInstanceHealthResult; } } } }
/** * <p> * Information about the health of the instances. * </p> * * @param instanceStates * Information about the health of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthResult withInstanceStates(java.util.Collection<InstanceState> instanceStates) { setInstanceStates(instanceStates); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceStates() == null) ? 0 : getInstanceStates().hashCode()); return hashCode; }
public DescribeInstanceHealthResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeInstanceHealthResult describeInstanceHealthResult = new DescribeInstanceHealthResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("InstanceStates/member", targetDepth)) { describeInstanceHealthResult.withInstanceStates(InstanceStateStaxUnmarshaller .getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return describeInstanceHealthResult; }
/** * <p> * Information about the health of the instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstanceStates(java.util.Collection)} or {@link #withInstanceStates(java.util.Collection)} if you want * to override the existing values. * </p> * * @param instanceStates * Information about the health of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthResult withInstanceStates(InstanceState... instanceStates) { if (this.instanceStates == null) { setInstanceStates(new com.amazonaws.internal.SdkInternalList<InstanceState>(instanceStates.length)); } for (InstanceState ele : instanceStates) { this.instanceStates.add(ele); } return this; }
/** * 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 (getInstanceStates() != null) sb.append("InstanceStates: ").append(getInstanceStates()); sb.append("}"); return sb.toString(); }
public DescribeInstanceHealthResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeInstanceHealthResult describeInstanceHealthResult = new DescribeInstanceHealthResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeInstanceHealthResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("InstanceStates", targetDepth)) { describeInstanceHealthResult.withInstanceStates(new ArrayList<InstanceState>()); continue; } if (context.testExpression("InstanceStates/member", targetDepth)) { describeInstanceHealthResult.withInstanceStates(InstanceStateStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeInstanceHealthResult; } } } }
/** * <p> * Information about the health of the instances. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param instanceStates <p> * Information about the health of the instances. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeInstanceHealthResult withInstanceStates( java.util.Collection<InstanceState> instanceStates) { setInstanceStates(instanceStates); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceStates() == null) ? 0 : getInstanceStates().hashCode()); return hashCode; }
/** * <p> * Information about the health of the instances. * </p> * * @param instanceStates * Information about the health of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthResult withInstanceStates(java.util.Collection<InstanceState> instanceStates) { setInstanceStates(instanceStates); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeInstanceHealthResult == false) return false; DescribeInstanceHealthResult other = (DescribeInstanceHealthResult) obj; if (other.getInstanceStates() == null ^ this.getInstanceStates() == null) return false; if (other.getInstanceStates() != null && other.getInstanceStates().equals(this.getInstanceStates()) == false) return false; return true; } }
/** * <p> * Information about the health of the instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstanceStates(java.util.Collection)} or {@link #withInstanceStates(java.util.Collection)} if you want * to override the existing values. * </p> * * @param instanceStates * Information about the health of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthResult withInstanceStates(InstanceState... instanceStates) { if (this.instanceStates == null) { setInstanceStates(new com.amazonaws.internal.SdkInternalList<InstanceState>(instanceStates.length)); } for (InstanceState ele : instanceStates) { this.instanceStates.add(ele); } return this; }
/** * 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 (getInstanceStates() != null) sb.append("InstanceStates: " + getInstanceStates()); sb.append("}"); return sb.toString(); }
/** * <p> * Information about the health of the instances. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param instanceStates <p> * Information about the health of the instances. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeInstanceHealthResult withInstanceStates(InstanceState... instanceStates) { if (getInstanceStates() == null) { this.instanceStates = new java.util.ArrayList<InstanceState>(instanceStates.length); } for (InstanceState value : instanceStates) { this.instanceStates.add(value); } return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceStates() == null) ? 0 : getInstanceStates().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeInstanceHealthResult == false) return false; DescribeInstanceHealthResult other = (DescribeInstanceHealthResult) obj; if (other.getInstanceStates() == null ^ this.getInstanceStates() == null) return false; if (other.getInstanceStates() != null && other.getInstanceStates().equals(this.getInstanceStates()) == 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 (getInstanceStates() != null) sb.append("InstanceStates: ").append(getInstanceStates()); sb.append("}"); return sb.toString(); }
public void updateInstanceState(Ec2Instance instance, List<String> loadBalancerNames) { for (String elb : loadBalancerNames) { DescribeInstanceHealthResult result = awsElbClient.describeInstanceHealth(new DescribeInstanceHealthRequest(elb)); Optional<InstanceState> state = result.getInstanceStates().stream().filter(s -> s.getInstanceId().equals(instance.getInstanceId())).findFirst(); if (!state.isPresent()) { instance.updateState(AwsState.UNKNOWN); } else { instance.updateState(AwsState.valueOf(state.get().getState().toUpperCase())); } } }
public Observable<AwsState> pollForInstanceState(final String loadBalancer) { try { return Observable.from(elbAsyncClient.describeInstanceHealthAsync(new DescribeInstanceHealthRequest().withLoadBalancerName(loadBalancer).withInstances(new Instance().withInstanceId(instanceId)))) .flatMap(result -> { Optional<InstanceState> state = result.getInstanceStates().stream().filter(i -> i.getInstanceId().equals(instanceId)).findFirst(); return just(state.map(instanceState -> AwsState.map(instanceState.getState())).orElse(AwsState.UNKNOWN)); }); } catch (AmazonClientException e) { LOG.error(LogConstants.ERROR_EXECUTING_REQUEST, e); throw new AwsException(e); } }