brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [5/6] incubator-brooklyn git commit: ssh async-exec: incorporate comments + logging
Date Tue, 23 Dec 2014 15:13:11 GMT
ssh async-exec: incorporate comments + logging

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

Branch: refs/heads/master
Commit: 63483f8ea3611d6534ee27bea4debe085f488e4d
Parents: ee8d521
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Dec 23 14:10:02 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Dec 23 14:10:02 2014 +0000

----------------------------------------------------------------------
 .../java/brooklyn/internal/BrooklynFeatureEnablement.java |  9 ++++++++-
 .../brooklyn/util/internal/ssh/ShellAbstractTool.java     |  1 -
 .../java/brooklyn/util/internal/ssh/sshj/SshjTool.java    | 10 ++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/63483f8e/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
index d8aa66e..9946ac7 100644
--- a/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
+++ b/core/src/main/java/brooklyn/internal/BrooklynFeatureEnablement.java
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
 
 import brooklyn.internal.storage.BrooklynStorage;
 import brooklyn.management.ha.HighAvailabilityMode;
+import brooklyn.util.internal.ssh.ShellTool;
 
 import com.google.common.annotations.Beta;
 import com.google.common.collect.Maps;
@@ -84,6 +85,12 @@ public class BrooklynFeatureEnablement {
      */
     public static final String FEATURE_INFER_CATALOG_ITEM_ON_REBIND = "brooklyn.backwardCompatibility.feature.inferCatalogItemOnRebind";
     
+    /**
+     * When executing over ssh, whether to support the "async exec" approach, or only the
classic approach.
+     * 
+     * If this feature is disabled, then even if the {@link ShellTool#PROP_EXEC_ASYNC} is
configured it
+     * will still use the classic ssh approach.
+     */
     public static final String FEATURE_SSH_ASYNC_EXEC = "brooklyn.experimental.feature.ssh.asyncExec";
 
     private static final Map<String, Boolean> FEATURE_ENABLEMENTS = Maps.newLinkedHashMap();
@@ -104,7 +111,7 @@ public class BrooklynFeatureEnablement {
         setDefault(FEATURE_USE_BROOKLYN_LIVE_OBJECTS_DATAGRID_STORAGE, false);
         setDefault(FEATURE_RENAME_THREADS, false);
         setDefault(FEATURE_INFER_CATALOG_ITEM_ON_REBIND, true);
-        setDefault(FEATURE_SSH_ASYNC_EXEC, true);
+        setDefault(FEATURE_SSH_ASYNC_EXEC, false);
     }
     
     static {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/63483f8e/core/src/main/java/brooklyn/util/internal/ssh/ShellAbstractTool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/internal/ssh/ShellAbstractTool.java b/core/src/main/java/brooklyn/util/internal/ssh/ShellAbstractTool.java
index 41dc886..82624d7 100644
--- a/core/src/main/java/brooklyn/util/internal/ssh/ShellAbstractTool.java
+++ b/core/src/main/java/brooklyn/util/internal/ssh/ShellAbstractTool.java
@@ -297,7 +297,6 @@ public abstract class ShellAbstractTool implements ShellTool {
          * will continue to be written 
          * note that some modes require \$RESULT passed in order to access a variable, whereas
most just need $ */
         protected List<String> buildRunScriptCommand() {
-            // TODO 
             String touchCmd = String.format("touch %s %s %s %s", stdoutPath, stderrPath,
exitStatusPath, pidPath);
             String cmd = String.format("( %s > %s 2> %s < /dev/null ; echo $? >
%s ) & disown", scriptPath, stdoutPath, stderrPath, exitStatusPath);
             MutableList.Builder<String> cmds = MutableList.<String>builder()

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/63483f8e/core/src/main/java/brooklyn/util/internal/ssh/sshj/SshjTool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/internal/ssh/sshj/SshjTool.java b/core/src/main/java/brooklyn/util/internal/ssh/sshj/SshjTool.java
index 154c433..e7ecd0c 100644
--- a/core/src/main/java/brooklyn/util/internal/ssh/sshj/SshjTool.java
+++ b/core/src/main/java/brooklyn/util/internal/ssh/sshj/SshjTool.java
@@ -319,6 +319,9 @@ public class SshjTool extends SshAbstractTool implements SshTool {
         if (Boolean.TRUE.equals(execAsync) && BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_SSH_ASYNC_EXEC))
{
             return execScriptAsyncAndPoll(props, commands, env);
         } else {
+            if (Boolean.TRUE.equals(execAsync)) {
+                if (LOG.isDebugEnabled()) LOG.debug("Ignoring ssh exec-async configuration,
because feature is disabled");
+            }
             return new ToolAbstractExecScript(props) {
                 public int run() {
                     String scriptContents = toScript(props, commands, env);
@@ -397,15 +400,18 @@ public class SshjTool extends SshAbstractTool implements SshTool {
                 stderrCount += (countingErr == null) ? 0 : countingErr.getCount();
                 
                 if (longPollResult == 0) {
+                    if (LOG.isDebugEnabled()) LOG.debug("Long-poll succeeded (exit status
0) on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                     return longPollResult; // success
                     
                 } else if (longPollResult == -1) {
                     // probably a connection failure; try again
+                    if (LOG.isDebugEnabled()) LOG.debug("Long-poll received exit status -1;
will retry on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                     return null;
                     
                 } else {
                     // want to double-check whether this is the exit-code from the async
process, or
                     // some unexpected failure in our long-poll command.
+                    if (LOG.isDebugEnabled()) LOG.debug("Long-poll received exit status "+longPollResult+";
retrieving actual status on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                     Integer result = retrieveStatusCommand();
                     if (result != null) {
                         return result;
@@ -434,14 +440,17 @@ public class SshjTool extends SshAbstractTool implements SshTool {
                     String statusOutStr = new String(statusOut.toByteArray()).trim();
                     if (Strings.isEmpty(statusOutStr)) {
                         // suggests not yet completed; will retry with long-poll
+                        if (LOG.isDebugEnabled()) LOG.debug("Long-poll retrieved status directly;
command successful but no result available on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                         return null;
                     } else {
+                        if (LOG.isDebugEnabled()) LOG.debug("Long-poll retrieved status directly;
returning '"+statusOutStr+"' on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                         int result = Integer.parseInt(statusOutStr);
                         return result;
                     }
 
                 } else if (statusResult == -1) {
                     // probably a connection failure; try again with long-poll
+                    if (LOG.isDebugEnabled()) LOG.debug("Long-poll retrieving status directly
received exit status -1; will retry on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                     return null;
                     
                 } else {
@@ -454,6 +463,7 @@ public class SshjTool extends SshAbstractTool implements SshTool {
                         err.write(statusErr.toByteArray());
                     }
                     
+                    if (LOG.isDebugEnabled()) LOG.debug("Long-poll retrieving status failed;
returning "+statusResult+" on "+SshjTool.this.toString()+" (for "+getSummary()+")");
                     return statusResult;
                 }
             }


Mime
View raw message