@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; }
public ListenerDescription unmarshall(StaxUnmarshallerContext context) throws Exception { ListenerDescription listenerDescription = new ListenerDescription(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return listenerDescription; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Listener", targetDepth)) { listenerDescription.setListener(ListenerStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("PolicyNames", targetDepth)) { listenerDescription.withPolicyNames(new ArrayList<String>()); continue; } if (context.testExpression("PolicyNames/member", targetDepth)) { listenerDescription.withPolicyNames(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return listenerDescription; } } } }
/** * <p> * The policies. If there are no policies enabled, the list is empty. * </p> * * @param policyNames * The policies. If there are no policies enabled, the list is empty. * @return Returns a reference to this object so that method calls can be chained together. */ public ListenerDescription withPolicyNames(java.util.Collection<String> policyNames) { setPolicyNames(policyNames); return this; }
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()); }
/** * <p> * The policies. If there are no policies enabled, the list is empty. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param policyNames <p> * The policies. If there are no policies enabled, the list is * empty. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public ListenerDescription withPolicyNames(String... policyNames) { if (getPolicyNames() == null) { this.policyNames = new java.util.ArrayList<String>(policyNames.length); } for (String value : policyNames) { this.policyNames.add(value); } return this; }
/** * <p> * The listener. * </p> * * @param listener * The listener. * @return Returns a reference to this object so that method calls can be chained together. */ public ListenerDescription withListener(Listener listener) { setListener(listener); return this; }
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()); }
/** * <p> * The listener. * </p> * * @param listener * The listener. * @return Returns a reference to this object so that method calls can be chained together. */ public ListenerDescription withListener(Listener listener) { setListener(listener); return this; }
@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 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); }
public ListenerDescription unmarshall(StaxUnmarshallerContext context) throws Exception { ListenerDescription listenerDescription = new ListenerDescription(); 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("Listener", targetDepth)) { listenerDescription.setListener(ListenerStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } if (context.testExpression("PolicyNames/member", targetDepth)) { listenerDescription.withPolicyNames(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return listenerDescription; }
/** * <p> * The policies. If there are no policies enabled, the list is empty. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setPolicyNames(java.util.Collection)} or {@link #withPolicyNames(java.util.Collection)} if you want to * override the existing values. * </p> * * @param policyNames * The policies. If there are no policies enabled, the list is empty. * @return Returns a reference to this object so that method calls can be chained together. */ public ListenerDescription withPolicyNames(String... policyNames) { if (this.policyNames == null) { setPolicyNames(new com.amazonaws.internal.SdkInternalList<String>(policyNames.length)); } for (String ele : policyNames) { this.policyNames.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 (getListener() != null) sb.append("Listener: ").append(getListener()).append(","); if (getPolicyNames() != null) sb.append("PolicyNames: ").append(getPolicyNames()); sb.append("}"); return sb.toString(); }
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 ListenerDescription unmarshall(StaxUnmarshallerContext context) throws Exception { ListenerDescription listenerDescription = new ListenerDescription(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return listenerDescription; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Listener", targetDepth)) { listenerDescription.setListener(ListenerStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("PolicyNames", targetDepth)) { listenerDescription.withPolicyNames(new ArrayList<String>()); continue; } if (context.testExpression("PolicyNames/member", targetDepth)) { listenerDescription.withPolicyNames(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return listenerDescription; } } } }
/** * <p> * The policies. If there are no policies enabled, the list is empty. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param policyNames <p> * The policies. If there are no policies enabled, the list is * empty. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public ListenerDescription withPolicyNames(java.util.Collection<String> policyNames) { setPolicyNames(policyNames); return this; }
@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; }
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; }
/** * <p> * The policies. If there are no policies enabled, the list is empty. * </p> * * @param policyNames * The policies. If there are no policies enabled, the list is empty. * @return Returns a reference to this object so that method calls can be chained together. */ public ListenerDescription withPolicyNames(java.util.Collection<String> policyNames) { setPolicyNames(policyNames); return this; }
@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; } }