Package energy.eddie.aiida.streamers
Class StreamerManager
java.lang.Object
energy.eddie.aiida.streamers.StreamerManager
- All Implemented Interfaces:
AutoCloseable
The StreamerManager manages the lifecycle of
AiidaStreamer.
Other components should rely on the StreamerManager for creating or stopping streamers.-
Constructor Summary
ConstructorsConstructorDescriptionStreamerManager(Aggregator aggregator, ApplicationInformationService applicationInformationService, FailedToSendRepository failedToSendRepository, com.fasterxml.jackson.databind.ObjectMapper mapper, PermissionLatestRecordMap permissionLatestRecordMap) The mapper is passed to theAiidaStreamerinstances that which use it to convert POJOs to JSON. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all streamers to allow for an orderly shutdown.voidcreateNewStreamer(Permission permission) Creates a newAiidaStreamerfor the specified permission and stores it internally.voidSends the passed status message in a blocking manner and then terminally stops the streamer.reactor.core.publisher.Flux<UUID> Returns a Flux on which the ID of a permission is published when the EP requests a termination for this permission.
-
Constructor Details
-
StreamerManager
@Autowired public StreamerManager(Aggregator aggregator, ApplicationInformationService applicationInformationService, FailedToSendRepository failedToSendRepository, com.fasterxml.jackson.databind.ObjectMapper mapper, PermissionLatestRecordMap permissionLatestRecordMap) The mapper is passed to theAiidaStreamerinstances that which use it to convert POJOs to JSON. As the mapper is shared, make sure the used implementation is thread-safe and supports sharing.
-
-
Method Details
-
createNewStreamer
public void createNewStreamer(Permission permission) throws IllegalArgumentException, org.eclipse.paho.mqttv5.common.MqttException Creates a newAiidaStreamerfor the specified permission and stores it internally. The created streamer will receive any matchingAiidaRecordas requested by the data need of the permission.- Parameters:
permission- Permission for which an AiidaStreamer should be created.- Throws:
IllegalArgumentException- If an AiidaStreamer for the passed permission has already been created.org.eclipse.paho.mqttv5.common.MqttException
-
terminationRequestsFlux
Returns a Flux on which the ID of a permission is published when the EP requests a termination for this permission. The Flux allows only one subscriber and buffers, ensuring no values get lost.- Returns:
- Flux of permissionIDs for which the EP requested termination.
-
stopStreamer
Sends the passed status message in a blocking manner and then terminally stops the streamer.- Parameters:
message- Message to send before stopping the streamer. The status should be one ofPermissionStatus.TERMINATED,PermissionStatus.REVOKEDorPermissionStatus.FULFILLED.
-
close
public void close()Closes all streamers to allow for an orderly shutdown. Note that this blocks until all streamers have finished closing, which may be indefinitely in the current implementation.- Specified by:
closein interfaceAutoCloseable
-