public class PVLogger
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.sql.Connection |
_connection
current database connection
|
protected ConnectionDictionary |
_connectionDictionary
connection dictionary
|
protected java.util.Map<java.lang.String,LoggerSession> |
LOGGER_SESSIONS
logger sessions keyed by channel group ID
|
protected xal.service.pvlogger.PersistentStore |
PERSISTENT_STORE
database store
|
protected xal.service.pvlogger.SnapshotPublisher |
SNAPSHOT_PUBLISHER
snapshot publisher
|
Constructor and Description |
---|
PVLogger()
Constructor
|
PVLogger(ConnectionDictionary connectionDictionary)
Primary Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
closeConnection()
close the database connection if a connection exists and set the connection to null
|
MachineSnapshot |
fetchMachineSnapshot(long snapshotID)
Fetch the machine snapshot corresponding to the specified snasphot ID
|
MachineSnapshot[] |
fetchMachineSnapshotsInRange(java.lang.String type,
java.util.Date startTime,
java.util.Date endTime)
Fetch the machine snapshots within the specified time range.
|
java.lang.String[] |
fetchTypes()
Fetch channel groups as an array of types
|
java.lang.String[] |
fetchTypes(java.lang.String serviceID)
Fetch the channel groups associated with the service ID as an array of types
|
protected void |
finalize()
sql connections should be closed manually
|
static PVLogger |
getBrowsingInstance()
get an instance for browsing the PV Logger data
|
ChannelGroup |
getChannelGroup(java.lang.String type)
Get the channel group corresponding to the specified type.
|
ConnectionDictionary |
getConnectionDictionary()
get the connection dictionary
|
protected java.sql.Connection |
getDatabaseConnection()
get the current database connection creating it if necessary
|
LoggerSession |
getLoggerSession(java.lang.String groupID)
Get the logger session with the specified groupID
|
java.util.Collection<LoggerSession> |
getLoggerSessions()
Get all logger sessions managed by this PV Logger
|
static PVLogger |
getLoggingInstance()
get an instance for logging PV data to the database
|
protected java.sql.Connection |
getNewDatabaseConnection()
make a new database connection
|
double |
getPublishingPeriod()
Get the publishing period
|
boolean |
hasLoggerSession(java.lang.String groupID)
Determine if a logger session exists for the specified group
|
boolean |
isPublishing()
determine if the snapshot publisher is publishing snapshots periodically
|
MachineSnapshot |
loadChannelSnapshotsInto(MachineSnapshot machineSnapshot)
Fetch the channel snapshots from the data source and populate the machine snapshot
|
static ConnectionDictionary |
newBrowsingConnectionDictionary()
generate a new connection dictionary appropriate for browsing logged data
|
static ConnectionDictionary |
newLoggingConnectionDictionary()
generate a new connection dictionary appropriate for logging
|
void |
publishSnapshots()
publish any scheduled snapshots remaining in the queue
|
LoggerSession |
reloadLoggerSession(java.lang.String groupID)
Reload the logger session for the specified channel group
|
void |
removeAllLoggerSessions()
remove all logger sessions
|
void |
removeLoggerSession(java.lang.String groupID)
Stop the logger session with the specified group ID and remove it from the PV Logger
|
java.util.List<LoggerSession> |
requestEnabledLoggerSessionsForService(java.lang.String serviceID)
Request enabled logger sessions for the specified service
|
LoggerSession |
requestLoggerSession(java.lang.String groupID)
If a logger session already exists for the channel group, get it otherwise create a new one
|
java.util.List<LoggerSession> |
requestLoggerSessionsForService(java.lang.String serviceID)
Request logger sessions for the specified service
|
void |
restart()
restart logging sessions and publishing snapshots
|
void |
setConnectionDictionary(ConnectionDictionary dictionary)
set the connection dictionary
|
void |
setPublishingPeriod(double period)
Set the publishing period
|
void |
start()
start logging sessions and publishing snapshots
|
void |
stop()
stop logging sessions and publishing snapshots but publish any scheduled snapshots
|
protected static boolean |
testConnection(java.sql.Connection connection)
Test whether the connection is good
|
protected final xal.service.pvlogger.PersistentStore PERSISTENT_STORE
protected final xal.service.pvlogger.SnapshotPublisher SNAPSHOT_PUBLISHER
protected ConnectionDictionary _connectionDictionary
protected java.util.Map<java.lang.String,LoggerSession> LOGGER_SESSIONS
protected java.sql.Connection _connection
public PVLogger(ConnectionDictionary connectionDictionary)
public PVLogger()
public static PVLogger getBrowsingInstance()
public static PVLogger getLoggingInstance()
public static ConnectionDictionary newLoggingConnectionDictionary()
public static ConnectionDictionary newBrowsingConnectionDictionary()
public ConnectionDictionary getConnectionDictionary()
public void setConnectionDictionary(ConnectionDictionary dictionary)
public LoggerSession getLoggerSession(java.lang.String groupID)
groupID
- the channel group IDpublic java.util.Collection<LoggerSession> getLoggerSessions()
public void removeAllLoggerSessions()
public void removeLoggerSession(java.lang.String groupID)
groupID
- group ID of the logger session to removepublic boolean hasLoggerSession(java.lang.String groupID)
groupID
- group ID of the logger session for which to lookpublic java.util.List<LoggerSession> requestEnabledLoggerSessionsForService(java.lang.String serviceID) throws java.sql.SQLException
serviceID
- service namejava.sql.SQLException
public java.util.List<LoggerSession> requestLoggerSessionsForService(java.lang.String serviceID) throws java.sql.SQLException
serviceID
- service namejava.sql.SQLException
public LoggerSession requestLoggerSession(java.lang.String groupID) throws java.sql.SQLException
groupID
- the name of the channel groupjava.sql.SQLException
public LoggerSession reloadLoggerSession(java.lang.String groupID) throws java.sql.SQLException
groupID
- the name of the channel groupjava.sql.SQLException
public boolean isPublishing()
public void start()
public void restart()
public void stop()
public void publishSnapshots()
public double getPublishingPeriod()
public void setPublishingPeriod(double period)
period
- publishing period in secondspublic MachineSnapshot fetchMachineSnapshot(long snapshotID) throws java.sql.SQLException
snapshotID
- machine snaspshot IDjava.sql.SQLException
public MachineSnapshot[] fetchMachineSnapshotsInRange(java.lang.String type, java.util.Date startTime, java.util.Date endTime) throws java.sql.SQLException
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 rangejava.sql.SQLException
public MachineSnapshot loadChannelSnapshotsInto(MachineSnapshot machineSnapshot) throws java.sql.SQLException
machineSnapshot
- The machine snapshot for which to fetch the channel snapshots and load themjava.sql.SQLException
public java.lang.String[] fetchTypes() throws java.sql.SQLException
java.sql.SQLException
public java.lang.String[] fetchTypes(java.lang.String serviceID) throws java.sql.SQLException
serviceID
- service ID of groups to fetchjava.sql.SQLException
public ChannelGroup getChannelGroup(java.lang.String type) throws java.sql.SQLException
type
- channel group typejava.sql.SQLException
protected java.sql.Connection getDatabaseConnection()
protected java.sql.Connection getNewDatabaseConnection()
public void closeConnection()
protected static boolean testConnection(java.sql.Connection connection)
connection
- the connection to testprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable