Class DataCollectorFactory
DataCollector
instances.
This singleton factory provides methods for creating, retrieving, and managing data collectors
associated with storage engines. It supports different collection strategies based on the
specified CollectionMode
:
- MANUAL - Collects only the latest values when explicitly requested
- STREAMING - Automatically collects all values at regular intervals
The factory maintains a registry of active collectors and provides thread pools for executing collection operations and scheduling periodic tasks. It ensures that only one collector exists per storage engine and collector ID combination.
This class uses a thread-safe implementation to handle concurrent access and provides proper resource management through shutdown operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Base abstract class for data collector implementations that provides common functionality for both manual and streaming collection modes.protected static class
Default implementation of theSnapshotProcessor
interface that forwards collected data directly to the storage engine.protected class
Data collector implementation for theCollectionMode.MANUAL
mode.protected class
Base abstract class for data collector implementations that provides common functionality for both manual and streaming collection modes. -
Method Summary
Modifier and TypeMethodDescriptionstatic DataCollectorFactory
Gets the singleton instance of the factory.getOrCreateCollector
(StorageEngine storageEngine, CollectorId collectorId) Creates or retrieves a data collector with the default snapshot processor.getOrCreateCollector
(StorageEngine storageEngine, CollectorId collectorId, SnapshotProcessor dataProcessor) Creates or retrieves a data collector with a custom snapshot processor.void
removeCollectors
(StorageEngine storageEngine) Removes all collectors associated with the specified storage engine.
-
Method Details
-
getInstance
Gets the singleton instance of the factory.If the instance doesn't exist yet, it is created in a thread-safe manner.
- Returns:
- The singleton instance of
DataCollectorFactory
-
getOrCreateCollector
Creates or retrieves a data collector with the default snapshot processor.This method creates a storage session with the default strategy of forwarding collected data to the historian interface when appropriate.
- Parameters:
storageEngine
- The storage engine to associate with the collectorcollectorId
- The identifier for the collector, including its collection mode- Returns:
- A
DataCollector
instance for the specified parameters
-
getOrCreateCollector
public DataCollector getOrCreateCollector(StorageEngine storageEngine, CollectorId collectorId, SnapshotProcessor dataProcessor) Creates or retrieves a data collector with a custom snapshot processor.This method creates a storage session with a custom storage strategy. The default session will collect data based on the mode, and when the data is ready to be sent, it will send it to the storage strategy.
This is a way for implementors to get the vast majority of the management between tags, tag groups, collection modes, and so on handled for them, while still having full control over how data is actually sent to the storage system internally.
- Parameters:
storageEngine
- The storage engine to associate with the collectorcollectorId
- The identifier for the collector, including its collection modedataProcessor
- The custom snapshot processor to use for processing collected data- Returns:
- A
DataCollector
instance for the specified parameters
-
removeCollectors
Removes all collectors associated with the specified storage engine.This method safely shuts down all collectors before removing them from the registry. The shutdown process ensures that any pending data is processed before the collectors are terminated.
- Parameters:
storageEngine
- The storage engine whose collectors should be removed
-