Class FnApiControlClient

java.lang.Object
org.apache.beam.runners.fnexecution.control.FnApiControlClient
All Implemented Interfaces:
Closeable, AutoCloseable, InstructionRequestHandler

public class FnApiControlClient extends Object implements 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 Details

    • forRequestObserver

      public static FnApiControlClient forRequestObserver(String workerId, org.apache.beam.vendor.grpc.v1p69p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest> requestObserver, ConcurrentMap<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 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.v1p69p0.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> asResponseObserver()
    • getProcessBundleDescriptor

      public org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor getProcessBundleDescriptor(String id)
    • registerProcessBundleDescriptor

      public void registerProcessBundleDescriptor(org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor processBundleDescriptor)
      Specified by:
      registerProcessBundleDescriptor in interface InstructionRequestHandler
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getWorkerId

      public String getWorkerId()
    • onClose

      public void onClose(Consumer<FnApiControlClient> onCloseListener)