org.jclouds.openstack.cinder.v1.predicates
Class SnapshotPredicates

java.lang.Object
  extended by 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); 
 }    
 
 
You can also use the static convenience methods as so.
 Snapshot snapshot = snapshotApi.create(volumeId);
 
 if (!SnapshotPredicates.awaitAvailable(snapshotApi).apply(snapshot.getId())) {
    throw new TimeoutException("Timeout on snapshot: " + snapshot);     
 }
 
 


Constructor Summary
SnapshotPredicates()
           
 
Method Summary
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotPredicates

public SnapshotPredicates()
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 zone 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 zone 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)


Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.