You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/05/11 15:32:54 UTC

[1/8] incubator-brooklyn git commit: Nodejs riak sample app

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master addf30e23 -> 125f01e00


Nodejs riak sample app

- Refactoring the NodeJsWebAppSshDriver
install packages from package.json as non-root


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

Branch: refs/heads/master
Commit: ac3bab73dc271a6c9e5e2f769e9c1d5e2f053b85
Parents: 7b97cee
Author: Valentin Aitken <va...@cloudsoftcorp.com>
Authored: Wed Apr 22 20:56:49 2015 +0300
Committer: Valentin Aitken <va...@cloudsoftcorp.com>
Committed: Sun Apr 26 20:27:57 2015 +0300

----------------------------------------------------------------------
 .../brooklyn/demo/nodejs-riak-todo.yaml         | 46 ++++++++++++++++++++
 .../brooklyn/entity/nosql/riak/RiakCluster.java |  2 +
 .../entity/nosql/riak/RiakClusterImpl.java      |  3 ++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    | 13 +++---
 4 files changed, 59 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac3bab73/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-riak-todo.yaml
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-riak-todo.yaml b/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-riak-todo.yaml
new file mode 100644
index 0000000..d963671
--- /dev/null
+++ b/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-riak-todo.yaml
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: "Node.JS Todo Application"
+origin: "https://github.com/amirrajan/nodejs-todo/"
+location:
+  jclouds:aws-ec2:us-west-1:
+    imageId: us-west-1/ami-c33cdd87
+services:
+- type: brooklyn.entity.nosql.riak.RiakCluster
+  initialSize: 2
+  id: mycluster
+  brooklyn.config:
+    provisioning.properties:
+      osFamily: centos
+      minCores: 4
+      minRam: 2048
+- type: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs-riak1
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/bostko/nodejs-todo.git"
+    appFileName: server.js
+    appName: nodejs-todo
+    nodePackages:
+    - basho-riak-client
+    env:
+      NODE_ENV: production
+      RIAK_NODES: >
+        $brooklyn:component("mycluster").attributeWhenReady("riak.cluster.nodeListPbPort")
+    launch.latch: $brooklyn:component("mycluster").attributeWhenReady("service.isUp")
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac3bab73/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
index a5a3838..41aa6be 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakCluster.java
@@ -54,6 +54,8 @@ public interface RiakCluster extends DynamicCluster {
 
     AttributeSensor<String> NODE_LIST = Sensors.newStringSensor("riak.cluster.nodeList", "List of nodes (including ports), comma separated");
 
+    AttributeSensor<String> NODE_LIST_PB_PORT = Sensors.newStringSensor("riak.cluster.nodeListPbPort", "List of nodes (including ports for riak db clients), comma separated");
+
     AttributeSensor<URI> RIAK_CONSOLE_URI = Attributes.MAIN_URI;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac3bab73/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
index becaee7..637346e 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakClusterImpl.java
@@ -182,13 +182,16 @@ public class RiakClusterImpl extends DynamicClusterImpl implements RiakCluster {
 
     private void calculateClusterAddresses() {
         List<String> addresses = Lists.newArrayList();
+        List<String> addressesPbPort = Lists.newArrayList();
         for (Entity entity : this.getMembers()) {
             if (entity instanceof RiakNode && entity.getAttribute(Attributes.SERVICE_UP)) {
                 RiakNode riakNode = (RiakNode) entity;
                 addresses.add(riakNode.getAttribute(Attributes.SUBNET_HOSTNAME) + ":" + riakNode.getAttribute(RiakNode.RIAK_WEB_PORT));
+                addressesPbPort.add(riakNode.getAttribute(Attributes.SUBNET_HOSTNAME) + ":" + riakNode.getAttribute(RiakNode.RIAK_PB_PORT));
             }
         }
         setAttribute(RiakCluster.NODE_LIST, Joiner.on(",").join(addresses));
+        setAttribute(RiakCluster.NODE_LIST_PB_PORT, Joiner.on(",").join(addressesPbPort));
     }
 
     protected boolean belongsInServerPool(Entity member) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac3bab73/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index fb2eb25..3beee70 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -103,6 +103,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
                         BashCommands.installPackage("software-properties-common python-software-properties python g++ make"),
                         BashCommands.sudo("add-apt-repository ppa:chris-lea/node.js"))))
                 .add(BashCommands.installPackage(MutableMap.of("yum", "git nodejs npm", "apt", "git-core nodejs"), null))
+                .add("mkdir \"$HOME/.npm\"")
                 .add(BashCommands.sudo("npm install -g n"))
                 .add(BashCommands.sudo("n " + getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION)))
                 .build();
@@ -116,11 +117,6 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
     public void customize() {
         List<String> commands = Lists.newLinkedList();
 
-        List<String> packages = getEntity().getConfig(NodeJsWebAppService.NODE_PACKAGE_LIST);
-        if (packages != null && packages.size() > 0) {
-            commands.add(BashCommands.sudo("npm install -g " + Joiner.on(' ').join(packages)));
-        }
-
         String gitRepoUrl = getEntity().getConfig(NodeJsWebAppService.APP_GIT_REPOSITORY_URL);
         String archiveUrl = getEntity().getConfig(NodeJsWebAppService.APP_ARCHIVE_URL);
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
@@ -128,12 +124,19 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
             throw new IllegalStateException("Only one of Git or archive URL must be set for " + getEntity());
         } else if (Strings.isNonBlank(gitRepoUrl)) {
             commands.add(String.format("git clone %s %s", gitRepoUrl, appName));
+            commands.add(String.format("cd %s", appName));
         } else if (Strings.isNonBlank(archiveUrl)) {
             ArchiveUtils.deploy(archiveUrl, getMachine(), getRunDir());
         } else {
             throw new IllegalStateException("At least one of Git or archive URL must be set for " + getEntity());
         }
 
+        commands.add(BashCommands.ifFileExistsElse1("package.json", "npm install"));
+        List<String> packages = getEntity().getConfig(NodeJsWebAppService.NODE_PACKAGE_LIST);
+        if (packages != null && packages.size() > 0) {
+            commands.add(BashCommands.sudo("npm install -g " + Joiner.on(' ').join(packages)));
+        }
+
         newScript(CUSTOMIZING)
                 .body.append(commands)
                 .execute();


[7/8] incubator-brooklyn git commit: This closes #631

Posted by sj...@apache.org.
This closes #631


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

Branch: refs/heads/master
Commit: e52f79d1b898f282b39db64ed8577e676c9f8106
Parents: 0535095 0d5d79d
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Mon May 11 14:09:47 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Mon May 11 14:09:47 2015 +0100

----------------------------------------------------------------------
 pom.xml                         | 21 +++++++++++++--------
 usage/downstream-parent/pom.xml |  8 ++++----
 2 files changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[4/8] incubator-brooklyn git commit: Reorganise version properties in root pom.xml

Posted by sj...@apache.org.
Reorganise version properties in root pom.xml

No changes to versions, simply a re-order and a comment to keep versions
synchronised with usage/downstream-parent/pom.xml


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

Branch: refs/heads/master
Commit: 9215c12e22ad2828901906bd2824cbc14eb2a6e3
Parents: d0cbcf3
Author: Richard Downer <ri...@apache.org>
Authored: Wed May 6 10:25:06 2015 +0100
Committer: Richard Downer <ri...@apache.org>
Committed: Wed May 6 10:25:06 2015 +0100

----------------------------------------------------------------------
 pom.xml | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9215c12e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 962bc30..b4f2e3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -123,21 +123,29 @@
         <!-- Dependencies -->
         <brooklyn.version>0.7.0-SNAPSHOT</brooklyn.version>  <!-- BROOKLYN_VERSION -->
         <jclouds.groupId>org.apache.jclouds</jclouds.groupId>
+
+        <!-- These dependencies also appear in usage/downstream-parent/pom.xml -
+           - please synchronise versions between these two pom files -->
         <jclouds.version>1.9.0</jclouds.version>
-        <guava.version>17.0</guava.version>
-        <groovy.version>2.3.4</groovy.version> <!-- Version supported by https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-2.9.0-Release-Notes -->
         <logback.version>1.0.7</logback.version>
-        <testng.version>6.8.8</testng.version>
-        <mockito.version>1.10.8</mockito.version>
         <slf4j.version>1.6.6</slf4j.version>  <!-- used for java.util.logging jul-to-slf4j interception -->
+        <guava.version>17.0</guava.version>
         <xstream.version>1.4.7</xstream.version>
         <jackson.version>1.9.13</jackson.version>  <!-- codehaus jackson, used by brooklyn rest server -->
         <fasterxml.jackson.version>2.4.2</fasterxml.jackson.version>  <!-- more recent jackson, but not compatible with old annotations! -->
         <jersey.version>1.18.1</jersey.version>
+        <httpclient.version>4.2.5</httpclient.version>
+        <commons-lang3.version>3.1</commons-lang3.version>
+        <groovy.version>2.3.4</groovy.version> <!-- Version supported by https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-2.9.0-Release-Notes -->
+        <jsr305.version>2.0.1</jsr305.version>
+        <snakeyaml.version>1.11</snakeyaml.version>
+
+        <!-- Ordinary dependencies -->
+        <testng.version>6.8.8</testng.version>
+        <mockito.version>1.10.8</mockito.version>
         <swagger.version>1.0.1</swagger.version>
         <jansi.version>1.2.1</jansi.version>
         <gson.version>2.2.2</gson.version>
-        <jsr305.version>2.0.1</jsr305.version>
         <ivy.version>2.2.0</ivy.version>
         <mx4j.version>3.0.1</mx4j.version>
         <bouncycastle.version>1.49</bouncycastle.version>
@@ -147,18 +155,15 @@
         <jetty.version>8.1.4.v20120524</jetty.version>
         <airline.version>0.6</airline.version>
         <mockwebserver.version>20121111</mockwebserver.version>
-        <httpclient.version>4.2.5</httpclient.version>
         <freemarker.version>2.3.19</freemarker.version>
         <commons-io.version>2.4</commons-io.version>
         <hazelcast.version>3.0</hazelcast.version>
         <jsonPath.version>0.9.1</jsonPath.version>
-        <commons-lang3.version>3.1</commons-lang3.version>
         <commons-compress.version>1.4</commons-compress.version>
         <qpid.version>0.20</qpid.version>
         <mongodb.version>2.11.4</mongodb.version>
         <riak.version>1.4.0</riak.version>
         <maven-war-plugin.version>2.4</maven-war-plugin.version>
-        <snakeyaml.version>1.11</snakeyaml.version>
         <validation-api.version>1.0.0.GA</validation-api.version>
         <geronimo-jms_1.1_spec.version>1.1.1</geronimo-jms_1.1_spec.version>
         <sleepycat-je.version>5.0.34</sleepycat-je.version>


[8/8] incubator-brooklyn git commit: This closes #612

Posted by sj...@apache.org.
This closes #612


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

Branch: refs/heads/master
Commit: 125f01e0031fa439108012f8a77eff211a12a2a2
Parents: e52f79d ac3bab7
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Mon May 11 14:16:55 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Mon May 11 14:16:55 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/demo/nodejs-riak-todo.yaml         | 46 ++++++++++++++++++++
 .../brooklyn/entity/nosql/riak/RiakCluster.java |  2 +
 .../entity/nosql/riak/RiakClusterImpl.java      |  3 ++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    | 13 +++---
 4 files changed, 59 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[6/8] incubator-brooklyn git commit: This closes #624

Posted by sj...@apache.org.
This closes #624


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

Branch: refs/heads/master
Commit: 0535095bed6e07272a63f21f63c62773c61a2d92
Parents: addf30e 29bcd8e
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Mon May 11 14:05:42 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Mon May 11 14:05:42 2015 +0100

----------------------------------------------------------------------
 .../entity/basic/SoftwareProcessImpl.java       | 29 ++++++++++++++++----
 1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[5/8] incubator-brooklyn git commit: Version conflicts in usage/downstream-parent/pom.xml

Posted by sj...@apache.org.
Version conflicts in usage/downstream-parent/pom.xml

Synchronise version properties so that brooklyn-downstream-parent
depends on the same version dependencies as brooklyn.


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

Branch: refs/heads/master
Commit: 0d5d79ddcca1ee90f893bb8b65c850a147e2962b
Parents: 9215c12
Author: Richard Downer <ri...@apache.org>
Authored: Wed May 6 10:27:09 2015 +0100
Committer: Richard Downer <ri...@apache.org>
Committed: Wed May 6 10:27:09 2015 +0100

----------------------------------------------------------------------
 usage/downstream-parent/pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d5d79dd/usage/downstream-parent/pom.xml
----------------------------------------------------------------------
diff --git a/usage/downstream-parent/pom.xml b/usage/downstream-parent/pom.xml
index 252d032..0c968a9 100644
--- a/usage/downstream-parent/pom.xml
+++ b/usage/downstream-parent/pom.xml
@@ -51,12 +51,12 @@
     <slf4j.version>1.6.6</slf4j.version>  <!-- used for java.util.logging jul-to-slf4j interception -->
     <guava.version>17.0</guava.version>
     <xstream.version>1.4.7</xstream.version>
-    <jackson.version>1.9.13</jackson.version>
-    <fasterxml.jackson.version>2.2.0</fasterxml.jackson.version>
-    <jersey.version>1.12</jersey.version>
+    <jackson.version>1.9.13</jackson.version>  <!-- codehaus jackson, used by brooklyn rest server -->
+    <fasterxml.jackson.version>2.4.2</fasterxml.jackson.version>  <!-- more recent jackson, but not compatible with old annotations! -->
+    <jersey.version>1.18.1</jersey.version>
     <httpclient.version>4.2.5</httpclient.version>
     <commons-lang3.version>3.1</commons-lang3.version>
-    <groovy.version>2.3.4</groovy.version>
+    <groovy.version>2.3.4</groovy.version> <!-- Version supported by https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-2.9.0-Release-Notes -->
     <jsr305.version>2.0.1</jsr305.version>
     <snakeyaml.version>1.11</snakeyaml.version>
   </properties>


[3/8] incubator-brooklyn git commit: Log subsequent isRunning exceptions at debug level

Posted by sj...@apache.org.
Log subsequent isRunning exceptions at debug level


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

Branch: refs/heads/master
Commit: 29bcd8e36821163afb43d40748e02d4674d29c31
Parents: 5a4e83a
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Tue May 5 18:41:12 2015 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue May 5 18:41:12 2015 +0300

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/SoftwareProcessImpl.java     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29bcd8e3/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index eedc546..8df4457 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -505,7 +505,12 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
 
                 isRunningResult = false;
                 if (driver != null) {
-                    log.error("checked " + this + ", 'is running' threw an exception", e);
+                    String msg = "checked " + this + ", 'is running' threw an exception; logging subsequent exceptions at debug level";
+                    if (firstFailure == null) {
+                        log.error(msg, e);
+                    } else {
+                        log.debug(msg, e);
+                    }
                 } else {
                     // provide extra context info, as we're seeing this happen in strange circumstances
                     log.error(this+" concurrent start and shutdown detected", e);
@@ -522,7 +527,7 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
             String msg = "Software process entity "+this+" did not pass is-running check within "+
                     "the required "+startTimeout+" limit ("+timer.getDurationElapsed().toStringRounded()+" elapsed)";
             if (firstFailure != null) {
-                msg += "; check failed with exception: " + firstFailure.getMessage();
+                msg += "; check failed at least once with exception: " + firstFailure.getMessage() + ", see logs for details";
             }
             log.warn(msg+" (throwing)");
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);


[2/8] incubator-brooklyn git commit: Don't fail on startup in case of an isRunning exception

Posted by sj...@apache.org.
Don't fail on startup in case of an isRunning exception

During entity startup treat isRunning exceptions as temporary failures and wait until timeout, don't propagate them on the spot. Could be caused by a temporary problem, for example connectivity issues.


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

Branch: refs/heads/master
Commit: 5a4e83a2604b7f03f679690006517f8189732aa3
Parents: d8a9a6f
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Mon May 4 15:27:35 2015 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue May 5 18:40:30 2015 +0300

----------------------------------------------------------------------
 .../entity/basic/SoftwareProcessImpl.java       | 24 +++++++++++++++-----
 1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5a4e83a2/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index ce28efd..eedc546 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -494,17 +494,26 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
         CountdownTimer timer = startTimeout.countdownTimer();
         boolean isRunningResult = false;
         long delay = 100;
+        Exception firstFailure = null;
         while (!isRunningResult && !timer.isExpired()) {
             Time.sleep(delay);
             try {
                 isRunningResult = driver.isRunning();
+                if (log.isDebugEnabled()) log.debug("checked {}, 'is running' returned: {}", this, isRunningResult);
             } catch (Exception  e) {
-                ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-                // provide extra context info, as we're seeing this happen in strange circumstances
-                if (driver==null) throw new IllegalStateException(this+" concurrent start and shutdown detected");
-                throw new IllegalStateException("Error detecting whether "+this+" is running: "+e, e);
+                Exceptions.propagateIfFatal(e);
+
+                isRunningResult = false;
+                if (driver != null) {
+                    log.error("checked " + this + ", 'is running' threw an exception", e);
+                } else {
+                    // provide extra context info, as we're seeing this happen in strange circumstances
+                    log.error(this+" concurrent start and shutdown detected", e);
+                }
+                if (firstFailure == null) {
+                    firstFailure = e;
+                }
             }
-            if (log.isDebugEnabled()) log.debug("checked {}, is running returned: {}", this, isRunningResult);
             // slow exponential delay -- 1.1^N means after 40 tries and 50s elapsed, it reaches the max of 5s intervals
             // TODO use Repeater 
             delay = Math.min(delay*11/10, 5000);
@@ -512,9 +521,12 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
         if (!isRunningResult) {
             String msg = "Software process entity "+this+" did not pass is-running check within "+
                     "the required "+startTimeout+" limit ("+timer.getDurationElapsed().toStringRounded()+" elapsed)";
+            if (firstFailure != null) {
+                msg += "; check failed with exception: " + firstFailure.getMessage();
+            }
             log.warn(msg+" (throwing)");
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
-            throw new IllegalStateException(msg);
+            throw new IllegalStateException(msg, firstFailure);
         }
     }