Package xal.service.pvlogger
Class LoggerSession
java.lang.Object
xal.service.pvlogger.LoggerSession
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final double
default logging period in secondsprotected boolean
protected final LoggerChangeListener
protected ChannelGroup
protected static final int
initial timer delayprotected MachineSnapshot
latest snapshot taken which may or may not have been publishedprotected double
logging period in secondsprotected TimerTask
protected final Timer
protected final MessageCenter
protected final xal.service.pvlogger.SnapshotPublisher
publisher of snapshots to the persistent store -
Constructor Summary
ConstructorsConstructorDescriptionLoggerSession
(ChannelGroup group, xal.service.pvlogger.SnapshotPublisher publisher) LoggerSession constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLoggerChangeListener
(LoggerChangeListener listener) Add a logger change listener to receive logger change events.protected void
dispose of the logging taskGet the active channel group for this sessionGet the channels which we are attempting to monitor and logGet the latest machine snapshot which may or may not have been publisheddouble
Get the loggin period.boolean
Determine whether this logger session is enabledboolean
Reveal whether the logger is scheduled to run periodicallyprotected final TimerTask
get a new timer task for periodic loggingfinal void
publishSnapshot
(MachineSnapshot machineSnapshot) Publish the machine snapshot to the persistent storage.void
Remove a logger change listener from receiving logger change events.void
Resume periodic logging with the most recent settings if enabled.void
setChannelGroup
(ChannelGroup group) Set the channel group for this logger sessionprotected void
setEnabled
(boolean enable) Set whether this session should be enabledvoid
setLoggingPeriod
(double period) Set the period between events where we take and store machine snapshots.void
Start periodically logging machine state to the persistent storage.void
startLogging
(double period) Start periodically logging machine state to the persistent storage.void
Stop the periodic machine state logging.final MachineSnapshot
Take a snapshot and publish it immediatelyfinal MachineSnapshot
takeAndPublishSnapshot
(String comment) Take a snapshot and publish it immediatelyprotected final MachineSnapshot
Take a snapshot and schedule it for publicationfinal MachineSnapshot
Take a snapshot of the current machine state.
-
Field Details
-
INITIAL_DELAY
protected static final int INITIAL_DELAYinitial timer delay- See Also:
-
DEFAULT_LOGGING_PERIOD
protected static final double DEFAULT_LOGGING_PERIODdefault logging period in seconds- See Also:
-
snapshotPublisher
protected final xal.service.pvlogger.SnapshotPublisher snapshotPublisherpublisher of snapshots to the persistent store -
latestMachineSnapshot
latest snapshot taken which may or may not have been published -
messageCenter
-
eventProxy
-
group
-
logTimer
-
logTask
-
loggingPeriod
protected double loggingPeriodlogging period in seconds -
enabled
protected boolean enabled
-
-
Constructor Details
-
LoggerSession
LoggerSession constructor- Parameters:
group
- Group of channels to log.publisher
- The snapshot publisher.
-
-
Method Details
-
addLoggerChangeListener
Add a logger change listener to receive logger change events.- Parameters:
listener
- The listener of the logger change events.
-
removeLoggerChangeListener
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
Get the active channel group for this session- Returns:
- the channel group
-
setChannelGroup
Set the channel group for this logger session- Parameters:
group
- the new channel group for this logger session
-
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
Get the latest machine snapshot which may or may not have been published- Returns:
- the latest machine snapshot
-
takeAndPublishSnapshot
Take a snapshot and publish it immediately- Returns:
- the published snapshot
-
takeAndPublishSnapshot
Take a snapshot and publish it immediately- Parameters:
comment
- machine snapshot comment- Returns:
- the published snapshot
-
takeAndScheduleSnapshotForPublication
Take a snapshot and schedule it for publication- Returns:
- the scheduled snapshot
-
takeSnapshot
Take a snapshot of the current machine state.- Returns:
- A snapshot of the current machine state.
-
publishSnapshot
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
get a new timer task for periodic logging
-