mirror of https://github.com/apache/jclouds.git
minor improvements to elastic load balancer functionality
This commit is contained in:
parent
9751d6a539
commit
43a0fa4879
|
@ -28,7 +28,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils.GetRegionFromLocation;
|
import org.jclouds.aws.ec2.util.EC2Utils.GetRegionFromLocation;
|
||||||
import org.jclouds.aws.elb.ELBClient;
|
import org.jclouds.aws.elb.ELBClient;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
@ -60,16 +60,9 @@ public class EC2LoadBalanceNodesStrategy implements LoadBalanceNodesStrategy {
|
||||||
int instancePort, Set<String> instanceIds) {
|
int instancePort, Set<String> instanceIds) {
|
||||||
String region = getRegionFromLocation.apply(location);
|
String region = getRegionFromLocation.apply(location);
|
||||||
String dnsName = new String();
|
String dnsName = new String();
|
||||||
|
|
||||||
// TODO: Fix temp hack
|
|
||||||
String availabilityZone = new String();
|
|
||||||
for (String az : AvailabilityZone.zones) {
|
|
||||||
if (az.startsWith(region))
|
|
||||||
availabilityZone = az;
|
|
||||||
}
|
|
||||||
|
|
||||||
dnsName = elbClient.createLoadBalancerInRegion(region, name, protocol, loadBalancerPort,
|
dnsName = elbClient.createLoadBalancerInRegion(region, name, protocol, loadBalancerPort,
|
||||||
instancePort, availabilityZone);
|
instancePort, EC2Utils.getAvailabilityZonesForRegion(region));
|
||||||
|
|
||||||
List<String> instanceIdlist = new ArrayList<String>(instanceIds);
|
List<String> instanceIdlist = new ArrayList<String>(instanceIds);
|
||||||
String[] instanceIdArray = new String[instanceIdlist.size()];
|
String[] instanceIdArray = new String[instanceIdlist.size()];
|
||||||
|
|
|
@ -22,7 +22,9 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.http.HttpUtils.addFormParamTo;
|
import static org.jclouds.http.HttpUtils.addFormParamTo;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -54,6 +56,17 @@ public class EC2Utils {
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] getAvailabilityZonesForRegion(String region)
|
||||||
|
{
|
||||||
|
Set<String> availabilityZones = new HashSet<String>();
|
||||||
|
for (String az : AvailabilityZone.zones) {
|
||||||
|
if (az.startsWith(region))
|
||||||
|
availabilityZones.add(az);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String[])availabilityZones.toArray(new String[availabilityZones.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
public static void indexStringArrayToFormValuesWithPrefix(HttpRequest request, String prefix,
|
public static void indexStringArrayToFormValuesWithPrefix(HttpRequest request, String prefix,
|
||||||
Object input) {
|
Object input) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.xml.CreateLoadBalancerResponseHandler;
|
import org.jclouds.aws.ec2.xml.CreateLoadBalancerResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
import org.jclouds.aws.ec2.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
||||||
|
import org.jclouds.aws.elb.binders.BindAvailabilityZonesToIndexedFormParams;
|
||||||
import org.jclouds.aws.elb.binders.BindELBInstanceIdsToIndexedFormParams;
|
import org.jclouds.aws.elb.binders.BindELBInstanceIdsToIndexedFormParams;
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
import org.jclouds.aws.elb.domain.LoadBalancer;
|
||||||
import org.jclouds.aws.elb.xml.DescribeLoadBalancersResponseHandler;
|
import org.jclouds.aws.elb.xml.DescribeLoadBalancersResponseHandler;
|
||||||
|
@ -69,7 +70,7 @@ public interface ELBAsyncClient {
|
||||||
@FormParam("Listeners.member.1.Protocol") String protocol,
|
@FormParam("Listeners.member.1.Protocol") String protocol,
|
||||||
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
||||||
@FormParam("Listeners.member.1.InstancePort") int instancePort,
|
@FormParam("Listeners.member.1.InstancePort") int instancePort,
|
||||||
@FormParam("AvailabilityZones.member.1") String availabilityZone);
|
@BinderParam(BindAvailabilityZonesToIndexedFormParams.class) String... availabilityZones);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ELBClient#deleteLoadBalancerInRegion
|
* @see ELBClient#deleteLoadBalancerInRegion
|
||||||
|
|
|
@ -44,11 +44,13 @@ public interface ELBClient {
|
||||||
* Port for the load balancer to listen on
|
* Port for the load balancer to listen on
|
||||||
* @param instancePort
|
* @param instancePort
|
||||||
* Port to forward the request to
|
* Port to forward the request to
|
||||||
|
* @param availabilityZones
|
||||||
|
* load balancer availability zones
|
||||||
* @return dns the DNS name for the load balancer
|
* @return dns the DNS name for the load balancer
|
||||||
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/"
|
* @see <a href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/"
|
||||||
*/
|
*/
|
||||||
String createLoadBalancerInRegion(@Nullable String region, String name, String protocol,
|
String createLoadBalancerInRegion(@Nullable String region, String name, String protocol,
|
||||||
int loadBalancerPort, int instancePort, String availabilityZone);
|
int loadBalancerPort, int instancePort, String... availabilityZones);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete load balancer
|
* Delete load balancer
|
||||||
|
|
Loading…
Reference in New Issue