Class NodeGroupInterpreter
This class extends Interpreter to provide workflow execution
capabilities while delegating node group operations to a wrapped NodeGroup instance.
This follows the same three-level architecture as NodeInterpreter:
- Level 1 (POJO):
NodeGroup- pure POJO with inventory management - Level 2 (Actor): ActorRef<NodeGroup> - actor wrapper for concurrent execution
- Level 3 (Workflow): NodeGroupInterpreter - workflow capabilities + IIActorRef wrapper
Design principle: NodeGroup remains a pure POJO, independent of ActorSystem. NodeGroupInterpreter wraps NodeGroup to add workflow capabilities without modifying the NodeGroup class.
- Author:
- devteam@scivicslab.com
-
Nested Class Summary
Nested classes/interfaces inherited from class com.scivicslab.pojoactor.workflow.Interpreter
com.scivicslab.pojoactor.workflow.Interpreter.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IaCStreamingAccumulatorIaCStreamingAccumulator for displaying workflow steps with cowsay ASCII art.private ExecutorServiceDedicated executor service for DB writes.private DistributedLogStoreDirect reference to the log store for synchronous read operations.private com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> Actor reference for the distributed log store.private final NodeGroupThe wrapped NodeGroup POJO that handles inventory and node creation.private StringThe overlay directory path for YAML overlay feature.private longSession ID for the current workflow execution.private booleanVerbose output flag.Fields inherited from class com.scivicslab.pojoactor.workflow.Interpreter
code, currentState, currentTransitionIndex, logger, selfActorRef, system, workflowBaseDir -
Constructor Summary
ConstructorsConstructorDescriptionNodeGroupInterpreter(NodeGroup nodeGroup, com.scivicslab.pojoactor.workflow.IIActorSystem system) Constructs a NodeGroupInterpreter that wraps the specified NodeGroup. -
Method Summary
Modifier and TypeMethodDescriptionCreates a single Node for localhost execution.createNodesForGroup(String groupName) Creates Node objects for all hosts in the specified group.Gets the IaCStreamingAccumulator for displaying workflow steps.Gets the DB executor service.Gets the inventory object.Gets the log store for direct read operations.com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> Gets the log store actor for async write operations.Gets the wrapped NodeGroup instance.Gets the overlay directory path.longGets the session ID.private StringgetTransitionNote(com.scivicslab.pojoactor.workflow.Transition transition) transitionのnoteを取得する。60文字または最初の行までに制限。 noteがない場合は空文字列を返す。booleanChecks if verbose mode is enabled.protected voidonEnterTransition(com.scivicslab.pojoactor.workflow.Transition transition) Hook called when entering a transition during workflow execution.protected voidonExitTransition(com.scivicslab.pojoactor.workflow.Transition transition, boolean success, com.scivicslab.pojoactor.core.ActionResult result) Hook called after a transition completes (success or failure).voidsetAccumulator(IaCStreamingAccumulator accumulator) Sets the IaCStreamingAccumulator for displaying workflow steps.voidsetLogStore(DistributedLogStore logStore, com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> logStoreActor, ExecutorService dbExecutor, long sessionId) Sets the distributed log store for structured logging.voidsetOverlayDir(String overlayDir) Sets the overlay directory for YAML overlay feature.voidsetVerbose(boolean verbose) Sets verbose mode for detailed output.Methods inherited from class com.scivicslab.pojoactor.workflow.Interpreter
action, addToAccumulator, addToAccumulator, apply, call, execCode, findMatchingActors, findMatchingChildActors, findNextMatchingTransition, generateChildName, getCode, getCurrentState, getCurrentTransitionIndex, getToState, getWorkflowBaseDir, hasCodeLoaded, loadWorkflowFromClasspath, matchesCurrentState, matchesStatePattern, readJson, readXml, readYaml, readYaml, readYaml, removeChildActor, reset, runUntilEnd, runUntilEnd, runWorkflow, runWorkflow, setCode, setSelfActorRef, setWorkflowBaseDir, transitionTo
-
Field Details
-
nodeGroup
-
overlayDir
The overlay directory path for YAML overlay feature. When set, workflows are loaded with overlay applied. -
verbose
Verbose output flag. When true, displays full YAML for each transition instead of truncated version. -
accumulator
IaCStreamingAccumulator for displaying workflow steps with cowsay ASCII art. When set, workflow step transitions are displayed using this accumulator. -
logStoreActor
Actor reference for the distributed log store. Used to send log messages asynchronously to avoid blocking workflow execution. -
logStore
Direct reference to the log store for synchronous read operations. Reads don't need to go through the actor since they don't need serialization. -
dbExecutor
Dedicated executor service for DB writes. Should be a single-threaded pool to ensure serialized writes. -
sessionId
Session ID for the current workflow execution.
-
-
Constructor Details
-
NodeGroupInterpreter
public NodeGroupInterpreter(NodeGroup nodeGroup, com.scivicslab.pojoactor.workflow.IIActorSystem system) Constructs a NodeGroupInterpreter that wraps the specified NodeGroup.- Parameters:
nodeGroup- theNodeGroupinstance to wrapsystem- the actor system for workflow execution
-
-
Method Details
-
createNodesForGroup
Creates Node objects for all hosts in the specified group.Delegates to the wrapped
NodeGroup.createNodesForGroup(String)method.- Parameters:
groupName- the name of the group from the inventory file- Returns:
- the list of created Node objects
-
createLocalNode
Creates a single Node for localhost execution.Delegates to the wrapped
NodeGroup.createLocalNode()method.- Returns:
- a list containing a single localhost Node
-
getInventory
Gets the inventory object.- Returns:
- the loaded inventory, or null if not loaded
-
getNodeGroup
Gets the wrapped NodeGroup instance.This allows direct access to the underlying POJO when needed.
- Returns:
- the wrapped NodeGroup
-
setOverlayDir
Sets the overlay directory for YAML overlay feature.When an overlay directory is set, workflows will be loaded with overlay applied, allowing environment-specific configuration.
- Parameters:
overlayDir- the path to the overlay directory containing overlay-conf.yaml
-
getOverlayDir
Gets the overlay directory path.- Returns:
- the overlay directory path, or null if not set
-
setVerbose
Sets verbose mode for detailed output.When enabled, displays full YAML for each transition in cowsay output instead of the truncated version.
- Parameters:
verbose- true to enable verbose output
-
isVerbose
Checks if verbose mode is enabled.- Returns:
- true if verbose mode is enabled
-
setAccumulator
Sets the IaCStreamingAccumulator for displaying workflow steps.When set, workflow step transitions are displayed using cowsay ASCII art via this accumulator. The accumulator's cowfile setting determines which character is used.
- Parameters:
accumulator- the accumulator to use for cowsay display
-
getAccumulator
Gets the IaCStreamingAccumulator for displaying workflow steps.- Returns:
- the cowsay accumulator, or null if not set
-
setLogStore
public void setLogStore(DistributedLogStore logStore, com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> logStoreActor, ExecutorService dbExecutor, long sessionId) Sets the distributed log store for structured logging.Database writes are performed asynchronously via the logStore actor using the dedicated dbExecutor to avoid blocking workflow execution. Direct reads can use the logStore reference directly.
- Parameters:
logStore- the log store instance (for direct reads)logStoreActor- the actor reference for the log store (for async writes)dbExecutor- the dedicated executor service for DB writessessionId- the session ID for this execution
-
getLogStore
Gets the log store for direct read operations.- Returns:
- the log store, or null if not set
-
getLogStoreActor
Gets the log store actor for async write operations.- Returns:
- the log store actor, or null if not set
-
getDbExecutor
Gets the DB executor service.- Returns:
- the DB executor service, or null if not set
-
getSessionId
-
onEnterTransition
Hook called when entering a transition during workflow execution.Displays the workflow name and transition definition using cowsay. In normal mode, shows first 10 lines. In verbose mode, shows the full YAML after the cowsay output.
- Overrides:
onEnterTransitionin classcom.scivicslab.pojoactor.workflow.Interpreter- Parameters:
transition- the transition being entered
-
onExitTransition
protected void onExitTransition(com.scivicslab.pojoactor.workflow.Transition transition, boolean success, com.scivicslab.pojoactor.core.ActionResult result) Hook called after a transition completes (success or failure).Logs the transition result to the distributed log store for workflow execution reporting.
- Overrides:
onExitTransitionin classcom.scivicslab.pojoactor.workflow.Interpreter- Parameters:
transition- the transition that was attemptedsuccess- true if the transition succeeded, false if it failedresult- the ActionResult from executing the transition's actions
-
getTransitionNote
transitionのnoteを取得する。60文字または最初の行までに制限。 noteがない場合は空文字列を返す。
-