Class SQLiteHistorian
- java.lang.Object
- 
- com.inductiveautomation.gateway.tsdb.historians.SQLiteHistorian
 
- 
- All Implemented Interfaces:
- Historian,- HistorianSyncSource,- AnnotationQueryProvider,- AnnotationStorageProvider
 
 public class SQLiteHistorian extends java.lang.Object implements Historian, HistorianSyncSource, AnnotationQueryProvider, AnnotationStorageProvider Created by colby.clegg on 3/18/2016.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classSQLiteHistorian.DBLockClosableprotected classSQLiteHistorian.Queryprotected classSQLiteHistorian.SQLiteStorageSessionprotected static classSQLiteHistorian.Tablesprotected static classSQLiteHistorian.Tag
 - 
Field SummaryFields Modifier and Type Field Description static Property<java.lang.String>FILE_PATH- 
Fields inherited from interface com.inductiveautomation.gateway.tsdb.api.HistorianQUALITY_NOT_FOUND
 
- 
 - 
Constructor SummaryConstructors Constructor Description SQLiteHistorian()SQLiteHistorian(java.lang.String filePath)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>browse(java.util.Optional<java.lang.String> filter)Returns a list of paths with data stored, optionally matching a filter.StorageSessioncreateStorageSession()Used to store values to the historian.protected SQLiteHistorian.TagcreateTag(java.lang.String tagPath)protected SQLiteHistorian.TagcreateTag(java.sql.Connection c, java.lang.String tagPath)voiddelete(java.util.List<java.lang.String> paths)Deletes the tags and all data for the specified paths.voidexecuteMaintenance()protected java.sql.ConnectiongetConnection()javax.sql.DataSourcegetDatasource()Returns the datasource used for storing syncable data.<T> TgetProperty(Property<T> prop)Returns the configured or status property requested, or the default value if no further info is available.StatusgetQueryStatus()Returns the status of the storage system.StatusgetStorageStatus()Returns the status of the storage system.protected intgetStorageSyncId()HistoricalDatagetSyncableAnnotations(long syncId)intgetSyncableCount(long syncId)Returns the number of data points that could be synchronized from the given point.HistoricalDatagetSyncableRetiredTags(long syncId)HistoricalDatagetSyncableTagData(long syncId)longgetSyncIdTimestamp(long syncId)Returns the timestamp of the start of the sync group.protected longgetTotalDataCount()booleanhasSyncableData(long syncId)Returns whether there is data available to sync based on the provided id.voidinitDriver()voidinitialize(PropertySet properties)protected voidinitializeSync()protected SQLiteHistorian.DBLockClosablelockDB()protected voidnewSyncId()protected booleanpropertiesDiffer(PropertySet a, PropertySet b)QueryResultquery(java.util.List<java.lang.String> tags, long startTime, long endTime, boolean includeBounding)Queries the values for the given paths over the specified span of time.java.util.List<Annotation>queryAnnotations(java.util.List<QualifiedPath> paths, java.util.Date start, java.util.Date end, TypeFilter filter, java.lang.String queryId)voidregister(java.lang.String tagPath, PropertySet properties)Provides information about a path.voidshutdown()java.util.List<QualifiedValue>storeAnnotations(java.util.List<Annotation> annotations)java.util.List<HistoricalData>sync(long syncId)This returns a set of data- it's up to the implementation to decide what makes sense.QualifiedPathtransformToHistoricalPath(java.lang.String tagPath)voidunregister(java.lang.String tagPath)
 
- 
- 
- 
Field Detail- 
FILE_PATHpublic static final Property<java.lang.String> FILE_PATH 
 
- 
 - 
Method Detail- 
getProperty@Nullable public <T> T getProperty(Property<T> prop) Description copied from interface:HistorianReturns the configured or status property requested, or the default value if no further info is available. Most of these properties are defined in HistorianProperties.- Specified by:
- getPropertyin interface- Historian
 
 - 
lockDBprotected SQLiteHistorian.DBLockClosable lockDB() 
 - 
getTotalDataCountprotected long getTotalDataCount() 
 - 
getQueryStatuspublic Status getQueryStatus() Description copied from interface:HistorianReturns the status of the storage system. If the system does not support querying, NotAvailable will be returned.- Specified by:
- getQueryStatusin interface- Historian
 
 - 
getStorageStatuspublic Status getStorageStatus() Description copied from interface:HistorianReturns the status of the storage system. If the system does not support storage, NotAvailable will be returned. If this is the case, calls to createStorageSession will fail.- Specified by:
- getStorageStatusin interface- Historian
 
 - 
getConnectionprotected java.sql.Connection getConnection() throws java.sql.SQLException- Throws:
- java.sql.SQLException
 
 - 
initDriverpublic void initDriver() throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
initializepublic void initialize(PropertySet properties) throws java.lang.Exception - Specified by:
- initializein interface- Historian
- Throws:
- java.lang.Exception
 
 - 
getDatasourcepublic javax.sql.DataSource getDatasource() Description copied from interface:HistorianSyncSourceReturns the datasource used for storing syncable data.- Specified by:
- getDatasourcein interface- HistorianSyncSource
 
 - 
propertiesDifferprotected boolean propertiesDiffer(PropertySet a, PropertySet b) 
 - 
registerpublic void register(java.lang.String tagPath, PropertySet properties) throws java.lang.ExceptionDescription copied from interface:HistorianProvides information about a path. May be called before or after values have been stored, will replace any previous information stored for a path. The property values are usually defined in HistorianProperties.
 - 
unregisterpublic void unregister(java.lang.String tagPath) throws java.lang.Exception- Specified by:
- unregisterin interface- Historian
- Throws:
- java.lang.Exception
 
 - 
createTagprotected SQLiteHistorian.Tag createTag(java.sql.Connection c, java.lang.String tagPath) throws java.lang.Exception - Throws:
- java.lang.Exception
 
 - 
createTagprotected SQLiteHistorian.Tag createTag(java.lang.String tagPath) throws java.lang.Exception - Throws:
- java.lang.Exception
 
 - 
createStorageSessionpublic StorageSession createStorageSession() throws java.lang.Exception Description copied from interface:HistorianUsed to store values to the historian. Should be used for the immediate set of values and then closed. It should not be held open for longer than necessary.It implements AutoClosable, and should often be used in a try-with-resources block, such as: 
 try(StorageSession s = historian.createStorageSession()){ s.store... }Important: Not every historian will support storage, some are read-only. This can be checked by calling getStorageStatus() and checking the return for "NotSupported". - Specified by:
- createStorageSessionin interface- Historian
- Throws:
- java.lang.Exception
 
 - 
browsepublic java.util.List<java.lang.String> browse(java.util.Optional<java.lang.String> filter) Description copied from interface:HistorianReturns a list of paths with data stored, optionally matching a filter.
 - 
deletepublic void delete(java.util.List<java.lang.String> paths) Description copied from interface:HistorianDeletes the tags and all data for the specified paths. Paths may be wildcards using "*". Only expected to work if the historian supports storage, as indicated by getStorageStatus().
 - 
querypublic QueryResult query(java.util.List<java.lang.String> tags, long startTime, long endTime, boolean includeBounding) Description copied from interface:HistorianQueries the values for the given paths over the specified span of time. The implementation will conform to the following rules:
 - If endTime is less than start time, results MAY be provided latest first. If that is not possible, the parameters will be swapped and values returned as normal.
- The result will have a unique PathInfo item for EACH of the paths passed in. If a path is specified multiple times, it will be returned multiple times.
- If a path is not valid, the query result will return ONE DataPoint for the query start time with a quality of 404 (NOT FOUND)
- The timestamps for a given path will be ascending, though between paths they may not be.
 
 - 
storeAnnotationspublic java.util.List<QualifiedValue> storeAnnotations(java.util.List<Annotation> annotations) - Specified by:
- storeAnnotationsin interface- AnnotationStorageProvider
 
 - 
queryAnnotationspublic java.util.List<Annotation> queryAnnotations(java.util.List<QualifiedPath> paths, java.util.Date start, java.util.Date end, TypeFilter filter, java.lang.String queryId) - Specified by:
- queryAnnotationsin interface- AnnotationQueryProvider
 
 - 
executeMaintenancepublic void executeMaintenance() 
 - 
initializeSyncprotected void initializeSync() throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
hasSyncableDatapublic boolean hasSyncableData(long syncId) Description copied from interface:HistorianSyncSourceReturns whether there is data available to sync based on the provided id.- Specified by:
- hasSyncableDatain interface- HistorianSyncSource
 
 - 
syncpublic java.util.List<HistoricalData> sync(long syncId) Description copied from interface:HistorianSyncSourceThis returns a set of data- it's up to the implementation to decide what makes sense. If the caller wants more data, it can just call again.- Specified by:
- syncin interface- HistorianSyncSource
- Parameters:
- syncId- if 0, returns next set of available data based on last query. Otherwise, starts at the given time period.
 
 - 
getSyncableTagDatapublic HistoricalData getSyncableTagData(long syncId) 
 - 
getSyncableAnnotationspublic HistoricalData getSyncableAnnotations(long syncId) 
 - 
getSyncableRetiredTagspublic HistoricalData getSyncableRetiredTags(long syncId) 
 - 
transformToHistoricalPathpublic QualifiedPath transformToHistoricalPath(java.lang.String tagPath) 
 - 
newSyncIdprotected void newSyncId() 
 - 
getStorageSyncIdprotected int getStorageSyncId() 
 - 
getSyncableCountpublic int getSyncableCount(long syncId) Description copied from interface:HistorianSyncSourceReturns the number of data points that could be synchronized from the given point.- Specified by:
- getSyncableCountin interface- HistorianSyncSource
 
 - 
getSyncIdTimestamppublic long getSyncIdTimestamp(long syncId) Description copied from interface:HistorianSyncSourceReturns the timestamp of the start of the sync group.- Specified by:
- getSyncIdTimestampin interface- HistorianSyncSource
 
 
- 
 
-