public class FnApiControlClient extends java.lang.Object implements java.io.Closeable, InstructionRequestHandler
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.
Modifier and Type | Method and 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) |
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)
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).
public java.util.concurrent.CompletionStage<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> handle(org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest request)
handle
in interface InstructionRequestHandler
public org.apache.beam.vendor.grpc.v1p48p1.io.grpc.stub.StreamObserver<org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionResponse> asResponseObserver()
public org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor getProcessBundleDescriptor(java.lang.String id)
public void registerProcessBundleDescriptor(org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleDescriptor processBundleDescriptor)
registerProcessBundleDescriptor
in interface InstructionRequestHandler
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public java.lang.String getWorkerId()
public void onClose(java.util.function.Consumer<FnApiControlClient> onCloseListener)