@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; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceStates() == null) ? 0 : getInstanceStates().hashCode()); return hashCode; }
/** * 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(); }
@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; 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 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); } }
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 boolean checkInstanceInServiceOnAllElb(Instance newInstance, List<String> loadBalancerNames) { if (newInstance == null) { throw new IllegalStateException("Unable to check null instance"); } for (String elb : loadBalancerNames) { DescribeInstanceHealthResult result = awsElbClient.describeInstanceHealth(new DescribeInstanceHealthRequest(elb)); Optional<InstanceState> state = result.getInstanceStates().stream().filter(s -> s.getInstanceId().equals(newInstance.getInstanceId())).findFirst(); if (!state.isPresent()) { log.info("instance state for instance " + newInstance.getInstanceId() + " on elb " + elb + " is unknown"); return false; } log.info("instance state for instance " + newInstance.getInstanceId() + " on elb " + elb + " is " + state.get().getState()); if (!"InService".equals(state.get().getState())) { return false; } } return true; }
private void updateInstancesStateOnLoadBalancer(String loadBalancerName, List<Ec2Instance> instances) { DescribeInstanceHealthResult result = awsElbClient.describeInstanceHealth(new DescribeInstanceHealthRequest(loadBalancerName)); instances.forEach(i -> result.getInstanceStates().stream().filter(s -> s.getInstanceId().equals(i.getInstanceId())).findFirst().ifPresent(s -> i.updateState(AwsState.map(s.getState())))); }