@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; }
/** * 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 (getListener() != null) sb.append("Listener: ").append(getListener()).append(","); if (getPolicyNames() != null) sb.append("PolicyNames: ").append(getPolicyNames()); sb.append("}"); return sb.toString(); }
@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; }
@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; }
/** * 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 (getListener() != null) sb.append("Listener: " + getListener() + ","); if (getPolicyNames() != null) sb.append("PolicyNames: " + getPolicyNames()); sb.append("}"); return sb.toString(); }
@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; } }
public void marshall(ListenerDescription _listenerDescription, Request<?> request, String _prefix) { String prefix; if (_listenerDescription.getListener() != null) { prefix = _prefix + "Listener"; Listener listener = _listenerDescription.getListener(); ListenerStaxMarshaller.getInstance().marshall(listener, request, prefix + "."); } if (_listenerDescription.getPolicyNames() != null) { prefix = _prefix + "PolicyNames"; java.util.List<String> policyNames = _listenerDescription.getPolicyNames(); int policyNamesIndex = 1; String policyNamesPrefix = prefix; for (String policyNamesItem : policyNames) { prefix = policyNamesPrefix + ".member." + policyNamesIndex; if (policyNamesItem != null) { request.addParameter(prefix, StringUtils.fromString(policyNamesItem)); } policyNamesIndex++; } prefix = policyNamesPrefix; } }
@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; }
/** * 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 (getListener() != null) sb.append("Listener: ").append(getListener()).append(","); if (getPolicyNames() != null) sb.append("PolicyNames: ").append(getPolicyNames()); sb.append("}"); return sb.toString(); }
@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; }
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 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 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); }
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())); }
private void disableStickinessOnListener(String loadbalancerName, ListenerDescription listenerDescription) { log.info("Disable stickiness on loadbalancer " + loadbalancerName + " : " + listenerDescription.getListener().getLoadBalancerPort()); List<String> policyNames = new ArrayList<>(listenerDescription.getPolicyNames()); policyNames.remove(DEPLOY_STICKINESS_POLICY + "-" + loadbalancerName); awsElbClient.setLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest().withLoadBalancerName(loadbalancerName).withPolicyNames(policyNames).withLoadBalancerPort(listenerDescription.getListener().getLoadBalancerPort())); }
private void addPublicIngress(AmazonEC2 targetAmazonEC2, String elbGroupId, LoadBalancerDescription sourceDescription) { List<IpPermission> permissions = sourceDescription.getListenerDescriptions().stream().map(l -> new IpPermission() .withIpProtocol("tcp") .withFromPort(l.getListener().getLoadBalancerPort()) .withToPort(l.getListener().getLoadBalancerPort()) .withIpv4Ranges(new IpRange().withCidrIp("0.0.0.0/0")) //TODO(cfieber)-ipv6 ).collect(Collectors.toList()); targetAmazonEC2.authorizeSecurityGroupIngress(new AuthorizeSecurityGroupIngressRequest() .withGroupId(elbGroupId) .withIpPermissions(permissions) ); }
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; }
new SetLoadBalancerPoliciesOfListenerRequest() .withLoadBalancerName(loadBalancerName) .withLoadBalancerPort(l.getListener().getLoadBalancerPort()) .withPolicyNames(l.getPolicyNames().stream().map(policyNameMap::get).collect(Collectors.toList()))
if (!hasElbIngressPermission) { sourceDescription.getListenerDescriptions().forEach(l -> { Listener listener = l.getListener(); IpPermission newPermission = new IpPermission().withIpProtocol("tcp") .withFromPort(listener.getInstancePort()).withToPort(listener.getInstancePort())