java.lang.Object
com.scivicslab.pojoactor.core.ActorRef<NodeInterpreter>
com.scivicslab.turingworkflow.workflow.IIActorRef<NodeInterpreter>
com.scivicslab.turingworkflow.plugins.ssh.NodeActor
All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName, AutoCloseable

public class NodeActor extends com.scivicslab.turingworkflow.workflow.IIActorRef<NodeInterpreter>
Interpreter-interfaced actor reference for 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 code
  • readYaml - Reads a YAML workflow definition from a file path
  • readJson - Reads a JSON workflow definition from a file path
  • readXml - Reads an XML workflow definition from a file path
  • reset - Resets the interpreter state

Infrastructure actions (Node-specific):

  • executeCommand - Executes a command and reports to accumulator (default)
  • executeCommandQuiet - Executes a command without reporting
  • executeSudoCommand - 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

    Constructors
    Constructor
    Description
    NodeActor(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 Type
    Method
    Description
    com.scivicslab.pojoactor.core.ActionResult
    apply(String args)
    Applies a JSON patch or transformation to the interpreter's JSON state.
    com.scivicslab.pojoactor.core.ActionResult
    Builds changed Docusaurus documents using yarn install and yarn build.
    com.scivicslab.pojoactor.core.ActionResult
    call(String args)
    Calls (loads and prepares) a sub-workflow from a file.
    com.scivicslab.pojoactor.core.ActionResult
    Clones documents that were detected as changed from their git repositories.
    com.scivicslab.pojoactor.core.ActionResult
    Deploys changed document builds to the public_html directory.
    com.scivicslab.pojoactor.core.ActionResult
    Detects which documents have changed by comparing local and remote git state.
    com.scivicslab.pojoactor.core.ActionResult
    A no-op action that always succeeds, returning the first argument as the result.
    com.scivicslab.pojoactor.core.ActionResult
    Executes the loaded workflow code.
    com.scivicslab.pojoactor.core.ActionResult
    Executes a command on the remote node and reports output to the accumulator.
    com.scivicslab.pojoactor.core.ActionResult
    Executes a command on the remote node without reporting to the accumulator.
    com.scivicslab.pojoactor.core.ActionResult
    Executes a command with sudo privileges and reports output to the accumulator.
    com.scivicslab.pojoactor.core.ActionResult
    Executes a command with sudo privileges without reporting to the accumulator.
    com.scivicslab.pojoactor.core.ActionResult
    print(String args)
    Prints a text message to standard output.
    com.scivicslab.pojoactor.core.ActionResult
    Outputs JSON State at the given path in pretty JSON format via outputMultiplexer.
    com.scivicslab.pojoactor.core.ActionResult
    Outputs JSON State at the given path in YAML format via outputMultiplexer.
    com.scivicslab.pojoactor.core.ActionResult
    Reads a JSON workflow definition from a file path.
    com.scivicslab.pojoactor.core.ActionResult
    Reads an XML workflow definition from a file path.
    com.scivicslab.pojoactor.core.ActionResult
    Reads a YAML workflow definition from a file path.
    com.scivicslab.pojoactor.core.ActionResult
    reset(String args)
    Resets the interpreter state, clearing the loaded workflow code and current state.
    com.scivicslab.pojoactor.core.ActionResult
    Runs the loaded workflow until it reaches an end state or exceeds the iteration limit.
    com.scivicslab.pojoactor.core.ActionResult
    Loads and runs a workflow file to completion in a single action.
    com.scivicslab.pojoactor.core.ActionResult
    sleep(String args)
    Pauses execution for the specified number of milliseconds.

    Methods inherited from class com.scivicslab.turingworkflow.workflow.IIActorRef

    callByActionName, hasAnnotatedAction, invokeAnnotatedAction, parseFirstArgument

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NodeActor

      public NodeActor(String actorName, NodeInterpreter object)
      Constructs a new NodeActor with the specified actor name and node interpreter object.
      Parameters:
      actorName - the name of this actor
      object - the NodeInterpreter instance 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 actor
      object - the NodeInterpreter instance managed by this actor reference
      system - the actor system managing this actor
  • Method Details

    • execCode

      public com.scivicslab.pojoactor.core.ActionResult execCode(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult readYaml(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult readJson(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult readXml(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult reset(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult runUntilEnd(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult call(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult runWorkflow(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult apply(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult executeCommand(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult executeCommandQuiet(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult executeSudoCommand(String args)
      Executes a command with sudo privileges and reports output to the accumulator.

      Requires the SUDO_PASSWORD environment 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

      public com.scivicslab.pojoactor.core.ActionResult executeSudoCommandQuiet(String args)
      Executes a command with sudo privileges without reporting to the accumulator.

      Requires the SUDO_PASSWORD environment variable to be set. Unlike executeSudoCommand, 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

      public com.scivicslab.pojoactor.core.ActionResult sleep(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult print(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult doNothing(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult detectDocumentChanges(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult cloneChangedDocuments(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult buildChangedDocuments(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult deployChangedDocuments(String args)
      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 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 deployed
    • printJson

      public com.scivicslab.pojoactor.core.ActionResult printJson(String args)
      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

      public com.scivicslab.pojoactor.core.ActionResult printYaml(String args)
      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