Class InstancePredicates
- java.lang.Object
-
- org.jclouds.openstack.trove.v1.predicates.InstancePredicates
-
public class InstancePredicates extends Object
Tests to see if instance 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 Instance status has reached a desired state. This is useful when your Instance needs to be 100% ready before you can continue with execution.Instance instance = instanceApi.create(100); RetryablePredicate<String> awaitAvailable = RetryablePredicate.create( InstancePredicates.available(instanceApi), 600, 10, 10, TimeUnit.SECONDS); if (!awaitAvailable.apply(instance.getId())) { throw new TimeoutException("Timeout on instance: " + instance); }
Instance instance = instanceApi.create(100); if (!InstancePredicates.awaitAvailable(instanceApi).apply(instance.getId())) { throw new TimeoutException("Timeout on instance: " + instance); }
-
-
Constructor Summary
Constructors Constructor Description InstancePredicates()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.common.base.Predicate<Instance>
awaitAvailable(InstanceApi instanceApi)
Wait until an Instance is Available.static com.google.common.base.Predicate<Instance>
awaitDeleted(InstanceApi instanceApi)
Wait until an Instance no longer exists.static com.google.common.base.Predicate<Instance>
awaitStatus(InstanceApi instanceApi, Instance.Status status, long maxWaitInSec, long periodInSec)
Wait until instance is in the status specified.
-
-
-
Method Detail
-
awaitAvailable
public static com.google.common.base.Predicate<Instance> awaitAvailable(InstanceApi instanceApi)
Wait until an Instance is Available.- Parameters:
instanceApi
- The InstanceApi in the region where your Instance resides.- Returns:
- RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
-
awaitDeleted
public static com.google.common.base.Predicate<Instance> awaitDeleted(InstanceApi instanceApi)
Wait until an Instance no longer exists.- Parameters:
instanceApi
- The InstanceApi in the region where your Instance resides.- Returns:
- RetryablePredicate That will check whether the Instance exists. every 5 seconds for a maxiumum of 10 minutes.
-
awaitStatus
public static com.google.common.base.Predicate<Instance> awaitStatus(InstanceApi instanceApi, Instance.Status status, long maxWaitInSec, long periodInSec)
Wait until instance is in the status specified.- Parameters:
instanceApi
- The InstanceApi in the region where your Instance resides.status
- Wait until instance in in this status.maxWaitInSec
- Maximum time to wait.periodInSec
- Interval between retries.- Returns:
- RetryablePredicate That will check whether the Instance exists.
-
-