Class NodeGroupInterpreter

java.lang.Object
com.scivicslab.turingworkflow.workflow.Interpreter
com.scivicslab.turingworkflow.plugins.inventory.NodeGroupInterpreter

public class NodeGroupInterpreter extends com.scivicslab.turingworkflow.workflow.Interpreter
Level 3 wrapper that adds workflow capabilities to a NodeGroup POJO.

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.

Since:
1.0
Author:
devteam@scivicslab.com
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.scivicslab.turingworkflow.workflow.Interpreter

    com.scivicslab.turingworkflow.workflow.Interpreter.ActionFailureListener, com.scivicslab.turingworkflow.workflow.Interpreter.BreakpointListener, com.scivicslab.turingworkflow.workflow.Interpreter.Builder
  • Field Summary

    Fields inherited from class com.scivicslab.turingworkflow.workflow.Interpreter

    code, currentState, currentTransitionIndex, logger, paused, selfActorRef, stopRequested, system, workflowBaseDir
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeGroupInterpreter(NodeGroup nodeGroup, com.scivicslab.turingworkflow.workflow.IIActorSystem system)
    Constructs a NodeGroupInterpreter that wraps the specified NodeGroup.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a single Node for localhost execution.
    Creates Node objects for all hosts in the specified group.
    Gets the WorkflowStreamingAccumulator 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.
    long
    Gets the session ID.
    boolean
    Checks if verbose mode is enabled.
    protected void
    onEnterTransition(com.scivicslab.turingworkflow.workflow.Transition transition)
    Hook called when entering a transition during workflow execution.
    protected void
    onExitTransition(com.scivicslab.turingworkflow.workflow.Transition transition, boolean success, com.scivicslab.pojoactor.core.ActionResult result)
    Hook called after a transition completes (success or failure).
    void
    Sets the WorkflowStreamingAccumulator for displaying workflow steps.
    void
    setLogStore(DistributedLogStore logStore, com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> logStoreActor, ExecutorService dbExecutor, long sessionId)
    Sets the distributed log store for structured logging.
    void
    setOverlayDir(String overlayDir)
    Sets the overlay directory for YAML overlay feature.
    void
    setVerbose(boolean verbose)
    Sets verbose mode for detailed output.

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

    action, addToAccumulator, addToAccumulator, apply, call, clearStop, execCode, findMatchingActors, findMatchingChildActors, findNextMatchingTransition, generateChildName, getCode, getCurrentState, getCurrentTransitionIndex, getToState, getWorkflowBaseDir, hasCodeLoaded, isPaused, isStopRequested, loadWorkflowFromClasspath, matchesCurrentState, matchesStatePattern, readJson, readXml, readYaml, readYaml, readYaml, removeChildActor, requestStop, reset, resume, runUntilEnd, runUntilEnd, runWorkflow, runWorkflow, setActionFailureListener, setBreakpointListener, setCode, setSelfActorRef, setWorkflowBaseDir, transitionTo

    Methods inherited from class java.lang.Object

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

    • NodeGroupInterpreter

      public NodeGroupInterpreter(NodeGroup nodeGroup, com.scivicslab.turingworkflow.workflow.IIActorSystem system)
      Constructs a NodeGroupInterpreter that wraps the specified NodeGroup.
      Parameters:
      nodeGroup - the NodeGroup instance to wrap
      system - the actor system for workflow execution
  • Method Details

    • createNodesForGroup

      public List<Node> createNodesForGroup(String groupName)
      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

      public List<Node> createLocalNode()
      Creates a single Node for localhost execution.

      Delegates to the wrapped NodeGroup.createLocalNode() method.

      Returns:
      a list containing a single localhost Node
    • getInventory

      public InventoryParser.Inventory getInventory()
      Gets the inventory object.
      Returns:
      the loaded inventory, or null if not loaded
    • getNodeGroup

      public NodeGroup getNodeGroup()
      Gets the wrapped NodeGroup instance.

      This allows direct access to the underlying POJO when needed.

      Returns:
      the wrapped NodeGroup
    • setOverlayDir

      public void setOverlayDir(String overlayDir)
      Sets the overlay directory for YAML overlay feature.
      Parameters:
      overlayDir - the path to the overlay directory containing overlay-conf.yaml
    • getOverlayDir

      public String getOverlayDir()
      Gets the overlay directory path.
      Returns:
      the overlay directory path, or null if not set
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets verbose mode for detailed output.
      Parameters:
      verbose - true to enable verbose output
    • isVerbose

      public boolean isVerbose()
      Checks if verbose mode is enabled.
      Returns:
      true if verbose mode is enabled
    • setAccumulator

      public void setAccumulator(WorkflowStreamingAccumulator accumulator)
      Sets the WorkflowStreamingAccumulator for displaying workflow steps.
      Parameters:
      accumulator - the accumulator to use for cowsay display
    • getAccumulator

      public WorkflowStreamingAccumulator getAccumulator()
      Gets the WorkflowStreamingAccumulator 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.
      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 writes
      sessionId - the session ID for this execution
    • getLogStore

      public DistributedLogStore getLogStore()
      Gets the log store for direct read operations.
      Returns:
      the log store, or null if not set
    • getLogStoreActor

      public com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> getLogStoreActor()
      Gets the log store actor for async write operations.
      Returns:
      the log store actor, or null if not set
    • getDbExecutor

      public ExecutorService getDbExecutor()
      Gets the DB executor service.
      Returns:
      the DB executor service, or null if not set
    • getSessionId

      public long getSessionId()
      Gets the session ID.
      Returns:
      the session ID, or -1 if not set
    • onEnterTransition

      protected void onEnterTransition(com.scivicslab.turingworkflow.workflow.Transition transition)
      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:
      onEnterTransition in class com.scivicslab.turingworkflow.workflow.Interpreter
      Parameters:
      transition - the transition being entered
    • onExitTransition

      protected void onExitTransition(com.scivicslab.turingworkflow.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:
      onExitTransition in class com.scivicslab.turingworkflow.workflow.Interpreter
      Parameters:
      transition - the transition that was attempted
      success - true if the transition succeeded, false if it failed
      result - the ActionResult from executing the transition's actions