mirror of https://github.com/apache/jclouds.git
Create load balancer rule should be asynchronous
This commit is contained in:
parent
31bd7c237b
commit
d9f01e0ff8
|
@ -80,9 +80,9 @@ public interface LoadBalancerAsyncClient {
|
|||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "createLoadBalancerRule")
|
||||
@SelectJson("loadbalancerrule")
|
||||
@SelectJson("jobid")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<LoadBalancerRule> createLoadBalancerRuleForPublicIP(@QueryParam("publicipid") long publicIPId,
|
||||
ListenableFuture<Long> createLoadBalancerRuleForPublicIP(@QueryParam("publicipid") long publicIPId,
|
||||
@QueryParam("algorithm") Algorithm algorithm, @QueryParam("name") String name,
|
||||
@QueryParam("privateport") int privatePort, @QueryParam("publicport") int publicPort);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface LoadBalancerClient {
|
|||
* balanced from
|
||||
* @return newly created rule
|
||||
*/
|
||||
LoadBalancerRule createLoadBalancerRuleForPublicIP(long publicIPId, Algorithm algorithm, String name,
|
||||
Long createLoadBalancerRuleForPublicIP(long publicIPId, Algorithm algorithm, String name,
|
||||
int privatePort, int publicPort);
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.cloudstack.domain.AsyncJob;
|
|||
import org.jclouds.cloudstack.domain.AsyncJob.Builder;
|
||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
|
@ -71,7 +72,8 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
|
|||
.put("ipforwardingrule", IPForwardingRule.class)
|
||||
.put("network", Network.class)
|
||||
.put("ipaddress", PublicIPAddress.class)
|
||||
.put("virtualmachine", VirtualMachine.class).build();
|
||||
.put("virtualmachine", VirtualMachine.class)
|
||||
.put("loadbalancer", LoadBalancerRule.class).build();
|
||||
private final Json json;
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
|
||||
|
@ -94,8 +94,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
while (rule == null && attempts < 10) {
|
||||
ip = reuseOrAssociate.apply(network);
|
||||
try {
|
||||
rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN,
|
||||
Long jobId = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN,
|
||||
prefix, 22, 22);
|
||||
assertTrue(jobComplete.apply(jobId));
|
||||
AsyncJob<LoadBalancerRule> asyncJob = client.getAsyncJobClient().getAsyncJob(jobId);
|
||||
LoadBalancerRule result = asyncJob.getResult();
|
||||
rule = result;
|
||||
} catch (IllegalStateException e) {
|
||||
// very likely an ip conflict, so retry;
|
||||
attempts++;
|
||||
|
|
Loading…
Reference in New Issue