Class H2LogReader

java.lang.Object
com.scivicslab.actoriac.log.H2LogReader
All Implemented Interfaces:
AutoCloseable

public class H2LogReader extends Object implements 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
  • Field Details

  • Constructor Details

    • H2LogReader

      public H2LogReader(Path dbPath) throws SQLException
      Opens the log database for reading.
      Parameters:
      dbPath - path to the database file (without extension)
      Throws:
      SQLException - if database connection fails
    • H2LogReader

      public H2LogReader(String host, int port, String dbPath) throws SQLException
      Opens a remote log database via H2 TCP server.

      Connects to an H2 log server started with the log-server command.

      Parameters:
      host - H2 server hostname (typically "localhost")
      port - H2 server TCP port
      dbPath - database path on the server
      Throws:
      SQLException - if database connection fails
  • Method Details

    • getLogsByNode

      public List<LogEntry> getLogsByNode(long sessionId, String nodeId)
      Gets logs filtered by node ID.
      Parameters:
      sessionId - the session ID
      nodeId - the node ID to filter by
      Returns:
      list of log entries for the specified node
    • getLogsByLevel

      public List<LogEntry> getLogsByLevel(long sessionId, LogLevel minLevel)
      Gets logs filtered by minimum log level.
      Parameters:
      sessionId - the session ID
      minLevel - the minimum log level to include
      Returns:
      list of log entries at or above the specified level
    • getSummary

      public SessionSummary getSummary(long sessionId)
      Gets a summary of the specified session.
      Parameters:
      sessionId - the session ID
      Returns:
      the session summary, or null if not found
    • getLatestSessionId

      public long getLatestSessionId()
      Gets the latest session ID.
      Returns:
      the latest session ID, or -1 if no sessions exist
    • listSessions

      public List<SessionSummary> listSessions(int limit)
      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

      public List<SessionSummary> listSessionsByWorkflow(String workflowName, int limit)
      Lists sessions filtered by workflow name.
      Parameters:
      workflowName - the workflow name to filter by
      limit - maximum number of sessions to return
      Returns:
      list of session summaries for the specified workflow
    • listSessionsByOverlay

      public List<SessionSummary> listSessionsByOverlay(String overlayName, int limit)
      Lists sessions filtered by overlay name.
      Parameters:
      overlayName - the overlay name to filter by
      limit - maximum number of sessions to return
      Returns:
      list of session summaries for the specified overlay
    • listSessionsByInventory

      public List<SessionSummary> listSessionsByInventory(String inventoryName, int limit)
      Lists sessions filtered by inventory name.
      Parameters:
      inventoryName - the inventory name to filter by
      limit - maximum number of sessions to return
      Returns:
      list of session summaries for the specified inventory
    • listSessionsAfter

      public List<SessionSummary> listSessionsAfter(LocalDateTime startedAfter, int limit)
      Lists sessions started after the specified time.
      Parameters:
      startedAfter - only include sessions started after this time
      limit - maximum number of sessions to return
      Returns:
      list of session summaries started after the specified time
    • getNodesInSession

      public List<H2LogReader.NodeInfo> getNodesInSession(long sessionId)
      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

      public void close() throws SQLException
      Specified by:
      close in interface AutoCloseable
      Throws:
      SQLException