Class FnApiControlClient

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, InstructionRequestHandler

    public class FnApiControlClient
    extends java.lang.Object
    implements java.io.Closeable, InstructionRequestHandler
    A client for the control plane of an SDK harness, which can issue requests to it over the Fn API.

    This class presents a low-level Java API de-inverting the Fn API's gRPC layer.

    The Fn API is inverted so the runner is the server and the SDK harness is the client, for firewalling reasons (the runner may execute in a more privileged environment forbidding outbound connections).

    This low-level client is responsible only for correlating requests with responses.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> asResponseObserver()  
      void close()  
      static FnApiControlClient forRequestObserver​(java.lang.String workerId, org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest> requestObserver, java.util.concurrent.ConcurrentMap<java.lang.String,​org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor> processBundleDescriptors)
      Returns a FnApiControlClient which will submit its requests to the provided observer.
      org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor getProcessBundleDescriptor​(java.lang.String id)  
      java.lang.String getWorkerId()  
      java.util.concurrent.CompletionStage<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> handle​(org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest request)  
      void onClose​(java.util.function.Consumer<FnApiControlClient> onCloseListener)  
      void registerProcessBundleDescriptor​(org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor processBundleDescriptor)  
      • Methods inherited from class java.lang.Object

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

      • forRequestObserver

        public static FnApiControlClient forRequestObserver​(java.lang.String workerId,
                                                            org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest> requestObserver,
                                                            java.util.concurrent.ConcurrentMap<java.lang.String,​org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor> processBundleDescriptors)
        Returns a FnApiControlClient which will submit its requests to the provided observer.

        It is the responsibility of the caller to register this object as an observer of incoming responses (this will generally be done as part of fulfilling the contract of a gRPC service).

      • handle

        public java.util.concurrent.CompletionStage<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> handle​(org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest request)
        Specified by:
        handle in interface InstructionRequestHandler
      • asResponseObserver

        public org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> asResponseObserver()
      • getProcessBundleDescriptor

        public org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor getProcessBundleDescriptor​(java.lang.String id)
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • getWorkerId

        public java.lang.String getWorkerId()
      • onClose

        public void onClose​(java.util.function.Consumer<FnApiControlClient> onCloseListener)