Class MemoryBackedHistorian
- java.lang.Object
-
- com.inductiveautomation.gateway.tsdb.historians.MemoryBackedHistorian
-
- All Implemented Interfaces:
Historian,StorageSession,java.lang.AutoCloseable
public class MemoryBackedHistorian extends java.lang.Object implements Historian, StorageSession
A tag historian that stores data in memory. Supports max age and max size constraints, on the historian, and per-tag.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMemoryBackedHistorian.Tag
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.gateway.tsdb.api.Historian
QUALITY_NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description MemoryBackedHistorian()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddNode(MemoryBackedHistorian.Tag node)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.voidclose()StorageSessioncreateStorageSession()Used to store values to the historian.voiddelete(java.util.List<java.lang.String> paths)Deletes the tags and all data for the specified paths.<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.java.lang.LonggetTotalDataCount()voidinitialize(PropertySet properties)protected voidperformTimePruning(boolean force)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.voidregister(java.lang.String tag, PropertySet properties)Provides information about a path.voidshutdown()voidstore(java.lang.String tag, java.lang.Object value, int quality, long timestamp)Stores a value for the given tag path.voidunregister(java.lang.String tag)
-
-
-
Method Detail
-
initialize
public void initialize(PropertySet properties) throws java.lang.Exception
- Specified by:
initializein interfaceHistorian- Throws:
java.lang.Exception
-
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 interfaceHistorian
-
getTotalDataCount
public java.lang.Long getTotalDataCount()
-
register
public void register(java.lang.String tag, PropertySet properties)Description 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.
-
unregister
public void unregister(java.lang.String tag)
- Specified by:
unregisterin interfaceHistorian
-
store
public void store(java.lang.String tag, java.lang.Object value, int quality, long timestamp) throws java.lang.ExceptionDescription copied from interface:StorageSessionStores a value for the given tag path.- Specified by:
storein interfaceStorageSession- Throws:
java.lang.Exception
-
performTimePruning
protected void performTimePruning(boolean force)
-
browse
public 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.
-
delete
public 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().
-
query
public 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.
-
addNode
protected void addNode(MemoryBackedHistorian.Tag node)
-
getStorageStatus
public 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 interfaceHistorian
-
getQueryStatus
public 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 interfaceHistorian
-
createStorageSession
public StorageSession createStorageSession()
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 interfaceHistorian
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.io.IOException
-
-