java.lang.Object
com.inductiveautomation.historian.gateway.api.storage.realtime.DataCollectorFactory

public class DataCollectorFactory extends Object
Factory for creating and managing 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.

  • Method Details

    • getInstance

      public static DataCollectorFactory 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

      public DataCollector getOrCreateCollector(StorageEngine storageEngine, CollectorId collectorId)
      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 collector
      collectorId - 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 collector
      collectorId - The identifier for the collector, including its collection mode
      dataProcessor - The custom snapshot processor to use for processing collected data
      Returns:
      A DataCollector instance for the specified parameters
    • removeCollectors

      public void removeCollectors(StorageEngine storageEngine)
      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