Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jclouds.elb.domain;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Date;
 import java.util.Set;
 
A load balancer is represented by a DNS name and a set of ports. The load balancer is the destination to which all requests intended for your application should be directed. Each load balancer can distribute requests to multiple EC2 instances. Load Balancers can span multiple Availability Zones within an EC2 region, but they cannot span multiple regions.

note

Elastic Load Balancing automatically generates a DNS name for each load balancer. You can map any other domain name (such as www.example.com) to the automatically generated DNS name using CNAME. Or you can use an Amazon Route 53 alias for the load balancer's DNS name. Amazon Route 53 provides secure and reliable routing to the infrastructure that uses AWS products, such as Amazon EC2, Amazon Simple Storage Service (Amazon S3), or Elastic Load Balancing. For more information on using Amazon Route 53 for your load balancer, see Using Domain Names with Elastic Load Balancing. For information about CNAME records, see the CNAME Record Wikipedia article.

Author(s):
Adrian Cole
See also:
doc
 
 public class LoadBalancer {
    public static Builder<?> builder() {
       return new ConcreteBuilder();
    }
 
    public Builder<?> toBuilder() {
       return new ConcreteBuilder().fromLoadBalancer(this);
    }
 
    public abstract static class Builder<T extends Builder<T>> {
       protected abstract T self();
 
       protected String name;
       protected Date createdTime;
       protected String dnsName;
       protected HealthCheck healthCheck;
       protected ImmutableSet.Builder<StringinstanceIds = ImmutableSet.<Stringbuilder();
       protected ImmutableSet.Builder<ListenerWithPolicieslisteners = ImmutableSet.<ListenerWithPoliciesbuilder();
       protected ImmutableSet.Builder<StringavailabilityZones = ImmutableSet.<Stringbuilder();
       protected Optional<Schemescheme = Optional.absent();
       protected Optional<SecurityGroupAndOwnersourceSecurityGroup = Optional.absent();
       protected Optional<StringVPCId = Optional.absent();
       protected ImmutableSet.Builder<StringsecurityGroups = ImmutableSet.<Stringbuilder();
       protected ImmutableSet.Builder<Stringsubnets = ImmutableSet.<Stringbuilder();
       protected Optional<StringhostedZoneName = Optional.absent();
       protected Optional<StringhostedZoneId = Optional.absent();

      
 
       public T name(String name) {
          this. = name;
          return self();
       }

      
 
       public T createdTime(Date createdTime) {
          this. = createdTime;
          return self();
       }

      
 
       public T dnsName(String dnsName) {
         this. = dnsName;
         return self();
      }

      
      public T healthCheck(HealthCheck healthCheck) {
         this. = healthCheck;
         return self();
      }

      
      public T instanceIds(Iterable<StringinstanceIds) {
         this..addAll(checkNotNull(instanceIds"instanceIds"));
         return self();
      }

      
      public T instanceId(String instanceId) {
         this..add(checkNotNull(instanceId"instanceId"));
         return self();
      }

      
      public T listeners(Iterable<ListenerWithPolicieslisteners) {
         this..addAll(checkNotNull(listeners"listeners"));
         return self();
      }

      
      public T listener(ListenerWithPolicies listener) {
         this..add(checkNotNull(listener"listener"));
         return self();
      }

      
      public T availabilityZones(Iterable<StringavailabilityZones) {
         this..addAll(checkNotNull(availabilityZones"availabilityZones"));
         return self();
      }

      
      public T availabilityZone(String availabilityZone) {
         this..add(checkNotNull(availabilityZone"availabilityZone"));
         return self();
      }

      
      public T scheme(Scheme scheme) {
         this. = Optional.fromNullable(scheme);
         return self();
      }

      
      public T sourceSecurityGroup(SecurityGroupAndOwner scheme) {
         this. = Optional.fromNullable(scheme);
         return self();
      }

      
      public T VPCId(String VPCId) {
         this. = Optional.fromNullable(VPCId);
         return self();
      }

      
      public T securityGroups(Iterable<StringsecurityGroups) {
         this..addAll(checkNotNull(securityGroups"securityGroups"));
         return self();
      }

      
      public T securityGroup(String securityGroup) {
         this..add(checkNotNull(securityGroup"securityGroup"));
         return self();
      }

      
      public T subnets(Iterable<Stringsubnets) {
         this..addAll(checkNotNull(subnets"subnets"));
         return self();
      }

      
      public T subnet(String subnet) {
         this..add(checkNotNull(subnet"subnet"));
         return self();
      }

      
      public T hostedZoneName(String hostedZoneName) {
         this. = Optional.fromNullable(hostedZoneName);
         return self();
      }

      
      public T hostedZoneId(String hostedZoneId) {
         this. = Optional.fromNullable(hostedZoneId);
         return self();
      }
      public LoadBalancer build() {
         return new LoadBalancer(.build(), .build(),
               .build(), );
      }
      public T fromLoadBalancer(LoadBalancer in) {
         return this.name(in.getName()).createdTime(in.getCreatedTime()).dnsName(in.getDnsName())
               .healthCheck(in.getHealthCheck()).listeners(in.getListeners()).instanceIds(in.getInstanceIds())
               .availabilityZones(in.getAvailabilityZones()).scheme(in.getScheme().orNull())
               .sourceSecurityGroup(in.getSourceSecurityGroup().orNull()).VPCId(in.getVPCId().orNull())
               .securityGroups(in.getSecurityGroups()).subnets(in.getSubnets())
               .hostedZoneName(in.getHostedZoneName().orNull()).hostedZoneId(in.getHostedZoneId().orNull());
      }
   }
   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
      @Override
      protected ConcreteBuilder self() {
         return this;
      }
   }
   protected final String name;
   protected final Date createdTime;
   protected final String dnsName;
   protected final HealthCheck healthCheck;
   protected final Set<StringinstanceIds;
   protected final Set<ListenerWithPolicieslisteners;
   protected final Set<StringavailabilityZones;
   protected final Optional<Schemescheme;
   protected final Optional<StringVPCId;
   protected final Set<StringsecurityGroups;
   protected final Set<Stringsubnets;
   protected final Optional<StringhostedZoneName;
   protected final Optional<StringhostedZoneId;
   protected LoadBalancer(String nameDate createdTimeString dnsNameHealthCheck healthCheck,
         Iterable<StringinstanceIdsIterable<ListenerWithPolicieslistenersIterable<StringavailabilityZones,
         Optional<SchemeschemeOptional<SecurityGroupAndOwnersourceSecurityGroupOptional<StringVPCId,
         Iterable<StringsecurityGroupsIterable<StringsubnetsOptional<StringhostedZoneName,
         Optional<StringhostedZoneId) {
      this. = checkNotNull(name"name");
      this. = checkNotNull(createdTime"createdTime");
      this. = checkNotNull(dnsName"dnsName");
      this. = checkNotNull(healthCheck"healthCheck");
      this. = ImmutableSet.copyOf(checkNotNull(instanceIds"instanceIds"));
      this. = ImmutableSet.copyOf(checkNotNull(listeners"listeners"));
      this. = ImmutableSet.copyOf(checkNotNull(availabilityZones"availabilityZones"));
      this. = checkNotNull(scheme"scheme");
      this. = checkNotNull(sourceSecurityGroup"sourceSecurityGroup");
      this. = checkNotNull(VPCId"VPCId");
      this. = ImmutableSet.copyOf(checkNotNull(securityGroups"securityGroups"));
      this. = ImmutableSet.copyOf(checkNotNull(subnets"subnets"));
      this. = checkNotNull(hostedZoneName"hostedZoneName");
      this. = checkNotNull(hostedZoneId"hostedZoneId");
   }

   
The name associated with the LoadBalancer. The name must be unique within your set of LoadBalancers.
   public String getName() {
      return ;
   }

   
Provides the date and time the LoadBalancer was created.
   public Date getCreatedTime() {
      return ;
   }

   
Specifies the external DNS name associated with the LoadBalancer.
   public String getDnsName() {
      return ;
   }

   
Specifies information regarding the various health probes conducted on the LoadBalancer.
   public HealthCheck getHealthCheck() {
      return ;
   }

   
Provides a list of EC2 instance IDs for the LoadBalancer.
   public Set<StringgetInstanceIds() {
      return ;
   }

   
Provides a list of listeners for the LoadBalancer.
      return ;
   }

   
Specifies a list of Availability Zones.
   public Set<StringgetAvailabilityZones() {
      return ;
   }

   
Type of the loadbalancer; This option is only available for LoadBalancers attached to an Amazon VPC.
   public Optional<SchemegetScheme() {
      return ;
   }

   
The security group that you can use as part of your inbound rules for your LoadBalancer's back-end Amazon EC2 application instances. To only allow traffic from LoadBalancers, add a security group rule to your back end instance that specifies this source security group as the inbound source.
      return ;
   }

   
Provides the ID of the VPC attached to the LoadBalancer.
   public Optional<StringgetVPCId() {
      return ;
   }

   
The security groups the LoadBalancer is a member of (VPC only).
   public Set<StringgetSecurityGroups() {
      return ;
   }

   
Provides a list of VPC subnet IDs for the LoadBalancer.
   public Set<StringgetSubnets() {
      return ;
   }
   
   
Provides the name of the Amazon Route 53 hosted zone that is associated with the LoadBalancer
   public Optional<StringgetHostedZoneName() {
      return ;
   }
   
   
Provides the ID of the Amazon Route 53 hosted zone name that is associated with the LoadBalancer.
   public Optional<StringgetHostedZoneId() {
      return ;
   }

   
   public int hashCode() {
      return Objects.hashCode();
   }

   
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      LoadBalancer other = (LoadBalancerobj;
      return Objects.equal(this.other.name) && Objects.equal(this.other.createdTime);
   }

   
   public String toString() {
      return Objects.toStringHelper(this).omitNullValues().add("name").add("createdTime")
            .add("dnsName").add("healthCheck").add("instanceIds")
            .add("listeners").add("availabilityZones").add("scheme".orNull())
            .add("sourceSecurityGroup".orNull()).add("VPCId".orNull())
            .add("securityGroups").add("subnets")
            .add("hostedZoneName".orNull()).add("hostedZoneId".orNull()).toString();
   }
New to GrepCode? Check out our FAQ X