Class ActorHelper

java.lang.Object
com.scivicslab.turingworkflow.plugins.ssh.ActorHelper

public final class ActorHelper extends Object
Shared helper methods used by both NodeActor and NodeGroupActor.

Eliminates code duplication between the two actor classes for common operations like multiplexer output, argument parsing, and error handling.

Since:
2.10.0
Author:
devteam@scivicslab.com
  • Method Details

    • sendToMultiplexer

      public static void sendToMultiplexer(com.scivicslab.turingworkflow.workflow.IIActorSystem system, String sourceName, String formatted)
      Sends formatted output to the outputMultiplexer, line by line.
      Parameters:
      system - the actor system
      sourceName - the source actor name
      formatted - the formatted output text
    • parseMaxIterations

      public static int parseMaxIterations(String arg, int defaultValue)
      Parses a max iterations value from a JSON array argument.
      Parameters:
      arg - the JSON array string (e.g., "[10]")
      defaultValue - the default value if parsing fails
      Returns:
      the parsed value or defaultValue
    • getFirst

      public static String getFirst(String args)
      Extracts the first element from a JSON array string. Returns empty string on failure (lenient).
      Parameters:
      args - the JSON array string
      Returns:
      the first element, or empty string
    • extractCommandFromArgs

      public static String extractCommandFromArgs(String arg)
      Extracts a command string from JSON array arguments. Throws on failure (strict).
      Parameters:
      arg - the JSON array string
      Returns:
      the extracted command string
      Throws:
      IllegalArgumentException - if the argument is invalid or empty
    • combineOutput

      public static String combineOutput(Node.CommandResult result)
      Combines stdout and stderr from a CommandResult into a single string.
      Parameters:
      result - the command result
      Returns:
      combined output string
    • extractRootCauseMessage

      public static String extractRootCauseMessage(ExecutionException e)
      Extracts a meaningful error message from an ExecutionException.
      Parameters:
      e - the execution exception
      Returns:
      the root cause message