Example usage for com.amazonaws.services.elasticloadbalancing.model LoadBalancerDescription getCreatedTime

List of usage examples for com.amazonaws.services.elasticloadbalancing.model LoadBalancerDescription getCreatedTime

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticloadbalancing.model LoadBalancerDescription getCreatedTime.

Prototype


public java.util.Date getCreatedTime() 

Source Link

Document

The date and time the load balancer was created.

Usage

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.ElbDetail.java

License:Open Source License

private void buildUI(DescribeLoadBalancersResult detail) {

    JTabbedPane tabs = new JTabbedPane();

    tabs.add("Load Balancer", primaryScrollPane);

    final JTable healthCheckTable = new JTable(healthCheckTableModel);
    JScrollPane healthCheckScrollPane = new JScrollPane(healthCheckTable);
    tabs.add("Health Check", healthCheckScrollPane);

    final JTable listenersTable = new JTable(listenersTableModel);
    JScrollPane listenersScrollPane = new JScrollPane(listenersTable);
    tabs.add("Listeners", listenersScrollPane);

    this.add(tabs, BorderLayout.CENTER);

    List<LoadBalancerDescription> elbs = detail.getLoadBalancerDescriptions();
    if (!elbs.isEmpty()) {

        LoadBalancerDescription elb = elbs.get(0);

        if (!elb.getAvailabilityZones().isEmpty()) {

            StringBuilder azs = new StringBuilder();
            for (String az : elb.getAvailabilityZones()) {
                azs.append(az).append(", ");
            }//w w w. ja v  a  2s .c  o  m

            primaryTableModel.addRow(new Object[] { "Availability Zones", azs.toString() });
        }

        if (elb.getCanonicalHostedZoneName() != null) {
            primaryTableModel
                    .addRow(new Object[] { "Canonical Hosted Zone name", elb.getCanonicalHostedZoneName() });
        }
        if (elb.getCanonicalHostedZoneNameID() != null) {
            primaryTableModel.addRow(
                    new Object[] { "Canonical Hosted Zone name Id", elb.getCanonicalHostedZoneNameID() });
        }
        if (elb.getCreatedTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", elb.getCreatedTime() });
        }
        if (elb.getDNSName() != null) {
            primaryTableModel.addRow(new Object[] { "DNS Name", elb.getDNSName() });
        }

        if (!elb.getInstances().isEmpty()) {

            StringBuilder instances = new StringBuilder();
            for (Instance instance : elb.getInstances()) {
                instances.append(instance.getInstanceId()).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Instances", instances.toString() });
        }

        if (elb.getLoadBalancerName() != null) {
            primaryTableModel.addRow(new Object[] { "Load Balander Name", elb.getLoadBalancerName() });
        }
        if (elb.getScheme() != null) {
            primaryTableModel.addRow(new Object[] { "Scheme", elb.getScheme() });
        }

        if (!elb.getSecurityGroups().isEmpty()) {

            StringBuilder sgs = new StringBuilder();
            for (String sg : elb.getSecurityGroups()) {
                sgs.append(sg).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Security Groups", sgs.toString() });
        }

        if (elb.getSourceSecurityGroup() != null) {
            primaryTableModel.addRow(
                    new Object[] { "Source Security Group", elb.getSourceSecurityGroup().getGroupName() });
        }

        if (!elb.getSubnets().isEmpty()) {

            StringBuilder subnets = new StringBuilder();
            for (String subnet : elb.getSubnets()) {
                subnets.append(subnet).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Subnets", subnets.toString() });
        }

        if (elb.getVPCId() != null) {
            primaryTableModel.addRow(new Object[] { "VPC Id", elb.getVPCId() });
        }

        /**
         * Health Check
         */

        healthCheckTableModel.addColumn("Property");
        healthCheckTableModel.addColumn("Value");

        HealthCheck healthCheck = elb.getHealthCheck();
        if (healthCheck.getHealthyThreshold() != null) {
            healthCheckTableModel.addRow(new Object[] { "Threshold", healthCheck.getHealthyThreshold() });
        }
        if (healthCheck.getInterval() != null) {
            healthCheckTableModel.addRow(new Object[] { "Interval", healthCheck.getInterval() });
        }
        if (healthCheck.getTarget() != null) {
            healthCheckTableModel.addRow(new Object[] { "Target", healthCheck.getTarget() });
        }
        if (healthCheck.getTimeout() != null) {
            healthCheckTableModel.addRow(new Object[] { "Timeout", healthCheck.getTimeout() });
        }
        if (healthCheck.getUnhealthyThreshold() != null) {
            healthCheckTableModel
                    .addRow(new Object[] { "Unhealth Threshold", healthCheck.getUnhealthyThreshold() });
        }

        /**
         * Listeners
         */

        listenersTableModel.addColumn("Instance Port");
        listenersTableModel.addColumn("Instance Protocol");
        listenersTableModel.addColumn("Load Balancer Port");
        listenersTableModel.addColumn("Load Balancer Protocol");
        listenersTableModel.addColumn("SSL Certificate Id");

        List<ListenerDescription> listenerDescriptions = elb.getListenerDescriptions();
        for (ListenerDescription description : listenerDescriptions) {

            Listener listener = description.getListener();

            String ssl = "";
            if (listener.getSSLCertificateId() != null) {
                ssl = listener.getSSLCertificateId();
            }

            listenersTableModel
                    .addRow(new Object[] { listener.getInstancePort(), listener.getInstanceProtocol(),
                            listener.getLoadBalancerPort(), listener.getProtocol(), ssl });
        }
    }
}

From source file:com.netflix.simianarmy.aws.janitor.crawler.ELBJanitorCrawler.java

License:Apache License

private List<Resource> getELBResources(String... elbNames) {
    List<Resource> resources = new LinkedList<Resource>();
    AWSClient awsClient = getAWSClient();

    for (LoadBalancerDescription elb : awsClient.describeElasticLoadBalancers(elbNames)) {
        Resource resource = new AWSResource().withId(elb.getLoadBalancerName())
                .withRegion(getAWSClient().region()).withResourceType(AWSResourceType.ELB)
                .withLaunchTime(elb.getCreatedTime());
        resource.setOwnerEmail(getOwnerEmailForResource(resource));
        resources.add(resource);//from   w ww.  j  a v  a  2  s  .  c  om
        List<Instance> instances = elb.getInstances();
        if (instances == null || instances.size() == 0) {
            resource.setAdditionalField("instanceCount", "0");
            resource.setDescription("instances=none");
            LOGGER.debug(String.format("No instances found for ELB %s", resource.getId()));
        } else {
            resource.setAdditionalField("instanceCount", "" + instances.size());
            ArrayList<String> instanceList = new ArrayList<String>(instances.size());
            LOGGER.debug(String.format("Found %d instances for ELB %s", instances.size(), resource.getId()));
            for (Instance instance : instances) {
                String instanceId = instance.getInstanceId();
                instanceList.add(instanceId);
            }
            String instancesStr = StringUtils.join(instanceList, ",");
            resource.setDescription(String.format("instances=%s", instances));
            LOGGER.debug(String.format("Resource ELB %s has instances %s", resource.getId(), instancesStr));
        }

        for (TagDescription tagDescription : awsClient.describeElasticLoadBalancerTags(resource.getId())) {
            for (Tag tag : tagDescription.getTags()) {
                LOGGER.debug(String.format("Adding tag %s = %s to resource %s", tag.getKey(), tag.getValue(),
                        resource.getId()));
                resource.setTag(tag.getKey(), tag.getValue());
            }
        }
    }

    Map<String, List<String>> elbtoASGMap = buildELBtoASGMap();
    for (Resource resource : resources) {
        List<String> asgList = elbtoASGMap.get(resource.getId());
        if (asgList != null && asgList.size() > 0) {
            resource.setAdditionalField("referencedASGCount", "" + asgList.size());
            String asgStr = StringUtils.join(asgList, ",");
            resource.setDescription(resource.getDescription() + ", ASGS=" + asgStr);
            LOGGER.debug(String.format("Resource ELB %s is referenced by ASGs %s", resource.getId(), asgStr));
        } else {
            resource.setAdditionalField("referencedASGCount", "0");
            resource.setDescription(resource.getDescription() + ", ASGS=none");
            LOGGER.debug(String.format("No ASGs found for ELB %s", resource.getId()));
        }
    }

    return resources;
}

From source file:com.zotoh.cloudapi.aws.ElasticLoadBalancer.java

License:Open Source License

private LoadBalancer toELB(LoadBalancerDescription desc) {
    LoadBalancer b = null;/*  w  ww .  j a  v a  2  s  .c  o m*/
    if (desc != null) {
        ProviderContext x = _svc.getCloud().getContext();
        b = new LoadBalancer();

        b.setCreationTimestamp(desc.getCreatedTime().getTime());
        b.setProviderRegionId(x.getRegionId());
        b.setAddressType(LoadBalancerAddressType.DNS);
        b.setCurrentState(LoadBalancerState.ACTIVE);
        b.setProviderOwnerId(x.getAccountNumber());
        b.setName(desc.getLoadBalancerName());
        b.setDescription(b.getName());
        b.setProviderLoadBalancerId(b.getName());
        b.setAddress(desc.getDNSName());

        // zones
        {
            List<String> lst = desc.getAvailabilityZones();
            if (!isNil(lst)) {
                b.setProviderDataCenterIds(lst.toArray(new String[0]));
            }
        }
        // servers
        {
            List<Instance> lst = desc.getInstances();
            List<String> s = LT();
            if (!isNil(lst))
                for (int i = 0; i < lst.size(); ++i) {
                    s.add(lst.get(i).getInstanceId());
                }
            b.setProviderServerIds(s.toArray(new String[0]));
        }
        // listeners/ports
        {
            List<ListenerDescription> lst = desc.getListenerDescriptions();
            List<LbListener> rc = LT();
            int[] pports;
            if (lst != null)
                for (int i = 0; i < lst.size(); ++i) {
                    rc.add(toLis(lst.get(i)));
                }
            b.setListeners(rc.toArray(new LbListener[0]));
            pports = new int[rc.size()];
            for (int i = 0; i < pports.length; ++i) {
                pports[i] = rc.get(i).getPublicPort();
            }
            b.setPublicPorts(pports);
        }

        // unsupported
        desc.getHealthCheck();
        desc.getPolicies();
        desc.getSourceSecurityGroup();
        desc.getCanonicalHostedZoneName();
    }

    return b;
}