Class NodeGroupActor
java.lang.Object
com.scivicslab.pojoactor.core.ActorRef<NodeGroupInterpreter>
com.scivicslab.turingworkflow.workflow.IIActorRef<NodeGroupInterpreter>
com.scivicslab.turingworkflow.plugins.inventory.NodeGroupActor
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName,AutoCloseable
public class NodeGroupActor
extends com.scivicslab.turingworkflow.workflow.IIActorRef<NodeGroupInterpreter>
Interpreter-interfaced actor reference for
NodeGroupInterpreter instances.
This class provides a concrete implementation of IIActorRef
specifically for NodeGroupInterpreter objects. It manages groups of infrastructure
nodes and can apply actions to all nodes in a group using wildcard patterns.
NodeGroupInterpreter extends Interpreter, so this class can execute main workflows that orchestrate multiple nodes.
Supported actions:
Workflow actions (from Interpreter):
runWorkflow- Loads and runs a workflow filereadYaml- Reads a YAML workflow definitionrunUntilEnd- Executes the workflow until completion
NodeGroup actions:
hasInventory- Returns true if inventory is loaded (for conditional branching)createNodeActors- Creates child actors for all nodes in a specified groupapply- Applies an action to child actors matching a wildcard patternhasAccumulator- Returns true if accumulator exists (for idempotent workflows)createAccumulator- Creates an accumulator for result collectiongetAccumulatorSummary- Gets the collected resultsgetSessionId- Gets the current session ID for log queries
Node Actor Hierarchy:
When createNodeActors is called, it creates a parent-child relationship:
NodeGroup (parent) +- node-web-01 (child NodeActor) +- node-web-02 (child NodeActor) +- node-db-01 (child NodeActor)
Example YAML Workflow:
name: setup-nodegroup
steps:
# Step 1: Create node actors
- states: [0, 1]
actions:
- actor: nodeGroup
method: createNodeActors
arguments: ["web-servers"]
# Step 2: Run workflow on all nodes (load and execute in one step)
- states: [1, end]
actions:
- actor: nodeGroup
method: apply
arguments: ['{"actor": "node-*", "method": "runWorkflow", "arguments": ["deploy.yaml"]}']
- Since:
- 1.0
- Author:
- devteam@scivicslab.com
-
Field Summary
Fields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
ConstructorsConstructorDescriptionNodeGroupActor(String actorName, NodeGroupInterpreter object) Constructs a new NodeGroupActor with the specified actor name and nodeGroupInterpreter object.NodeGroupActor(String actorName, NodeGroupInterpreter object, com.scivicslab.turingworkflow.workflow.IIActorSystem system) Constructs a new NodeGroupActor with the specified actor name, nodeGroupInterpreter object, and actor system. -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.core.ActionResultapplyAction(String args) Applies an action to child actors matching a wildcard pattern.com.scivicslab.pojoactor.core.ActionResultcreateAccumulator(String args) Creates an accumulator (no-op, kept for backward compatibility).com.scivicslab.pojoactor.core.ActionResultcreateNodeActorsAction(String args) Creates child actors for all nodes in a specified group.com.scivicslab.pojoactor.core.ActionResultDoes nothing, returns the argument as result.com.scivicslab.pojoactor.core.ActionResultExecutes the current step code.com.scivicslab.pojoactor.core.ActionResultExecutes a command on all child node actors.com.scivicslab.pojoactor.core.ActionResultGets the summary from the output multiplexer.com.scivicslab.pojoactor.core.ActionResultgetSessionId(String args) Gets the current session ID.com.scivicslab.pojoactor.core.ActionResultgetWorkflowPath(String args) Gets the current workflow file path.com.scivicslab.pojoactor.core.ActionResulthasAccumulator(String args) Checks if accumulator exists.com.scivicslab.pojoactor.core.ActionResulthasInventory(String args) Checks if inventory is loaded.com.scivicslab.pojoactor.core.ActionResultOutputs JSON State at the given path in pretty JSON format via outputMultiplexer.com.scivicslab.pojoactor.core.ActionResultPrints a summary of the current session's verification results.com.scivicslab.pojoactor.core.ActionResultOutputs JSON State at the given path in YAML format via outputMultiplexer.com.scivicslab.pojoactor.core.ActionResultReads a YAML workflow definition.com.scivicslab.pojoactor.core.ActionResultrunUntilEnd(String args) Runs the workflow until completion.com.scivicslab.pojoactor.core.ActionResultrunWorkflow(String args) Loads and runs a workflow file.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
-
NodeGroupActor
Constructs a new NodeGroupActor with the specified actor name and nodeGroupInterpreter object.- Parameters:
actorName- the name of this actorobject- theNodeGroupInterpreterinstance managed by this actor reference
-
NodeGroupActor
public NodeGroupActor(String actorName, NodeGroupInterpreter object, com.scivicslab.turingworkflow.workflow.IIActorSystem system) Constructs a new NodeGroupActor with the specified actor name, nodeGroupInterpreter object, and actor system.- Parameters:
actorName- the name of this actorobject- theNodeGroupInterpreterinstance managed by this actor referencesystem- the actor system managing this actor
-
-
Method Details
-
execCode
Executes the current step code.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult indicating success or failure
-
runUntilEnd
Runs the workflow until completion.- Parameters:
args- the argument string (optional max iterations)- Returns:
- ActionResult indicating success or failure
-
runWorkflow
Loads and runs a workflow file.- Parameters:
args- JSON array with workflow file path and optional max iterations- Returns:
- ActionResult indicating success or failure
-
readYaml
Reads a YAML workflow definition.- Parameters:
args- JSON array with file path- Returns:
- ActionResult indicating success or failure
-
hasInventory
Checks if inventory is loaded.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with true if inventory exists
-
createNodeActorsAction
Creates child actors for all nodes in a specified group.- Parameters:
args- JSON array with group name- Returns:
- ActionResult indicating success or failure
-
applyAction
Applies an action to child actors matching a wildcard pattern.- Parameters:
args- JSON object defining the action to apply- Returns:
- ActionResult indicating success or failure
-
executeCommandOnAllNodesAction
Executes a command on all child node actors.- Parameters:
args- JSON array with command- Returns:
- ActionResult with execution results
-
hasAccumulator
Checks if accumulator exists.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with true if accumulator exists
-
createAccumulator
Creates an accumulator (no-op, kept for backward compatibility).- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with success
-
getAccumulatorSummaryAction
Gets the summary from the output multiplexer.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with the summary
-
printSessionSummaryAction
Prints a summary of the current session's verification results.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with the summary
-
getSessionId
Gets the current session ID.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with the session ID
-
getWorkflowPath
Gets the current workflow file path.- Parameters:
args- the argument string (not used)- Returns:
- ActionResult with the workflow path
-
doNothing
Does nothing, returns the argument as result.- Parameters:
args- the argument string- Returns:
- ActionResult with the argument
-
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
-