Class LoggerSession

java.lang.Object
xal.service.pvlogger.LoggerSession

public class LoggerSession extends Object
LoggerSession manages a session of logging machine state. One can create an instance to log the current machine state either on demand or periodically.
Author:
tap
  • Field Details

    • INITIAL_DELAY

      protected static final int INITIAL_DELAY
      initial timer delay
      See Also:
    • DEFAULT_LOGGING_PERIOD

      protected static final double DEFAULT_LOGGING_PERIOD
      default logging period in seconds
      See Also:
    • snapshotPublisher

      protected final xal.service.pvlogger.SnapshotPublisher snapshotPublisher
      publisher of snapshots to the persistent store
    • latestMachineSnapshot

      protected volatile MachineSnapshot latestMachineSnapshot
      latest snapshot taken which may or may not have been published
    • messageCenter

      protected final MessageCenter messageCenter
    • eventProxy

      protected final LoggerChangeListener eventProxy
    • group

      protected ChannelGroup group
    • logTimer

      protected final Timer logTimer
    • logTask

      protected TimerTask logTask
    • loggingPeriod

      protected double loggingPeriod
      logging period in seconds
    • enabled

      protected boolean enabled
  • Constructor Details

    • LoggerSession

      public LoggerSession(ChannelGroup group, xal.service.pvlogger.SnapshotPublisher publisher)
      LoggerSession constructor
      Parameters:
      group - Group of channels to log.
      publisher - The snapshot publisher.
  • Method Details

    • addLoggerChangeListener

      public void addLoggerChangeListener(LoggerChangeListener listener)
      Add a logger change listener to receive logger change events.
      Parameters:
      listener - The listener of the logger change events.
    • removeLoggerChangeListener

      public void removeLoggerChangeListener(LoggerChangeListener listener)
      Remove a logger change listener from receiving logger change events.
      Parameters:
      listener - The listener of the logger change events.
    • resumeLogging

      public void resumeLogging()
      Resume periodic logging with the most recent settings if enabled.
    • startLogging

      public void startLogging()
      Start periodically logging machine state to the persistent storage.
    • startLogging

      public void startLogging(double period)
      Start periodically logging machine state to the persistent storage.
      Parameters:
      period - The period in seconds between events where we take and store machine snapshots.
    • stopLogging

      public void stopLogging()
      Stop the periodic machine state logging.
    • isLogging

      public boolean isLogging()
      Reveal whether the logger is scheduled to run periodically
      Returns:
      true if the logger is scheduled to run periodically or false otherwise
    • setLoggingPeriod

      public void setLoggingPeriod(double period)
      Set the period between events where we take and store machine snapshots.
      Parameters:
      period - The period in seconds between events where we take and store machine snapshots.
    • getLoggingPeriod

      public double getLoggingPeriod()
      Get the loggin period.
      Returns:
      The period in seconds between events where we take and store machine snapshots.
    • isEnabled

      public boolean isEnabled()
      Determine whether this logger session is enabled
      Returns:
      true if this logger session is enabled and false if not
    • setEnabled

      protected void setEnabled(boolean enable)
      Set whether this session should be enabled
      Parameters:
      enable - true to enable this session and false to disable it
    • getChannelGroup

      public ChannelGroup getChannelGroup()
      Get the active channel group for this session
      Returns:
      the channel group
    • setChannelGroup

      public void setChannelGroup(ChannelGroup group)
      Set the channel group for this logger session
      Parameters:
      group - the new channel group for this logger session
    • getChannels

      public Collection<Channel> getChannels()
      Get the channels which we are attempting to monitor and log
      Returns:
      a collection of the channels we wish to monitor and log
    • getLatestMachineSnapshot

      public MachineSnapshot getLatestMachineSnapshot()
      Get the latest machine snapshot which may or may not have been published
      Returns:
      the latest machine snapshot
    • takeAndPublishSnapshot

      public final MachineSnapshot takeAndPublishSnapshot()
      Take a snapshot and publish it immediately
      Returns:
      the published snapshot
    • takeAndPublishSnapshot

      public final MachineSnapshot takeAndPublishSnapshot(String comment)
      Take a snapshot and publish it immediately
      Parameters:
      comment - machine snapshot comment
      Returns:
      the published snapshot
    • takeAndScheduleSnapshotForPublication

      protected final MachineSnapshot takeAndScheduleSnapshotForPublication()
      Take a snapshot and schedule it for publication
      Returns:
      the scheduled snapshot
    • takeSnapshot

      public final MachineSnapshot takeSnapshot()
      Take a snapshot of the current machine state.
      Returns:
      A snapshot of the current machine state.
    • publishSnapshot

      public final void publishSnapshot(MachineSnapshot machineSnapshot)
      Publish the machine snapshot to the persistent storage.
      Parameters:
      machineSnapshot - The machine snapshot to publish.
    • disposeLoggingTask

      protected void disposeLoggingTask()
      dispose of the logging task
    • newLoggingTask

      protected final TimerTask newLoggingTask()
      get a new timer task for periodic logging