Class NodeIIAR
java.lang.Object
com.scivicslab.pojoactor.core.ActorRef<NodeInterpreter>
com.scivicslab.pojoactor.workflow.IIActorRef<NodeInterpreter>
com.scivicslab.actoriac.NodeIIAR
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName, AutoCloseable
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 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
Example YAML Workflow:
name: deploy-application
steps:
- states: ["0", "1"]
actions:
- actor: this
method: executeCommand
arguments:
- "apt-get update"
- states: ["1", "end"]
actions:
- actor: this
method: executeCommand
arguments:
- "ls -la"
- Author:
- devteam@scivics-lab.com
-
Field Summary
FieldsFields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
ConstructorsConstructorDescriptionNodeIIAR(String actorName, NodeInterpreter object) Constructs a new NodeIIAR with the specified actor name and node interpreter object.NodeIIAR(String actorName, NodeInterpreter object, com.scivicslab.pojoactor.workflow.IIActorSystem system) Constructs a new NodeIIAR with the specified actor name, node interpreter object, and actor system. -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.core.ActionResultcallByActionName(String actionName, String arg) Invokes an action on the node by name with the given arguments.private StringcombineOutput(Node.CommandResult result) Combines stdout and stderr into a single output string.private com.scivicslab.pojoactor.core.ActionResultprivate com.scivicslab.pojoactor.core.ActionResultprivate com.scivicslab.pojoactor.core.ActionResultprivate com.scivicslab.pojoactor.core.ActionResultprivate StringExtracts a command string from JSON array arguments.private StringExtracts the root cause message from an ExecutionException.private com.scivicslab.pojoactor.core.ActionResulthandleCommandAction(String actionName, String arg) Handles SSH command execution actions.private com.scivicslab.pojoactor.core.ActionResulthandleDocumentAction(String actionName, String arg) Handles document workflow actions (detect, clone, build, deploy).private com.scivicslab.pojoactor.core.ActionResulthandleReadJson(String arg) private com.scivicslab.pojoactor.core.ActionResulthandleReadXml(String arg) private com.scivicslab.pojoactor.core.ActionResulthandleReadYaml(String arg) private com.scivicslab.pojoactor.core.ActionResulthandleUtilityAction(String actionName, String arg) Handles utility actions (sleep, print, doNothing).private com.scivicslab.pojoactor.core.ActionResulthandleWorkflowAction(String actionName, String arg) Handles workflow-related actions (from Interpreter).private intparseMaxIterations(String arg, int defaultValue) private voidReports command result to the accumulator actor if available.Methods inherited from class com.scivicslab.pojoactor.core.ActorRef
ask, ask, askNow, clearJsonState, clearPendingMessages, close, createChild, getJsonBoolean, getJsonInt, getJsonString, getJsonString, getName, getNamesOfChildren, getParentName, hasJson, hasJsonState, initLogger, isAlive, json, putJson, setParentName, system, tell, tell, tellNow
-
Field Details
-
logger
-
-
Constructor Details
-
NodeIIAR
Constructs a new NodeIIAR with the specified actor name and node interpreter object.- Parameters:
actorName- the name of this actorobject- theNodeInterpreterinstance managed by this actor reference
-
NodeIIAR
public NodeIIAR(String actorName, NodeInterpreter object, com.scivicslab.pojoactor.workflow.IIActorSystem system) Constructs a new NodeIIAR 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
-
callByActionName
Invokes an action on the node by name with the given arguments.This method dispatches to specialized handler methods based on the action type:
- Workflow actions:
handleWorkflowAction(String, String) - Command execution actions:
handleCommandAction(String, String) - Utility actions:
handleUtilityAction(String, String)
- Specified by:
callByActionNamein interfacecom.scivicslab.pojoactor.core.CallableByActionName- Specified by:
callByActionNamein classcom.scivicslab.pojoactor.workflow.IIActorRef<NodeInterpreter>- Parameters:
actionName- the name of the action to executearg- the argument string (file path for read operations, JSON array for commands)- Returns:
- an
ActionResultindicating success or failure with a message
- Workflow actions:
-
handleWorkflowAction
private com.scivicslab.pojoactor.core.ActionResult handleWorkflowAction(String actionName, String arg) throws InterruptedException, ExecutionException Handles workflow-related actions (from Interpreter).- Parameters:
actionName- the action namearg- the argument string- Returns:
- ActionResult if handled, null if not a workflow action
- Throws:
InterruptedExceptionExecutionException
-
handleCommandAction
private com.scivicslab.pojoactor.core.ActionResult handleCommandAction(String actionName, String arg) throws InterruptedException, ExecutionException Handles SSH command execution actions.- Parameters:
actionName- the action namearg- the argument string- Returns:
- ActionResult if handled, null if not a command action
- Throws:
InterruptedExceptionExecutionException
-
handleUtilityAction
private com.scivicslab.pojoactor.core.ActionResult handleUtilityAction(String actionName, String arg) Handles utility actions (sleep, print, doNothing).- Parameters:
actionName- the action namearg- the argument string- Returns:
- ActionResult if handled, null if not a utility action
-
handleDocumentAction
private com.scivicslab.pojoactor.core.ActionResult handleDocumentAction(String actionName, String arg) throws InterruptedException, ExecutionException Handles document workflow actions (detect, clone, build, deploy).- Parameters:
actionName- the action namearg- the argument string- Returns:
- ActionResult if handled, null if not a document action
- Throws:
InterruptedExceptionExecutionException
-
handleReadYaml
private com.scivicslab.pojoactor.core.ActionResult handleReadYaml(String arg) throws InterruptedException, ExecutionException -
handleReadJson
private com.scivicslab.pojoactor.core.ActionResult handleReadJson(String arg) throws InterruptedException, ExecutionException -
handleReadXml
private com.scivicslab.pojoactor.core.ActionResult handleReadXml(String arg) throws InterruptedException, ExecutionException -
parseMaxIterations
-
executeCommandQuiet
private com.scivicslab.pojoactor.core.ActionResult executeCommandQuiet(String arg) throws InterruptedException, ExecutionException -
executeSudoCommandQuiet
private com.scivicslab.pojoactor.core.ActionResult executeSudoCommandQuiet(String arg) throws InterruptedException, ExecutionException -
executeCommandWithReport
private com.scivicslab.pojoactor.core.ActionResult executeCommandWithReport(String arg) throws InterruptedException, ExecutionException -
executeSudoCommandWithReport
private com.scivicslab.pojoactor.core.ActionResult executeSudoCommandWithReport(String arg) throws InterruptedException, ExecutionException -
reportToAccumulator
Reports command result to the accumulator actor if available. -
combineOutput
Combines stdout and stderr into a single output string. -
extractRootCauseMessage
Extracts the root cause message from an ExecutionException. -
extractCommandFromArgs
Extracts a command string from JSON array arguments.Expects arguments in the format:
["command string"]- Parameters:
arg- the JSON array argument string- Returns:
- the extracted command string
- Throws:
IllegalArgumentException- if the argument format is invalid
-