Class ActorHelper
java.lang.Object
com.scivicslab.turingworkflow.plugins.ssh.ActorHelper
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 Summary
Modifier and TypeMethodDescriptionstatic StringcombineOutput(Node.CommandResult result) Combines stdout and stderr from a CommandResult into a single string.static StringExtracts a command string from JSON array arguments.static StringExtracts a meaningful error message from an ExecutionException.static StringExtracts the first element from a JSON array string.static intparseMaxIterations(String arg, int defaultValue) Parses a max iterations value from a JSON array argument.static voidsendToMultiplexer(com.scivicslab.turingworkflow.workflow.IIActorSystem system, String sourceName, String formatted) Sends formatted output to the outputMultiplexer, line by line.
-
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 systemsourceName- the source actor nameformatted- the formatted output text
-
parseMaxIterations
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
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
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
Combines stdout and stderr from a CommandResult into a single string.- Parameters:
result- the command result- Returns:
- combined output string
-
extractRootCauseMessage
Extracts a meaningful error message from an ExecutionException.- Parameters:
e- the execution exception- Returns:
- the root cause message
-