Class NodeGroupInterpreter

java.lang.Object
com.scivicslab.pojoactor.workflow.Interpreter
com.scivicslab.actoriac.NodeGroupInterpreter

public class NodeGroupInterpreter extends com.scivicslab.pojoactor.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.

Author:
devteam@scivics-lab.com
  • Nested Class Summary

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

    com.scivicslab.pojoactor.workflow.Interpreter.Builder
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Distributed log store for structured logging.
    private final NodeGroup
    The wrapped NodeGroup POJO that handles inventory and node creation.
    private String
    The overlay directory path for YAML overlay feature.
    private long
    Session ID for the current workflow execution.
    private boolean
    Verbose output flag.

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

    code, currentState, currentVertexIndex, logger, selfActorRef, system, workflowBaseDir
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeGroupInterpreter(NodeGroup nodeGroup, com.scivicslab.pojoactor.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 inventory object.
    Gets the log store.
    Gets the wrapped NodeGroup instance.
    Gets the overlay directory path.
    long
    Gets the session ID.
    boolean
    Checks if verbose mode is enabled.
    protected void
    onEnterVertex(com.scivicslab.pojoactor.workflow.Vertex vertex)
    Hook called when entering a vertex during workflow execution.
    void
    setLogStore(DistributedLogStore logStore, 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.pojoactor.workflow.Interpreter

    action, addToAccumulator, addToAccumulator, apply, call, execCode, findMatchingActors, findMatchingChildActors, findNextMatchingVertex, generateChildName, getCode, getCurrentState, getCurrentVertexIndex, getToState, getWorkflowBaseDir, hasCodeLoaded, loadWorkflowFromClasspath, matchesCurrentState, matchesStatePattern, readJson, readXml, readYaml, readYaml, readYaml, removeChildActor, reset, runUntilEnd, runUntilEnd, runWorkflow, runWorkflow, setCode, setSelfActorRef, setWorkflowBaseDir, transitionTo

    Methods inherited from class Object

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

    • nodeGroup

      private final NodeGroup nodeGroup
      The wrapped NodeGroup POJO that handles inventory and node creation.
    • overlayDir

      private String overlayDir
      The overlay directory path for YAML overlay feature. When set, workflows are loaded with overlay applied.
    • verbose

      private boolean verbose
      Verbose output flag. When true, displays full YAML for each vertex instead of truncated version.
    • logStore

      Distributed log store for structured logging.
    • sessionId

      private long 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 - 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

      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

      public void setOverlayDir(String overlayDir)
      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

      public void setVerbose(boolean verbose)
      Sets verbose mode for detailed output.

      When enabled, displays full YAML for each vertex in cowsay output instead of the truncated version.

      Parameters:
      verbose - true to enable verbose output
    • isVerbose

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

      public void setLogStore(DistributedLogStore logStore, long sessionId)
      Sets the distributed log store for structured logging.
      Parameters:
      logStore - the log store to use
      sessionId - the session ID for this execution
    • getLogStore

      Gets the log store.
      Returns:
      the log store, or null if not set
    • getSessionId

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

      protected void onEnterVertex(com.scivicslab.pojoactor.workflow.Vertex vertex)
      Hook called when entering a vertex during workflow execution.

      Displays the workflow name and vertex definition using cowsay. In normal mode, shows first 10 lines. In verbose mode, shows the full YAML after the cowsay output.

      Overrides:
      onEnterVertex in class com.scivicslab.pojoactor.workflow.Interpreter
      Parameters:
      vertex - the vertex being entered