|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.sns.tools.pvlogger.SqlStateStore
SqlStateStore is an implementation of StateStore that provides persistent storage of machine state in a SQL database.
| Field Summary | |
protected java.sql.Connection |
_connection
|
protected DatabaseAdaptor |
_databaseAdaptor
|
protected java.sql.PreparedStatement |
CHANNEL_SNAPSHOT_INSERT
|
protected java.sql.PreparedStatement |
CHANNEL_SNAPSHOT_QUERY_BY_MACHINE_SNAPSHOT
|
protected static java.lang.String |
MACHINE_SNAPSHOT_COMMENT_COL
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_INSERT
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_NEXT_PKEY
|
protected static java.lang.String |
MACHINE_SNAPSHOT_PKEY
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_QUERY
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_QUERY_BY_PKEY
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_QUERY_BY_TIMERANGE
|
protected java.sql.PreparedStatement |
MACHINE_SNAPSHOT_QUERY_BY_TYPE_TIMERANGE
|
protected static java.lang.String |
MACHINE_SNAPSHOT_SEQ
|
protected static java.lang.String |
MACHINE_SNAPSHOT_TABLE
|
protected static java.lang.String |
MACHINE_SNAPSHOT_TIME_COL
|
protected static java.lang.String |
MACHINE_SNAPSHOT_TYPE_COL
|
protected static java.lang.String |
PV_PKEY
|
protected java.sql.PreparedStatement |
PV_QUERY
|
protected static java.lang.String |
PV_SNAPSHOT_MACHINE_SNAPSHOT_COL
|
protected static java.lang.String |
PV_SNAPSHOT_PV_COL
|
protected static java.lang.String |
PV_SNAPSHOT_SEVERITY_COL
|
protected static java.lang.String |
PV_SNAPSHOT_STATUS_COL
|
protected static java.lang.String |
PV_SNAPSHOT_TABLE
|
protected static java.lang.String |
PV_SNAPSHOT_TIMESTAMP_COL
|
protected static java.lang.String |
PV_SNAPSHOT_VALUE_COL
|
protected static java.lang.String |
PV_TABLE
|
protected static java.lang.String |
SGNL_VALUE_ARRAY_TYPE
|
protected static java.lang.String |
SNAPSHOT_TYPE_DESC_COL
|
protected static java.lang.String |
SNAPSHOT_TYPE_PERIOD_COL
|
protected static java.lang.String |
SNAPSHOT_TYPE_PKEY
|
protected static java.lang.String |
SNAPSHOT_TYPE_PV_NAME_PKEY
|
protected static java.lang.String |
SNAPSHOT_TYPE_PV_PV_PKEY
|
protected java.sql.PreparedStatement |
SNAPSHOT_TYPE_PV_QUERY_BY_NAME
|
protected static java.lang.String |
SNAPSHOT_TYPE_PV_TABLE
|
protected java.sql.PreparedStatement |
SNAPSHOT_TYPE_QUERY
|
protected java.sql.PreparedStatement |
SNAPSHOT_TYPE_QUERY_BY_NAME
|
protected static java.lang.String |
SNAPSHOT_TYPE_TABLE
|
| Constructor Summary | |
SqlStateStore(ConnectionDictionary dictionary)
Construct a SqlStateStore and connect it to a database specified by the url and with user and password access. |
|
SqlStateStore(DatabaseAdaptor adaptor,
java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
Construct a SqlStateStore and connect it to a database specified by the url and with user and password access. |
|
SqlStateStore(java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
Construct a SqlStateStore and connect it to a database specified by the url and with user and password access. |
|
| Method Summary | |
protected void |
connect(java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
Create a database connection to the persistent data storage. |
protected ChannelSnapshot[] |
fetchChannelSnapshotsForMachine(long id)
Fetch the channel snapshots associated with a machine snapshot given by the machine snapshot's unique identifier. |
ChannelGroup |
fetchGroup(java.lang.String type)
Fetch a channel group for the specified logger type |
MachineSnapshot |
fetchMachineSnapshot(long id)
Fetch the machine snapshot associated with the unique machine snapshot identifier. |
protected MachineSnapshot[] |
fetchMachineSnapshotsInRange(java.util.Date startTime,
java.util.Date endTime)
Fetch the machine snapshots within the specified time range. |
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 an array of logger types |
protected java.sql.PreparedStatement |
getChannelSnapshotInsertStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getChannelSnapshotQueryByMachineSnapshotStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotInsertStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotNextPrimaryKeyStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotQueryByPkeyStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotQueryByTimerangeStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotQueryByTypeTimerangeStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getMachineSnapshotQueryStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getPvQueryStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getSnapshotTypePvQueryByNameStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getSnapshotTypeQueryByNameStatement()
Create the prepared statement if it does not already exist. |
protected java.sql.PreparedStatement |
getSnapshotTypeQueryStatement()
Create the prepared statement if it does not already exist. |
MachineSnapshot |
loadChannelSnapshotsInto(MachineSnapshot machineSnapshot)
Fetch the channel snapshots from the data source and populate the machine snapshot |
void |
publish(ChannelSnapshot snapshot,
long machineId)
Publish the channel snapshot and associate it with the machine snapshot given by the machine snapshop id. |
void |
publish(MachineSnapshot machineSnapshot)
Publish the machine snapshot. |
protected double[] |
toDoubleArray(java.lang.Number[] numbers)
Convert an array of numbers to an array of double values. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final java.lang.String PV_TABLE
protected static final java.lang.String MACHINE_SNAPSHOT_TABLE
protected static final java.lang.String PV_SNAPSHOT_TABLE
protected static final java.lang.String SNAPSHOT_TYPE_TABLE
protected static final java.lang.String SNAPSHOT_TYPE_PV_TABLE
protected static final java.lang.String SGNL_VALUE_ARRAY_TYPE
protected static final java.lang.String PV_PKEY
protected static final java.lang.String PV_SNAPSHOT_MACHINE_SNAPSHOT_COL
protected static final java.lang.String PV_SNAPSHOT_PV_COL
protected static final java.lang.String PV_SNAPSHOT_TIMESTAMP_COL
protected static final java.lang.String PV_SNAPSHOT_VALUE_COL
protected static final java.lang.String PV_SNAPSHOT_STATUS_COL
protected static final java.lang.String PV_SNAPSHOT_SEVERITY_COL
protected static final java.lang.String MACHINE_SNAPSHOT_PKEY
protected static final java.lang.String MACHINE_SNAPSHOT_TIME_COL
protected static final java.lang.String MACHINE_SNAPSHOT_TYPE_COL
protected static final java.lang.String MACHINE_SNAPSHOT_COMMENT_COL
protected static final java.lang.String SNAPSHOT_TYPE_PV_NAME_PKEY
protected static final java.lang.String SNAPSHOT_TYPE_PV_PV_PKEY
protected static final java.lang.String SNAPSHOT_TYPE_PKEY
protected static final java.lang.String SNAPSHOT_TYPE_DESC_COL
protected static final java.lang.String SNAPSHOT_TYPE_PERIOD_COL
protected static final java.lang.String MACHINE_SNAPSHOT_SEQ
protected DatabaseAdaptor _databaseAdaptor
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_NEXT_PKEY
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_INSERT
protected java.sql.PreparedStatement CHANNEL_SNAPSHOT_INSERT
protected java.sql.PreparedStatement PV_QUERY
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_QUERY
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_QUERY_BY_PKEY
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_QUERY_BY_TYPE_TIMERANGE
protected java.sql.PreparedStatement MACHINE_SNAPSHOT_QUERY_BY_TIMERANGE
protected java.sql.PreparedStatement CHANNEL_SNAPSHOT_QUERY_BY_MACHINE_SNAPSHOT
protected java.sql.PreparedStatement SNAPSHOT_TYPE_QUERY
protected java.sql.PreparedStatement SNAPSHOT_TYPE_QUERY_BY_NAME
protected java.sql.PreparedStatement SNAPSHOT_TYPE_PV_QUERY_BY_NAME
protected java.sql.Connection _connection
| Constructor Detail |
public SqlStateStore(DatabaseAdaptor adaptor,
java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
throws StateStoreException
adaptor - The database adaptorurlSpec - The url of the databaseuser - The user to loginpassword - The user's password for login
StateStoreException - if a SQL exception is thrown
public SqlStateStore(java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
throws StateStoreException
urlSpec - The url of the databaseuser - The user to loginpassword - The user's password for login
StateStoreException - if a SQL exception is thrown
public SqlStateStore(ConnectionDictionary dictionary)
throws StateStoreException
dictionary - The dictionary containing the connection information
StateStoreException - if a SQL exception is thrown| Method Detail |
protected void connect(java.lang.String urlSpec,
java.lang.String user,
java.lang.String password)
throws StateStoreException
urlSpec - The url of the databaseuser - The user to loginpassword - The user's password for login
StateStoreException - if a SQL exception is thrown
protected java.sql.PreparedStatement getMachineSnapshotNextPrimaryKeyStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getMachineSnapshotInsertStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getChannelSnapshotInsertStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getPvQueryStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getMachineSnapshotQueryStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getMachineSnapshotQueryByPkeyStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getMachineSnapshotQueryByTypeTimerangeStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getMachineSnapshotQueryByTimerangeStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getChannelSnapshotQueryByMachineSnapshotStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getSnapshotTypeQueryStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getSnapshotTypeQueryByNameStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
protected java.sql.PreparedStatement getSnapshotTypePvQueryByNameStatement()
throws java.sql.SQLException
java.sql.SQLException - if an exception occurs during a SQL evaluation
public void publish(ChannelSnapshot snapshot,
long machineId)
throws StateStoreException
publish in interface StateStoresnapshot - The channel snapshot to publishmachineId - The unique id of the associated machine snapshot
StateStoreException - if a SQL exception is thrown
public void publish(MachineSnapshot machineSnapshot)
throws StateStoreException
publish in interface StateStoremachineSnapshot - The machine snapshot to publish.
StateStoreException - if a SQL exception is thrown
public java.lang.String[] fetchTypes()
throws StateStoreException
fetchTypes in interface StateStoreStateStoreException - if a SQL exception is thrown
public ChannelGroup fetchGroup(java.lang.String type)
throws StateStoreException
fetchGroup in interface StateStoretype - the logger type
StateStoreException - if a SQL exception is thrown
public MachineSnapshot fetchMachineSnapshot(long id)
throws StateStoreException
fetchMachineSnapshot in interface StateStoreid - The unique machine snapshot identifier
StateStoreException - if a SQL exception is thrown
public MachineSnapshot loadChannelSnapshotsInto(MachineSnapshot machineSnapshot)
throws StateStoreException
loadChannelSnapshotsInto in interface StateStoremachineSnapshot - The machine snapshot for which to fetch the channel snapshots and load them
StateStoreException
public MachineSnapshot[] fetchMachineSnapshotsInRange(java.lang.String type,
java.util.Date startTime,
java.util.Date endTime)
throws StateStoreException
fetchMachineSnapshotsInRange in interface StateStoretype - 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
StateStoreException - if a SQL exception is thrown
protected MachineSnapshot[] fetchMachineSnapshotsInRange(java.util.Date startTime,
java.util.Date endTime)
throws StateStoreException
startTime - The start time of the time rangeendTime - The end time of the time range
StateStoreException - if a SQL exception is thrown
protected ChannelSnapshot[] fetchChannelSnapshotsForMachine(long id)
throws StateStoreException
id - The unique machine identifier.
StateStoreException - if a SQL exception is thrownprotected double[] toDoubleArray(java.lang.Number[] numbers)
numbers - The array of numbers to convert
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||