brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject git commit: fix for loss of stdout/stderr streams
Date Tue, 07 Oct 2014 08:22:37 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master b11274a45 -> 67ad4f4f4


fix for loss of stdout/stderr streams


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

Branch: refs/heads/master
Commit: 67ad4f4f4ad35067ad01b2adc9e36ae0bd7e5cc5
Parents: b11274a
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Oct 7 01:20:47 2014 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Oct 7 01:22:08 2014 -0700

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/BrooklynTaskTags.java |  1 +
 .../basic/AbstractSoftwareProcessSshDriver.java      | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/67ad4f4f/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
index db16c4b..bb57f15 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
@@ -250,6 +250,7 @@ public class BrooklynTaskTags extends TaskTags {
 
     /** returns the tag for the indicated stream, or null */
     public static WrappedStream stream(Task<?> task, String streamType) {
+        if (task==null) return null;
         for (Object tag: task.getTags())
             if ((tag instanceof WrappedStream) && ((WrappedStream)tag).streamType.equals(streamType))
                 return (WrappedStream)tag;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/67ad4f4f/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
index 0e4ddf0..fb26dc5 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import brooklyn.config.BrooklynLogging;
+import brooklyn.entity.basic.BrooklynTaskTags.WrappedStream;
 import brooklyn.entity.basic.lifecycle.NaiveScriptRunner;
 import brooklyn.entity.basic.lifecycle.ScriptHelper;
 import brooklyn.entity.drivers.downloads.DownloadResolver;
@@ -286,12 +287,14 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
             if (environment!=null) {
                 Tasks.addTagDynamically(BrooklynTaskTags.tagForEnvStream(BrooklynTaskTags.STREAM_ENV,
environment));
             }
-            ByteArrayOutputStream stdout = new ByteArrayOutputStream();
-            Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDOUT,
stdout));
-            ByteArrayOutputStream stderr = new ByteArrayOutputStream();
-            Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDERR,
stderr));
-            flags.put("out", stdout);
-            flags.put("err", stderr);
+            if (BrooklynTaskTags.stream(Tasks.current(), BrooklynTaskTags.STREAM_STDOUT)==null)
{
+                ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+                Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDOUT,
stdout));
+                ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+                Tasks.addTagDynamically(BrooklynTaskTags.tagForStreamSoft(BrooklynTaskTags.STREAM_STDERR,
stderr));
+                flags.put("out", stdout);
+                flags.put("err", stderr);
+            }
         }
         if (!flags.containsKey("logPrefix")) flags.put("logPrefix", ""+entity.getId()+"@"+getLocation().getDisplayName());
         return getMachine().execScript(flags, summaryForLogging, script, environment);


Mime
View raw message