Package xal.service.pvlogger
Class PVLogger
java.lang.Object
xal.service.pvlogger.PVLogger
Provides a public interface to the PV Logger package
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connection
current database connectionprotected ConnectionDictionary
connection dictionaryprotected final Map<String,
LoggerSession> logger sessions keyed by channel group IDprotected final xal.service.pvlogger.PersistentStore
database storeprotected final xal.service.pvlogger.SnapshotPublisher
snapshot publisher -
Constructor Summary
ConstructorsConstructorDescriptionPVLogger()
ConstructorPVLogger
(ConnectionDictionary connectionDictionary) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
close the database connection if a connection exists and set the connection to nullfetchMachineSnapshot
(long snapshotID) Fetch the machine snapshot corresponding to the specified snasphot IDfetchMachineSnapshotsInRange
(String type, Date startTime, Date endTime) Fetch the machine snapshots within the specified time range.String[]
Fetch channel groups as an array of typesString[]
fetchTypes
(String serviceID) Fetch the channel groups associated with the service ID as an array of typesprotected void
finalize()
sql connections should be closed manuallystatic PVLogger
get an instance for browsing the PV Logger datagetChannelGroup
(String type) Get the channel group corresponding to the specified type.get the connection dictionaryprotected Connection
get the current database connection creating it if necessarygetLoggerSession
(String groupID) Get the logger session with the specified groupIDGet all logger sessions managed by this PV Loggerstatic PVLogger
get an instance for logging PV data to the databaseprotected Connection
make a new database connectiondouble
Get the publishing periodboolean
hasLoggerSession
(String groupID) Determine if a logger session exists for the specified groupboolean
determine if the snapshot publisher is publishing snapshots periodicallyloadChannelSnapshotsInto
(MachineSnapshot machineSnapshot) Fetch the channel snapshots from the data source and populate the machine snapshotstatic ConnectionDictionary
generate a new connection dictionary appropriate for browsing logged datastatic ConnectionDictionary
generate a new connection dictionary appropriate for loggingvoid
publish any scheduled snapshots remaining in the queuereloadLoggerSession
(String groupID) Reload the logger session for the specified channel groupvoid
remove all logger sessionsvoid
removeLoggerSession
(String groupID) Stop the logger session with the specified group ID and remove it from the PV LoggerrequestEnabledLoggerSessionsForService
(String serviceID) Request enabled logger sessions for the specified servicerequestLoggerSession
(String groupID) If a logger session already exists for the channel group, get it otherwise create a new onerequestLoggerSessionsForService
(String serviceID) Request logger sessions for the specified servicevoid
restart()
restart logging sessions and publishing snapshotsvoid
setConnectionDictionary
(ConnectionDictionary dictionary) set the connection dictionaryvoid
setPublishingPeriod
(double period) Set the publishing periodvoid
start()
start logging sessions and publishing snapshotsvoid
stop()
stop logging sessions and publishing snapshots but publish any scheduled snapshotsprotected static boolean
testConnection
(Connection connection) Test whether the connection is good
-
Field Details
-
persistentStore
protected final xal.service.pvlogger.PersistentStore persistentStoredatabase store -
snapshotPublisher
protected final xal.service.pvlogger.SnapshotPublisher snapshotPublishersnapshot publisher -
connectionDictionary
connection dictionary -
loggerSessions
logger sessions keyed by channel group ID -
connection
current database connection
-
-
Constructor Details
-
PVLogger
Primary Constructor -
PVLogger
public PVLogger()Constructor
-
-
Method Details
-
getBrowsingInstance
get an instance for browsing the PV Logger data -
getLoggingInstance
get an instance for logging PV data to the database -
newLoggingConnectionDictionary
generate a new connection dictionary appropriate for logging -
newBrowsingConnectionDictionary
generate a new connection dictionary appropriate for browsing logged data -
getConnectionDictionary
get the connection dictionary -
setConnectionDictionary
set the connection dictionary -
getLoggerSession
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
Get all logger sessions managed by this PV Logger- Returns:
- the collection of logger sessions
-
removeAllLoggerSessions
public void removeAllLoggerSessions()remove all logger sessions -
removeLoggerSession
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
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
Request logger sessions for the specified service- Parameters:
serviceID
- service name- Returns:
- the list of logger sessions
- Throws:
SQLException
-
requestLoggerSession
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
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
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 restrictionstartTime
- The start time of the time rangeendTime
- 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
Fetch channel groups as an array of types- Returns:
- array of types corresponding to all of the channel groups
- Throws:
SQLException
-
fetchTypes
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
Get the channel group corresponding to the specified type.- Parameters:
type
- channel group type- Throws:
SQLException
-
getDatabaseConnection
get the current database connection creating it if necessary -
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
Test whether the connection is good- Parameters:
connection
- the connection to test- Returns:
- true if the connection is good and false if not
-
finalize
sql connections should be closed manually
-