ServiceNotUpDiagnostics: populate properly Previously we only re-populated the ServiceNotUpDiagnostics when serviceUp changed. However, this meant we did it once at the start (where it said âno-driverâ) and then not again if startup failed, so serviceUp was left as âfalseâ.
Now we also re-populate the ServiceNotUpDiagnostics if the serviceState changes (and serviceUp=false), e.g. if we conclude on-fire etc. Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/9157eb9c Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/9157eb9c Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/9157eb9c Branch: refs/heads/master Commit: 9157eb9c434602d91ea6a897364026cb5844748b Parents: 23d9580 Author: Aled Sage <[email protected]> Authored: Fri Sep 18 20:52:51 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Sep 21 14:33:20 2015 +0100 ---------------------------------------------------------------------- .../brooklyn/entity/software/base/SoftwareProcessImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9157eb9c/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 33cd4f4..b635242 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,6 +157,7 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft if (!(entity instanceof SoftwareProcess)) { throw new IllegalArgumentException("Expected SoftwareProcess, but got entity "+entity); } + subscribe(ImmutableMap.of("notifyOfInitialValue", true), entity, Attributes.SERVICE_STATE_ACTUAL, this); subscribe(ImmutableMap.of("notifyOfInitialValue", true), entity, Attributes.SERVICE_UP, this); } @@ -167,8 +168,12 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft protected void onUpdated() { Boolean up = entity.getAttribute(SERVICE_UP); + Lifecycle state = entity.getAttribute(SERVICE_STATE_ACTUAL); if (up == null || up) { - entity.setAttribute(ServiceStateLogic.SERVICE_NOT_UP_DIAGNOSTICS, ImmutableMap.<String, Object>of()); + entity.sensors().set(ServiceStateLogic.SERVICE_NOT_UP_DIAGNOSTICS, ImmutableMap.<String, Object>of()); + } else if (state == Lifecycle.STOPPING || state == Lifecycle.STOPPED || state == Lifecycle.DESTROYED) { + // stopping/stopped, so expect not to be up; get rid of the diagnostics. + entity.sensors().set(ServiceStateLogic.SERVICE_NOT_UP_DIAGNOSTICS, ImmutableMap.<String, Object>of()); } else { ((SoftwareProcess)entity).populateServiceNotUpDiagnostics(); }
