@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getProtocol() == null) ? 0 : getProtocol().hashCode()); hashCode = prime * hashCode + ((getLoadBalancerPort() == null) ? 0 : getLoadBalancerPort().hashCode()); hashCode = prime * hashCode + ((getInstanceProtocol() == null) ? 0 : getInstanceProtocol().hashCode()); hashCode = prime * hashCode + ((getInstancePort() == null) ? 0 : getInstancePort().hashCode()); hashCode = prime * hashCode + ((getSSLCertificateId() == null) ? 0 : getSSLCertificateId().hashCode()); return hashCode; }
public Listener unmarshall(StaxUnmarshallerContext context) throws Exception { Listener listener = new Listener(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; listener.setProtocol(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; listener.setLoadBalancerPort(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; listener.setInstanceProtocol(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; listener.setInstancePort(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; listener.setSSLCertificateId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getListener() == null) ? 0 : getListener().hashCode()); hashCode = prime * hashCode + ((getPolicyNames() == null) ? 0 : getPolicyNames().hashCode()); return hashCode; }
/** * Constructs a new Listener object. Callers should use the setter or fluent setter (with...) methods to initialize * any additional object members. * * @param protocol * The load balancer transport protocol to use for routing: HTTP, HTTPS, TCP, or SSL. * @param loadBalancerPort * The port on which the load balancer is listening. On EC2-VPC, you can specify any port from the range * 1-65535. On EC2-Classic, you can specify any port from the following list: 25, 80, 443, 465, 587, * 1024-65535. * @param instancePort * The port on which the instance is listening. */ public Listener(String protocol, Integer loadBalancerPort, Integer instancePort) { setProtocol(protocol); setLoadBalancerPort(loadBalancerPort); setInstancePort(instancePort); }
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()); }
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); }
if (getListeners() != null) { for (ListenerTask task : getListeners()) { Listener tmp = new Listener(task.getProtocol(), task.getLoadBalancerPort(), task.getInstancePort()); if (task.isSecure()) { tmp.setSSLCertificateId(task.getCertId());
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()); }
String createLoadBalancer(String name) { CreateLoadBalancerRequest request = new CreateLoadBalancerRequest(); request.setLoadBalancerName(name); request.withAvailabilityZones(elbAvailabilityZones.split(",")); List<Listener> listeners = new ArrayList<Listener>(); listeners.add(new Listener(elbProtocol, elbPortIn, elbPortOut)); request.setListeners(listeners); CreateLoadBalancerResult lbResult = elb.createLoadBalancer(request); appendText(lbResult.getDNSName() + NEW_LINE, elbFile); return request.getLoadBalancerName(); }
/** * <p> * The Amazon Resource Name (ARN) of the server certificate. * </p> * * @param sSLCertificateId * The Amazon Resource Name (ARN) of the server certificate. * @return Returns a reference to this object so that method calls can be chained together. */ public Listener withSSLCertificateId(String sSLCertificateId) { setSSLCertificateId(sSLCertificateId); return this; }
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; }
private Predicate<Listener> listenerCannotBeMigrated(LoadBalancerLocation source, LoadBalancerLocation target) { return l -> l.getSSLCertificateId() != null && !source.getCredentialAccount().equals(target.getCredentialAccount()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListenerDescription == false) return false; ListenerDescription other = (ListenerDescription) obj; if (other.getListener() == null ^ this.getListener() == null) return false; if (other.getListener() != null && other.getListener().equals(this.getListener()) == false) return false; if (other.getPolicyNames() == null ^ this.getPolicyNames() == null) return false; if (other.getPolicyNames() != null && other.getPolicyNames().equals(this.getPolicyNames()) == false) return false; return true; }
/** * <p> * The port on which the instance is listening. * </p> * * @param instancePort * The port on which the instance is listening. * @return Returns a reference to this object so that method calls can be chained together. */ public Listener withInstancePort(Integer instancePort) { setInstancePort(instancePort); return this; }
private void enableStickinessOnListener(String loadbalancerName, ListenerDescription listenerDescription) { log.info("Enable stickiness on loadbalancer " + loadbalancerName + " : " + listenerDescription.getListener().getLoadBalancerPort()); List<String> policyNames = new ArrayList<>(listenerDescription.getPolicyNames()); policyNames.add(DEPLOY_STICKINESS_POLICY + "-" + loadbalancerName); awsElbClient.setLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest().withLoadBalancerName(loadbalancerName).withPolicyNames(policyNames).withLoadBalancerPort(listenerDescription.getListener().getLoadBalancerPort())); }
/** * Constructs a new Listener object. Callers should use the setter or fluent * setter (with...) methods to initialize any additional object members. * * @param protocol <p> * The load balancer transport protocol to use for routing: HTTP, * HTTPS, TCP, or SSL. * </p> * @param loadBalancerPort <p> * The port on which the load balancer is listening. On EC2-VPC, * you can specify any port from the range 1-65535. On * EC2-Classic, you can specify any port from the following list: * 25, 80, 443, 465, 587, 1024-65535. * </p> * @param instancePort <p> * The port on which the instance is listening. * </p> */ public Listener(String protocol, Integer loadBalancerPort, Integer instancePort) { setProtocol(protocol); setLoadBalancerPort(loadBalancerPort); setInstancePort(instancePort); }
/** * <p> * The Amazon Resource Name (ARN) of the server certificate. * </p> * * @param sSLCertificateId * The Amazon Resource Name (ARN) of the server certificate. * @return Returns a reference to this object so that method calls can be chained together. */ public Listener withSSLCertificateId(String sSLCertificateId) { setSSLCertificateId(sSLCertificateId); return this; }
Listener listener = l.getListener(); IpPermission newPermission = new IpPermission().withIpProtocol("tcp") .withFromPort(listener.getInstancePort()).withToPort(listener.getInstancePort()) .withUserIdGroupPairs(new UserIdGroupPair().withGroupId(elbGroupId).withVpcId(target.getVpcId())); targetAmazonEC2.authorizeSecurityGroupIngress(new AuthorizeSecurityGroupIngressRequest()
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListenerDescription == false) return false; ListenerDescription other = (ListenerDescription) obj; if (other.getListener() == null ^ this.getListener() == null) return false; if (other.getListener() != null && other.getListener().equals(this.getListener()) == false) return false; if (other.getPolicyNames() == null ^ this.getPolicyNames() == null) return false; if (other.getPolicyNames() != null && other.getPolicyNames().equals(this.getPolicyNames()) == false) return false; return true; } }
/** * <p> * The port on which the instance is listening. * </p> * * @param instancePort * The port on which the instance is listening. * @return Returns a reference to this object so that method calls can be chained together. */ public Listener withInstancePort(Integer instancePort) { setInstancePort(instancePort); return this; }