Class GraphStageLogic

    • Constructor Detail

      • GraphStageLogic

        public GraphStageLogic​(int inCount,
                               int outCount)
      • GraphStageLogic

        public GraphStageLogic​(Shape shape)
    • Method Detail

      • NoPromise

        public static scala.concurrent.Promise<Done> NoPromise()
      • inCount

        public int inCount()
      • outCount

        public int outCount()
      • stageId

        public int stageId()
        INTERNAL API
        Returns:
        (undocumented)
      • stageId_$eq

        public void stageId_$eq​(int x$1)
      • attributes

        public Attributes attributes()
        INTERNAL API
        Returns:
        (undocumented)
      • attributes_$eq

        public void attributes_$eq​(Attributes x$1)
      • originalStage

        public OptionVal<GraphStageWithMaterializedValue<? extends Shape,​?>> originalStage()
        INTERNAL API

        If possible a link back to the operator that the logic was created with, used for debugging.

        Returns:
        (undocumented)
      • handlers

        public java.lang.Object[] handlers()
        INTERNAL API

        Input handlers followed by output handlers, use inHandler(id) and outHandler(id) to access the respective handlers.

        Returns:
        (undocumented)
      • inHandler

        public InHandler inHandler​(int id)
        INTERNAL API
        Parameters:
        id - (undocumented)
        Returns:
        (undocumented)
      • outHandler

        public OutHandler outHandler​(int id)
      • interpreter_$eq

        public void interpreter_$eq​(GraphInterpreter gi)
        INTERNAL API
        Parameters:
        gi - (undocumented)
      • interpreter

        public GraphInterpreter interpreter()
        INTERNAL API
        Returns:
        (undocumented)
      • materializer

        protected Materializer materializer()
        The Materializer that has set this GraphStage in motion.

        Can not be used from a GraphStage constructor. Access to materializer is provided by the akka.stream.scaladsl.Source.setup, akka.stream.scaladsl.Flow.setup and akka.stream.scaladsl.Sink.setup and their corresponding Java API factories.

        Returns:
        (undocumented)
      • subFusingMaterializer

        protected Materializer subFusingMaterializer()
        An Materializer that may run fusable parts of the graphs that it materializes within the same actor as the current GraphStage (if fusing is available). This materializer must not be shared outside of the GraphStage.
        Returns:
        (undocumented)
      • eagerTerminateInput

        protected final InHandler eagerTerminateInput()
        Input handler that terminates the operator upon receiving completion. The operator fails upon receiving a failure.
        Returns:
        (undocumented)
      • ignoreTerminateInput

        protected final InHandler ignoreTerminateInput()
        Input handler that does not terminate the operator upon receiving completion. The operator fails upon receiving a failure.
        Returns:
        (undocumented)
      • conditionalTerminateInput

        protected final InHandler conditionalTerminateInput​(scala.Function0<java.lang.Object> predicate)
        Input handler that terminates the state upon receiving completion if the given condition holds at that time. The operator fails upon receiving a failure.
        Parameters:
        predicate - (undocumented)
        Returns:
        (undocumented)
      • totallyIgnorantInput

        protected final InHandler totallyIgnorantInput()
        Input handler that does not terminate the operator upon receiving completion nor failure.
        Returns:
        (undocumented)
      • eagerTerminateOutput

        protected final OutHandler eagerTerminateOutput()
        Output handler that terminates the operator upon cancellation.
        Returns:
        (undocumented)
      • ignoreTerminateOutput

        protected final OutHandler ignoreTerminateOutput()
        Output handler that does not terminate the operator upon cancellation.
        Returns:
        (undocumented)
      • conditionalTerminateOutput

        protected final OutHandler conditionalTerminateOutput​(scala.Function0<java.lang.Object> predicate)
        Output handler that terminates the state upon receiving completion if the given condition holds at that time. The operator fails upon receiving a failure.
        Parameters:
        predicate - (undocumented)
        Returns:
        (undocumented)
      • setHandler

        protected final void setHandler​(Inlet<?> in,
                                        InHandler handler)
        Assigns callbacks for the events for an Inlet
        Parameters:
        in - (undocumented)
        handler - (undocumented)
      • setHandlers

        protected final void setHandlers​(Inlet<?> in,
                                         Outlet<?> out,
                                         InHandler handler)
        Assign callbacks for linear operator for both Inlet and Outlet
        Parameters:
        in - (undocumented)
        out - (undocumented)
        handler - (undocumented)
      • getHandler

        protected final InHandler getHandler​(Inlet<?> in)
        Retrieves the current callback for the events on the given Inlet
        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • setHandler

        protected final void setHandler​(Outlet<?> out,
                                        OutHandler handler)
        Assigns callbacks for the events for an Outlet
        Parameters:
        out - (undocumented)
        handler - (undocumented)
      • getHandler

        protected final OutHandler getHandler​(Outlet<?> out)
        Retrieves the current callback for the events on the given Outlet
        Parameters:
        out - (undocumented)
        Returns:
        (undocumented)
      • pull

        protected final <T> void pull​(Inlet<T> in)
        Requests an element on the given port. Calling this method twice before an element arrived will fail. There can only be one outstanding request at any given time. The method hasBeenPulled() can be used query whether pull is allowed to be called or not. This method will also fail if the port is already closed.
        Parameters:
        in - (undocumented)
      • tryPull

        protected final <T> void tryPull​(Inlet<T> in)
        Requests an element on the given port unless the port is already closed. Calling this method twice before an element arrived will fail. There can only be one outstanding request at any given time. The method hasBeenPulled() can be used query whether pull is allowed to be called or not.
        Parameters:
        in - (undocumented)
      • cancel

        protected final <T> void cancel​(Inlet<T> in)
        Requests to stop receiving events from a given input port. Cancelling clears any ungrabbed elements from the port.
        Parameters:
        in - (undocumented)
      • grab

        protected final <T> T grab​(Inlet<T> in)
        Once the callback {@link InHandler.onPush()} for an input port has been invoked, the element that has been pushed can be retrieved via this method. After grab() has been called the port is considered to be empty, and further calls to grab() will fail until the port is pulled again and a new element is pushed as a response.

        The method isAvailable() can be used to query if the port has an element that can be grabbed or not.

        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • hasBeenPulled

        protected final <T> boolean hasBeenPulled​(Inlet<T> in)
        Indicates whether there is already a pending pull for the given input port. If this method returns true then isAvailable() must return false for that same port.
        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • isAvailable

        protected final <T> boolean isAvailable​(Inlet<T> in)
        Indicates whether there is an element waiting at the given input port. grab() can be used to retrieve the element. After calling grab() this method will return false.

        If this method returns true then hasBeenPulled() will return false for that same port.

        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • isClosed

        protected final <T> boolean isClosed​(Inlet<T> in)
        Indicates whether the port has been closed. A closed port cannot be pulled.
        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • push

        protected final <T> void push​(Outlet<T> out,
                                      T elem)
        Emits an element through the given output port. Calling this method twice before a pull() has been arrived will fail. There can be only one outstanding push request at any given time. The method isAvailable() can be used to check if the port is ready to be pushed or not.
        Parameters:
        out - (undocumented)
        elem - (undocumented)
      • setKeepGoing

        protected final void setKeepGoing​(boolean enabled)
        Controls whether this operator shall shut down when all its ports are closed, which is the default. In order to have it keep going past that point this method needs to be called with a true argument before all ports are closed, and afterwards it will not be closed until this method is called with a false argument or the operator is terminated via completeStage() or failStage().
        Parameters:
        enabled - (undocumented)
      • complete

        protected final <T> void complete​(Outlet<T> out)
        Signals that there will be no more elements emitted on the given port.
        Parameters:
        out - (undocumented)
      • fail

        protected final <T> void fail​(Outlet<T> out,
                                      java.lang.Throwable ex)
        Signals failure through the given port.
        Parameters:
        out - (undocumented)
        ex - (undocumented)
      • cancelStage

        public final void cancelStage​(java.lang.Throwable cause)
        Automatically invokes <T>cancel(akka.stream.Inlet<T>) or <T>complete(akka.stream.Outlet<T>) on all the input or output ports that have been called, then marks the stage as stopped.

        This method is a backport from Akka 2.6 and already includes a cause parameter for binary compatibility with Akka 2.6. This parameter is not propagated to upstream stages in Akka 2.5 which does not support propagation of cancellation causes. However, it will be used as an error if the Attributes.CancellationStrategy.FailStage cancellation strategy was chosen.

        You can use SubscriptionWithCancelException.NoMoreElementsNeeded as a default if you do not want to pass additional information.

        Parameters:
        cause - (undocumented)
      • completeStage

        public final void completeStage()
        Automatically invokes cancel() or complete() on all the input or output ports that have been called, then marks the operator as stopped.
      • failStage

        public final void failStage​(java.lang.Throwable ex)
        Automatically invokes cancel() or fail() on all the input or output ports that have been called, then marks the operator as stopped.
        Parameters:
        ex - (undocumented)
      • isAvailable

        public final <T> boolean isAvailable​(Outlet<T> out)
        Return true if the given output port is ready to be pushed.
        Parameters:
        out - (undocumented)
        Returns:
        (undocumented)
      • isClosed

        protected final <T> boolean isClosed​(Outlet<T> out)
        Indicates whether the port has been closed. A closed port cannot be pushed.
        Parameters:
        out - (undocumented)
        Returns:
        (undocumented)
      • readN

        protected final <T> void readN​(Inlet<T> in,
                                       int n,
                                       scala.Function1<scala.collection.Seq<T>,​scala.runtime.BoxedUnit> andThen,
                                       scala.Function1<scala.collection.Seq<T>,​scala.runtime.BoxedUnit> onClose)
        Read a number of elements from the given inlet and continue with the given function, suspending execution if necessary. This action replaces the InHandler for the given inlet if suspension is needed and reinstalls the current handler upon receiving the last onPush() signal.

        If upstream closes before N elements have been read, the onClose function is invoked with the elements which were read.

        Parameters:
        in - (undocumented)
        n - (undocumented)
        andThen - (undocumented)
        onClose - (undocumented)
      • readN

        protected final <T> void readN​(Inlet<T> in,
                                       int n,
                                       Procedure<java.util.List<T>> andThen,
                                       Procedure<java.util.List<T>> onClose)
        Java API: Read a number of elements from the given inlet and continue with the given function, suspending execution if necessary. This action replaces the InHandler for the given inlet if suspension is needed and reinstalls the current handler upon receiving the last onPush() signal (before invoking the andThen function).
        Parameters:
        in - (undocumented)
        n - (undocumented)
        andThen - (undocumented)
        onClose - (undocumented)
      • read

        protected final <T> void read​(Inlet<T> in,
                                      scala.Function1<T,​scala.runtime.BoxedUnit> andThen,
                                      scala.Function0<scala.runtime.BoxedUnit> onClose)
        Read an element from the given inlet and continue with the given function, suspending execution if necessary. This action replaces the InHandler for the given inlet if suspension is needed and reinstalls the current handler upon receiving the onPush() signal (before invoking the andThen function).
        Parameters:
        in - (undocumented)
        andThen - (undocumented)
        onClose - (undocumented)
      • read

        protected final <T> void read​(Inlet<T> in,
                                      Procedure<T> andThen,
                                      Effect onClose)
        Java API: Read an element from the given inlet and continue with the given function, suspending execution if necessary. This action replaces the InHandler for the given inlet if suspension is needed and reinstalls the current handler upon receiving the onPush() signal (before invoking the andThen function).
        Parameters:
        in - (undocumented)
        andThen - (undocumented)
        onClose - (undocumented)
      • abortReading

        protected final void abortReading​(Inlet<?> in)
        Abort outstanding (suspended) reading for the given inlet, if there is any. This will reinstall the replaced handler that was in effect before the read call.
        Parameters:
        in - (undocumented)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              scala.collection.immutable.Iterable<T> elems,
                                              scala.Function0<scala.runtime.BoxedUnit> andThen)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              scala.collection.immutable.Iterable<T> elems)
        Emit a sequence of elements through the given outlet, suspending execution if necessary. This action replaces the OutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal.
        Parameters:
        out - (undocumented)
        elems - (undocumented)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              java.util.Iterator<T> elems)
        Java API

        Emit a sequence of elements through the given outlet, suspending execution if necessary. This action replaces the AbstractOutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal.

        Parameters:
        out - (undocumented)
        elems - (undocumented)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              java.util.Iterator<T> elems,
                                              Effect andThen)
        Java API

        Emit a sequence of elements through the given outlet, suspending execution if necessary. This action replaces the AbstractOutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal.

        Parameters:
        out - (undocumented)
        elems - (undocumented)
        andThen - (undocumented)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              scala.collection.Iterator<T> elems,
                                              scala.Function0<scala.runtime.BoxedUnit> andThen)
        Emit a sequence of elements through the given outlet and continue with the given thunk afterwards, suspending execution if necessary. This action replaces the OutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal (before invoking the andThen function).
        Parameters:
        out - (undocumented)
        elems - (undocumented)
        andThen - (undocumented)
      • emitMultiple

        protected final <T> void emitMultiple​(Outlet<T> out,
                                              scala.collection.Iterator<T> elems)
        Emit a sequence of elements through the given outlet, suspending execution if necessary. This action replaces the OutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal.
        Parameters:
        out - (undocumented)
        elems - (undocumented)
      • emit

        protected final <T> void emit​(Outlet<T> out,
                                      T elem,
                                      scala.Function0<scala.runtime.BoxedUnit> andThen)
        Emit an element through the given outlet and continue with the given thunk afterwards, suspending execution if necessary. This action replaces the OutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal (before invoking the andThen function).
        Parameters:
        out - (undocumented)
        elem - (undocumented)
        andThen - (undocumented)
      • emit

        protected final <T> void emit​(Outlet<T> out,
                                      T elem)
        Emit an element through the given outlet, suspending execution if necessary. This action replaces the OutHandler for the given outlet if suspension is needed and reinstalls the current handler upon receiving an onPull() signal.
        Parameters:
        out - (undocumented)
        elem - (undocumented)
      • emit

        protected final <T> void emit​(Outlet<T> out,
                                      T elem,
                                      Effect andThen)
      • abortEmitting

        protected final void abortEmitting​(Outlet<?> out)
        Abort outstanding (suspended) emissions for the given outlet, if there are any. This will reinstall the replaced handler that was in effect before the emit call.
        Parameters:
        out - (undocumented)
      • passAlong

        protected final <Out,​In extends Out> void passAlong​(Inlet<In> from,
                                                                  Outlet<Out> to,
                                                                  boolean doFinish,
                                                                  boolean doFail,
                                                                  boolean doPull)
      • passAlong$default$3

        protected final <Out,​In extends Out> boolean passAlong$default$3()
      • passAlong$default$4

        protected final <Out,​In extends Out> boolean passAlong$default$4()
      • passAlong$default$5

        protected final <Out,​In extends Out> boolean passAlong$default$5()
      • getAsyncCallback

        public final <T> AsyncCallback<T> getAsyncCallback​(scala.Function1<T,​scala.runtime.BoxedUnit> handler)
        Obtain a callback object that can be used asynchronously to re-enter the current GraphStage with an asynchronous notification. The invoke() method of the returned AsyncCallback is safe to be called from other threads. It will in the background thread-safely delegate to the passed callback function. I.e. invoke() will be called by other thread and the passed handler will be invoked eventually in a thread-safe way by the execution environment.

        In case stream is not yet materialized AsyncCallback will buffer events until stream is available.

        {@link AsyncCallback.invokeWithFeedback()} has an internal promise that will be failed if event cannot be processed due to stream completion.

        To be thread safe this method must only be called from either the constructor of the graph operator during materialization or one of the methods invoked by the graph operator machinery, such as onPush and onPull.

        This object can be cached and reused within the same GraphStageLogic.

        Parameters:
        handler - (undocumented)
        Returns:
        (undocumented)
      • getStageActor

        protected final GraphStageLogic.StageActor getStageActor​(scala.Function1<scala.Tuple2<ActorRef,​java.lang.Object>,​scala.runtime.BoxedUnit> receive)
        Initialize a StageActorRef which can be used to interact with from the outside world "as-if" an Actor. The messages are looped through the <T>getAsyncCallback(scala.Function1<T,scala.runtime.BoxedUnit>) mechanism of GraphStage so they are safe to modify internal state of this operator.

        This method must (the earliest) be called after the GraphStageLogic constructor has finished running, for example from the preStart() callback the graph operator logic provides.

        Created StageActorRef to get messages and watch other actors in synchronous way.

        The StageActorRef's lifecycle is bound to the operator, in other words when the operator is finished, the Actor will be terminated as well. The entity backing the StageActorRef is not a real Actor, but the GraphStageLogic itself, therefore it does not react to PoisonPill.

        Parameters:
        receive - callback that will be called upon receiving of a message by this special Actor
        Returns:
        minimal actor with watch method
      • getEagerStageActor

        protected GraphStageLogic.StageActor getEagerStageActor​(Materializer eagerMaterializer,
                                                                boolean poisonPillCompatibility,
                                                                scala.Function1<scala.Tuple2<ActorRef,​java.lang.Object>,​scala.runtime.BoxedUnit> receive)
        INTERNAL API
        Parameters:
        eagerMaterializer - (undocumented)
        poisonPillCompatibility - (undocumented)
        receive - (undocumented)
        Returns:
        (undocumented)
      • stageActorName

        protected java.lang.String stageActorName()
        Override and return a name to be given to the StageActor of this operator.

        This method will be only invoked and used once, during the first getStageActor(scala.Function1<scala.Tuple2<akka.actor.ActorRef,java.lang.Object>,scala.runtime.BoxedUnit>) invocation whichc reates the actor, since subsequent getStageActors calls function like become, rather than creating new actors.

        Returns an empty string by default, which means that the name will a unique generated String (e.g. "$$a").

        Returns:
        (undocumented)
      • beforePreStart

        protected void beforePreStart()
        INTERNAL API
      • afterPostStop

        protected void afterPostStop()
        INTERNAL API
      • onFeedbackDispatched

        public void onFeedbackDispatched()
        Called from interpreter thread by GraphInterpreter.runAsyncInput
      • preStart

        public void preStart()
                      throws java.lang.Exception
        Invoked before any external events are processed, at the startup of the operator.
        Throws:
        java.lang.Exception
      • postStop

        public void postStop()
                      throws java.lang.Exception
        Invoked after processing of external events stopped because the operator is about to stop or fail.
        Throws:
        java.lang.Exception