Interface DistributedLogStore
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
H2LogStore
Interface for distributed log storage.
This interface defines operations for storing and querying logs from distributed workflow execution across multiple nodes.
The interface provides singleton access for components that need database connection (e.g., WorkflowReporter). The singleton is set at workflow startup and cleared after execution.
- Since:
- 1.0
- Author:
- devteam@scivicslab.com
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classInternal holder for the singletonDistributedLogStoreinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidendSession(long sessionId, SessionStatus status) Ends a session with the given status.Gets the database connection for read-only operations.getErrors(long sessionId) Retrieves error logs for a session.static DistributedLogStoreGets the singleton instance.longGets the most recent session ID.getLogsByLevel(long sessionId, LogLevel minLevel) Retrieves log entries filtered by level.getLogsByNode(long sessionId, String nodeId) Retrieves all log entries for a specific node in a session.getSummary(long sessionId) Gets a summary of the session.listSessions(int limit) Lists all sessions.voidRecords a log entry.voidRecords a log entry with transition context.voidlogAction(long sessionId, String nodeId, String label, String actionName, int exitCode, long durationMs, String output) Records an action result.voidmarkNodeFailed(long sessionId, String nodeId, String reason) Marks a node as failed in this session.voidmarkNodeSuccess(long sessionId, String nodeId) Marks a node as succeeded in this session.static voidsetInstance(DistributedLogStore store) Sets the singleton instance.longstartSession(String workflowName, int nodeCount) Starts a new workflow execution session.longstartSession(String workflowName, String overlayName, String inventoryName, int nodeCount) Starts a new workflow execution session with overlay and inventory info.default longstartSession(String workflowName, String overlayName, String inventoryName, int nodeCount, String cwd, String gitCommit, String gitBranch, String commandLine, String pluginVersion, String pluginCommit) Starts a new workflow execution session with full execution context.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
setInstance
Sets the singleton instance.Called when starting workflow execution.
- Parameters:
store- the DistributedLogStore instance to use globally
-
getInstance
Gets the singleton instance.- Returns:
- the global DistributedLogStore instance, or null if not set
-
getConnection
Connection getConnection()Gets the database connection for read-only operations.Components should NOT close this connection. The connection is owned by the store and will be closed when execution ends.
- Returns:
- the JDBC connection
-
startSession
Starts a new workflow execution session.- Parameters:
workflowName- name of the workflow being executednodeCount- number of nodes participating in this session- Returns:
- session ID for subsequent log entries
-
startSession
Starts a new workflow execution session with overlay and inventory info.- Parameters:
workflowName- name of the workflow being executedoverlayName- name of the overlay being used (may be null)inventoryName- name of the inventory file being used (may be null)nodeCount- number of nodes participating in this session- Returns:
- session ID for subsequent log entries
-
startSession
default long startSession(String workflowName, String overlayName, String inventoryName, int nodeCount, String cwd, String gitCommit, String gitBranch, String commandLine, String pluginVersion, String pluginCommit) Starts a new workflow execution session with full execution context.- Parameters:
workflowName- name of the workflow being executedoverlayName- name of the overlay being used (may be null)inventoryName- name of the inventory file being used (may be null)nodeCount- number of nodes participating in this sessioncwd- current working directorygitCommit- git commit hash of the workflow directory (may be null)gitBranch- git branch name (may be null)commandLine- the command line used to invoke the workflowpluginVersion- plugin versionpluginCommit- plugin git commit hash (may be null)- Returns:
- session ID for subsequent log entries
-
log
Records a log entry.- Parameters:
sessionId- session ID from startSession()nodeId- identifier of the node generating this loglevel- log levelmessage- log message
-
log
Records a log entry with transition context.- Parameters:
sessionId- session ID from startSession()nodeId- identifier of the nodelabel- current label in workflowlevel- log levelmessage- log message
-
logAction
void logAction(long sessionId, String nodeId, String label, String actionName, int exitCode, long durationMs, String output) Records an action result.- Parameters:
sessionId- session IDnodeId- node identifierlabel- labelactionName- action/method nameexitCode- command exit code (0 for success)durationMs- execution duration in millisecondsoutput- command output or result message
-
markNodeSuccess
Marks a node as succeeded in this session.- Parameters:
sessionId- session IDnodeId- node identifier
-
markNodeFailed
Marks a node as failed in this session.- Parameters:
sessionId- session IDnodeId- node identifierreason- failure reason
-
endSession
Ends a session with the given status.- Parameters:
sessionId- session IDstatus- final status
-
getLogsByNode
Retrieves all log entries for a specific node in a session.- Parameters:
sessionId- session IDnodeId- node identifier- Returns:
- list of log entries
-
getLogsByLevel
Retrieves log entries filtered by level.- Parameters:
sessionId- session IDminLevel- minimum log level to include- Returns:
- list of log entries
-
getErrors
Retrieves error logs for a session.- Parameters:
sessionId- session ID- Returns:
- list of error log entries
-
getSummary
Gets a summary of the session.- Parameters:
sessionId- session ID- Returns:
- session summary
-
getLatestSessionId
long getLatestSessionId()Gets the most recent session ID.- Returns:
- latest session ID, or -1 if no sessions exist
-
listSessions
Lists all sessions.- Parameters:
limit- maximum number of sessions to return- Returns:
- list of session summaries
-