com.amazonaws.services.elasticloadbalancing.model.Listener Java Examples

The following examples show how to use com.amazonaws.services.elasticloadbalancing.model.Listener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PortsCheckerImpl.java    From fullstop with Apache License 2.0 5 votes vote down vote up
@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());
    }
 
Example #2
Source File: FetchElasticLoadBalancersJobTest.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@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"));
}
 
Example #3
Source File: AwsLoadBalancerProcess.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
public void startListener(AwsProcessClient awsProcessClient, Long loadBalancerNo, Integer loadBalancerPort) {
    AwsLoadBalancer awsLoadBalancer = awsLoadBalancerDao.read(loadBalancerNo);
    LoadBalancerListener listener = loadBalancerListenerDao.read(loadBalancerNo, loadBalancerPort);

    try {
        // リスナー作成情報
        CreateLoadBalancerListenersRequest request = new CreateLoadBalancerListenersRequest();
        request.withLoadBalancerName(awsLoadBalancer.getName());

        Listener listener2 = new Listener();
        listener2.withProtocol(listener.getProtocol());
        listener2.withLoadBalancerPort(listener.getLoadBalancerPort());
        listener2.withInstancePort(listener.getServicePort());
        if (listener.getSslKeyNo() != null) {
            AwsSslKey awsSslKey = awsSslKeyDao.read(listener.getSslKeyNo());
            listener2.withSSLCertificateId(awsSslKey.getSslcertificateid());
        }
        request.withListeners(listener2);

        // リスナーの作成
        awsProcessClient.getElbClient().createLoadBalancerListeners(request);

        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-200121", awsLoadBalancer.getName(),
                    listener.getLoadBalancerPort()));
        }

        // イベントログ出力
        processLogger.debug(null, null, "AwsElbListenerCreate",
                new Object[] { awsProcessClient.getPlatform().getPlatformName(), awsLoadBalancer.getName(),
                        listener.getLoadBalancerPort() });

    } catch (RuntimeException e) {
        // ステータスを更新
        listener = loadBalancerListenerDao.read(loadBalancerNo, loadBalancerPort);
        listener.setStatus(LoadBalancerListenerStatus.WARNING.toString());
        loadBalancerListenerDao.update(listener);

        throw e;
    }

    // ステータスを更新
    listener = loadBalancerListenerDao.read(loadBalancerNo, loadBalancerPort);
    listener.setStatus(LoadBalancerListenerStatus.RUNNING.toString());
    listener.setConfigure(false);
    loadBalancerListenerDao.update(listener);
}