org.jclouds.openstack.nova.v2_0.predicates
Class ServerPredicates
java.lang.Object
org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates
public class ServerPredicates
- extends Object
This class tests to see if a Server or ServerCreated has reached a desired status. This class is most useful when
paired with a RetryablePredicate as in the code below. Together these classes can be used to block execution until
the Server or ServerCreated has reached that desired status. This is useful when your Server needs to be 100% ready
before you can continue with execution.
For example, you can use the factory methods like so.
ServerCreated serverCreated = serverApi.create("my-server", image.getId(), flavor.getId());
if (!ServerPredicates.awaitActive(serverApi).apply(serverCreated.getId())) {
throw new TimeoutException("Timeout on server: " + serverCreated);
}
{@code
if (!ServerPredicates.awaitStatus(serverApi, ACTIVE, 300, 2).apply(server.getId())) {
throw new TimeoutException("Timeout on server: " + serverCreated);
}
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ServerPredicates
public ServerPredicates()
awaitActive
public static com.google.common.base.Predicate<String> awaitActive(ServerApi serverApi)
- Waits until a Server is ACTIVE.
- Parameters:
serverApi - The ServerApi in the zone where your Server resides.
- Returns:
- Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
awaitShutoff
public static com.google.common.base.Predicate<String> awaitShutoff(ServerApi serverApi)
- Waits until a Server is SHUTOFF.
- Parameters:
serverApi - The ServerApi in the zone where your Server resides.
- Returns:
- Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
awaitStatus
public static com.google.common.base.Predicate<String> awaitStatus(ServerApi serverApi,
Server.Status status,
long maxWaitInSec,
long periodInSec)
- Waits until a Server reaches Status.
- Parameters:
serverApi - The ServerApi in the zone where your Server resides.
- Returns:
- Predicate that will check the status every periodInSec seconds for a maximum of maxWaitInSec minutes.
Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.