/*
* 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.
*/packageorg.apache.nifi.processors.grpc;importcom.fasterxml.jackson.core.JsonProcessingException;importcom.fasterxml.jackson.databind.JsonNode;importcom.fasterxml.jackson.databind.ObjectMapper;importcom.google.gson.Gson;importcom.google.gson.GsonBuilder;importcom.google.protobuf.ByteString;importio.grpc.CompressorRegistry;importio.grpc.DecompressorRegistry;importio.grpc.ManagedChannel;importio.grpc.netty.NettyChannelBuilder;importio.grpc.stub.StreamObserver;importio.netty.handler.ssl.SslContext;importorg.apache.nifi.annotation.behavior.InputRequirement;importorg.apache.nifi.annotation.behavior.SupportsBatching;importorg.apache.nifi.annotation.behavior.WritesAttribute;importorg.apache.nifi.annotation.behavior.WritesAttributes;importorg.apache.nifi.annotation.documentation.CapabilityDescription;importorg.apache.nifi.annotation.documentation.DeprecationNotice;importorg.apache.nifi.annotation.documentation.Tags;importorg.apache.nifi.annotation.lifecycle.OnScheduled;importorg.apache.nifi.annotation.lifecycle.OnShutdown;importorg.apache.nifi.components.PropertyDescriptor;importorg.apache.nifi.components.ValidationContext;importorg.apache.nifi.components.ValidationResult;importorg.apache.nifi.flowfile.FlowFile;importorg.apache.nifi.logging.ComponentLog;importorg.apache.nifi.processor.*;importorg.apache.nifi.processor.exception.ProcessException;importorg.apache.nifi.processor.util.StandardValidators;importorg.apache.nifi.processors.grpc.gen.edge.v1.*;importorg.apache.nifi.processors.grpc.id.EntityType;importorg.apache.nifi.processors.grpc.ssl.SslContextProvider;importorg.apache.nifi.processors.grpc.util.EdgeUtils;importorg.apache.nifi.ssl.SSLContextService;importorg.apache.nifi.util.StopWatch;importjava.io.InputStream;importjava.net.InetAddress;importjava.net.UnknownHostException;importjava.util.*;importjava.util.concurrent.ConcurrentHashMap;importjava.util.concurrent.ConcurrentMap;importjava.util.concurrent.TimeUnit;importjava.util.concurrent.atomic.AtomicReference;importjava.util.concurrent.locks.ReentrantLock;importjava.util.function.Consumer;@SupportsBatching@Tags({
"grpc","rpc","client"})@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)@CapabilityDescription("Sends FlowFiles, optionally with content, to a configurable remote gRPC service endpoint. The remote gRPC service must abide by the service IDL defined in NiFi. "+" gRPC isn't intended to carry large payloads, so this processor should be used only when FlowFile"+" sizes are on the order of megabytes. The default maximum message size is 4MB.")@WritesAttributes({
@WritesAttribute(attribute ="invokegrpc.response.code", description ="The response code that is returned (0 = ERROR, 1 = SUCCESS, 2 = RETRY)"),@WritesAttribute(attribute ="invokegrpc.response.body", description ="The response message that is returned"),@WritesAttribute(attribute ="invokegrpc.service.host", description ="The remote gRPC service hostname"),@WritesAttribute(attribute ="invokegrpc.service.port", description ="The remote gRPC service port"),@WritesAttribute(attribute ="invokegrpc.service.cloudKey", description ="The remote gRPC service cloudKey"),@WritesAttribute(attribute ="invokegrpc.service.cloudSecret", description ="The remote gRPC service cloudSecret"),@WritesAttribute(attribute ="invokegrpc.java.exception.class", description ="The Java exception class raised when the processor fails"),@WritesAttribute(attribute ="invokegrpc.java.exception.message", description ="The Java exception message raised when the processor fails"),})@DeprecationNotice(reason ="No planned alternatives to be offered. Use custom processors instead.")publicclassInvokeGRPCextendsAbstractProcessor{
publicstaticfinalStringRESPONSE_CODE="invokegrpc.response.code";publicstaticfinalStringRESPONSE_BODY="invokegrpc.response.body";publicstaticfinalStringSERVICE_HOST="invokegrpc.service.host";publicstaticfinalStringSERVICE_PORT="invokegrpc.service.port";publicstaticfinalStringROUTING_CLOUD_KEY="invokegrpc.service.cloudKey";publicstaticfinalStringROUTING_CLOUD_SECRET="invokegrpc.service.cloudSecret";publicstaticfinalStringEXCEPTION_CLASS="invokegrpc.java.exception.class";publicstaticfinalStringEXCEPTION_MESSAGE="invokegrpc.java.exception.message";// propertiespublicstaticfinalPropertyDescriptorPROP_SERVICE_HOST=newPropertyDescriptor.Builder().name("Remote gRPC service hostname").description("Remote host which will be connected to").required(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();publicstaticfinalPropertyDescriptorPROP_SERVICE_PORT=newPropertyDescriptor.Builder().name("Remote gRPC service port").description("Remote port which will be connected to").required(true).addValidator(StandardValidators.PORT_VALIDATOR).build();