Fix SoftwareProcess.ServiceNotUpDiagnosticsCollector race

Previously we subscribed to serviceUp and then called onUpdated.
However, this meant that it could execute onUpdated in two threads
concurrently (if we very quickly got a callback of serviceUp changing).

Instead we now use “notifyOfInitialValue”, which will call us in our
event-handling thread with the initial value of the sensor as a 
pseudo-event for the subscription manager.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/23d95802
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/23d95802
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/23d95802

Branch: refs/heads/master
Commit: 23d9580225d4481d80a808e09f0699616dcfef30
Parents: 7ee7d41
Author: Aled Sage <[email protected]>
Authored: Fri Sep 18 20:00:11 2015 +0100
Committer: Aled Sage <[email protected]>
Committed: Mon Sep 21 14:33:20 2015 +0100

----------------------------------------------------------------------
 .../apache/brooklyn/entity/software/base/SoftwareProcessImpl.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/23d95802/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
 
b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
index 54b7c47..33cd4f4 100644
--- 
a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
+++ 
b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
@@ -157,8 +157,7 @@ public abstract class SoftwareProcessImpl extends 
AbstractEntity implements Soft
             if (!(entity instanceof SoftwareProcess)) {
                 throw new IllegalArgumentException("Expected SoftwareProcess, 
but got entity "+entity);
             }
-            subscribe(entity, Attributes.SERVICE_UP, this);
-            onUpdated();
+            subscribe(ImmutableMap.of("notifyOfInitialValue", true), entity, 
Attributes.SERVICE_UP, this);
         }
 
         @Override

Reply via email to