Github user alasdairhodge commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/583#discussion_r104893802
--- Diff: core/src/main/java/org/apache/brooklyn/core/entity/Entities.java
---
@@ -1139,6 +1141,29 @@ public static void warnOnIgnoringConfig(Entity
entity, ConfigKey<?> key) {
log.warn("Ignoring "+key+" set on "+entity+"
("+entity.getConfig(key)+")");
}
+ /** Waits until the passed entity satisfies the supplied predicate. */
+ public static void waitFor(Entity entity, Predicate<Entity> condition,
Duration timeout) {
+ try {
+ String description = "Waiting for " + condition + " on " +
entity;
+ Tasks.setBlockingDetails(description);
+
+ Repeater repeater = Repeater.create(description)
+ .until(isSatisfied(entity, condition))
+ .limitTimeTo(timeout)
+ .backoffTo(Duration.ONE_SECOND)
+ .rethrowException();
+
+ if (!repeater.run()) {
--- End diff --
Timeout is indicated by the `run` method returning `false`, rather than via
an exception. Since we set `rethrowException`, anything thrown by the passed
`Callable` will be rethrown on timeout.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---