jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Everett Toews <notificati...@github.com>
Subject Re: [jclouds-labs-openstack] Adds service predicates and more tests (#186)
Date Fri, 03 Apr 2015 15:29:00 GMT
> +import static com.google.common.base.Preconditions.checkNotNull;
> +import static java.util.concurrent.TimeUnit.SECONDS;
> +import static org.jclouds.util.Predicates2.retry;
> +
> +import org.jclouds.openstack.poppy.v1.domain.Service;
> +import org.jclouds.openstack.poppy.v1.domain.ServiceStatus;
> +import org.jclouds.openstack.poppy.v1.features.ServiceApi;
> +import com.google.common.base.Predicate;
> +
> +public class ServicePredicates {
> +   public static Predicate<Service> awaitDeployed(ServiceApi serviceApi) {
> +      StatusUpdatedPredicate statusPredicate = new StatusUpdatedPredicate(serviceApi,
ServiceStatus.DEPLOYED);
> +      return retry(statusPredicate, 1200, 15, 15, SECONDS);
> +   }
> +
> +   private static class StatusUpdatedPredicate implements Predicate<Service> {

This should really be a more generalized status predicate like [ServerStatusPredicate](https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java#L92).
The convenience method `awaitDeployed` can then be built on that.

I know it's unlikely that anyone would ever want to await on any of the other `ServiceStatus`
in this particular case but the general style should still be followed.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/186/files#r27735322
Mime
View raw message