Class NodeActor
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName,AutoCloseable
NodeInterpreter instances.
This class provides a concrete implementation of IIActorRef
specifically for NodeInterpreter objects. It handles action invocations
by name, supporting both workflow execution actions (inherited from Interpreter)
and infrastructure actions (SSH command execution).
Supported actions:
Workflow actions (from Interpreter):
execCode- Executes the loaded workflow codereadYaml- Reads a YAML workflow definition from a file pathreadJson- Reads a JSON workflow definition from a file pathreadXml- Reads an XML workflow definition from a file pathreset- Resets the interpreter state
Infrastructure actions (Node-specific):
executeCommand- Executes a command and reports to accumulator (default)executeCommandQuiet- Executes a command without reportingexecuteSudoCommand- Executes sudo command and reports to accumulator (default)executeSudoCommandQuiet- Executes sudo command without reporting
- Since:
- 2.0.0
- Author:
- devteam@scivicslab.com
-
Field Summary
Fields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
ConstructorsConstructorDescriptionNodeActor(String actorName, NodeInterpreter object) Constructs a new NodeActor with the specified actor name and node interpreter object.NodeActor(String actorName, NodeInterpreter object, com.scivicslab.turingworkflow.workflow.IIActorSystem system) Constructs a new NodeActor with the specified actor name, node interpreter object, and actor system. -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.core.ActionResultApplies a JSON patch or transformation to the interpreter's JSON state.com.scivicslab.pojoactor.core.ActionResultbuildChangedDocuments(String args) Builds changed Docusaurus documents using yarn install and yarn build.com.scivicslab.pojoactor.core.ActionResultCalls (loads and prepares) a sub-workflow from a file.com.scivicslab.pojoactor.core.ActionResultcloneChangedDocuments(String args) Clones documents that were detected as changed from their git repositories.com.scivicslab.pojoactor.core.ActionResultdeployChangedDocuments(String args) Deploys changed document builds to the public_html directory.com.scivicslab.pojoactor.core.ActionResultdetectDocumentChanges(String args) Detects which documents have changed by comparing local and remote git state.com.scivicslab.pojoactor.core.ActionResultA no-op action that always succeeds, returning the first argument as the result.com.scivicslab.pojoactor.core.ActionResultExecutes the loaded workflow code.com.scivicslab.pojoactor.core.ActionResultexecuteCommand(String args) Executes a command on the remote node and reports output to the accumulator.com.scivicslab.pojoactor.core.ActionResultexecuteCommandQuiet(String args) Executes a command on the remote node without reporting to the accumulator.com.scivicslab.pojoactor.core.ActionResultexecuteSudoCommand(String args) Executes a command with sudo privileges and reports output to the accumulator.com.scivicslab.pojoactor.core.ActionResultExecutes a command with sudo privileges without reporting to the accumulator.com.scivicslab.pojoactor.core.ActionResultPrints a text message to standard output.com.scivicslab.pojoactor.core.ActionResultOutputs JSON State at the given path in pretty JSON format via outputMultiplexer.com.scivicslab.pojoactor.core.ActionResultOutputs JSON State at the given path in YAML format via outputMultiplexer.com.scivicslab.pojoactor.core.ActionResultReads a JSON workflow definition from a file path.com.scivicslab.pojoactor.core.ActionResultReads an XML workflow definition from a file path.com.scivicslab.pojoactor.core.ActionResultReads a YAML workflow definition from a file path.com.scivicslab.pojoactor.core.ActionResultResets the interpreter state, clearing the loaded workflow code and current state.com.scivicslab.pojoactor.core.ActionResultrunUntilEnd(String args) Runs the loaded workflow until it reaches an end state or exceeds the iteration limit.com.scivicslab.pojoactor.core.ActionResultrunWorkflow(String args) Loads and runs a workflow file to completion in a single action.com.scivicslab.pojoactor.core.ActionResultPauses execution for the specified number of milliseconds.Methods inherited from class com.scivicslab.turingworkflow.workflow.IIActorRef
callByActionName, hasAnnotatedAction, invokeAnnotatedAction, parseFirstArgumentMethods inherited from class com.scivicslab.pojoactor.core.ActorRef
ask, ask, askNow, clearJsonState, clearPendingMessages, close, createChild, expandVariables, getJsonBoolean, getJsonInt, getJsonString, getJsonString, getLastResult, getName, getNamesOfChildren, getParentName, hasJson, hasJsonState, initLogger, isAlive, json, putJson, setLastResult, setParentName, system, tell, tell, tellNow, toStringOfJson, toStringOfYaml
-
Constructor Details
-
NodeActor
Constructs a new NodeActor with the specified actor name and node interpreter object.- Parameters:
actorName- the name of this actorobject- theNodeInterpreterinstance managed by this actor reference
-
NodeActor
public NodeActor(String actorName, NodeInterpreter object, com.scivicslab.turingworkflow.workflow.IIActorSystem system) Constructs a new NodeActor with the specified actor name, node interpreter object, and actor system.- Parameters:
actorName- the name of this actorobject- theNodeInterpreterinstance managed by this actor referencesystem- the actor system managing this actor
-
-
Method Details
-
execCode
Executes the loaded workflow code.JSON args format: ignored (no arguments required).
- Parameters:
args- JSON array string (unused)- Returns:
- ActionResult with the execution outcome
-
readYaml
Reads a YAML workflow definition from a file path.If an overlay directory is configured on the interpreter, the YAML is loaded with overlay variable substitution applied.
JSON args format:
["path/to/workflow.yaml"]- Parameters:
args- JSON array containing the file path as the first element- Returns:
- ActionResult indicating success or failure with error details
-
readJson
Reads a JSON workflow definition from a file path.JSON args format:
["path/to/workflow.json"]- Parameters:
args- JSON array containing the file path as the first element- Returns:
- ActionResult indicating success or failure with error details
-
readXml
Reads an XML workflow definition from a file path.JSON args format:
["path/to/workflow.xml"]- Parameters:
args- JSON array containing the file path as the first element- Returns:
- ActionResult indicating success or failure with error details
-
reset
Resets the interpreter state, clearing the loaded workflow code and current state.JSON args format: ignored (no arguments required).
- Parameters:
args- JSON array string (unused)- Returns:
- ActionResult indicating success or failure
-
runUntilEnd
Runs the loaded workflow until it reaches an end state or exceeds the iteration limit.JSON args format:
[maxIterations]where maxIterations is optional (defaults to 10000).- Parameters:
args- JSON array optionally containing the max iterations as the first element- Returns:
- ActionResult with the workflow execution outcome
-
call
Calls (loads and prepares) a sub-workflow from a file.JSON args format:
["path/to/sub-workflow.yaml"]- Parameters:
args- JSON array containing the workflow file path as the first element- Returns:
- ActionResult with the call outcome
-
runWorkflow
Loads and runs a workflow file to completion in a single action.JSON args format:
["path/to/workflow.yaml"]or["path/to/workflow.yaml", maxIterations].- Parameters:
args- JSON array with workflow file path and optional max iterations- Returns:
- ActionResult with the workflow execution outcome
-
apply
Applies a JSON patch or transformation to the interpreter's JSON state.JSON args format: a JSON string representing the transformation to apply.
- Parameters:
args- the JSON transformation arguments- Returns:
- ActionResult with the apply outcome
-
executeCommand
Executes a command on the remote node and reports output to the accumulator.Output is streamed in real-time to the outputMultiplexer if available. After execution, the full result is reported to the accumulator.
JSON args format:
["command-to-execute"]- Parameters:
args- JSON array containing the command as the first element- Returns:
- ActionResult with success status and combined stdout/stderr
-
executeCommandQuiet
Executes a command on the remote node without reporting to the accumulator.Unlike
executeCommand, this action does not stream output or report results to the outputMultiplexer.JSON args format:
["command-to-execute"]- Parameters:
args- JSON array containing the command as the first element- Returns:
- ActionResult with exit code, stdout, and stderr in the result string
-
executeSudoCommand
Executes a command with sudo privileges and reports output to the accumulator.Requires the
SUDO_PASSWORDenvironment variable to be set. Output is streamed in real-time to the outputMultiplexer if available.JSON args format:
["command-to-execute"]- Parameters:
args- JSON array containing the command as the first element- Returns:
- ActionResult with success status and combined stdout/stderr
-
executeSudoCommandQuiet
Executes a command with sudo privileges without reporting to the accumulator.Requires the
SUDO_PASSWORDenvironment variable to be set. UnlikeexecuteSudoCommand, this action does not stream output.JSON args format:
["command-to-execute"]- Parameters:
args- JSON array containing the command as the first element- Returns:
- ActionResult with exit code, stdout, and stderr in the result string
-
sleep
Pauses execution for the specified number of milliseconds.JSON args format:
["milliseconds"](e.g.,["5000"]for 5 seconds).- Parameters:
args- JSON array containing the sleep duration in milliseconds- Returns:
- ActionResult indicating success or failure if interrupted
-
print
Prints a text message to standard output.JSON args format:
["text to print"]- Parameters:
args- JSON array containing the text to print as the first element- Returns:
- ActionResult with the printed text
-
doNothing
A no-op action that always succeeds, returning the first argument as the result.Useful as a placeholder or pass-through in workflow definitions.
JSON args format:
["optional message"]- Parameters:
args- JSON array containing an optional message- Returns:
- ActionResult with success and the first argument as the result
-
detectDocumentChanges
Detects which documents have changed by comparing local and remote git state.JSON args format:
["path/to/doc-list.txt"]- Parameters:
args- JSON array containing the document list file path- Returns:
- ActionResult with the number of changed documents detected
-
cloneChangedDocuments
Clones documents that were detected as changed from their git repositories.Only processes documents previously identified by
detectDocumentChanges. Performs a fresh clone (removes existing directory first) to avoid conflicts.JSON args format:
["path/to/doc-list.txt"]- Parameters:
args- JSON array containing the document list file path- Returns:
- ActionResult with the number of documents cloned
-
buildChangedDocuments
Builds changed Docusaurus documents using yarn install and yarn build.Only processes documents previously identified by
detectDocumentChanges.JSON args format:
["path/to/doc-list.txt"]- Parameters:
args- JSON array containing the document list file path- Returns:
- ActionResult with the number of documents built
-
deployChangedDocuments
Deploys changed document builds to the public_html directory.Copies the build output of each changed document to
~/public_html/. Only processes documents previously identified bydetectDocumentChanges.JSON args format:
["path/to/doc-list.txt"]- Parameters:
args- JSON array containing the document list file path- Returns:
- ActionResult with the number of documents deployed
-
printJson
Outputs JSON State at the given path in pretty JSON format via outputMultiplexer.- Parameters:
args- the path to output (from JSON array)- Returns:
- ActionResult with the formatted JSON
-
printYaml
Outputs JSON State at the given path in YAML format via outputMultiplexer.- Parameters:
args- the path to output (from JSON array)- Returns:
- ActionResult with the formatted YAML
-