Class AbstractDatasourceSink<T extends PersistentData>
java.lang.Object
com.inductiveautomation.ignition.gateway.storeforward.sinks.AbstractSink<T>
com.inductiveautomation.ignition.gateway.storeforward.sinks.AbstractDatasourceSink<T>
- Type Parameters:
T
- the type ofPersistentData
that this sink can handle
- All Implemented Interfaces:
DataConsumer<T>
,DataSink<T>
- Direct Known Subclasses:
HistoricalRecordSink
An abstract base class for sinks that use a data source to store data.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.inductiveautomation.ignition.gateway.storeforward.sinks.AbstractSink
AbstractSink.SinkWriter
-
Field Summary
FieldsFields inherited from class com.inductiveautomation.ignition.gateway.storeforward.sinks.AbstractSink
batchSize, faultedTimestamp, faultError, flavor, lastInitAttempt, name, RETRY_TIME, status, storageId, storeMetric
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractDatasourceSink
(GatewayContext context, StorageId storageId, PersistentFlavor<T> flavor, int batchSize) The default constructor for creating instances ofAbstractDatasourceSink
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Datasource
Returns theDatasource
for this datasource sink that can be used for data storage.Returns the datasource name for this datasource sink.protected QueryCache
Returns theQueryCache
for the Datasource belonging to this datasource sink.boolean
Determines whether the data sink is currently accepting data.protected boolean
protected void
onStorageFailure
(List<T> data, Exception e) protected void
runFirstTimeChecks
(Connection conn) Runs a series of checks on the connection before allowing it to be used for storing data.void
shutdown()
Shuts down the data sink.void
startup()
Starts up the data sink.void
Stores a list of persistent data.protected abstract void
storeToConnection
(SRConnection conn, List<T> data) Stores the given data to the specified connection.protected void
storeToDatasource
(Datasource ds, List<T> data) Stores the list of supported TPersistentData
to the database.protected void
Uninitializes the sink.protected boolean
Returns whether JDBC batching should be used when inserting data.Methods inherited from class com.inductiveautomation.ignition.gateway.storeforward.sinks.AbstractSink
createLogger, getContext, getFaultReason, getInfo, getLogger, getMetricPrefix, getName, getStorageId, getSupportedFlavor, getTypeDescription, getWriter, initialize, isFaulted, isInitialized, isStarted, markStoreMetric, maybeInit, onException, toString, validateFlavor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.gateway.storeforward.DataConsumer
storeData
-
Field Details
-
datasourceName
-
queryCache
-
-
Constructor Details
-
AbstractDatasourceSink
protected AbstractDatasourceSink(GatewayContext context, StorageId storageId, PersistentFlavor<T> flavor, int batchSize) The default constructor for creating instances ofAbstractDatasourceSink
.- Parameters:
context
- theGatewayContext
used for operations within the sinkstorageId
- the storage id used for determining which datasource to store data toflavor
- thePersistentFlavor
that defines the type of data that this sink will writebatchSize
- the number of data that should be written in each batch
-
-
Method Details
-
startup
public void startup()Description copied from interface:DataSink
Starts up the data sink.- Specified by:
startup
in interfaceDataSink<T extends PersistentData>
- Overrides:
startup
in classAbstractSink<T extends PersistentData>
-
shutdown
public void shutdown()Description copied from interface:DataSink
Shuts down the data sink.- Specified by:
shutdown
in interfaceDataSink<T extends PersistentData>
- Overrides:
shutdown
in classAbstractSink<T extends PersistentData>
-
uninitialize
protected void uninitialize()Description copied from class:AbstractSink
Uninitializes the sink.- Overrides:
uninitialize
in classAbstractSink<T extends PersistentData>
-
isAccepting
public boolean isAccepting()Description copied from interface:DataSink
Determines whether the data sink is currently accepting data.- Specified by:
isAccepting
in interfaceDataSink<T extends PersistentData>
- Overrides:
isAccepting
in classAbstractSink<T extends PersistentData>
- Returns:
- true if the data sink is accepting data, false otherwise
-
storeData
Description copied from interface:DataConsumer
Stores a list of persistent data.- Parameters:
data
- The data to be stored- Throws:
DataStorageException
- if an error occurs while storing data
-
isDatasourceAvailable
protected boolean isDatasourceAvailable() -
getDatasourceName
Returns the datasource name for this datasource sink.- Returns:
- the current datasource name for the datasource sink
-
getDatasource
Returns theDatasource
for this datasource sink that can be used for data storage.- Returns:
- the datasource pertaining to this datasource sink
-
useBatching
protected boolean useBatching()Returns whether JDBC batching should be used when inserting data.- Returns:
- the flag indicating whether batching should be used
-
getQueryCache
Returns theQueryCache
for the Datasource belonging to this datasource sink.- Returns:
- the datasource query cache
-
storeToDatasource
Stores the list of supported TPersistentData
to the database. First, batching is done, and then the operation is handed off tostoreToConnection(SRConnection, List)
A commit occurs once all batches execute. If a failure occurs, then the transaction is rolled back.
- Parameters:
ds
- the datasource to store persistent data todata
- the list of persistent data to store- Throws:
DataStorageException
- if an error occurs while storing data
-
storeToConnection
Stores the given data to the specified connection.- Parameters:
conn
- the connection to store the data todata
- the data to be stored- Throws:
Exception
- if there is an error storing the data
-
runFirstTimeChecks
Runs a series of checks on the connection before allowing it to be used for storing data. This includes checking whether the connection supports batch updates, and logging a warning if it does not.- Parameters:
conn
- the connection to check- Throws:
SQLException
- if there is an error while running the checks
-
onStorageFailure
- Throws:
DataStorageException
-