Class VolumePredicates
java.lang.Object
org.jclouds.openstack.cinder.v1.predicates.VolumePredicates
Tests to see if volume 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 Volume status has reached a desired state.
This is useful when your Volume needs to be 100% ready before you can continue with execution.
Volume volume = volumeApi.create(100);
RetryablePredicate<String> awaitAvailable = RetryablePredicate.create(
VolumePredicates.available(volumeApi), 600, 10, 10, TimeUnit.SECONDS);
if (!awaitAvailable.apply(volume.getId())) {
throw new TimeoutException("Timeout on volume: " + volume);
}
You can also use the static convenience methods as so.
Volume volume = volumeApi.create(100);
if (!VolumePredicates.awaitAvailable(volumeApi).apply(volume.getId())) {
throw new TimeoutException("Timeout on volume: " + volume);
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Predicate
<Volume> awaitAvailable
(VolumeApi volumeApi) Wait until a Volume is Available.static com.google.common.base.Predicate
<Volume> awaitDeleted
(VolumeApi volumeApi) Wait until a Volume no longer exists.static com.google.common.base.Predicate
<Volume> awaitInUse
(VolumeApi volumeApi) Wait until a Volume is In Use.static com.google.common.base.Predicate
<Volume> awaitStatus
(VolumeApi volumeApi, Volume.Status status, long maxWaitInSec, long periodInSec)
-
Constructor Details
-
VolumePredicates
public VolumePredicates()
-
-
Method Details
-
awaitAvailable
Wait until a Volume is Available.- Parameters:
volumeApi
- The VolumeApi in the region where your Volume resides.- Returns:
- RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
-
awaitInUse
Wait until a Volume is In Use.- Parameters:
volumeApi
- The VolumeApi in the region where your Volume resides.- Returns:
- RetryablePredicate That will check the status every 5 seconds for a maxiumum of 10 minutes.
-
awaitDeleted
Wait until a Volume no longer exists.- Parameters:
volumeApi
- The VolumeApi in the region where your Volume resides.- Returns:
- RetryablePredicate That will check the whether the Volume exists every 5 seconds for a maxiumum of 10 minutes.
-
awaitStatus
public static com.google.common.base.Predicate<Volume> awaitStatus(VolumeApi volumeApi, Volume.Status status, long maxWaitInSec, long periodInSec)
-