Class BeamFnDataInboundObserver2

  • All Implemented Interfaces:
    java.lang.AutoCloseable, CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>, FnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>

    public class BeamFnDataInboundObserver2
    extends java.lang.Object
    implements CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
    Decodes BeamFnApi.Elements partitioning them using the provided DataEndpoints and TimerEndpoints.

    Note that this receiver uses a queue to buffer and pass elements from one thread to be processed by the thread which invokes awaitCompletion().

    Closing the receiver will unblock any upstream producer and downstream consumer exceptionally.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)  
      void awaitCompletion()
      Uses the callers thread to process all elements received until we receive the end of the stream from the upstream producer for all endpoints specified.
      void close()
      .
      void flush()
      Eagerly flushes any data that is buffered in this channel.
      static BeamFnDataInboundObserver2 forConsumers​(java.util.List<DataEndpoint<?>> dataEndpoints, java.util.List<TimerEndpoint<?>> timerEndpoints)
      Creates a receiver that is able to consume elements multiplexing on to the provided set of endpoints.
      java.util.List<java.lang.String> getUnfinishedEndpoints()
      Get all unfinished data and timers endpoints represented as [transform_id]:data and [transform_id]:timers:[timer_family_id].
      boolean multiplexElements​(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)
      Dispatches the data and timers from the elements to corresponding receivers.
      void reset()
      Enables this receiver to be used again for another bundle.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • forConsumers

        public static BeamFnDataInboundObserver2 forConsumers​(java.util.List<DataEndpoint<?>> dataEndpoints,
                                                              java.util.List<TimerEndpoint<?>> timerEndpoints)
        Creates a receiver that is able to consume elements multiplexing on to the provided set of endpoints.
      • accept

        public void accept​(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)
                    throws java.lang.Exception
        Specified by:
        accept in interface FnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
        Throws:
        java.lang.Exception
      • flush

        public void flush()
                   throws java.lang.Exception
        Description copied from interface: CloseableFnDataReceiver
        Eagerly flushes any data that is buffered in this channel.
        Specified by:
        flush in interface CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
        Throws:
        java.lang.Exception
      • close

        public void close()
                   throws java.lang.Exception
        Description copied from interface: CloseableFnDataReceiver
        .

        Does nothing if this CloseableFnDataReceiver is already closed.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
        Throws:
        java.lang.Exception
      • awaitCompletion

        public void awaitCompletion()
                             throws java.lang.Exception
        Uses the callers thread to process all elements received until we receive the end of the stream from the upstream producer for all endpoints specified.

        Erroneous elements passed from the producer will be visible to the caller of this method.

        Throws:
        java.lang.Exception
      • multiplexElements

        public boolean multiplexElements​(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)
                                  throws java.lang.Exception
        Dispatches the data and timers from the elements to corresponding receivers. Returns true if all the endpoints are done after elements dispatching.
        Throws:
        java.lang.Exception
      • reset

        public void reset()
        Enables this receiver to be used again for another bundle.
      • getUnfinishedEndpoints

        public java.util.List<java.lang.String> getUnfinishedEndpoints()
        Get all unfinished data and timers endpoints represented as [transform_id]:data and [transform_id]:timers:[timer_family_id].