@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getLoadBalancerName() == null) ? 0 : getLoadBalancerName().hashCode()); hashCode = prime * hashCode + ((getInstances() == null) ? 0 : getInstances().hashCode()); return hashCode; }
/** * <p> * The IDs of the instances. * </p> * * @param instances * The IDs of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withInstances(java.util.Collection<Instance> instances) { setInstances(instances); return this; }
/** * Constructs a new DescribeInstanceHealthRequest object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param loadBalancerName * The name of the load balancer. */ public DescribeInstanceHealthRequest(String loadBalancerName) { setLoadBalancerName(loadBalancerName); }
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 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; }
/** * <p> * The IDs of the instances. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param instances <p> * The IDs of the instances. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeInstanceHealthRequest withInstances(Instance... instances) { if (getInstances() == null) { this.instances = new java.util.ArrayList<Instance>(instances.length); } for (Instance value : instances) { this.instances.add(value); } return this; }
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())))); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeInstanceHealthRequest == false) return false; DescribeInstanceHealthRequest other = (DescribeInstanceHealthRequest) obj; if (other.getLoadBalancerName() == null ^ this.getLoadBalancerName() == null) return false; if (other.getLoadBalancerName() != null && other.getLoadBalancerName().equals(this.getLoadBalancerName()) == false) return false; if (other.getInstances() == null ^ this.getInstances() == null) return false; if (other.getInstances() != null && other.getInstances().equals(this.getInstances()) == false) return false; return true; }
/** * <p> * The name of the load balancer. * </p> * * @param loadBalancerName * The name of the load balancer. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withLoadBalancerName(String loadBalancerName) { setLoadBalancerName(loadBalancerName); return this; }
/** * <p> * The IDs of the instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstances(java.util.Collection)} or {@link #withInstances(java.util.Collection)} if you want to * override the existing values. * </p> * * @param instances * The IDs of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withInstances(Instance... instances) { if (this.instances == null) { setInstances(new com.amazonaws.internal.SdkInternalList<Instance>(instances.length)); } for (Instance ele : instances) { this.instances.add(ele); } return this; }
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())); } } }
/** * 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 (getLoadBalancerName() != null) sb.append("LoadBalancerName: ").append(getLoadBalancerName()).append(","); if (getInstances() != null) sb.append("Instances: ").append(getInstances()); sb.append("}"); return sb.toString(); }
/** * Constructs a new DescribeInstanceHealthRequest object. Callers should use * the setter or fluent setter (with...) methods to initialize any * additional object members. * * @param loadBalancerName <p> * The name of the load balancer. * </p> */ public DescribeInstanceHealthRequest(String loadBalancerName) { setLoadBalancerName(loadBalancerName); }
/** * <p> * The IDs of the instances. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param instances <p> * The IDs of the instances. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeInstanceHealthRequest withInstances(java.util.Collection<Instance> instances) { setInstances(instances); return this; }
public Request<DescribeInstanceHealthRequest> marshall(DescribeInstanceHealthRequest describeInstanceHealthRequest) { if (describeInstanceHealthRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<DescribeInstanceHealthRequest> request = new DefaultRequest<DescribeInstanceHealthRequest>(describeInstanceHealthRequest, "AmazonElasticLoadBalancing"); request.addParameter("Action", "DescribeInstanceHealth"); request.addParameter("Version", "2012-06-01"); request.setHttpMethod(HttpMethodName.POST); if (describeInstanceHealthRequest.getLoadBalancerName() != null) { request.addParameter("LoadBalancerName", StringUtils.fromString(describeInstanceHealthRequest.getLoadBalancerName())); } if (!describeInstanceHealthRequest.getInstances().isEmpty() || !((com.amazonaws.internal.SdkInternalList<Instance>) describeInstanceHealthRequest.getInstances()).isAutoConstruct()) { com.amazonaws.internal.SdkInternalList<Instance> instancesList = (com.amazonaws.internal.SdkInternalList<Instance>) describeInstanceHealthRequest .getInstances(); int instancesListIndex = 1; for (Instance instancesListValue : instancesList) { if (instancesListValue.getInstanceId() != null) { request.addParameter("Instances.member." + instancesListIndex + ".InstanceId", StringUtils.fromString(instancesListValue.getInstanceId())); } instancesListIndex++; } } return request; }
/** * Constructs a new DescribeInstanceHealthRequest object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param loadBalancerName * The name of the load balancer. */ public DescribeInstanceHealthRequest(String loadBalancerName) { setLoadBalancerName(loadBalancerName); }
/** * <p> * The IDs of the instances. * </p> * * @param instances * The IDs of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withInstances(java.util.Collection<Instance> instances) { setInstances(instances); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getLoadBalancerName() == null) ? 0 : getLoadBalancerName().hashCode()); hashCode = prime * hashCode + ((getInstances() == null) ? 0 : getInstances().hashCode()); return hashCode; }
/** * <p> * The name of the load balancer. * </p> * * @param loadBalancerName * The name of the load balancer. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withLoadBalancerName(String loadBalancerName) { setLoadBalancerName(loadBalancerName); return this; }
/** * <p> * The IDs of the instances. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstances(java.util.Collection)} or {@link #withInstances(java.util.Collection)} if you want to * override the existing values. * </p> * * @param instances * The IDs of the instances. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeInstanceHealthRequest withInstances(Instance... instances) { if (this.instances == null) { setInstances(new com.amazonaws.internal.SdkInternalList<Instance>(instances.length)); } for (Instance ele : instances) { this.instances.add(ele); } return this; }