Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/213#discussion_r18506142
--- Diff: core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
---
@@ -114,6 +117,21 @@ private ServiceStateLogic() {}
}
public static void setExpectedState(Entity entity, Lifecycle state) {
+ if (state==Lifecycle.RUNNING) {
+ Boolean up =
((EntityInternal)entity).getAttribute(Attributes.SERVICE_UP);
+ if (!Boolean.TRUE.equals(up)) {
+ // pause briefly to allow any recent problem-clearing
processing to complete
+ Stopwatch timer = Stopwatch.createStarted();
+ boolean nowUp =
Repeater.create().every(Duration.millis(10)).limitTimeTo(Duration.millis(200)).until(entity,
--- End diff --
I'm always reluctant to add sleeps into the code (even if it is a nicely
implemented one that limits the length of the sleep).
I prefer the `backOffTo` rather than the `every`, e.g.
`.backOffTo(Duration.millis(20))`.
I'm ok with merging this because it improves the race. But the race still
exists, and may well still bite us on apache jenkins where the machines are low
powered so things could take more than 200ms.
---
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.
---