You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/02/23 11:07:21 UTC

[1/3] brooklyn-server git commit: add test illustrating the failure in dacf18b831e1e5e1383d662a873643a3c3cabac6

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 5e947cef0 -> a0a713ee6


add test illustrating the failure in dacf18b831e1e5e1383d662a873643a3c3cabac6


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

Branch: refs/heads/master
Commit: 1bbe475818e5912f28009ff221b9fd75ce1ff4e2
Parents: 5cbfd5f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Feb 22 17:22:30 2017 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Feb 22 17:22:30 2017 +0000

----------------------------------------------------------------------
 .../core/entity/ApplicationLifecycleStateTest.java  | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1bbe4758/core/src/test/java/org/apache/brooklyn/core/entity/ApplicationLifecycleStateTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/ApplicationLifecycleStateTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/ApplicationLifecycleStateTest.java
index d340d31..a27e3f3 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/ApplicationLifecycleStateTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/ApplicationLifecycleStateTest.java
@@ -29,6 +29,7 @@ import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.entity.trait.FailingEntity;
 import org.apache.brooklyn.core.test.BrooklynMgmtUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestApplicationImpl;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.collections.CollectionFunctionals;
@@ -70,6 +71,21 @@ public class ApplicationLifecycleStateTest extends BrooklynMgmtUnitTestSupport {
         assertHealthEventually(app, Lifecycle.ON_FIRE, false);
     }
     
+    public static class TestApplicationDoStartFailing extends TestApplicationImpl {
+        @Override
+        protected void doStart(Collection<? extends Location> locations) {
+            super.doStart(locations);
+            throw new RuntimeException("deliberate failure");
+        }
+    }
+    public void testAppFailsCausesAppToFail() throws Exception {
+        TestApplication app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class,
+                TestApplicationDoStartFailing.class));
+        
+        startAndAssertException(app, ImmutableList.<Location>of());
+        assertHealthEventually(app, Lifecycle.ON_FIRE, false);
+    }
+    
     public void testSomeChildFailsOnStartCausesAppToFail() throws Exception {
         TestApplication app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)
                 .child(EntitySpec.create(TestEntity.class))


[2/3] brooklyn-server git commit: fix the problem in the previous test

Posted by dr...@apache.org.
fix the problem in the previous test

where failure in custom start behaviour in applications does not cause an app to go on fire


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

Branch: refs/heads/master
Commit: 4e0be7f696325adad0389aac3b756c043cb268d9
Parents: 1bbe475
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Feb 22 17:23:02 2017 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Feb 22 17:26:20 2017 +0000

----------------------------------------------------------------------
 .../core/entity/AbstractApplication.java        | 51 +++++++++++++++-----
 1 file changed, 38 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4e0be7f6/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
index 857635d..55b0c27 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
@@ -147,24 +147,35 @@ public abstract class AbstractApplication extends AbstractEntity implements Star
         Collection<? extends Location> locationsToUse = locations==null ? ImmutableSet.<Location>of() : locations;
         ServiceProblemsLogic.clearProblemsIndicator(this, START);
         ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application starting");
+        ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(this, START.getName());
         setExpectedStateAndRecordLifecycleEvent(Lifecycle.STARTING);
         try {
-            preStart(locationsToUse);
-
-            // Opportunity to block startup until other dependent components are available
-            Object val = config().get(START_LATCH);
-            if (val != null) log.debug("{} finished waiting for start-latch; continuing...", this);
-
-            doStart(locationsToUse);
-            postStart(locationsToUse);
-
+            try {
+                
+                preStart(locationsToUse);
+                
+                // Opportunity to block startup until other dependent components are available
+                Object val = config().get(START_LATCH);
+                if (val != null) log.debug("{} finished waiting for start-latch; continuing...", this);
+                
+                doStart(locationsToUse);
+                postStart(locationsToUse);
+                
+            } catch (ProblemStartingChildrenException e) {
+                throw Exceptions.propagate(e);
+            } catch (Exception e) {
+                // should remember problems, apart from those that happened starting children
+                // fixed bug introduced by the fix in dacf18b831e1e5e1383d662a873643a3c3cabac6
+                // where failures in special code at application root don't cause app to go on fire 
+                ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, START.getName(), Exceptions.collapseText(e));
+                throw Exceptions.propagate(e);
+            }
+            
         } catch (Exception e) {
-            // TODO should probably remember these problems then clear?  if so, do it here ... or on all effectors?
-            // ServiceProblemsLogic.updateProblemsIndicator(this, START, e);
-
             recordApplicationEvent(Lifecycle.ON_FIRE);
             // no need to log here; the effector invocation should do that
             throw Exceptions.propagate(e);
+            
         } finally {
             ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL);
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
@@ -180,9 +191,23 @@ public abstract class AbstractApplication extends AbstractEntity implements Star
     }
     
     protected void doStart(Collection<? extends Location> locations) {
-        StartableMethods.start(this, locations);        
+        doStartChildren(locations);        
+    }
+    
+    protected void doStartChildren(Collection<? extends Location> locations) {
+        try {
+            StartableMethods.start(this, locations);
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            throw new ProblemStartingChildrenException(e);
+        }
     }
 
+    private static class ProblemStartingChildrenException extends RuntimeException {
+        private static final long serialVersionUID = 7710856289284536803L;
+        private ProblemStartingChildrenException(Exception cause) { super(cause); }
+    }
+    
     /**
      * Default is no-op. Subclasses can override.
      * */


[3/3] brooklyn-server git commit: This closes #568

Posted by dr...@apache.org.
This closes #568


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

Branch: refs/heads/master
Commit: a0a713ee64939b0e5552926933270a6f95d92eb9
Parents: 5e947ce 4e0be7f
Author: Duncan Godwin <dr...@googlemail.com>
Authored: Thu Feb 23 11:06:59 2017 +0000
Committer: Duncan Godwin <dr...@googlemail.com>
Committed: Thu Feb 23 11:06:59 2017 +0000

----------------------------------------------------------------------
 .../core/entity/AbstractApplication.java        | 51 +++++++++++++++-----
 .../entity/ApplicationLifecycleStateTest.java   | 16 ++++++
 2 files changed, 54 insertions(+), 13 deletions(-)
----------------------------------------------------------------------