brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [02/19] incubator-brooklyn git commit: Shutdown BrooklynNode gracefully on restart
Date Thu, 19 Mar 2015 14:07:20 GMT
Shutdown BrooklynNode gracefully on restart


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

Branch: refs/heads/master
Commit: de5b8d5afbe842857976886ee47489e0b69110ad
Parents: d3beb51
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Fri Feb 27 12:54:21 2015 +0200
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Thu Mar 19 16:01:28 2015 +0200

----------------------------------------------------------------------
 .../entity/brooklynnode/BrooklynNodeImpl.java     | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/de5b8d5a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
index 20dc032..3827971 100644
--- a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeImpl.java
@@ -40,6 +40,7 @@ import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.basic.ServiceStateLogic;
 import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
+import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters.StopMode;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.brooklynnode.effector.BrooklynNodeUpgradeEffectorBody;
 import brooklyn.entity.brooklynnode.effector.SetHighAvailabilityModeEffectorBody;
@@ -154,17 +155,30 @@ public class BrooklynNodeImpl extends SoftwareProcessImpl implements
BrooklynNod
     @Override
     protected void preStop() {
         super.preStop();
+        shutdownGracefully();
+    }
+
+    @Override
+    protected void preRestart() {
+        super.preRestart();
+        shutdownGracefully();
+        DynamicTasks.queue("post-shutdown", new Runnable() { public void run() {
+            //set by shutdown - clear it so the entity starts cleanly. Does the indicator
bring any value at all?
+            ServiceNotUpLogic.clearNotUpIndicator(BrooklynNodeImpl.this, SHUTDOWN.getName());
+        }});
+    }
 
+    private void shutdownGracefully() {
         // Shutdown only if accessible: any of stop_* could have already been called.
         // Don't check serviceUp=true because stop() will already have set serviceUp=false
&& expectedState=stopping
         if (Boolean.TRUE.equals(getAttribute(BrooklynNode.WEB_CONSOLE_ACCESSIBLE))) {
             queueShutdownTask();
             queueWaitExitTask();
         } else {
-            log.info("Skipping children.isEmpty check and shutdown call, because web-console
not up for {}", this);
+            log.info("Skipping graceful shutdown call, because web-console not up for {}",
this);
         }
     }
-    
+
     private void queueWaitExitTask() {
         //give time to the process to die gracefully after closing the shutdown call
         DynamicTasks.queue(Tasks.builder().name("wait for graceful stop").body(new Runnable()
{


Mime
View raw message