Search in sources :

Example 11 with LoadBalancerDescription

use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project SimianArmy by Netflix.

the class TestELBJanitorCrawler method testElbsWithNoInstances.

@Test
public void testElbsWithNoInstances() {
    boolean includeInstances = false;
    AWSClient client = createMockAWSClient();
    List<LoadBalancerDescription> elbs = createELBList(includeInstances);
    addELBsToMock(client, elbs);
    ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
    List<Resource> resources = crawler.resources();
    verifyELBList(resources, elbs);
}
Also used : Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription) Test(org.testng.annotations.Test)

Example 12 with LoadBalancerDescription

use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project SimianArmy by Netflix.

the class TestELBJanitorCrawler method testElbsWithMultipleReferencedASGs.

@Test
public void testElbsWithMultipleReferencedASGs() {
    boolean includeInstances = true;
    boolean includeELbs = false;
    AWSClient client = createMockAWSClient();
    List<LoadBalancerDescription> elbs = createELBList(includeInstances);
    List<AutoScalingGroup> asgs = createASGList(includeELbs);
    asgs.get(0).setLoadBalancerNames(Arrays.asList("elb1", "elb2"));
    addELBsToMock(client, elbs);
    addASGsToMock(client, asgs);
    ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
    List<Resource> resources = crawler.resources();
    verifyELBList(resources, elbs, 1);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription) Test(org.testng.annotations.Test)

Example 13 with LoadBalancerDescription

use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.

the class ZookeeperElbFilterTest method foundCloudformationZookeeper.

@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));
}
Also used : ListenerDescription(com.amazonaws.services.elasticloadbalancing.model.ListenerDescription) ArrayList(java.util.ArrayList) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription) Test(org.junit.Test)

Example 14 with LoadBalancerDescription

use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.

the class AwsUtils method findLoadBalancers.

/**
     * Fetches and filters a Region's ELBs
     * @param amazonElasticLoadBalancing
     * @param filter
     * @return
     */
public static List<LoadBalancerDescription> findLoadBalancers(AmazonElasticLoadBalancing amazonElasticLoadBalancing, ELBFilter filter) {
    List<LoadBalancerDescription> loadBalancers = amazonElasticLoadBalancing.describeLoadBalancers().getLoadBalancerDescriptions();
    List<LoadBalancerDescription> result = new ArrayList<>(loadBalancers.size());
    for (LoadBalancerDescription loadBalancer : loadBalancers) {
        if (filter.accept(loadBalancer)) {
            result.add(loadBalancer);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)

Example 15 with LoadBalancerDescription

use of com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription in project chassis by Kixeye.

the class ServerInstanceContext method initExhibitor.

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);
}
Also used : ListenerDescription(com.amazonaws.services.elasticloadbalancing.model.ListenerDescription) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) LoadBalancerDescription(com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)

Aggregations

LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)17 Test (org.junit.Test)7 ListenerDescription (com.amazonaws.services.elasticloadbalancing.model.ListenerDescription)6 Resource (com.netflix.simianarmy.Resource)6 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)6 ArrayList (java.util.ArrayList)6 Test (org.testng.annotations.Test)5 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)3 Instance (com.amazonaws.services.elasticloadbalancing.model.Instance)2 Regions (com.amazonaws.regions.Regions)1 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 DescribeRegionsResult (com.amazonaws.services.ec2.model.DescribeRegionsResult)1 DescribeTagsRequest (com.amazonaws.services.ec2.model.DescribeTagsRequest)1 DescribeTagsResult (com.amazonaws.services.ec2.model.DescribeTagsResult)1 Region (com.amazonaws.services.ec2.model.Region)1 AmazonElasticLoadBalancing (com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancing)1 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult)1 Listener (com.amazonaws.services.elasticloadbalancing.model.Listener)1 Tag (com.amazonaws.services.elasticloadbalancing.model.Tag)1 TagDescription (com.amazonaws.services.elasticloadbalancing.model.TagDescription)1