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 DataEndpoint
s and
TimerEndpoint
s.
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 TypeMethodDescriptionvoid
accept
(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements) void
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 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.Get all unfinished data and timers endpoints represented as [transform_id]:data and [transform_id]:timers:[timer_family_id].boolean
boolean
multiplexElements
(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.void
reset()
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:
accept
in interfaceFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
- Throws:
Exception
-
flush
Description copied from interface:CloseableFnDataReceiver
Eagerly flushes any data that is buffered in this channel.- Specified by:
flush
in interfaceCloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>
- Throws:
Exception
-
close
Description copied from interface:CloseableFnDataReceiver
.Does nothing if this
CloseableFnDataReceiver
is already closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in 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].
-