Interface LogManager
-
- All Superinterfaces:
ADEPT2Service
public interface LogManager extends ADEPT2Service
A log manager is a service to record (i.e. log) information. It manages differentLog
s which are used to store different kinds of information. The structure of a log (which information is stored? which data type is used?) is determined by a schema. The log provides dedicated methods to write entries to and read entries from the log.The log manager is not necessarily a singular entity. Each log manager is assigned a single data source, i.e. if different logs should be kept in different data sources there's a log manager - containing the respective logs - for each one.
What must be considered here is that thequery(SessionToken, String, int)
method allows direct access to the logged data, so even efficient SQL joins between different log tables are possible. However, this is only true if the involved logs are stored in the same data source!Each log entry (or the entry of a complex column) is uniquely identified by an ID. These IDs are created from a sequence in ascending order. I.e. they allow a more fine-grained temporal ordering, since timestamps may sometimes be inadequate. Some DBMSs may not support sub-second precision, and while
System.currentTimeMillis()
may support millisecond precision it does often not support millisecond accuracy. I.e. logged entries with only a few milliseconds between them may receive the same timestamp.- Author:
- Patrick Schmidt
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
formatCondition(SessionToken session, Log log, String conditionFormat, Serializable... values)
Formats the given condition format string and values to an SQL condition that can e.g. be used in the WHERE clause ofquery(SessionToken, String, int)
orLog.read(SessionToken, String, String, int, String...)
.ExecutionHistory
getExecutionHistory()
Returns the execution history managed by this log manager.ResultSet
query(SessionToken session, String sqlQuery, int maxEntries)
Executes a user-defined SQL query on the data source of this log manager.-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, shutdown, start
-
-
-
-
Method Detail
-
getExecutionHistory
ExecutionHistory getExecutionHistory()
Returns the execution history managed by this log manager.- Returns:
- the execution history managed by this log manager
-
query
ResultSet query(SessionToken session, String sqlQuery, int maxEntries) throws SQLException
Executes a user-defined SQL query on the data source of this log manager. This allows e.g. efficient SQL joins between different log tables. The results are returned in aResultSet
. This method only returns the specified number of entries; all excess entries are silently dropped.The returned result set is disconnected, i.e. all its data is cached in memory and therefore doesn't require an open connection to the database. This is required because connections are not serialisable and this method is potentially called remotely.
TODO: explain how data is stored (table names, uuids stored as strings, etc.)
- Parameters:
session
- The session which is used to check for access rights on this method.sqlQuery
- the SQL query to be executedmaxEntries
- the maximum number of entries to return; the excess entries are silently dropped;0
disables this limit- Returns:
- a disconnected result set (i.e. all data is cached in memory)
- Throws:
SQLException
- if a database access error occurs
-
formatCondition
String formatCondition(SessionToken session, Log log, String conditionFormat, Serializable... values) throws DataSourceException
Formats the given condition format string and values to an SQL condition that can e.g. be used in the WHERE clause ofquery(SessionToken, String, int)
orLog.read(SessionToken, String, String, int, String...)
.{{c:[prefix.]<column name> <comparison operator>}} AND {c:[prefix.]<column name> <comparison operator>}}
TODO describe format- Parameters:
session
- The session which is used to check for access rights on this method.log
- The log for which to create the WHERE clause.conditionFormat
- the condition format stringvalues
- the values to be filled in the condition format string; the number of values must match the condition format string- Returns:
- an SQL condition formatted from the given column, comparison operator and value
- Throws:
DataSourceException
- if an unrecoverable error occurs while accessing the data source
-
-