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(OutboundAggregator aggregator, FailedToSendRepository failedToSendRepository, tools.jackson.databind.ObjectMapper mapper, SchemaFormatterRegistry schemaFormatterRegistry, 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.reactor.core.publisher.Flux<PermissionCommand> Returns a Flux on which aPermissionCommandis published whenever the EP sends a control command for one of the managed permissions.voidcreateNewStreamer(Permission permission) Creates a newAiidaStreamerfor the specified permission and stores it internally.voidpublishSchemaPayload(UUID permissionId, AiidaSchema schema, String payload) Publishes a payload of the provided schema to the streamer for the provided permission.voidsetTransmissionEnabled(UUID permissionId, boolean enabled) Enables or disables data transmission for the streamer of the passed permission.voidSends the passed status message in a blocking manner and then terminally stops the streamer.voidupdateSchedule(Permission permission) Applies a new transmission schedule to the streamer of the passed permission by rebuilding its record flux with the new aggregation cadence.
-
Constructor Details
-
StreamerManager
@Autowired public StreamerManager(OutboundAggregator aggregator, FailedToSendRepository failedToSendRepository, tools.jackson.databind.ObjectMapper mapper, SchemaFormatterRegistry schemaFormatterRegistry, 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
-
setTransmissionEnabled
Enables or disables data transmission for the streamer of the passed permission. While disabled, no records are published to the EP. -
updateSchedule
Applies a new transmission schedule to the streamer of the passed permission by rebuilding its record flux with the new aggregation cadence. -
publishSchemaPayload
Publishes a payload of the provided schema to the streamer for the provided permission. -
commandFlux
Returns a Flux on which aPermissionCommandis published whenever the EP sends a control command for one of the managed permissions. The Flux allows only one subscriber and buffers, ensuring no values get lost.- Returns:
- Flux of permission commands received from the EP.
-
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
-