Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to jclouds, Inc. (jclouds) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. jclouds 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 {
   
Specifies the type of LoadBalancer. This option is only available for LoadBalancers attached to an Amazon VPC.
 
    public static enum Scheme {

      
the LoadBalancer has a publicly resolvable DNS name that resolves to public IP addresses
 
       INTERNET_FACING,
      
the LoadBalancer has a publicly resolvable DNS name that resolves to private IP addresses.
 
       INTERNAL,
      
The scheme was returned unrecognized.
 
       UNRECOGNIZED;
 
       public String value() {
          return (..to(.name()));
       }
 
       @Override
       public String toString() {
          return value();
       }
 
       public static Scheme fromValue(String scheme) {
          try {
             return valueOf(..to(.checkNotNull(scheme"scheme")));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
    }
 
    public static Builder<?> builder() {
       return new ConcreteBuilder();
    }
 
    public Builder<?> toBuilder() {
       return new ConcreteBuilder().fromLoadBalancer(this);
    }
 
    public static abstract 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 Optional<Schemescheme = Optional.absent();
      protected Optional<StringVPCId = 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 scheme(Scheme scheme) {
         this. = Optional.fromNullable(scheme);
         return self();
      }

      
      public T VPCId(String VPCId) {
         this. = Optional.fromNullable(VPCId);
         return self();
      }
      public LoadBalancer build() {
         return new LoadBalancer(.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())
                  .scheme(in.getScheme().orNull()).VPCId(in.getVPCId().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 Optional<Schemescheme;
   protected final Optional<StringVPCId;
   protected LoadBalancer(String nameDate createdTimeString dnsNameHealthCheck healthCheck,
            Iterable<StringinstanceIdsIterable<ListenerWithPolicieslistenersOptional<Schemescheme,
            Optional<StringVPCId) {
      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. = checkNotNull(scheme"scheme");
      this. = checkNotNull(VPCId"VPCId");
   }

   
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 ;
   }

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

   
Provides the ID of the VPC attached to the LoadBalancer.
   public Optional<StringgetVPCId() {
      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("scheme".orNull()).add("VPCId".orNull()).toString();
   }
New to GrepCode? Check out our FAQ X