Class LogStoreActor
java.lang.Object
com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore>
com.scivicslab.turingworkflow.workflow.IIActorRef<DistributedLogStore>
com.scivicslab.turingworkflow.plugins.logdb.LogStoreActor
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.CallableByActionName,AutoCloseable
public class LogStoreActor
extends com.scivicslab.turingworkflow.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.
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:
- 1.0
- Author:
- devteam@scivicslab.com
-
Field Summary
Fields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
ConstructorsConstructorDescriptionLogStoreActor(String actorName, DistributedLogStore logStore, com.scivicslab.turingworkflow.workflow.IIActorSystem system, ExecutorService dbExecutor) Constructs a new LogStoreActor. -
Method Summary
Modifier and TypeMethodDescriptioncom.scivicslab.pojoactor.core.ActionResultendSession(String arg) Ends a workflow session with a terminal status.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 with execution metadata.com.scivicslab.pojoactor.core.ActionResultmarkNodeFailed(String arg) Marks a node as failed in the current session.com.scivicslab.pojoactor.core.ActionResultmarkNodeSuccess(String arg) Marks a node as succeeded in the current session.com.scivicslab.pojoactor.core.ActionResultstartSession(String arg) Starts a new workflow session.Methods inherited from class com.scivicslab.turingworkflow.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
-
Constructor Details
-
LogStoreActor
public LogStoreActor(String actorName, DistributedLogStore logStore, com.scivicslab.turingworkflow.workflow.IIActorSystem system, ExecutorService dbExecutor) Constructs a new LogStoreActor.- 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
Logs a message with level.Expected JSON format:
{ "sessionId": 1, "nodeId": "node-01", "level": "INFO", "message": "Processing started" }- Parameters:
arg- JSON string containing sessionId (long), nodeId (String), level (String matchingLogLevel), and message (String)- Returns:
ActionResultwith success=true and message "Logged", or success=false with the error message on failure
-
logAction
Logs an action result with execution metadata.Expected JSON format:
{ "sessionId": 1, "nodeId": "node-01", "label": "deploy", "actionName": "runScript", "exitCode": 0, "durationMs": 1234, "output": "Script completed successfully" }- Parameters:
arg- JSON string containing sessionId (long), nodeId (String), label (String), actionName (String), exitCode (int), durationMs (long), and output (String)- Returns:
ActionResultwith success=true and message "Action logged", or success=false with the error message on failure
-
startSession
Starts a new workflow session.Expected JSON format:
{ "workflowName": "my-workflow", "overlayName": "production", "inventoryName": "hosts.yml", "nodeCount": 5 }- Parameters:
arg- JSON string containing workflowName (String), nodeCount (int), and optional overlayName (String) and inventoryName (String)- Returns:
ActionResultwith success=true and the session ID as the message, or success=false with the error message on failure
-
endSession
Ends a workflow session with a terminal status.Expected JSON format:
{ "sessionId": 1, "status": "COMPLETED" }- Parameters:
arg- JSON string containing sessionId (long) and status (String matchingSessionStatus)- Returns:
ActionResultwith success=true and message "Session ended", or success=false with the error message on failure
-
markNodeSuccess
Marks a node as succeeded in the current session.Expected JSON format:
{ "sessionId": 1, "nodeId": "node-01" }- Parameters:
arg- JSON string containing sessionId (long) and nodeId (String)- Returns:
ActionResultwith success=true and message "Node marked as success", or success=false with the error message on failure
-
markNodeFailed
Marks a node as failed in the current session.Expected JSON format:
{ "sessionId": 1, "nodeId": "node-01", "reason": "Connection timeout" }- Parameters:
arg- JSON string containing sessionId (long), nodeId (String), and reason (String)- Returns:
ActionResultwith success=true and message "Node marked as failed", or success=false with the error message on failure
-
getDbExecutor
Gets the dedicated executor service for DB writes.- Returns:
- the DB executor service
-