Class BeamFnDataGrpcMultiplexer2

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class BeamFnDataGrpcMultiplexer2
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A gRPC multiplexer for a specific Endpoints.ApiServiceDescriptor.

    Multiplexes data for inbound consumers based upon their instructionId.

    Multiplexing inbound and outbound streams is as thread safe as the consumers of those streams. For inbound streams, this is as thread safe as the inbound observers. For outbound streams, this is as thread safe as the underlying stream observer.

    TODO: Add support for multiplexing over multiple outbound observers by stickying the output location with a specific outbound observer.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> getInboundObserver()  
      org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> getOutboundObserver()  
      void registerConsumer​(java.lang.String instructionId, CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> receiver)
      Registers a consumer for the specified intruction id.
      java.lang.String toString()  
      void unregisterConsumer​(java.lang.String instructionId)
      Unregisters a consumer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BeamFnDataGrpcMultiplexer2

        public BeamFnDataGrpcMultiplexer2​(@Nullable org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor apiServiceDescriptor,
                                          OutboundObserverFactory outboundObserverFactory,
                                          OutboundObserverFactory.BasicFactory<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements,​org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> baseOutboundObserverFactory)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getInboundObserver

        public org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> getInboundObserver()
      • getOutboundObserver

        public org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> getOutboundObserver()
      • registerConsumer

        public void registerConsumer​(java.lang.String instructionId,
                                     CloseableFnDataReceiver<org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements> receiver)
        Registers a consumer for the specified intruction id.

        The BeamFnDataGrpcMultiplexer2 partitions BeamFnApi.Elements with multiple instruction ids ensuring that the receiver will only see BeamFnApi.Elements with a single instruction id.

        The caller must unregister the consumer when they no longer wish to receive messages.

      • unregisterConsumer

        public void unregisterConsumer​(java.lang.String instructionId)
        Unregisters a consumer.
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception