Class H2LogReader
java.lang.Object
com.scivicslab.actoriac.log.H2LogReader
- All Implemented Interfaces:
AutoCloseable
Read-only H2 log reader for querying workflow logs.
This class provides access to the H2 log database for querying logs. Uses AUTO_SERVER=TRUE to connect to the H2 server started by the writer process, allowing concurrent access while actor-IaC is writing logs.
- Author:
- devteam@scivics-lab.com
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordInformation about a node in a session. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionH2LogReader(String host, int port, String dbPath) Opens a remote log database via H2 TCP server.H2LogReader(Path dbPath) Opens the log database for reading. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longGets the latest session ID.getLogsByLevel(long sessionId, LogLevel minLevel) Gets logs filtered by minimum log level.getLogsByNode(long sessionId, String nodeId) Gets logs filtered by node ID.getNodesInSession(long sessionId) Gets all nodes that participated in a session.getSummary(long sessionId) Gets a summary of the specified session.listSessions(int limit) Lists recent sessions.listSessionsAfter(LocalDateTime startedAfter, int limit) Lists sessions started after the specified time.listSessionsByInventory(String inventoryName, int limit) Lists sessions filtered by inventory name.listSessionsByOverlay(String overlayName, int limit) Lists sessions filtered by overlay name.listSessionsByWorkflow(String workflowName, int limit) Lists sessions filtered by workflow name.listSessionsFiltered(String workflowName, String overlayName, String inventoryName, LocalDateTime startedAfter, int limit) Lists sessions filtered by criteria.listSessionsFiltered(String workflowName, String overlayName, String inventoryName, LocalDateTime startedAfter, LocalDateTime endedAfter, int limit) Lists sessions filtered by criteria including end time.private LogEntrymapLogEntry(ResultSet rs)
-
Field Details
-
connection
-
-
Constructor Details
-
H2LogReader
Opens the log database for reading.- Parameters:
dbPath- path to the database file (without extension)- Throws:
SQLException- if database connection fails
-
H2LogReader
Opens a remote log database via H2 TCP server.Connects to an H2 log server started with the
log-servercommand.- Parameters:
host- H2 server hostname (typically "localhost")port- H2 server TCP portdbPath- database path on the server- Throws:
SQLException- if database connection fails
-
-
Method Details
-
getLogsByNode
Gets logs filtered by node ID.- Parameters:
sessionId- the session IDnodeId- the node ID to filter by- Returns:
- list of log entries for the specified node
-
getLogsByLevel
Gets logs filtered by minimum log level.- Parameters:
sessionId- the session IDminLevel- the minimum log level to include- Returns:
- list of log entries at or above the specified level
-
getSummary
Gets a summary of the specified session.- Parameters:
sessionId- the session ID- Returns:
- the session summary, or null if not found
-
getLatestSessionId
Gets the latest session ID.- Returns:
- the latest session ID, or -1 if no sessions exist
-
listSessions
Lists recent sessions.- Parameters:
limit- maximum number of sessions to return- Returns:
- list of session summaries, ordered by start time descending
-
listSessionsFiltered
public List<SessionSummary> listSessionsFiltered(String workflowName, String overlayName, String inventoryName, LocalDateTime startedAfter, int limit) Lists sessions filtered by criteria.- Parameters:
workflowName- filter by workflow name (null to skip)overlayName- filter by overlay name (null to skip)inventoryName- filter by inventory name (null to skip)startedAfter- filter by start time (null to skip)limit- maximum number of sessions to return- Returns:
- list of session summaries matching the criteria
-
listSessionsFiltered
public List<SessionSummary> listSessionsFiltered(String workflowName, String overlayName, String inventoryName, LocalDateTime startedAfter, LocalDateTime endedAfter, int limit) Lists sessions filtered by criteria including end time.- Parameters:
workflowName- filter by workflow name (null to skip)overlayName- filter by overlay name (null to skip)inventoryName- filter by inventory name (null to skip)startedAfter- filter by start time (null to skip)endedAfter- filter by end time (null to skip)limit- maximum number of sessions to return- Returns:
- list of session summaries matching the criteria
-
listSessionsByWorkflow
Lists sessions filtered by workflow name.- Parameters:
workflowName- the workflow name to filter bylimit- maximum number of sessions to return- Returns:
- list of session summaries for the specified workflow
-
listSessionsByOverlay
Lists sessions filtered by overlay name.- Parameters:
overlayName- the overlay name to filter bylimit- maximum number of sessions to return- Returns:
- list of session summaries for the specified overlay
-
listSessionsByInventory
Lists sessions filtered by inventory name.- Parameters:
inventoryName- the inventory name to filter bylimit- maximum number of sessions to return- Returns:
- list of session summaries for the specified inventory
-
listSessionsAfter
Lists sessions started after the specified time.- Parameters:
startedAfter- only include sessions started after this timelimit- maximum number of sessions to return- Returns:
- list of session summaries started after the specified time
-
getNodesInSession
Gets all nodes that participated in a session.- Parameters:
sessionId- the session ID- Returns:
- list of node information, ordered by node ID
-
mapLogEntry
- Throws:
SQLException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException
-