Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.fn.harness.control;
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Throwables.getStackTraceAsString;
import java.util.EnumMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import org.apache.beam.fn.harness.logging.BeamFnLoggingMDC;
import org.apache.beam.model.fnexecution.v1.BeamFnApi;
import org.apache.beam.model.fnexecution.v1.BeamFnControlGrpc;
import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
import org.apache.beam.sdk.fn.channel.ManagedChannelFactory;
import org.apache.beam.sdk.fn.stream.OutboundObserverFactory;
import org.apache.beam.sdk.function.ThrowingFunction;
import org.apache.beam.vendor.grpc.v1p60p1.io.grpc.Status;
import org.apache.beam.vendor.grpc.v1p60p1.io.grpc.stub.StreamObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A client for the Beam Fn Control API. Uses an unbounded internal queue to pull down an unbounded
* number of requests.
*
*
Also can delegate to a set of handlers based upon the {@link
* BeamFnApi.InstructionRequest.RequestCase request type}.
*
*
When the inbound instruction stream finishes successfully, the {@code onFinish} is completed
* successfully signaling to the caller that this client will not produce any more {@link
* BeamFnApi.InstructionRequest}s. If the inbound instruction stream errors, the {@code onFinish} is
* completed exceptionally propagating the failure reason to the caller and signaling that this
* client will not produce any more {@link BeamFnApi.InstructionRequest}s.
*/
public class BeamFnControlClient {
private static final Logger LOG = LoggerFactory.getLogger(BeamFnControlClient.class);
private final StreamObserver outboundObserver;
private final EnumMap<
BeamFnApi.InstructionRequest.RequestCase,
ThrowingFunction>
handlers;
private final CompletableFuture