You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/11/29 13:40:21 UTC

[07/13] brooklyn-server git commit: ServiceFailureDetector: persist lastPublished

ServiceFailureDetector: persist lastPublished

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3a7b972b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3a7b972b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3a7b972b

Branch: refs/heads/master
Commit: 3a7b972b1876b1096c8a9a4b8d1879833681de84
Parents: b97cd17
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 16 09:59:46 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Nov 28 21:11:48 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/policy/ha/ServiceFailureDetector.java     | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3a7b972b/policy/src/main/java/org/apache/brooklyn/policy/ha/ServiceFailureDetector.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/org/apache/brooklyn/policy/ha/ServiceFailureDetector.java b/policy/src/main/java/org/apache/brooklyn/policy/ha/ServiceFailureDetector.java
index 5c5aaeb..cba2abd 100644
--- a/policy/src/main/java/org/apache/brooklyn/policy/ha/ServiceFailureDetector.java
+++ b/policy/src/main/java/org/apache/brooklyn/policy/ha/ServiceFailureDetector.java
@@ -108,6 +108,15 @@ public class ServiceFailureDetector extends ServiceStateLogic.ComputeServiceStat
             .description("Publish failed state periodically at the specified intervals, null to disable.")
             .build();
 
+    /**
+     * Indicates the last event that was published (so we don't accidentally publish repeated
+     * ENTITY_FAILED, etc). Needs to be persisted so that on rebind we don't publish a duplicate
+     * (we'll only publish again if we are in a different state from before Brooklyn was last
+     * shutdown).
+     */
+    @SetFromFlag
+    protected LastPublished lastPublished = LastPublished.NONE;
+
     protected Long firstUpTime;
     
     protected Long currentFailureStartTime = null;
@@ -117,8 +126,6 @@ public class ServiceFailureDetector extends ServiceStateLogic.ComputeServiceStat
     protected Long publishEntityRecoveredTime = null;
     protected Long setEntityOnFireTime = null;
     
-    protected LastPublished lastPublished = LastPublished.NONE;
-
     private final AtomicBoolean executorQueued = new AtomicBoolean(false);
     private volatile long executorTime = 0;
 
@@ -230,6 +237,7 @@ public class ServiceFailureDetector extends ServiceStateLogic.ComputeServiceStat
                     }
                     lastPublished = LastPublished.FAILED;
                     entity.sensors().emit(HASensors.ENTITY_FAILED, new HASensors.FailureDescriptor(entity, getFailureDescription(now)));
+                    requestPersist();
                 } else {
                     recomputeIn = Math.min(recomputeIn, delayBeforeCheck);
                 }
@@ -241,6 +249,7 @@ public class ServiceFailureDetector extends ServiceStateLogic.ComputeServiceStat
                     publishEntityRecoveredTime = null;
                     lastPublished = LastPublished.RECOVERED;
                     entity.sensors().emit(HASensors.ENTITY_RECOVERED, new HASensors.FailureDescriptor(entity, null));
+                    requestPersist();
                 } else {
                     recomputeIn = Math.min(recomputeIn, delayBeforeCheck);
                 }