mirror of https://github.com/apache/jclouds.git
minor improvements to elastic load balancer functionality
This commit is contained in:
parent
2db03edb18
commit
6b832c79cf
|
@ -114,7 +114,6 @@ public interface ELBAsyncClient {
|
||||||
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
||||||
ListenableFuture<? extends Set<LoadBalancer>> describeLoadBalancersInRegion(
|
ListenableFuture<? extends Set<LoadBalancer>> describeLoadBalancersInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
||||||
@FormParam("LoadBalancerName") @Nullable String name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,11 @@ public interface ELBClient {
|
||||||
void deregisterInstancesWithLoadBalancerInRegion(@Nullable String region, String name,
|
void deregisterInstancesWithLoadBalancerInRegion(@Nullable String region, String name,
|
||||||
String... instanceIds);
|
String... instanceIds);
|
||||||
|
|
||||||
Set<LoadBalancer> describeLoadBalancersInRegion(@Nullable String region, @Nullable String name);
|
/**
|
||||||
|
* Returns a set of elastic load balancers
|
||||||
|
* @param region
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Set<LoadBalancer> describeLoadBalancersInRegion(@Nullable String region);
|
||||||
|
|
||||||
}
|
}
|
|
@ -84,10 +84,12 @@ public class EC2LoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveT
|
||||||
for (NodeMetadata node : nodes) {
|
for (NodeMetadata node : nodes) {
|
||||||
instanceIds.add(node.getProviderId());
|
instanceIds.add(node.getProviderId());
|
||||||
}
|
}
|
||||||
Set<LoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(Region.US_EAST_1, tag);
|
Set<LoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(Region.US_EAST_1);
|
||||||
assertNotNull(elbs);
|
assertNotNull(elbs);
|
||||||
LoadBalancer elb = elbs.iterator().next();
|
for(LoadBalancer elb:elbs)
|
||||||
|
{
|
||||||
|
if(elb.getName().equals(tag))
|
||||||
assertEquals(elb.getInstanceIds(), instanceIds);
|
assertEquals(elb.getInstanceIds(), instanceIds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,9 @@ public class ELBClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
void testDescribeLoadBalancers() {
|
void testDescribeLoadBalancers() {
|
||||||
String name = "TestDescribeLoadBalancer";
|
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1,
|
||||||
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
Region.US_WEST_1, Region.AP_SOUTHEAST_1)) {
|
||||||
Set<LoadBalancer> allResults = client.describeLoadBalancersInRegion(region, name);
|
Set<LoadBalancer> allResults = client.describeLoadBalancersInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert (allResults.size() >= 1);
|
assert (allResults.size() >= 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,4 +69,7 @@ public interface LoadBalancerService {
|
||||||
@Beta
|
@Beta
|
||||||
void destroyLoadBalancer(String handle);
|
void destroyLoadBalancer(String handle);
|
||||||
|
|
||||||
|
@Beta
|
||||||
|
Set<String> listLoadBalancers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.predicates.NodePredicates;
|
import org.jclouds.compute.predicates.NodePredicates;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
||||||
|
import org.jclouds.compute.strategy.ListLoadBalancersStrategy;
|
||||||
import org.jclouds.compute.strategy.LoadBalanceNodesStrategy;
|
import org.jclouds.compute.strategy.LoadBalanceNodesStrategy;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||||
|
@ -68,17 +69,21 @@ public class BaseLoadBalancerService implements LoadBalancerService {
|
||||||
protected final ComputeServiceContext context;
|
protected final ComputeServiceContext context;
|
||||||
protected final LoadBalanceNodesStrategy loadBalancerStrategy;
|
protected final LoadBalanceNodesStrategy loadBalancerStrategy;
|
||||||
protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy;
|
protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy;
|
||||||
|
protected final ListLoadBalancersStrategy listLoadBalancersStrategy;
|
||||||
protected final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
|
protected final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BaseLoadBalancerService(ComputeServiceContext context,
|
protected BaseLoadBalancerService(ComputeServiceContext context,
|
||||||
LoadBalanceNodesStrategy loadBalancerStrategy,
|
LoadBalanceNodesStrategy loadBalancerStrategy,
|
||||||
DestroyLoadBalancerStrategy destroyLoadBalancerStrategy,
|
DestroyLoadBalancerStrategy destroyLoadBalancerStrategy,
|
||||||
|
ListLoadBalancersStrategy listLoadBalancersStrategy,
|
||||||
BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
|
BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
|
||||||
this.context = checkNotNull(context, "context");
|
this.context = checkNotNull(context, "context");
|
||||||
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
||||||
this.destroyLoadBalancerStrategy = checkNotNull(destroyLoadBalancerStrategy,
|
this.destroyLoadBalancerStrategy = checkNotNull(destroyLoadBalancerStrategy,
|
||||||
"destroyLoadBalancerStrategy");
|
"destroyLoadBalancerStrategy");
|
||||||
|
this.listLoadBalancersStrategy = checkNotNull(listLoadBalancersStrategy,
|
||||||
|
"listLoadBalancersStrategy");
|
||||||
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler,
|
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler,
|
||||||
"backoffLimitedRetryHandler");
|
"backoffLimitedRetryHandler");
|
||||||
}
|
}
|
||||||
|
@ -131,4 +136,10 @@ public class BaseLoadBalancerService implements LoadBalancerService {
|
||||||
logger.debug("<< destroyed load balancer(%s) success(%s)", loadBalancer, successful);
|
logger.debug("<< destroyed load balancer(%s) success(%s)", loadBalancer, successful);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> listLoadBalancers()
|
||||||
|
{
|
||||||
|
Set<String> loadBalancerSet = listLoadBalancersStrategy.execute();
|
||||||
|
return loadBalancerSet;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue