Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Adapter] Support motan RPC #1825

Merged
merged 6 commits into from
Dec 5, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
1、remove MotanAppContextFilter
2、format comment
zhangxn8 committed Nov 8, 2020
commit 66b97aa4e092b1e725f2abc133eee86b3fa22944
Original file line number Diff line number Diff line change
@@ -8,10 +8,8 @@
import com.weibo.api.motan.rpc.Request;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
zhangxn8 marked this conversation as resolved.
Show resolved Hide resolved
**/
*/
@SpiMeta(name = MotanAdapterGlobalConfig.BASE_SENTINEL_MOTAN_FILTER)
@Activation(sequence = 1)
public abstract class BaseMotanSentinelFilter implements Filter {
zhangxn8 marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

Original file line number Diff line number Diff line change
@@ -7,10 +7,8 @@
import com.weibo.api.motan.util.ReflectUtil;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public class MotanUtils {

private MotanUtils() {}
Original file line number Diff line number Diff line change
@@ -13,11 +13,9 @@
import com.weibo.api.motan.rpc.Response;

/**
* program: sentinel-parent
* description: consumer filter
* author: zhangxn8
**/
@Activation(key =MotanConstants.NODE_TYPE_REFERER)
*/
@Activation(key = MotanConstants.NODE_TYPE_REFERER)
@SpiMeta(name = MotanAdapterGlobalConfig.SENTINEL_MOTAN_CONSUMER)
public class SentinelMotanConsumerFilter extends BaseMotanSentinelFilter {

Original file line number Diff line number Diff line change
@@ -13,12 +13,12 @@
import com.weibo.api.motan.rpc.Request;
import com.weibo.api.motan.rpc.Response;

import java.util.Map;

/**
* program: sentinel-parent
* description: provider filter
* author: zhangxn8
**/
@Activation(key =MotanConstants.NODE_TYPE_SERVICE)
*/
@Activation(key = MotanConstants.NODE_TYPE_SERVICE)
@SpiMeta(name = MotanAdapterGlobalConfig.SENTINEL_MOTAN_PROVIDER)
public class SentinelMotanProviderFilter extends BaseMotanSentinelFilter {

@@ -40,11 +40,13 @@ String getInterfaceName(Caller<?> caller, String prefix) {
public Response filter(Caller<?> caller, Request request) {
Entry interfaceEntry = null;
Entry methodEntry = null;
Map<String, String> attachment = request.getAttachments();
String origin = attachment.getOrDefault(MotanAdapterGlobalConfig.APPLICATION, MotanAdapterGlobalConfig.MOTAN);
String prefix = MotanAdapterGlobalConfig.getMotanProviderPrefix();
String interfaceResourceName = getInterfaceName(caller, prefix);
String methodResourceName = getMethodName(caller, request, prefix);
try {
ContextUtil.enter(methodResourceName, "");
ContextUtil.enter(methodResourceName, origin);
interfaceEntry = SphU.entry(interfaceResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN);
methodEntry = SphU.entry(methodResourceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN,
request.getArguments());
Original file line number Diff line number Diff line change
@@ -7,10 +7,8 @@
import com.alibaba.csp.sentinel.util.StringUtil;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public class MotanAdapterGlobalConfig {

private static final String TRUE_STR = "true";
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
com.alibaba.csp.sentinel.adapter.motan.SentinelMotanProviderFilter
com.alibaba.csp.sentinel.adapter.motan.SentinelMotanConsumerFilter
com.alibaba.csp.sentinel.adapter.motan.MotanAppContextFilter
com.alibaba.csp.sentinel.adapter.motan.SentinelMotanConsumerFilter
Original file line number Diff line number Diff line change
@@ -12,10 +12,8 @@
import java.util.List;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public class SentinelMotanConsumerService {

private static final String INTERFACE_RES_KEY = MotanDemoService.class.getName();
@@ -53,7 +51,7 @@ public static void main(String[] args) {

// 使用服务
MotanDemoService service = motanDemoServiceReferer.getRef();
for (int i = 0 ;i< 20 ;i++) {
for (int i = 0 ;i< 5000 ;i++) {
System.out.println(service.hello("motan"));
}

Original file line number Diff line number Diff line change
@@ -10,10 +10,8 @@
import com.weibo.api.motan.util.MotanSwitcherUtil;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public class SentinelMotanProviderService {

public static void main(String[] args) {
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.alibaba.csp.sentinel.demo.motan.service;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public interface MotanDemoService {

String hello(String name);
Original file line number Diff line number Diff line change
@@ -3,10 +3,8 @@
import com.alibaba.csp.sentinel.demo.motan.service.MotanDemoService;

/**
* program: sentinel-parent
* description: ${description}
* author: zhangxn8
**/
*/
public class MotanDemoServiceImpl implements MotanDemoService {

@Override