Class PVLogger

java.lang.Object
xal.service.pvlogger.PVLogger

public class PVLogger extends Object
Provides a public interface to the PV Logger package
  • Field Details

    • persistentStore

      protected final xal.service.pvlogger.PersistentStore persistentStore
      database store
    • snapshotPublisher

      protected final xal.service.pvlogger.SnapshotPublisher snapshotPublisher
      snapshot publisher
    • connectionDictionary

      protected ConnectionDictionary connectionDictionary
      connection dictionary
    • loggerSessions

      protected final Map<String,LoggerSession> loggerSessions
      logger sessions keyed by channel group ID
    • connection

      protected Connection connection
      current database connection
  • Constructor Details

    • PVLogger

      public PVLogger(ConnectionDictionary connectionDictionary)
      Primary Constructor
    • PVLogger

      public PVLogger()
      Constructor
  • Method Details

    • getBrowsingInstance

      public static PVLogger getBrowsingInstance()
      get an instance for browsing the PV Logger data
    • getLoggingInstance

      public static PVLogger getLoggingInstance()
      get an instance for logging PV data to the database
    • newLoggingConnectionDictionary

      public static ConnectionDictionary newLoggingConnectionDictionary()
      generate a new connection dictionary appropriate for logging
    • newBrowsingConnectionDictionary

      public static ConnectionDictionary newBrowsingConnectionDictionary()
      generate a new connection dictionary appropriate for browsing logged data
    • getConnectionDictionary

      public ConnectionDictionary getConnectionDictionary()
      get the connection dictionary
    • setConnectionDictionary

      public void setConnectionDictionary(ConnectionDictionary dictionary)
      set the connection dictionary
    • getLoggerSession

      public LoggerSession getLoggerSession(String groupID)
      Get the logger session with the specified groupID
      Parameters:
      groupID - the channel group ID
      Returns:
      the logger session with the specified group ID or null if none exists
    • getLoggerSessions

      public Collection<LoggerSession> getLoggerSessions()
      Get all logger sessions managed by this PV Logger
      Returns:
      the collection of logger sessions
    • removeAllLoggerSessions

      public void removeAllLoggerSessions()
      remove all logger sessions
    • removeLoggerSession

      public void removeLoggerSession(String groupID)
      Stop the logger session with the specified group ID and remove it from the PV Logger
      Parameters:
      groupID - group ID of the logger session to remove
    • hasLoggerSession

      public boolean hasLoggerSession(String groupID)
      Determine if a logger session exists for the specified group
      Parameters:
      groupID - group ID of the logger session for which to look
      Returns:
      true if a session exists for the group and false if not
    • requestEnabledLoggerSessionsForService

      public List<LoggerSession> requestEnabledLoggerSessionsForService(String serviceID) throws SQLException
      Request enabled logger sessions for the specified service
      Parameters:
      serviceID - service name
      Returns:
      the list of logger sessions
      Throws:
      SQLException
    • requestLoggerSessionsForService

      public List<LoggerSession> requestLoggerSessionsForService(String serviceID) throws SQLException
      Request logger sessions for the specified service
      Parameters:
      serviceID - service name
      Returns:
      the list of logger sessions
      Throws:
      SQLException
    • requestLoggerSession

      public LoggerSession requestLoggerSession(String groupID) throws SQLException
      If a logger session already exists for the channel group, get it otherwise create a new one
      Parameters:
      groupID - the name of the channel group
      Returns:
      an existing logger session if one exists otherwise a new logger session or null if one could not be created
      Throws:
      SQLException
    • reloadLoggerSession

      public LoggerSession reloadLoggerSession(String groupID) throws SQLException
      Reload the logger session for the specified channel group
      Parameters:
      groupID - the name of the channel group
      Returns:
      the corresponding logger session or null if a corresponding logger session cannot be found or generated
      Throws:
      SQLException
    • isPublishing

      public boolean isPublishing()
      determine if the snapshot publisher is publishing snapshots periodically
    • start

      public void start()
      start logging sessions and publishing snapshots
    • restart

      public void restart()
      restart logging sessions and publishing snapshots
    • stop

      public void stop()
      stop logging sessions and publishing snapshots but publish any scheduled snapshots
    • publishSnapshots

      public void publishSnapshots()
      publish any scheduled snapshots remaining in the queue
    • getPublishingPeriod

      public double getPublishingPeriod()
      Get the publishing period
      Returns:
      publishing period in seconds
    • setPublishingPeriod

      public void setPublishingPeriod(double period)
      Set the publishing period
      Parameters:
      period - publishing period in seconds
    • fetchMachineSnapshot

      public MachineSnapshot fetchMachineSnapshot(long snapshotID) throws SQLException
      Fetch the machine snapshot corresponding to the specified snasphot ID
      Parameters:
      snapshotID - machine snaspshot ID
      Returns:
      machine snapshot corresponding to the specified ID
      Throws:
      SQLException
    • fetchMachineSnapshotsInRange

      public MachineSnapshot[] fetchMachineSnapshotsInRange(String type, Date startTime, Date endTime) throws SQLException
      Fetch the machine snapshots within the specified time range. If the type is not null, then restrict the machine snapshots to those of the specified type. The machine snapshots do not include the channel snapshots. A complete snapshot can be obtained using the fetchMachineSnapshot(id) method.
      Parameters:
      type - The type of machine snapshots to fetch or null for no restriction
      startTime - The start time of the time range
      endTime - The end time of the time range
      Returns:
      An array of machine snapshots meeting the specified criteria
      Throws:
      SQLException
    • loadChannelSnapshotsInto

      public MachineSnapshot loadChannelSnapshotsInto(MachineSnapshot machineSnapshot) throws SQLException
      Fetch the channel snapshots from the data source and populate the machine snapshot
      Parameters:
      machineSnapshot - The machine snapshot for which to fetch the channel snapshots and load them
      Returns:
      the machineSnapshot which is the same as the parameter returned for convenience
      Throws:
      SQLException
    • fetchTypes

      public String[] fetchTypes() throws SQLException
      Fetch channel groups as an array of types
      Returns:
      array of types corresponding to all of the channel groups
      Throws:
      SQLException
    • fetchTypes

      public String[] fetchTypes(String serviceID) throws SQLException
      Fetch the channel groups associated with the service ID as an array of types
      Parameters:
      serviceID - service ID of groups to fetch
      Returns:
      array of types corresponding to channel groups with the specified service ID
      Throws:
      SQLException
    • getChannelGroup

      public ChannelGroup getChannelGroup(String type) throws SQLException
      Get the channel group corresponding to the specified type.
      Parameters:
      type - channel group type
      Throws:
      SQLException
    • getDatabaseConnection

      protected Connection getDatabaseConnection()
      get the current database connection creating it if necessary
    • getNewDatabaseConnection

      protected Connection getNewDatabaseConnection()
      make a new database connection
    • closeConnection

      public void closeConnection()
      close the database connection if a connection exists and set the connection to null
    • testConnection

      protected static boolean testConnection(Connection connection)
      Test whether the connection is good
      Parameters:
      connection - the connection to test
      Returns:
      true if the connection is good and false if not
    • finalize

      protected void finalize() throws Throwable
      sql connections should be closed manually
      Overrides:
      finalize in class Object
      Throws:
      Throwable