Package energy.eddie.aiida.aggregator
Class Aggregator
java.lang.Object
energy.eddie.aiida.aggregator.Aggregator
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionAggregator(AiidaRecordRepository aiidaRecordRepository, InboundRecordRepository inboundRecordRepository, org.springframework.boot.actuate.health.HealthContributorRegistry healthContributorRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewDataSourceAdapter(DataSourceAdapter<? extends DataSource> dataSourceAdapter) Adds a newDataSourceAdapterto this aggregator and will subscribe to the Flux returned byDataSourceAdapter.start().voidclose()Closes allDataSourceAdapters and emits a complete signal for all the Flux returned byreactor.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 ofAiidaRecords that either contains all records or only contains records with aAiidaRecordValue.dataTag()that is in the setallowedCodes.voidremoveDataSourceAdapter(DataSourceAdapter<? extends DataSource> dataSourceAdapter) Removes aDataSourceAdapterfrom this aggregator and will close the datasource.
-
Constructor Details
-
Aggregator
public Aggregator(AiidaRecordRepository aiidaRecordRepository, InboundRecordRepository inboundRecordRepository, org.springframework.boot.actuate.health.HealthContributorRegistry healthContributorRegistry)
-
-
Method Details
-
addNewDataSourceAdapter
Adds a newDataSourceAdapterto this aggregator and will subscribe to the Flux returned byDataSourceAdapter.start().- Parameters:
dataSourceAdapter- The new data source adapter to add. No check is made if this is a duplicate.
-
removeDataSourceAdapter
Removes aDataSourceAdapterfrom 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 ofAiidaRecords that either contains all records or only contains records with aAiidaRecordValue.dataTag()that is in the setallowedCodes. All values must have a timestamp beforepermissionExpirationTime. Additionally, the records are buffered and aggregated by theCronExpressiontransmissionSchedule.- 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
allowedCodesset, a timestamp that is beforepermissionExpirationTimeand that are aggregated by thetransmissionSchedule.
-
close
public void close()Closes allDataSourceAdapters and emits a complete signal for all the Flux returned by- Specified by:
closein interfaceAutoCloseable
-