Class LoadBalancerPredicates
- java.lang.Object
-
- org.jclouds.rackspace.cloudloadbalancers.v1.predicates.LoadBalancerPredicates
-
public class LoadBalancerPredicates extends Object
Tests to see if loadBalancer has reached status. This class is most useful when paired with a RetryablePredicate as in the code below. This class can be used to block execution until the LoadBalancer status has reached a desired state. This is useful when your LoadBalancer needs to be 100% ready before you can continue with execution.
LoadBalancer loadBalancer = loadBalancerApi.create(loadBalancerRequest); RetryablePredicate<String> awaitAvailable = RetryablePredicate.create( LoadBalancerPredicates.available(loadBalancerApi), 600, 10, 10, TimeUnit.SECONDS); if (!awaitAvailable.apply(loadBalancer)) { throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer); }
LoadBalancer loadBalancer = loadBalancerApi.create(loadBalancerRequest); if (!LoadBalancerPredicates.awaitAvailable(loadBalancerApi).apply(loadBalancer)) { throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer); }
-
-
Constructor Summary
Constructors Constructor Description LoadBalancerPredicates()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.common.base.Predicate<LoadBalancer>
awaitAvailable(LoadBalancerApi loadBalancerApi)
Wait until a LoadBalancer is Available.static com.google.common.base.Predicate<LoadBalancer>
awaitDeleted(LoadBalancerApi loadBalancerApi)
Wait until a LoadBalancer no longer exists.static com.google.common.base.Predicate<LoadBalancer>
awaitStatus(LoadBalancerApi loadBalancerApi, LoadBalancer.Status status, long maxWaitInSec, long periodInSec)
-
-
-
Method Detail
-
awaitAvailable
public static com.google.common.base.Predicate<LoadBalancer> awaitAvailable(LoadBalancerApi loadBalancerApi)
Wait until a LoadBalancer is Available.- Parameters:
loadBalancerApi
- The LoadBalancerApi in the region where your LoadBalancer resides.- Returns:
- RetryablePredicate That will check the status every 3 seconds for a maxiumum of 5 minutes.
-
awaitDeleted
public static com.google.common.base.Predicate<LoadBalancer> awaitDeleted(LoadBalancerApi loadBalancerApi)
Wait until a LoadBalancer no longer exists.- Parameters:
loadBalancerApi
- The LoadBalancerApi in the region where your LoadBalancer resides.- Returns:
- RetryablePredicate That will check the whether the LoadBalancer exists every 3 seconds for a maxiumum of 5 minutes.
-
awaitStatus
public static com.google.common.base.Predicate<LoadBalancer> awaitStatus(LoadBalancerApi loadBalancerApi, LoadBalancer.Status status, long maxWaitInSec, long periodInSec)
-
-