@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getLoadBalancerName() == null) ? 0 : getLoadBalancerName().hashCode()); hashCode = prime * hashCode + ((getDNSName() == null) ? 0 : getDNSName().hashCode()); hashCode = prime * hashCode + ((getCanonicalHostedZoneName() == null) ? 0 : getCanonicalHostedZoneName().hashCode()); hashCode = prime * hashCode + ((getCanonicalHostedZoneNameID() == null) ? 0 : getCanonicalHostedZoneNameID().hashCode()); hashCode = prime * hashCode + ((getListenerDescriptions() == null) ? 0 : getListenerDescriptions().hashCode()); hashCode = prime * hashCode + ((getPolicies() == null) ? 0 : getPolicies().hashCode()); hashCode = prime * hashCode + ((getBackendServerDescriptions() == null) ? 0 : getBackendServerDescriptions().hashCode()); hashCode = prime * hashCode + ((getAvailabilityZones() == null) ? 0 : getAvailabilityZones().hashCode()); hashCode = prime * hashCode + ((getSubnets() == null) ? 0 : getSubnets().hashCode()); hashCode = prime * hashCode + ((getVPCId() == null) ? 0 : getVPCId().hashCode()); hashCode = prime * hashCode + ((getInstances() == null) ? 0 : getInstances().hashCode()); hashCode = prime * hashCode + ((getHealthCheck() == null) ? 0 : getHealthCheck().hashCode()); hashCode = prime * hashCode + ((getSourceSecurityGroup() == null) ? 0 : getSourceSecurityGroup().hashCode()); hashCode = prime * hashCode + ((getSecurityGroups() == null) ? 0 : getSecurityGroups().hashCode()); hashCode = prime * hashCode + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode()); hashCode = prime * hashCode + ((getScheme() == null) ? 0 : getScheme().hashCode()); return hashCode; }
private ListenerDescription getExhibitorListenerDescription(LoadBalancerDescription loadBalancer) { for(ListenerDescription listenerDescription:loadBalancer.getListenerDescriptions()){ if(listenerDescription.getListener().getProtocol().toLowerCase().equals("http")){ return listenerDescription; } } throw new BootstrapException("Unable to find any listeners which supports http on ELB " + loadBalancer.getLoadBalancerName()); }
private void processELB(String account, Region awsRegion, LoadBalancerDescription elb) { final Map<String, Object> metaData = newHashMap(); final List<String> errorMessages = newArrayList(); final String canonicalHostedZoneName = elb.getCanonicalHostedZoneName(); final List<String> instanceIds = elb.getInstances().stream().map(Instance::getInstanceId).collect(toList()); metaData.put("unsecuredPorts", unsecuredPorts); errorMessages.add(format("ELB %s listens on insecure ports! Only ports 80 and 443 are allowed", elb.getLoadBalancerName())); elb.getSecurityGroups(), account, awsRegion);
/** * <p> * The listeners for the load balancer. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param listenerDescriptions <p> * The listeners for the load balancer. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public LoadBalancerDescription withListenerDescriptions( ListenerDescription... listenerDescriptions) { if (getListenerDescriptions() == null) { this.listenerDescriptions = new java.util.ArrayList<ListenerDescription>( listenerDescriptions.length); } for (ListenerDescription value : listenerDescriptions) { this.listenerDescriptions.add(value); } return this; }
@Override public boolean accept(LoadBalancerDescription loadBalancer) { String[] pieces = loadBalancer.getLoadBalancerName().split("-"); if (pieces.length < 2) { return false; } // match ENV-Zoo* (Cloud Formation naming scheme) if (pieces[0].equalsIgnoreCase(environment) && pieces[1].startsWith("Zoo")) { return true; } // match exhibitor-ENV-internal (Original naming scheme) if (pieces.length == 3 && pieces[0].equalsIgnoreCase("exhibitor") && pieces[1].equalsIgnoreCase(environment) && pieces[2].equalsIgnoreCase("internal")) { return true; } return false; }
/** * <p> * The security groups for the load balancer. Valid only for load balancers * in a VPC. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param securityGroups <p> * The security groups for the load balancer. Valid only for load * balancers in a VPC. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public LoadBalancerDescription withSecurityGroups(String... securityGroups) { if (getSecurityGroups() == null) { this.securityGroups = new java.util.ArrayList<String>(securityGroups.length); } for (String value : securityGroups) { this.securityGroups.add(value); } 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; }
/** * <p> * The Availability Zones for the load balancer. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param availabilityZones <p> * The Availability Zones for the load balancer. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public LoadBalancerDescription withAvailabilityZones(String... availabilityZones) { if (getAvailabilityZones() == null) { this.availabilityZones = new java.util.ArrayList<String>(availabilityZones.length); } for (String value : availabilityZones) { this.availabilityZones.add(value); } return this; }
private boolean isInternetFacing(LoadBalancerDescription elb) { return elb.getScheme().equals("internet-facing"); }
private void configureHealthCheck(AmazonElasticLoadBalancing loadBalancing, LoadBalancerDescription source, String loadBalancerName) { HealthCheck healthCheck = new HealthCheck() .withTarget(source.getHealthCheck().getTarget()) .withInterval(source.getHealthCheck().getInterval()) .withTimeout(source.getHealthCheck().getTimeout()) .withUnhealthyThreshold(source.getHealthCheck().getUnhealthyThreshold()) .withHealthyThreshold(source.getHealthCheck().getHealthyThreshold()); loadBalancing.configureHealthCheck(new ConfigureHealthCheckRequest(loadBalancerName, healthCheck)); }
private void initExhibitor() { LOGGER.info("Initializing exhibitor info..."); List<LoadBalancerDescription> loadBalancers = AwsUtils.findLoadBalancers(amazonElasticLoadBalancing, new ZookeeperElbFilter(environment)); if(loadBalancers.size() == 0) { LOGGER.info("No Zookeeper ELBs for environment " + environment); return; } else if(loadBalancers.size() != 1){ throw new BootstrapException("Found multiple Zookeeper ELBs for environment " + environment); } LoadBalancerDescription loadBalancer = loadBalancers.get(0); ListenerDescription exhibitorListenerDescription = getExhibitorListenerDescription(loadBalancer); this.exhibitorHost = loadBalancer.getDNSName(); this.exhibitorPort = exhibitorListenerDescription.getListener().getLoadBalancerPort(); LOGGER.info("Initialized exhibitor info with: exhibitorHost: {}, exhibitorPort: {}", exhibitorHost, exhibitorPort); }
ctx.elbHostedZoneId = loadBalancers.get(0).getCanonicalHostedZoneNameID();
public LoadBalancerAttributes getLoadBalancerAttributes(LoadBalancerDescription sourceLoadBalancer, AmazonElasticLoadBalancing sourceClient) { LoadBalancerAttributes sourceAttributes = sourceClient.describeLoadBalancerAttributes( new DescribeLoadBalancerAttributesRequest().withLoadBalancerName(sourceLoadBalancer.getLoadBalancerName())).getLoadBalancerAttributes(); if (sourceLoadBalancer.getListenerDescriptions().stream().anyMatch(l -> l.getListener().getInstancePort() == 0)) { sourceAttributes.setCrossZoneLoadBalancing(new CrossZoneLoadBalancing().withEnabled(true)); } return sourceAttributes; }
@Override public List<Integer> check(final LoadBalancerDescription loadBalancerDescription) { return loadBalancerDescription.getListenerDescriptions() .stream() .map(ListenerDescription::getListener) .map(Listener::getLoadBalancerPort) .filter(p -> !jobsProperties.getElbAllowedPorts().contains(p)) .collect(Collectors.toList()); }
if (hasKubernetesTag(tagsByPublicElb.getOrDefault(elb.getLoadBalancerName(), emptyList()))) { continue; final Map<String, String> elbCtx = ImmutableMap.<String, String>builder() .putAll(accountRegionCtx) .put("load_balancer_name", elb.getLoadBalancerName()) .build(); jobExceptionHandler.onException(e, elbCtx);
protected void mapElbToSecurityGroups(LoadBalancerDescription lb, String elbArn, String region) { LinkageHelper linkage = newLinkageHelper().withFromArn(elbArn).withTargetLabel("AwsSecurityGroup") .withLinkLabel("ATTACHED_TO").withTargetValues(lb.getSecurityGroups().stream() .map(sg -> createArn("ec2", "security-group", sg)).collect(Collectors.toList())); linkage.execute(); }
/** * <p> * The IDs of the instances for the load balancer. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param instances <p> * The IDs of the instances for the load balancer. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public LoadBalancerDescription 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; }
target.setAvailabilityZones(sourceLoadBalancer.getAvailabilityZones()); if (target.getAvailabilityZones() == null || target.getAvailabilityZones().isEmpty()) { throw new IllegalStateException("No availability zones specified for load balancer migration");
return false; LoadBalancerDescription other = (LoadBalancerDescription) obj; if (other.getLoadBalancerName() == null ^ this.getLoadBalancerName() == null) return false; if (other.getLoadBalancerName() != null && other.getLoadBalancerName().equals(this.getLoadBalancerName()) == false) return false; if (other.getDNSName() == null ^ this.getDNSName() == null) return false; if (other.getDNSName() != null && other.getDNSName().equals(this.getDNSName()) == false) return false; if (other.getCanonicalHostedZoneName() == null ^ this.getCanonicalHostedZoneName() == null) return false; if (other.getCanonicalHostedZoneName() != null && other.getCanonicalHostedZoneName().equals(this.getCanonicalHostedZoneName()) == false) return false; if (other.getCanonicalHostedZoneNameID() == null ^ this.getCanonicalHostedZoneNameID() == null) return false; if (other.getCanonicalHostedZoneNameID() != null && other.getCanonicalHostedZoneNameID().equals(this.getCanonicalHostedZoneNameID()) == false) return false; if (other.getListenerDescriptions() == null ^ this.getListenerDescriptions() == null) return false; if (other.getListenerDescriptions() != null && other.getListenerDescriptions().equals(this.getListenerDescriptions()) == false) return false; if (other.getPolicies() == null ^ this.getPolicies() == null) return false; if (other.getPolicies() != null && other.getPolicies().equals(this.getPolicies()) == false) return false; if (other.getBackendServerDescriptions() == null ^ this.getBackendServerDescriptions() == null) return false; if (other.getBackendServerDescriptions() != null && other.getBackendServerDescriptions().equals(this.getBackendServerDescriptions()) == false)
Set<String> policiesToRetrieve = new HashSet<>(); Map<String, String> policyNameMap = new HashMap<>(); source.getListenerDescriptions().forEach(d -> policiesToRetrieve.addAll(d.getPolicyNames())); List<PolicyDescription> sourcePolicies = sourceClient.describeLoadBalancerPolicies( new DescribeLoadBalancerPoliciesRequest() .withLoadBalancerName(source.getLoadBalancerName()) .withPolicyNames(policiesToRetrieve)).getPolicyDescriptions(); List<PolicyDescription> targetPolicies = targetClient.describeLoadBalancerPolicies( source.getListenerDescriptions().forEach(l -> targetClient.setLoadBalancerPoliciesOfListener( new SetLoadBalancerPoliciesOfListenerRequest() .withLoadBalancerName(loadBalancerName)