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 Classes
    Modifier and Type
    Class
    Description
    protected static interface 
    Event to report.
    protected static final class 
    Event for when a stream terminated.
    protected static final class 
    Event 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.Receive

    Nested classes/interfaces inherited from interface org.apache.pekko.actor.Actor

    org.apache.pekko.actor.Actor.emptyBehavior$, org.apache.pekko.actor.Actor.ignoringBehavior$
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected C
    Modifiable config to control this actor.
    protected final org.eclipse.ditto.internal.utils.pekko.logging.DittoDiagnosticLoggingAdapter
    The logger.
    protected final org.apache.pekko.stream.Materializer
    The actor materializer to materialize streams.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Initialize the actor with a background streaming config.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.pekko.actor.AbstractActor.Receive
     
    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.
    com.typesafe.config.Config
     
     
    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 C
    parseConfig(com.typesafe.config.Config config)
    Construct a config object by parsing HOCON.
    protected void
    postEnhanceStatusReport(org.eclipse.ditto.json.JsonObjectBuilder statusReportBuilder)
    Append fields to the status report.
    protected void
    preEnhanceSleepingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder sleepingReceiveBuilder)
    Add message handling logic to the sleeping behavior of this actor.
    protected void
    preEnhanceStreamingBehavior(org.apache.pekko.japi.pf.ReceiveBuilder streamingReceiveBuilder)
    Add message handling logic to the streaming behavior of this actor.
    protected org.eclipse.ditto.json.JsonObject
    Render a single event as JSON for health reporting.
    protected org.eclipse.ditto.json.JsonArray
    Render known events as a JSON array.
    com.typesafe.config.Config
    setConfig(com.typesafe.config.Config config)
     
    protected void
    shutdownStream(org.eclipse.ditto.base.api.common.Shutdown shutdown)
     
    protected void
    Handle 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, timers

    Methods 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, unhandled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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, unhandled

    Methods inherited from interface org.eclipse.ditto.internal.utils.pekko.actors.ModifyConfigBehavior

    modifyConfigBehavior

    Methods inherited from interface org.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior

    retrieveConfigBehavior
  • Field Details

    • config

      protected C extends BackgroundStreamingConfig config
      Modifiable config to control this actor.
    • log

      protected final org.eclipse.ditto.internal.utils.pekko.logging.DittoDiagnosticLoggingAdapter log
      The logger.
    • materializer

      protected final org.apache.pekko.stream.Materializer materializer
      The actor materializer to materialize streams.
  • Constructor Details

    • AbstractBackgroundStreamingActorWithConfigWithStatusReport

      protected AbstractBackgroundStreamingActorWithConfigWithStatusReport(C config)
      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

      protected abstract C parseConfig(com.typesafe.config.Config config)
      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:
      createReceive in class org.apache.pekko.actor.AbstractActor
    • getConfig

      public com.typesafe.config.Config getConfig()
      Specified by:
      getConfig in interface org.eclipse.ditto.internal.utils.pekko.actors.RetrieveConfigBehavior
    • setConfig

      public com.typesafe.config.Config setConfig(com.typesafe.config.Config config)
      Specified by:
      setConfig in interface org.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.