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