Github user alasdairhodge commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/583#discussion_r104894009
--- 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 --
On the subject of exceptions, I toyed with the idea of throwing
`TimeoutException` instead of `IllegalStateException`, but am opting for
consistency/backwards compatibility with the existing `waitForServiceUp`
methods. (The standard `TimeoutException` is checked.)
---
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.
---