Package org.apache.beam.sdk.fn.data
Class BeamFnDataInboundObserver
java.lang.Object
org.apache.beam.sdk.fn.data.BeamFnDataInboundObserver
- All Implemented Interfaces:
AutoCloseable,CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>,FnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
public class BeamFnDataInboundObserver
extends 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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements) voidUses the callers thread to process all elements received until we receive the end of the stream from the upstream producer for all endpoints specified.voidclose().voidflush()Eagerly flushes any data that is buffered in this channel.static BeamFnDataInboundObserverforConsumers(List<DataEndpoint<?>> dataEndpoints, List<TimerEndpoint<?>> timerEndpoints) Creates a receiver that is able to consume elements multiplexing on to the provided set of endpoints.Get all unfinished data and timers endpoints represented as [transform_id]:data and [transform_id]:timers:[timer_family_id].booleanbooleanmultiplexElements(Iterator<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements.Data> dataElements, Iterator<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements.Timers> timerElements) Dispatches the data and timers from the elements to corresponding receivers.voidreset()Enables this receiver to be used again for another bundle.
-
Method Details
-
forConsumers
public static BeamFnDataInboundObserver forConsumers(List<DataEndpoint<?>> dataEndpoints, 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 Exception - Specified by:
acceptin interfaceFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>- Throws:
Exception
-
flush
Description copied from interface:CloseableFnDataReceiverEagerly flushes any data that is buffered in this channel.- Specified by:
flushin interfaceCloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>- Throws:
Exception
-
close
Description copied from interface:CloseableFnDataReceiver.Does nothing if this
CloseableFnDataReceiveris already closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>- Throws:
Exception
-
isConsumingReceivedData
public boolean isConsumingReceivedData() -
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.Erroneous elements passed from the producer will be visible to the caller of this method.
- Throws:
Exception
-
multiplexElements
public boolean multiplexElements(Iterator<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements.Data> dataElements, Iterator<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements.Timers> timerElements) throws Exception Dispatches the data and timers from the elements to corresponding receivers. Returns true if all the endpoints are done after elements dispatching.- Throws:
Exception
-
reset
public void reset()Enables this receiver to be used again for another bundle. -
getUnfinishedEndpoints
Get all unfinished data and timers endpoints represented as [transform_id]:data and [transform_id]:timers:[timer_family_id].
-