Пример #1
0
 /**
  * Describe load balancers.
  *
  * @param loadBalancerNames a list of load balancers to describe
  * @throws LoadBalancingException wraps checked exceptions
  */
 public List<LoadBalancer> describeLoadBalancers(List<String> loadBalancerNames)
     throws LoadBalancingException {
   Map<String, String> params = new HashMap<String, String>();
   if (loadBalancerNames != null && loadBalancerNames.size() > 0) {
     int i = 0;
     for (String name : loadBalancerNames) {
       params.put("LoadBalancerNames.member." + (i + 1), name);
       i++;
     }
   }
   HttpGet method = new HttpGet();
   DescribeLoadBalancersResponse response =
       makeRequestInt(
           method, "DescribeLoadBalancers", params, DescribeLoadBalancersResponse.class);
   List<com.xerox.amazonws.typica.loadbalance.jaxb.LoadBalancerDescription> result =
       response.getDescribeLoadBalancersResult().getLoadBalancerDescriptions().getMembers();
   List<LoadBalancer> ret = new ArrayList<LoadBalancer>();
   for (com.xerox.amazonws.typica.loadbalance.jaxb.LoadBalancerDescription lb : result) {
     List<com.xerox.amazonws.typica.loadbalance.jaxb.Instance> instList =
         lb.getInstances().getMembers();
     List<String> instances = new ArrayList<String>();
     for (com.xerox.amazonws.typica.loadbalance.jaxb.Instance inst : instList) {
       instances.add(inst.getInstanceId());
     }
     List<com.xerox.amazonws.typica.loadbalance.jaxb.Listener> listenerList =
         lb.getListeners().getMembers();
     List<Listener> listeners = new ArrayList<Listener>();
     for (com.xerox.amazonws.typica.loadbalance.jaxb.Listener listnr : listenerList) {
       listeners.add(
           new Listener(
               listnr.getProtocol(),
               listnr.getLoadBalancerPort().intValue(),
               listnr.getInstancePort().intValue()));
     }
     com.xerox.amazonws.typica.loadbalance.jaxb.HealthCheck hc = lb.getHealthCheck();
     HealthCheck healthCheck =
         new HealthCheck(
             hc.getTarget(),
             hc.getInterval().intValue(),
             hc.getTimeout().intValue(),
             hc.getUnhealthyThreshold().intValue(),
             hc.getHealthyThreshold().intValue());
     LoadBalancer newPoint =
         new LoadBalancer(
             lb.getLoadBalancerName(),
             lb.getDNSName(),
             listeners,
             lb.getAvailabilityZones().getMembers(),
             instances,
             healthCheck,
             lb.getCreatedTime().toGregorianCalendar());
     ret.add(newPoint);
   }
   return ret;
 }
Пример #2
0
 /**
  * Configure health check.
  *
  * @param loadBalancerName the name of the load balancer
  * @param healthCheck the details of the healthcheck
  * @throws LoadBalancingException wraps checked exceptions
  */
 public HealthCheck configureHealthCheck(String loadBalancerName, HealthCheck healthCheck)
     throws LoadBalancingException {
   Map<String, String> params = new HashMap<String, String>();
   params.put("LoadBalancerName", loadBalancerName);
   params.put("HealthCheck.Target", "" + healthCheck.getTarget());
   params.put("HealthCheck.Interval", "" + healthCheck.getInterval());
   params.put("HealthCheck.Timeout", "" + healthCheck.getTimeout());
   params.put("HealthCheck.UnhealthyThreshold", "" + healthCheck.getUnhealthyThreshold());
   params.put("HealthCheck.HealthyThreshold", "" + healthCheck.getHealthyThreshold());
   HttpGet method = new HttpGet();
   ConfigureHealthCheckResponse response =
       makeRequestInt(method, "ConfigureHealthCheck", params, ConfigureHealthCheckResponse.class);
   com.xerox.amazonws.typica.loadbalance.jaxb.HealthCheck hc =
       response.getConfigureHealthCheckResult().getHealthCheck();
   return new HealthCheck(
       hc.getTarget(),
       hc.getInterval().intValue(),
       hc.getTimeout().intValue(),
       hc.getUnhealthyThreshold().intValue(),
       hc.getHealthyThreshold().intValue());
 }