@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; }
@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; }
/** * 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(); }
/** {@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; }
@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; }
/** * <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; }
/** * 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 (getLoadBalancerDescriptions() != null) sb.append("LoadBalancerDescriptions: " + getLoadBalancerDescriptions() + ","); if (getNextMarker() != null) sb.append("NextMarker: " + getNextMarker()); sb.append("}"); return sb.toString(); }
@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; } }
@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; }
/** * 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(); }
@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; }
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; }
/** * * @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; }
private List<ListenerDescription> describeMatchingElbListeners(String loadbalancerName, List<Integer> ports) { DescribeLoadBalancersResult loadbalancer = awsElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerNames(loadbalancerName)); LoadBalancerDescription description = loadbalancer.getLoadBalancerDescriptions().get(0); return description.getListenerDescriptions().stream() .filter(d -> ports.contains(d.getListener().getLoadBalancerPort())) .filter(d -> d.getListener().getProtocol().startsWith("HTTP")) .collect(Collectors.toList()); }
/** * Gets the all elbs desc. * * @param elbClient the elb client * @param region the region * @param balancersRequest the balancers request * @return the all elbs desc */ public static List<LoadBalancerDescription> getAllElbsDesc(AmazonElasticLoadBalancing elbClient, Region region, DescribeLoadBalancersRequest balancersRequest) { List<LoadBalancerDescription> loadDescriptionList = new ArrayList<LoadBalancerDescription>(); DescribeLoadBalancersResult balancersResult; String marker; do { balancersResult = elbClient.describeLoadBalancers(balancersRequest); marker = balancersResult.getNextMarker(); balancersRequest.setMarker(marker); loadDescriptionList.addAll(balancersResult.getLoadBalancerDescriptions()); } while (null != marker); return loadDescriptionList; }
private LoadBalancerDescription getLoadBalancer(NetflixAmazonCredentials credentials, String region, String name) { try { AmazonElasticLoadBalancing client = getAmazonClientProvider() .getAmazonElasticLoadBalancing(credentials, region, true); DescribeLoadBalancersResult targetLookup = client.describeLoadBalancers( new DescribeLoadBalancersRequest().withLoadBalancerNames(name)); return targetLookup.getLoadBalancerDescriptions().get(0); } catch (Exception ignored) { return null; } }
/** {@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; }
private void forEachElb(Region region, Consumer<LoadBalancerDescription> consumer) { DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(); String marker = null; do { rateLimit(); DescribeLoadBalancersResult results = getClient().describeLoadBalancers(request.withMarker(marker)); marker = results.getNextMarker(); results.getLoadBalancerDescriptions().forEach(consumer); writeTagsToNeo4j(results, region, getClient()); request.setMarker(marker); } while (tokenHasNext(marker)); }
public void scanLoadBalancerNames(String... loadBalancerNames) { if (loadBalancerNames == null || loadBalancerNames.length == 0) { return; } DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(); request.setLoadBalancerNames(Arrays.asList(loadBalancerNames)); String marker = null; do { rateLimit(); DescribeLoadBalancersResult results = getClient().describeLoadBalancers(request); marker = results.getNextMarker(); results.getLoadBalancerDescriptions().forEach(it -> { projectElb(it, null); }); writeTagsToNeo4j(results, getRegion(), getClient()); request.setMarker(marker); } while (tokenHasNext(marker)); }