Java 类com.amazonaws.services.elasticloadbalancing.model.ListenerDescription 实例源码

项目:photon-model    文件:AWSLoadBalancerServiceTest.java   
private void verifyListeners(List<RouteConfiguration> routeConfigurations,
        List<ListenerDescription> listenerDescriptions) {

    routeConfigurations.forEach(route -> {
        Listener listener = getListenerByPort(Integer.valueOf(route.port),
                listenerDescriptions);

        assertEquals(Integer.valueOf(route.port), listener.getLoadBalancerPort());
        assertEquals(Integer.valueOf(route.instancePort), listener.getInstancePort());

        // Load Balancer https protocol is translated to tcp
        if (Protocol.HTTPS.name().equalsIgnoreCase(route.protocol)) {
            assertEquals(Protocol.TCP.name(), listener.getProtocol());
            assertEquals(Protocol.TCP.name(), listener.getInstanceProtocol());
        } else {
            assertEquals(route.protocol, listener.getProtocol());
            assertEquals(route.instanceProtocol, listener.getInstanceProtocol());
        }

    });
}
项目:cmn-project    文件:ELB.java   
public boolean httpsCertChanged() {
    Optional<ListenerDescription> remoteHTTPSListener = findRemoteHTTPSListener();

    if (!listenHTTPS || !remoteHTTPSListener.isPresent()) return false;
    String remoteCertARN = remoteHTTPSListener.get().getListener().getSSLCertificateId();

    if (cert != null) {    // cert files
        if (cert.status == ResourceStatus.LOCAL_ONLY
            || !cert.remoteCert.getServerCertificateMetadata().getArn().equals(remoteCertARN))
            return true;
        if (cert.changed()) return true;
    } else if (!remoteCertARN.equals(amazonCertARN)) {
        return true;
    }

    return false;
}
项目:cmn-project    文件:DescribeELBTask.java   
@Override
public void execute(Context context) throws Exception {
    String key = "elb/" + resource.id;
    context.output(key, String.format("status=%s, http=%s, https=%s",
        resource.status, resource.listenHTTP, resource.listenHTTPS));

    if (resource.remoteELB != null) {
        context.output(key, "dns=" + resource.remoteELB.getDNSName());
        for (ListenerDescription description : resource.remoteELB.getListenerDescriptions()) {
            Listener listener = description.getListener();
            context.output(key, String.format("listener=%s:%d=>%s:%d, cert=%s",
                listener.getProtocol(),
                listener.getLoadBalancerPort(),
                listener.getInstanceProtocol(),
                listener.getInstancePort(),
                listener.getSSLCertificateId()));
        }
    }
}
项目:chassis    文件:ServerInstanceContext.java   
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);
}
项目:photon-model    文件:AWSLoadBalancerServiceTest.java   
private Listener getListenerByPort(Integer port, List<ListenerDescription> descriptions) {
    ListenerDescription listenerDescription = descriptions.stream()
            .filter(ld -> ld.getListener().getLoadBalancerPort().equals(port)).findFirst()
            .orElse(null);

    assertNotNull(listenerDescription);
    return listenerDescription.getListener();
}
项目:fullstop    文件:PortsCheckerImpl.java   
@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());
    }
项目:cmn-project    文件:ELBTest.java   
@Test
void httpsCertChangedWithNewLocalCert() {
    elb.listenHTTPS = true;
    elb.remoteELB = new LoadBalancerDescription()
            .withListenerDescriptions(new ListenerDescription().withListener(new Listener("HTTPS", 443, 80)));
    elb.cert = new ServerCert("cert");
    elb.cert.foundInLocal();

    assertTrue(elb.httpsCertChanged());
}
项目:chassis    文件:ServerInstanceContext.java   
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());
}
项目:chassis    文件:ZookeeperElbFilterTest.java   
@Test
public void foundCloudformationZookeeper() {
    LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
    List<ListenerDescription> listenerDescriptions = new ArrayList<>();
    listenerDescriptions.add(new ListenerDescription());
    loadBalancer.setListenerDescriptions(listenerDescriptions);
    loadBalancer.setLoadBalancerName(ENVIRONMENT + "-Zookeeper-whatever");
    Assert.assertTrue(filter.accept(loadBalancer));
}
项目:chassis    文件:ZookeeperElbFilterTest.java   
@Test
public void foundInternalExhibitor() {
    LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
    List<ListenerDescription> listenerDescriptions = new ArrayList<>();
    listenerDescriptions.add(new ListenerDescription());
    loadBalancer.setListenerDescriptions(listenerDescriptions);
    loadBalancer.setLoadBalancerName("exhibitor-" + ENVIRONMENT + "-internal");
    Assert.assertTrue(filter.accept(loadBalancer));
}
项目:chassis    文件:ZookeeperElbFilterTest.java   
@Test
public void externalExhibitor() {
    LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
    List<ListenerDescription> listenerDescriptions = new ArrayList<>();
    listenerDescriptions.add(new ListenerDescription());
    loadBalancer.setListenerDescriptions(listenerDescriptions);
    loadBalancer.setLoadBalancerName("exhibitor-" + ENVIRONMENT);
    Assert.assertFalse(filter.accept(loadBalancer));
}
项目:chassis    文件:ZookeeperElbFilterTest.java   
@Test
public void randomUnmatchedELB() {
    LoadBalancerDescription loadBalancer = new LoadBalancerDescription();
    List<ListenerDescription> listenerDescriptions = new ArrayList<>();
    listenerDescriptions.add(new ListenerDescription());
    loadBalancer.setListenerDescriptions(listenerDescriptions);
    loadBalancer.setLoadBalancerName(RandomStringUtils.random(5,"abcd"));
    Assert.assertFalse(filter.accept(loadBalancer));
}
项目:clouck    文件:Ec2LoadBalancer.java   
public boolean notEqualListenerDescriptions(List<ListenerDescription> l1, List<ListenerDescription> l2) {
    for (ListenerDescription ld1 : l1) {
        Collections.sort(ld1.getPolicyNames());
    }
    for (ListenerDescription ld2 : l2) {
        Collections.sort(ld2.getPolicyNames());
    }
    return notEqualCollection(l1, l2);
}
项目:fullstop    文件:FetchElasticLoadBalancersJobTest.java   
@Before
public void setUp() throws Exception {
    this.violationSinkMock = mock(ViolationSink.class);
    this.clientProviderMock = mock(ClientProvider.class);
    this.accountIdSupplierMock = mock(AccountIdSupplier.class);
    this.jobsPropertiesMock = mock(JobsProperties.class);
    this.portsChecker = mock(PortsChecker.class);
    this.securityGroupsChecker = mock(SecurityGroupsChecker.class);
    this.mockAwsELBClient = mock(AmazonElasticLoadBalancingClient.class);
    this.mockAwsApplications = mock(AwsApplications.class);
    this.mockViolationService = mock(ViolationService.class);
    this.fetchTaupageYamlMock = mock(FetchTaupageYaml.class);
    this.mockAmiDetailsProvider = mock(AmiDetailsProvider.class);
    this.mockEC2InstanceProvider = mock(EC2InstanceProvider.class);

    final Listener listener = new Listener("HTTPS", 80, 80);

    final ListenerDescription listenerDescription = new ListenerDescription();
    listenerDescription.setListener(listener);

    final ArrayList<LoadBalancerDescription> elbs = newArrayList();
    final ArrayList<TagDescription> tagDescriptions = newArrayList();

    final LoadBalancerDescription publicELB = new LoadBalancerDescription();
    publicELB.setScheme("internet-facing");
    publicELB.setListenerDescriptions(newArrayList(listenerDescription));
    publicELB.setCanonicalHostedZoneName("test.com");
    publicELB.setInstances(asList(new Instance("i1"), new Instance("i2")));
    publicELB.setLoadBalancerName("publicELB");
    elbs.add(publicELB);
    tagDescriptions.add(
            new TagDescription()
                    .withLoadBalancerName("publicELB")
                    .withTags(newArrayList(
                            new Tag().withKey("someTag").withValue("someValue"))));

    final LoadBalancerDescription privateELB = new LoadBalancerDescription();
    privateELB.setScheme("internal");
    privateELB.setCanonicalHostedZoneName("internal.org");
    privateELB.setLoadBalancerName("privateELB");
    elbs.add(privateELB);

    for (int i = 1; i <= 20; i++) {
        final String loadBalancerName = "kubeELB" + i;
        final LoadBalancerDescription kubeELB = new LoadBalancerDescription();
        kubeELB.setScheme("internet-facing");
        kubeELB.setCanonicalHostedZoneName("test" + i + ".com");
        kubeELB.setLoadBalancerName(loadBalancerName);
        elbs.add(kubeELB);

        tagDescriptions.add(
                new TagDescription()
                        .withLoadBalancerName(loadBalancerName)
                        .withTags(newArrayList(
                                new Tag().withKey("someTag").withValue("someValue"),
                                new Tag().withKey("kubernetes.io/cluster/").withValue("owned"))));
    }

    mockDescribeELBResult = new DescribeLoadBalancersResult();
    mockDescribeELBResult.setLoadBalancerDescriptions(elbs);

    mockDescribeTagsResult = new DescribeTagsResult();
    mockDescribeTagsResult.setTagDescriptions(tagDescriptions);

    regions.add(REGION1);

    when(clientProviderMock.getClient(any(), any(String.class), any(Region.class))).thenReturn(mockAwsELBClient);

    when(mockEC2InstanceProvider.getById(anyString(), any(Region.class), anyString()))
            .thenReturn(Optional.of(new com.amazonaws.services.ec2.model.Instance().withInstanceId("foo").withImageId("bar")));
    when(mockAmiDetailsProvider.getAmiDetails(anyString(), any(Region.class), anyString()))
            .thenReturn(ImmutableMap.of("ami_id", "bar"));
}
项目:cmn-project    文件:ELB.java   
public boolean httpsListenerAdded() {
    Optional<ListenerDescription> remoteHTTPSListener = findRemoteHTTPSListener();
    return listenHTTPS && !remoteHTTPSListener.isPresent();
}
项目:cmn-project    文件:ELB.java   
public boolean httpsListenerRemoved() {
    Optional<ListenerDescription> remoteHTTPSListener = findRemoteHTTPSListener();
    return !listenHTTPS && remoteHTTPSListener.isPresent();
}
项目:cmn-project    文件:ELB.java   
private Optional<ListenerDescription> findRemoteHTTPSListener() {
    return remoteELB.getListenerDescriptions().stream().filter(listener -> "HTTPS".equalsIgnoreCase(listener.getListener().getProtocol())).findAny();
}