diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/FeignRequestInterceptor.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/FeignRequestInterceptor.java index 09515a8a3b..ef1c2dd095 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/FeignRequestInterceptor.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/FeignRequestInterceptor.java @@ -17,16 +17,14 @@ package org.apache.linkis.rpc.conf; -import feign.RequestInterceptor; -import feign.RequestTemplate; import org.apache.linkis.rpc.BaseRPCSender; import org.apache.linkis.rpc.constant.RpcConstant; import org.apache.linkis.server.BDPJettyServerHelper; import org.apache.linkis.server.Message; import org.apache.linkis.server.security.SSOUtils$; import org.apache.linkis.server.security.SecurityFilter$; + import org.springframework.stereotype.Component; -import scala.Tuple2; import java.io.UnsupportedEncodingException; import java.util.Arrays; @@ -34,24 +32,33 @@ import java.util.HashMap; import java.util.Map; +import scala.Tuple2; + +import feign.RequestInterceptor; +import feign.RequestTemplate; @Component public class FeignRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate requestTemplate) { - Map> headers = new HashMap<>(requestTemplate.headers()); + Map> headers = new HashMap<>(requestTemplate.headers()); + headers.put( + RpcConstant.LINKIS_LOAD_BALANCER_TYPE, + Arrays.asList(RpcConstant.LINKIS_LOAD_BALANCER_TYPE_RPC)); + Tuple2 userTicketKV = + SSOUtils$.MODULE$.getUserTicketKV(SecurityFilter$.MODULE$.OTHER_SYSTEM_IGNORE_UM_USER()); + headers.put(userTicketKV._1, Arrays.asList(userTicketKV._2)); + try { + String body = + new String( + requestTemplate.body(), + org.apache.linkis.common.conf.Configuration.BDP_ENCODING().getValue()); + Message message = BDPJettyServerHelper.gson().fromJson(body, Message.class); headers.put( - RpcConstant.LINKIS_LOAD_BALANCER_TYPE, Arrays.asList(RpcConstant.LINKIS_LOAD_BALANCER_TYPE_RPC)); - Tuple2 userTicketKV = - SSOUtils$.MODULE$.getUserTicketKV(SecurityFilter$.MODULE$.OTHER_SYSTEM_IGNORE_UM_USER()); - headers.put(userTicketKV._1, Arrays.asList(userTicketKV._2)); - try { - String body = new String(requestTemplate.body(), org.apache.linkis.common.conf.Configuration.BDP_ENCODING().getValue()); - Message message = BDPJettyServerHelper.gson().fromJson(body, Message.class); - headers.put(RpcConstant.FIXED_INSTANCE, Arrays.asList(BaseRPCSender.getFixedInstanceInfo(message))); - requestTemplate.headers(headers); - } catch (UnsupportedEncodingException e) { - } + RpcConstant.FIXED_INSTANCE, Arrays.asList(BaseRPCSender.getFixedInstanceInfo(message))); + requestTemplate.headers(headers); + } catch (UnsupportedEncodingException e) { } + } } diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/GatewayLoadBalancerConfiguration.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/GatewayLoadBalancerConfiguration.java index 479b2dea79..0c9aecf177 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/GatewayLoadBalancerConfiguration.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/GatewayLoadBalancerConfiguration.java @@ -17,8 +17,4 @@ package org.apache.linkis.rpc.loadbalancer; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.context.annotation.Configuration; - - public class GatewayLoadBalancerConfiguration {} diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/LinkisLoadBalancerClientConfiguration.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/LinkisLoadBalancerClientConfiguration.java index 6fca87cd5c..f4d501dfe4 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/LinkisLoadBalancerClientConfiguration.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/LinkisLoadBalancerClientConfiguration.java @@ -25,6 +25,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; + @Configuration @LoadBalancerClients(defaultConfiguration = {LinkisLoadBalancerClientConfiguration.class}) public class LinkisLoadBalancerClientConfiguration { diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/ServiceInstancePriorityLoadBalancer.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/ServiceInstancePriorityLoadBalancer.java index c1d6c37121..f9511fcf52 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/ServiceInstancePriorityLoadBalancer.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/loadbalancer/ServiceInstancePriorityLoadBalancer.java @@ -166,6 +166,6 @@ private Response getInstanceResponse( return null; } else { return new DefaultResponse(chooseInstance); - } + } } } diff --git a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/BaseRPCSender.scala b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/BaseRPCSender.scala index 21b5ee913b..1c4e43b3cc 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/BaseRPCSender.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/BaseRPCSender.scala @@ -17,20 +17,26 @@ package org.apache.linkis.rpc -import org.apache.commons.lang3.StringUtils import org.apache.linkis.DataWorkCloudApplication import org.apache.linkis.common.ServiceInstance import org.apache.linkis.common.exception.WarnException import org.apache.linkis.common.utils.Logging import org.apache.linkis.protocol.Protocol import org.apache.linkis.rpc.conf.DynamicFeignClient -import org.apache.linkis.rpc.conf.RPCConfiguration.{BDP_RPC_SENDER_ASYN_CONSUMER_THREAD_FREE_TIME_MAX, BDP_RPC_SENDER_ASYN_CONSUMER_THREAD_MAX, BDP_RPC_SENDER_ASYN_QUEUE_CAPACITY} +import org.apache.linkis.rpc.conf.RPCConfiguration.{ + BDP_RPC_SENDER_ASYN_CONSUMER_THREAD_FREE_TIME_MAX, + BDP_RPC_SENDER_ASYN_CONSUMER_THREAD_MAX, + BDP_RPC_SENDER_ASYN_QUEUE_CAPACITY +} import org.apache.linkis.rpc.constant.RpcConstant import org.apache.linkis.rpc.interceptor._ import org.apache.linkis.rpc.transform.{RPCConsumer, RPCProduct} import org.apache.linkis.server.Message +import org.apache.commons.lang3.StringUtils + import java.util + import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit @@ -71,7 +77,6 @@ private[rpc] class BaseRPCSender extends Sender with Logging { private[rpc] def getApplicationName = name - def getSenderInstance(): String = { null } diff --git a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/sender/SpringMVCRPCSender.scala b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/sender/SpringMVCRPCSender.scala index 199d0d9b4d..1aae1f0cf3 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/sender/SpringMVCRPCSender.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/sender/SpringMVCRPCSender.scala @@ -73,4 +73,5 @@ private[rpc] class SpringMVCRPCSender private[rpc] ( null } } + }