Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengJie1053 committed Nov 23, 2023
1 parent 0c1c4ed commit 95b655e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,48 @@

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;
import java.util.Collection;
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<String, Collection<String>> headers = new HashMap<>(requestTemplate.headers());
Map<String, Collection<String>> headers = new HashMap<>(requestTemplate.headers());
headers.put(
RpcConstant.LINKIS_LOAD_BALANCER_TYPE,
Arrays.asList(RpcConstant.LINKIS_LOAD_BALANCER_TYPE_RPC));
Tuple2<String, String> 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<String, String> 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) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ private Response<ServiceInstance> getInstanceResponse(
return null;
} else {
return new DefaultResponse(chooseInstance);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -71,7 +77,6 @@ private[rpc] class BaseRPCSender extends Sender with Logging {

private[rpc] def getApplicationName = name


def getSenderInstance(): String = {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ private[rpc] class SpringMVCRPCSender private[rpc] (
null
}
}

}

0 comments on commit 95b655e

Please sign in to comment.