Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/583#discussion_r104883037
--- 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 --
How about making this capture any exception with `runKeepingError` so that
the `throw` below could set it as a cause? Also then you can change the message
below to refer to whatever the actual error was, rather than assuming it's a
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.
---