Package org.apache.beam.sdk.fn.data
Class BeamFnDataInboundObserver2
- java.lang.Object
-
- org.apache.beam.sdk.fn.data.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>
DecodesBeamFnApi.Elementspartitioning them using the providedDataEndpoints andTimerEndpoints.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 Modifier and Type Class Description protected static classBeamFnDataInboundObserver2.CloseException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)voidawaitCompletion()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.voidclose().voidflush()Eagerly flushes any data that is buffered in this channel.static BeamFnDataInboundObserver2forConsumers(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].booleanmultiplexElements(org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements elements)Dispatches the data and timers from the elements to corresponding receivers.voidreset()Enables this receiver to be used again for another bundle.
-
-
-
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:
acceptin interfaceFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>- Throws:
java.lang.Exception
-
flush
public void flush() throws java.lang.ExceptionDescription 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:
java.lang.Exception
-
close
public void close() throws java.lang.ExceptionDescription copied from interface:CloseableFnDataReceiver.Does nothing if this
CloseableFnDataReceiveris already closed.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceCloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements>- Throws:
java.lang.Exception
-
awaitCompletion
public void awaitCompletion() throws java.lang.ExceptionUses 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.ExceptionDispatches 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].
-
-