Class Aggregator

java.lang.Object
energy.eddie.aiida.aggregator.Aggregator
All Implemented Interfaces:
AutoCloseable

@Component public class Aggregator extends Object implements AutoCloseable
  • Constructor Details

    • Aggregator

      public Aggregator(AiidaRecordRepository aiidaRecordRepository, InboundRecordRepository inboundRecordRepository, org.springframework.boot.actuate.health.HealthContributorRegistry healthContributorRegistry)
  • Method Details

    • addNewDataSourceAdapter

      public void addNewDataSourceAdapter(DataSourceAdapter<? extends DataSource> dataSourceAdapter)
      Adds a new DataSourceAdapter to this aggregator and will subscribe to the Flux returned by DataSourceAdapter.start().
      Parameters:
      dataSourceAdapter - The new data source adapter to add. No check is made if this is a duplicate.
    • removeDataSourceAdapter

      public void removeDataSourceAdapter(DataSourceAdapter<? extends DataSource> dataSourceAdapter)
      Removes a DataSourceAdapter from this aggregator and will close the datasource.
      Parameters:
      dataSourceAdapter - The datasource adapter to remove.
    • getFilteredFlux

      public reactor.core.publisher.Flux<AiidaRecord> getFilteredFlux(Set<ObisCode> allowedDataTags, AiidaAsset allowedAsset, Instant permissionExpirationTime, org.springframework.scheduling.support.CronExpression transmissionSchedule, UUID userId, UUID dataSourceId)
      Returns a Flux of AiidaRecords that either contains all records or only contains records with a AiidaRecordValue.dataTag() that is in the set allowedCodes. All values must have a timestamp before permissionExpirationTime. Additionally, the records are buffered and aggregated by the CronExpression transmissionSchedule.
      Parameters:
      allowedDataTags - Tags which should be included in the returned Flux.
      allowedAsset - The asset that should be included in the returned Flux.
      permissionExpirationTime - Instant when the permission expires.
      transmissionSchedule - The schedule at which the data should be transmitted.
      userId - The user id of the permission creator.
      Returns:
      A Flux on which will only have AiidaRecords with a code matching one of the codes of the allowedCodes set, a timestamp that is before permissionExpirationTime and that are aggregated by the transmissionSchedule.
    • close

      public void close()
      Closes all DataSourceAdapters and emits a complete signal for all the Flux returned by
      Specified by:
      close in interface AutoCloseable