Class LogStoreIIAR

java.lang.Object
com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore>
com.scivicslab.pojoactor.workflow.IIActorRef<DistributedLogStore>
com.scivicslab.actoriac.LogStoreIIAR
All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName, AutoCloseable

public class LogStoreIIAR extends com.scivicslab.pojoactor.workflow.IIActorRef<DistributedLogStore>
Actor wrapper for DistributedLogStore.

This actor centralizes all database writes for logging. It should be created under ROOT and used by all accumulator actors in the system.

To ensure logs are written without blocking workflow execution, this actor should be called using a dedicated ManagedThreadPool with 1 thread:

// Setup
system.addManagedThreadPool(1);  // index 1 for DB writes
ExecutorService dbPool = system.getManagedThreadPool(1);

// Usage from accumulator
logStoreActor.tell(store -> store.log(...), dbPool);

Actor Tree Position

ROOT
├── logStore              <-- this actor
├── accumulator           (system-level)
└── nodeGroup
    ├── accumulator       (workflow-level)
    └── node-*

Supported Actions

  • log - Log a message with level
  • logAction - Log an action result
  • startSession - Start a new workflow session
  • endSession - End a workflow session
  • markNodeSuccess - Mark a node as succeeded
  • markNodeFailed - Mark a node as failed
Since:
2.13.0
Author:
devteam@scivicslab.com
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ExecutorService
    The dedicated executor service for DB writes.
    private static final Logger
     

    Fields inherited from class com.scivicslab.pojoactor.core.ActorRef

    actorName, actorSystem, object
  • Constructor Summary

    Constructors
    Constructor
    Description
    LogStoreIIAR(String actorName, DistributedLogStore logStore, com.scivicslab.pojoactor.workflow.IIActorSystem system, ExecutorService dbExecutor)
    Constructs a new LogStoreIIAR.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.scivicslab.pojoactor.core.ActionResult
    Ends a workflow session.
    Gets the dedicated executor service for DB writes.
    com.scivicslab.pojoactor.core.ActionResult
    log(String arg)
    Logs a message with level.
    com.scivicslab.pojoactor.core.ActionResult
    Logs an action result.
    com.scivicslab.pojoactor.core.ActionResult
    Marks a node as failed.
    com.scivicslab.pojoactor.core.ActionResult
    Marks a node as succeeded.
    com.scivicslab.pojoactor.core.ActionResult
    Starts a new workflow session.

    Methods inherited from class com.scivicslab.pojoactor.workflow.IIActorRef

    callByActionName, hasAnnotatedAction, invokeAnnotatedAction, parseFirstArgument

    Methods 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

    Methods inherited from class Object

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

    • logger

      private static final Logger logger
    • dbExecutor

      private final ExecutorService dbExecutor
      The dedicated executor service for DB writes. Using a single-threaded pool ensures writes are serialized.
  • Constructor Details

    • LogStoreIIAR

      public LogStoreIIAR(String actorName, DistributedLogStore logStore, com.scivicslab.pojoactor.workflow.IIActorSystem system, ExecutorService dbExecutor)
      Constructs a new LogStoreIIAR.
      Parameters:
      actorName - the name of this actor (typically "logStore")
      logStore - the DistributedLogStore implementation
      system - the actor system
      dbExecutor - the dedicated executor service for DB writes (should be single-threaded)
  • Method Details

    • log

      public com.scivicslab.pojoactor.core.ActionResult log(String arg)
      Logs a message with level.
      Parameters:
      arg - JSON with sessionId, nodeId, level, message
      Returns:
      ActionResult
    • logAction

      public com.scivicslab.pojoactor.core.ActionResult logAction(String arg)
      Logs an action result.
      Parameters:
      arg - JSON with sessionId, nodeId, label, actionName, exitCode, durationMs, output
      Returns:
      ActionResult
    • startSession

      public com.scivicslab.pojoactor.core.ActionResult startSession(String arg)
      Starts a new workflow session.
      Parameters:
      arg - JSON with workflowName, overlayName, inventoryName, nodeCount
      Returns:
      ActionResult with session ID
    • endSession

      public com.scivicslab.pojoactor.core.ActionResult endSession(String arg)
      Ends a workflow session.
      Parameters:
      arg - JSON with sessionId, status
      Returns:
      ActionResult
    • markNodeSuccess

      public com.scivicslab.pojoactor.core.ActionResult markNodeSuccess(String arg)
      Marks a node as succeeded.
      Parameters:
      arg - JSON with sessionId, nodeId
      Returns:
      ActionResult
    • markNodeFailed

      public com.scivicslab.pojoactor.core.ActionResult markNodeFailed(String arg)
      Marks a node as failed.
      Parameters:
      arg - JSON with sessionId, nodeId, reason
      Returns:
      ActionResult
    • getDbExecutor

      Gets the dedicated executor service for DB writes.
      Returns:
      the DB executor service