Class AbstractBackgroundStreamingActorWithConfigWithStatusReport<C extends BackgroundStreamingConfig>
java.lang.Object
org.apache.pekko.actor.AbstractActor
org.apache.pekko.actor.AbstractActorWithTimers
org.eclipse.ditto.internal.utils.health.AbstractBackgroundStreamingActorWithConfigWithStatusReport<C>
- Type Parameters:
C- type of configuration.
- All Implemented Interfaces:
org.apache.pekko.actor.Actor,org.apache.pekko.actor.Timers,org.eclipse.ditto.internal.utils.pekko.actors.ModifyConfigBehavior,org.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior
public abstract class AbstractBackgroundStreamingActorWithConfigWithStatusReport<C extends BackgroundStreamingConfig>
extends org.apache.pekko.actor.AbstractActorWithTimers
implements org.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior, org.eclipse.ditto.internal.utils.pekko.actors.ModifyConfigBehavior
Common behavior for actors that stay alive for a long time running a stream over and over.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceEvent to report.protected static final classEvent for when a stream terminated.protected static final classEvent for when a stream started.Nested classes/interfaces inherited from class org.apache.pekko.actor.AbstractActor
org.apache.pekko.actor.AbstractActor.ActorContext, org.apache.pekko.actor.AbstractActor.ReceiveNested classes/interfaces inherited from interface org.apache.pekko.actor.Actor
org.apache.pekko.actor.Actor.emptyBehavior$, org.apache.pekko.actor.Actor.ignoringBehavior$ -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CModifiable config to control this actor.protected final org.eclipse.ditto.internal.utils.pekko.logging.DittoDiagnosticLoggingAdapterThe logger.protected final org.apache.pekko.stream.MaterializerThe actor materializer to materialize streams. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitialize the actor with a background streaming config. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pekko.actor.AbstractActor.Receiveprotected static <T> voidEnqueue an element into a deque of bounded size.com.typesafe.config.Configprotected Stream<org.apache.pekko.japi.Pair<Instant,AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> protected StatusDetailMessage.LevelgetMostSevereLevelFromEvents(Deque<org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> events) Get the most severe log level from events.protected abstract org.apache.pekko.stream.javadsl.Source<?,?> Get the stream that should be restarted again and again in the background as a source of whatever to be followed by a kill switch and a sink that ignores all elements.protected abstract CparseConfig(com.typesafe.config.Config config) Construct a config object by parsing HOCON.protected voidpostEnhanceStatusReport(org.eclipse.ditto.json.JsonObjectBuilder statusReportBuilder) Append fields to the status report.protected voidpreEnhanceSleepingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder sleepingReceiveBuilder) Add message handling logic to the sleeping behavior of this actor.protected voidpreEnhanceStreamingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder streamingReceiveBuilder) Add message handling logic to the streaming behavior of this actor.protected org.eclipse.ditto.json.JsonObjectrenderEvent(org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event> element) Render a single event as JSON for health reporting.protected org.eclipse.ditto.json.JsonArrayrenderEvents(Deque<org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> events) Render known events as a JSON array.com.typesafe.config.ConfigsetConfig(com.typesafe.config.Config config) protected voidshutdownStream(org.eclipse.ditto.base.api.common.Shutdown shutdown) protected voidHandle stream termination.Methods inherited from class org.apache.pekko.actor.AbstractActorWithTimers
aroundPostStop, aroundPreRestart, aroundReceive, getTimers, org$apache$pekko$actor$Timers$_setter_$org$apache$pekko$actor$Timers$$_timers_$eq, org$apache$pekko$actor$Timers$$_timers, timersMethods inherited from class org.apache.pekko.actor.AbstractActor
aroundPostRestart, aroundPreStart, context, emptyBehavior, getContext, getSelf, getSender, org$apache$pekko$actor$Actor$_setter_$context_$eq, org$apache$pekko$actor$Actor$_setter_$self_$eq, postRestart, postStop, preRestart, preRestart, preStart, receive, receiveBuilder, self, sender, supervisorStrategy, unhandledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.actor.Actor
aroundPostRestart, aroundPreStart, context, org$apache$pekko$actor$Actor$_setter_$context_$eq, org$apache$pekko$actor$Actor$_setter_$self_$eq, postRestart, postStop, preRestart, preStart, receive, self, sender, supervisorStrategy, unhandledMethods inherited from interface org.eclipse.ditto.internal.utils.pekko.actors.ModifyConfigBehavior
modifyConfigBehaviorMethods inherited from interface org.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior
retrieveConfigBehavior
-
Field Details
-
config
Modifiable config to control this actor. -
log
protected final org.eclipse.ditto.internal.utils.pekko.logging.DittoDiagnosticLoggingAdapter logThe logger. -
materializer
protected final org.apache.pekko.stream.Materializer materializerThe actor materializer to materialize streams.
-
-
Constructor Details
-
AbstractBackgroundStreamingActorWithConfigWithStatusReport
Initialize the actor with a background streaming config.- Parameters:
config- the background streaming config.
-
-
Method Details
-
enqueue
protected static <T> void enqueue(Deque<org.apache.pekko.japi.Pair<Instant, T>> queue, T element, int maxQueueSize) Enqueue an element into a deque of bounded size.- Type Parameters:
T- the type of elements.- Parameters:
queue- the deque.element- the element to enqueue.maxQueueSize- the maximum size of the queue.
-
parseConfig
Construct a config object by parsing HOCON.- Parameters:
config- the HOCON.- Returns:
- the config object.
-
getSource
protected abstract org.apache.pekko.stream.javadsl.Source<?,?> getSource()Get the stream that should be restarted again and again in the background as a source of whatever to be followed by a kill switch and a sink that ignores all elements.- Returns:
- the source.
-
preEnhanceSleepingBehavior
protected void preEnhanceSleepingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder sleepingReceiveBuilder) Add message handling logic to the sleeping behavior of this actor.- Parameters:
sleepingReceiveBuilder- the builder for the sleeping behavior.
-
preEnhanceStreamingBehavior
protected void preEnhanceStreamingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder streamingReceiveBuilder) Add message handling logic to the streaming behavior of this actor.- Parameters:
streamingReceiveBuilder- the builder for the streaming behavior.
-
postEnhanceStatusReport
protected void postEnhanceStatusReport(org.eclipse.ditto.json.JsonObjectBuilder statusReportBuilder) Append fields to the status report.- Parameters:
statusReportBuilder- the builder for the status report.
-
createReceive
public org.apache.pekko.actor.AbstractActor.Receive createReceive()- Specified by:
createReceivein classorg.apache.pekko.actor.AbstractActor
-
getConfig
public com.typesafe.config.Config getConfig()- Specified by:
getConfigin interfaceorg.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior
-
setConfig
public com.typesafe.config.Config setConfig(com.typesafe.config.Config config) - Specified by:
setConfigin interfaceorg.eclipse.ditto.internal.utils.pekko.actors.ModifyConfigBehavior
-
streamTerminated
protected void streamTerminated(AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event streamTerminated) Handle stream termination.- Parameters:
streamTerminated- the event of stream termination.
-
getEventStream
protected Stream<org.apache.pekko.japi.Pair<Instant,AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> getEventStream() -
shutdownStream
protected void shutdownStream(org.eclipse.ditto.base.api.common.Shutdown shutdown) -
getMostSevereLevelFromEvents
protected StatusDetailMessage.Level getMostSevereLevelFromEvents(Deque<org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> events) Get the most severe log level from events.- Returns:
- The most severe log level to report.
-
renderEvents
protected org.eclipse.ditto.json.JsonArray renderEvents(Deque<org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event>> events) Render known events as a JSON array.- Parameters:
events- events to render.- Returns:
- the rendered events.
-
renderEvent
protected org.eclipse.ditto.json.JsonObject renderEvent(org.apache.pekko.japi.Pair<Instant, AbstractBackgroundStreamingActorWithConfigWithStatusReport.Event> element) Render a single event as JSON for health reporting.- Parameters:
element- the event together with its timestamp.- Returns:
- the rendered JSON object.
-