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
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 levellogAction- Log an action resultstartSession- Start a new workflow sessionendSession- End a workflow sessionmarkNodeSuccess- Mark a node as succeededmarkNodeFailed- Mark a node as failed
- Since:
- 2.13.0
- Author:
- devteam@scivicslab.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExecutorServiceThe dedicated executor service for DB writes.private static final LoggerFields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
ConstructorsConstructorDescriptionLogStoreIIAR(String actorName, DistributedLogStore logStore, com.scivicslab.pojoactor.workflow.IIActorSystem system, ExecutorService dbExecutor) Constructs a new LogStoreIIAR. -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.core.ActionResultendSession(String arg) Ends a workflow session.Gets the dedicated executor service for DB writes.com.scivicslab.pojoactor.core.ActionResultLogs a message with level.com.scivicslab.pojoactor.core.ActionResultLogs an action result.com.scivicslab.pojoactor.core.ActionResultmarkNodeFailed(String arg) Marks a node as failed.com.scivicslab.pojoactor.core.ActionResultmarkNodeSuccess(String arg) Marks a node as succeeded.com.scivicslab.pojoactor.core.ActionResultstartSession(String arg) Starts a new workflow session.Methods inherited from class com.scivicslab.pojoactor.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
-
Field Details
-
logger
-
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 implementationsystem- the actor systemdbExecutor- the dedicated executor service for DB writes (should be single-threaded)
-
-
Method Details
-
log
-
logAction
-
startSession
Starts a new workflow session.- Parameters:
arg- JSON with workflowName, overlayName, inventoryName, nodeCount- Returns:
- ActionResult with session ID
-
endSession
Ends a workflow session.- Parameters:
arg- JSON with sessionId, status- Returns:
- ActionResult
-
markNodeSuccess
Marks a node as succeeded.- Parameters:
arg- JSON with sessionId, nodeId- Returns:
- ActionResult
-
markNodeFailed
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
-