brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [3/4] git commit: Addressed PR comments
Date Wed, 09 Jul 2014 14:39:16 GMT
Addressed PR comments


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

Branch: refs/heads/master
Commit: 5b0c1962a8ac08d695481ea58ac3fa860bd6443a
Parents: f8893bd
Author: Martin Harris <github@nakomis.com>
Authored: Wed Jul 9 12:28:29 2014 +0100
Committer: Martin Harris <github@nakomis.com>
Committed: Wed Jul 9 12:28:29 2014 +0100

----------------------------------------------------------------------
 .../entity/basic/BrooklynConfigKeys.java        |  6 ++---
 .../basic/AbstractSoftwareProcessDriver.java    |  6 ++---
 ...SoftwareProcessSshDriverIntegrationTest.java | 25 ++++++++++----------
 3 files changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5b0c1962/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java b/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
index 3c75335..1472308 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
@@ -44,10 +44,10 @@ public class BrooklynConfigKeys {
     public static final ConfigKey<String> PRE_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("pre.launch.command",
             "Command to be run prior to the launch method being called on the driver");
     
+    // The implementation in AbstractSoftwareSshDriver runs this command as an SSH command

     public static final ConfigKey<String> POST_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("post.launch.command",
-            "Command to be run after the launch method being called on the driver. The implementation
in AbstractSoftwareSshDriver "
-            + "runs this comamnd as an SSH command");
-        
+            "Command to be run after the launch method being called on the driver");
+    
     public static final BasicAttributeSensorAndConfigKey<String> INSTALL_DIR = new
TemplatedStringAttributeSensorAndConfigKey("install.dir", "Directory for this software to
be installed in",
             "${"
             + "config['"+ONBOX_BASE_DIR.getName()+"']!"

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5b0c1962/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
index f1a2397..b849d6f 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
@@ -14,10 +14,10 @@ import brooklyn.location.Location;
 import brooklyn.util.ResourceUtils;
 import brooklyn.util.task.DynamicTasks;
 import brooklyn.util.task.Tasks;
+import brooklyn.util.text.Strings;
 import brooklyn.util.text.TemplateProcessor;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableMap;
 
 /**
@@ -70,7 +70,7 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
             customize();
         }});
 
-        if (!Strings.isNullOrEmpty(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND)))
{
+        if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND)))
{
             DynamicTasks.queue("pre-launch command", new Runnable() { public void run() {
                 runPreLaunchCommand(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND));
             }});
@@ -81,7 +81,7 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
             launch();
         }});
         
-        if (!Strings.isNullOrEmpty(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND)))
{
+        if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND)))
{
             DynamicTasks.queue("post-launch command", new Runnable() { public void run()
{
                 runPostLaunchCommand(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND));
             }});

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5b0c1962/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessSshDriverIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessSshDriverIntegrationTest.java
b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessSshDriverIntegrationTest.java
index 73c2298..8d13694 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessSshDriverIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessSshDriverIntegrationTest.java
@@ -207,21 +207,20 @@ public class SoftwareProcessSshDriverIntegrationTest {
 
     @Test(groups="Integration")
     public void testPreAndPostLaunchCommands() throws IOException {
-        File tempPreLaunchFile = new File(tempDataDir, "prelaunch.txt");
-        File tempPostLaunchFile = new File(tempDataDir, "postlaunch.txt");
+        File tempFile = new File(tempDataDir, "tempFile.txt");
         localhost.setConfig(BrooklynConfigKeys.ONBOX_BASE_DIR, tempDataDir.getAbsolutePath());
-        app.createAndManageChild(EntitySpec.create(MyService.class)
-                .configure(SoftwareProcess.PRE_LAUNCH_COMMAND, String.format("echo foo >
%s", tempPreLaunchFile.getAbsoluteFile()))
-                .configure(SoftwareProcess.POST_LAUNCH_COMMAND, String.format("echo bar >
%s", tempPostLaunchFile.getAbsoluteFile())));
+        app.createAndManageChild(EntitySpec.create(VanillaSoftwareProcess.class)
+                .configure(VanillaSoftwareProcess.CHECK_RUNNING_COMMAND, "")
+                .configure(SoftwareProcess.PRE_LAUNCH_COMMAND, String.format("echo inPreLaunch
>> %s", tempFile.getAbsoluteFile()))
+                .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, String.format("echo inLaunch
>> %s", tempFile.getAbsoluteFile()))
+                .configure(SoftwareProcess.POST_LAUNCH_COMMAND, String.format("echo inPostLaunch
>> %s", tempFile.getAbsoluteFile())));
         app.start(ImmutableList.of(localhost));
-        List<String> prelaunch = Files.readLines(tempPreLaunchFile, Charsets.UTF_8);
-        List<String> postlaunch = Files.readLines(tempPostLaunchFile, Charsets.UTF_8);
-        assertEquals(prelaunch.size(), 1);
-        assertEquals(postlaunch.size(), 1);
-        assertEquals(postlaunch.get(0), "bar");
-        assertEquals(prelaunch.get(0), "foo");
-        tempPreLaunchFile.delete();
-        tempPostLaunchFile.delete();
+        List<String> output = Files.readLines(tempFile, Charsets.UTF_8);
+        assertEquals(output.size(), 3);
+        assertEquals(output.get(0), "inPreLaunch");
+        assertEquals(output.get(1), "inLaunch");
+        assertEquals(output.get(2), "inPostLaunch");
+        tempFile.delete();
     }
 
     @ImplementedBy(MyServiceImpl.class)


Mime
View raw message