@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getLoadBalancerDescriptions() == null) ? 0 : getLoadBalancerDescriptions().hashCode()); hashCode = prime * hashCode + ((getNextMarker() == null) ? 0 : getNextMarker().hashCode()); return hashCode; }
public DescribeLoadBalancersResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeLoadBalancersResult describeLoadBalancersResult = new DescribeLoadBalancersResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeLoadBalancersResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("LoadBalancerDescriptions", targetDepth)) { describeLoadBalancersResult.withLoadBalancerDescriptions(new ArrayList<LoadBalancerDescription>()); continue; } if (context.testExpression("LoadBalancerDescriptions/member", targetDepth)) { describeLoadBalancersResult.withLoadBalancerDescriptions(LoadBalancerDescriptionStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("NextMarker", targetDepth)) { describeLoadBalancersResult.setNextMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeLoadBalancersResult; } } } }
/** * <p> * Information about the load balancers. * </p> * * @param loadBalancerDescriptions * Information about the load balancers. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeLoadBalancersResult withLoadBalancerDescriptions(java.util.Collection<LoadBalancerDescription> loadBalancerDescriptions) { setLoadBalancerDescriptions(loadBalancerDescriptions); return this; }
/** {@inheritDoc} */ @Override public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException { initClients(); List<String> instanceIds = new ArrayList<>(); DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest().withLoadBalancerNames(loadBalancerName); List<LoadBalancerDescription> descs = amazonELBClient.describeLoadBalancers(req).getLoadBalancerDescriptions(); for (LoadBalancerDescription desc : descs) { for (Instance instance : desc.getInstances()) instanceIds.add(instance.getInstanceId()); } DescribeInstancesRequest instReq = new DescribeInstancesRequest().withInstanceIds(instanceIds); List<Reservation> reservations = amazonEC2Client.describeInstances(instReq).getReservations(); List<InetSocketAddress> addrs = new ArrayList<>(); for (Reservation reservation : reservations) { List<com.amazonaws.services.ec2.model.Instance> instances = reservation.getInstances(); for (com.amazonaws.services.ec2.model.Instance instance : instances) addrs.add(new InetSocketAddress(instance.getPrivateIpAddress(), 0)); } return addrs; }
public DescribeLoadBalancersResult describeLoadBalancers(DescribeLoadBalancersRequest request) { return new DescribeLoadBalancersResult() .withLoadBalancerDescriptions( describe(request, "loadBalancerNames", "loadBalancers", LoadBalancerDescription.class)); }
/** * <p> * The marker to use when requesting the next set of results. If there are no additional results, the string is * empty. * </p> * * @param nextMarker * The marker to use when requesting the next set of results. If there are no additional results, the string * is empty. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeLoadBalancersResult withNextMarker(String nextMarker) { setNextMarker(nextMarker); return this; }
/** * <p> * Information about the load balancers. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param loadBalancerDescriptions <p> * Information about the load balancers. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeLoadBalancersResult withLoadBalancerDescriptions( LoadBalancerDescription... loadBalancerDescriptions) { if (getLoadBalancerDescriptions() == null) { this.loadBalancerDescriptions = new java.util.ArrayList<LoadBalancerDescription>( loadBalancerDescriptions.length); } for (LoadBalancerDescription value : loadBalancerDescriptions) { this.loadBalancerDescriptions.add(value); } return this; }
public DescribeLoadBalancersResult describeLoadBalancers(DescribeLoadBalancersRequest request) { List<LoadBalancerDescription> loadBalancerDescriptions = describe(request, "loadBalancerNames", "loadBalancers", LoadBalancerDescription.class, new TypeReference<List<LoadBalancerDescription>>() { }); return new DescribeLoadBalancersResult().withLoadBalancerDescriptions(loadBalancerDescriptions); }
/** * <p> * The marker to use when requesting the next set of results. If there are no additional results, the string is * empty. * </p> * * @param nextMarker * The marker to use when requesting the next set of results. If there are no additional results, the string * is empty. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeLoadBalancersResult withNextMarker(String nextMarker) { setNextMarker(nextMarker); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeLoadBalancersResult == false) return false; DescribeLoadBalancersResult other = (DescribeLoadBalancersResult) obj; if (other.getLoadBalancerDescriptions() == null ^ this.getLoadBalancerDescriptions() == null) return false; if (other.getLoadBalancerDescriptions() != null && other.getLoadBalancerDescriptions().equals(this.getLoadBalancerDescriptions()) == false) return false; if (other.getNextMarker() == null ^ this.getNextMarker() == null) return false; if (other.getNextMarker() != null && other.getNextMarker().equals(this.getNextMarker()) == false) return false; return true; }
/** * Fetches and filters a Region's ELBs * @param amazonElasticLoadBalancing * @param filter * @return */ public static List<LoadBalancerDescription> findLoadBalancers(AmazonElasticLoadBalancing amazonElasticLoadBalancing, ELBFilter filter) { List<LoadBalancerDescription> loadBalancers = amazonElasticLoadBalancing.describeLoadBalancers().getLoadBalancerDescriptions(); List<LoadBalancerDescription> result = new ArrayList<>(loadBalancers.size()); for(LoadBalancerDescription loadBalancer:loadBalancers){ if(filter.accept(loadBalancer)){ result.add(loadBalancer); } } return result; }
public DescribeLoadBalancersResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeLoadBalancersResult describeLoadBalancersResult = new DescribeLoadBalancersResult(); 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("LoadBalancerDescriptions/member", targetDepth)) { describeLoadBalancersResult .withLoadBalancerDescriptions(LoadBalancerDescriptionStaxUnmarshaller .getInstance().unmarshall(context)); continue; } if (context.testExpression("NextMarker", targetDepth)) { describeLoadBalancersResult.setNextMarker(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return describeLoadBalancersResult; }
/** * <p> * Information about the load balancers. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setLoadBalancerDescriptions(java.util.Collection)} or * {@link #withLoadBalancerDescriptions(java.util.Collection)} if you want to override the existing values. * </p> * * @param loadBalancerDescriptions * Information about the load balancers. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeLoadBalancersResult withLoadBalancerDescriptions(LoadBalancerDescription... loadBalancerDescriptions) { if (this.loadBalancerDescriptions == null) { setLoadBalancerDescriptions(new com.amazonaws.internal.SdkInternalList<LoadBalancerDescription>(loadBalancerDescriptions.length)); } for (LoadBalancerDescription ele : loadBalancerDescriptions) { this.loadBalancerDescriptions.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 (getLoadBalancerDescriptions() != null) sb.append("LoadBalancerDescriptions: ").append(getLoadBalancerDescriptions()).append(","); if (getNextMarker() != null) sb.append("NextMarker: ").append(getNextMarker()); sb.append("}"); return sb.toString(); }
private boolean isBalancerAlive(String name) { Collection<String> names = new HashSet<String>(); names.add(name); DescribeLoadBalancersRequest describe = new DescribeLoadBalancersRequest(); describe.setLoadBalancerNames(names); try { DescribeLoadBalancersResult result = elb.describeLoadBalancers(describe); List<LoadBalancerDescription> description = result.getLoadBalancerDescriptions(); if (description.isEmpty()) { return false; } return true; } catch (AmazonServiceException e) { LOGGER.fatal("Exception in isBalancerAlive(" + name + ')', e); } return false; }
public DescribeLoadBalancersResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeLoadBalancersResult describeLoadBalancersResult = new DescribeLoadBalancersResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeLoadBalancersResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("LoadBalancerDescriptions", targetDepth)) { describeLoadBalancersResult.withLoadBalancerDescriptions(new ArrayList<LoadBalancerDescription>()); continue; } if (context.testExpression("LoadBalancerDescriptions/member", targetDepth)) { describeLoadBalancersResult.withLoadBalancerDescriptions(LoadBalancerDescriptionStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("NextMarker", targetDepth)) { describeLoadBalancersResult.setNextMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeLoadBalancersResult; } } } }
/** * <p> * Information about the load balancers. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param loadBalancerDescriptions <p> * Information about the load balancers. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public DescribeLoadBalancersResult withLoadBalancerDescriptions( java.util.Collection<LoadBalancerDescription> loadBalancerDescriptions) { setLoadBalancerDescriptions(loadBalancerDescriptions); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getLoadBalancerDescriptions() == null) ? 0 : getLoadBalancerDescriptions() .hashCode()); hashCode = prime * hashCode + ((getNextMarker() == null) ? 0 : getNextMarker().hashCode()); return hashCode; }
/** * * @param name * @param elbClient * @return */ public LoadBalancerDescription getLoadBalancerForName(String name, AmazonElasticLoadBalancing elbClient) { LoadBalancerDescription loadBalancer = null; try { DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest() .withLoadBalancerNames(name); DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request); if (result != null && result.getLoadBalancerDescriptions() != null) { loadBalancer = result.getLoadBalancerDescriptions().get(0); } } catch (AmazonServiceException e) { if (e.getErrorCode().equals("LoadBalancerNotFound")) { // if we can't find the ELB to delete, it's already gone log.warn("Could not find Load Balancer " + name, e); } } return loadBalancer; }
/** * <p> * Information about the load balancers. * </p> * * @param loadBalancerDescriptions * Information about the load balancers. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeLoadBalancersResult withLoadBalancerDescriptions(java.util.Collection<LoadBalancerDescription> loadBalancerDescriptions) { setLoadBalancerDescriptions(loadBalancerDescriptions); return this; }