Update adapter modules to update corresponding resource classification
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
086a6b0370
commit
800f6b9d65
|
|
@ -17,6 +17,7 @@ package com.alibaba.csp.sentinel.adapter.dubbo;
|
|||
|
||||
import com.alibaba.csp.sentinel.Entry;
|
||||
import com.alibaba.csp.sentinel.EntryType;
|
||||
import com.alibaba.csp.sentinel.ResourceTypeConstants;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.Tracer;
|
||||
import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboConfig;
|
||||
|
|
@ -54,8 +55,9 @@ public class SentinelDubboConsumerFilter implements Filter {
|
|||
Entry methodEntry = null;
|
||||
try {
|
||||
String resourceName = DubboUtils.getResourceName(invoker, invocation, DubboConfig.getDubboConsumerPrefix());
|
||||
interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT);
|
||||
methodEntry = SphU.entry(resourceName, EntryType.OUT);
|
||||
interfaceEntry = SphU.entry(invoker.getInterface().getName(),
|
||||
ResourceTypeConstants.COMMON_RPC, EntryType.OUT);
|
||||
methodEntry = SphU.entry(resourceName, ResourceTypeConstants.COMMON_RPC, EntryType.OUT);
|
||||
|
||||
Result result = invoker.invoke(invocation);
|
||||
if (result.hasException()) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package com.alibaba.csp.sentinel.adapter.dubbo;
|
|||
|
||||
import com.alibaba.csp.sentinel.Entry;
|
||||
import com.alibaba.csp.sentinel.EntryType;
|
||||
import com.alibaba.csp.sentinel.ResourceTypeConstants;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.Tracer;
|
||||
import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboConfig;
|
||||
|
|
@ -63,8 +64,9 @@ public class SentinelDubboProviderFilter implements Filter {
|
|||
// Only need to create entrance context at provider side, as context will take effect
|
||||
// at entrance of invocation chain only (for inbound traffic).
|
||||
ContextUtil.enter(resourceName, application);
|
||||
interfaceEntry = SphU.entry(interfaceName, EntryType.IN);
|
||||
methodEntry = SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments());
|
||||
interfaceEntry = SphU.entry(interfaceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN);
|
||||
methodEntry = SphU.entry(resourceName, ResourceTypeConstants.COMMON_RPC,
|
||||
EntryType.IN, invocation.getArguments());
|
||||
|
||||
Result result = invoker.invoke(invocation);
|
||||
if (result.hasException()) {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode entranceNode = context.getEntranceNode();
|
||||
ResourceWrapper entranceResource = entranceNode.getId();
|
||||
assertEquals(Constants.CONTEXT_DEFAULT_NAME, entranceResource.getName());
|
||||
assertSame(EntryType.IN, entranceResource.getType());
|
||||
assertSame(EntryType.IN, entranceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(interfaceName, EntryType.OUT);
|
||||
Set<Node> childList = entranceNode.getChildList();
|
||||
|
|
@ -111,7 +111,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode interfaceNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper interfaceResource = interfaceNode.getId();
|
||||
assertEquals(DemoService.class.getName(), interfaceResource.getName());
|
||||
assertSame(EntryType.OUT, interfaceResource.getType());
|
||||
assertSame(EntryType.OUT, interfaceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(resourceName, EntryType.OUT);
|
||||
childList = interfaceNode.getChildList();
|
||||
|
|
@ -119,7 +119,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode methodNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper methodResource = methodNode.getId();
|
||||
assertEquals(resourceName, methodResource.getName());
|
||||
assertSame(EntryType.OUT, methodResource.getType());
|
||||
assertSame(EntryType.OUT, methodResource.getEntryType());
|
||||
|
||||
// Verify curEntry
|
||||
Entry curEntry = context.getCurEntry();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode entranceNode = context.getEntranceNode();
|
||||
ResourceWrapper entranceResource = entranceNode.getId();
|
||||
assertEquals(resourceName, entranceResource.getName());
|
||||
assertSame(EntryType.IN, entranceResource.getType());
|
||||
assertSame(EntryType.IN, entranceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(interfaceName, EntryType.IN);
|
||||
Set<Node> childList = entranceNode.getChildList();
|
||||
|
|
@ -112,7 +112,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode interfaceNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper interfaceResource = interfaceNode.getId();
|
||||
assertEquals(DemoService.class.getName(), interfaceResource.getName());
|
||||
assertSame(EntryType.IN, interfaceResource.getType());
|
||||
assertSame(EntryType.IN, interfaceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments());
|
||||
childList = interfaceNode.getChildList();
|
||||
|
|
@ -120,7 +120,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode methodNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper methodResource = methodNode.getId();
|
||||
assertEquals(resourceName, methodResource.getName());
|
||||
assertSame(EntryType.IN, methodResource.getType());
|
||||
assertSame(EntryType.IN, methodResource.getEntryType());
|
||||
|
||||
// Verify curEntry
|
||||
Entry curEntry = context.getCurEntry();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package com.alibaba.csp.sentinel.adapter.dubbo;
|
|||
|
||||
import com.alibaba.csp.sentinel.Entry;
|
||||
import com.alibaba.csp.sentinel.EntryType;
|
||||
import com.alibaba.csp.sentinel.ResourceTypeConstants;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.Tracer;
|
||||
import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboConfig;
|
||||
|
|
@ -54,19 +55,23 @@ public class SentinelDubboConsumerFilter extends AbstractDubboFilter implements
|
|||
Entry methodEntry = null;
|
||||
try {
|
||||
String resourceName = getResourceName(invoker, invocation, DubboConfig.getDubboConsumerPrefix());
|
||||
interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT);
|
||||
methodEntry = SphU.entry(resourceName, EntryType.OUT);
|
||||
interfaceEntry = SphU.entry(invoker.getInterface().getName(), ResourceTypeConstants.COMMON_RPC,
|
||||
EntryType.OUT);
|
||||
methodEntry = SphU.entry(resourceName, ResourceTypeConstants.COMMON_RPC, EntryType.OUT);
|
||||
|
||||
Result result = invoker.invoke(invocation);
|
||||
if (result.hasException()) {
|
||||
Throwable e = result.getException();
|
||||
// Record common exception.
|
||||
Tracer.trace(result.getException());
|
||||
Tracer.traceEntry(e, interfaceEntry);
|
||||
Tracer.traceEntry(e, methodEntry);
|
||||
}
|
||||
return result;
|
||||
} catch (BlockException e) {
|
||||
return DubboFallbackRegistry.getConsumerFallback().handle(invoker, invocation, e);
|
||||
} catch (RpcException e) {
|
||||
Tracer.trace(e);
|
||||
Tracer.traceEntry(e, interfaceEntry);
|
||||
Tracer.traceEntry(e, methodEntry);
|
||||
throw e;
|
||||
} finally {
|
||||
if (methodEntry != null) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package com.alibaba.csp.sentinel.adapter.dubbo;
|
|||
|
||||
import com.alibaba.csp.sentinel.Entry;
|
||||
import com.alibaba.csp.sentinel.EntryType;
|
||||
import com.alibaba.csp.sentinel.ResourceTypeConstants;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.Tracer;
|
||||
import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboConfig;
|
||||
|
|
@ -60,18 +61,23 @@ public class SentinelDubboProviderFilter extends AbstractDubboFilter implements
|
|||
String resourceName = getResourceName(invoker, invocation, DubboConfig.getDubboProviderPrefix());
|
||||
String interfaceName = invoker.getInterface().getName();
|
||||
ContextUtil.enter(resourceName, application);
|
||||
interfaceEntry = SphU.entry(interfaceName, EntryType.IN);
|
||||
methodEntry = SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments());
|
||||
interfaceEntry = SphU.entry(interfaceName, ResourceTypeConstants.COMMON_RPC, EntryType.IN);
|
||||
methodEntry = SphU.entry(resourceName, ResourceTypeConstants.COMMON_RPC,
|
||||
EntryType.IN, invocation.getArguments());
|
||||
|
||||
Result result = invoker.invoke(invocation);
|
||||
if (result.hasException()) {
|
||||
Tracer.trace(result.getException());
|
||||
Throwable e = result.getException();
|
||||
// Record common exception.
|
||||
Tracer.traceEntry(e, interfaceEntry);
|
||||
Tracer.traceEntry(e, methodEntry);
|
||||
}
|
||||
return result;
|
||||
} catch (BlockException e) {
|
||||
return DubboFallbackRegistry.getProviderFallback().handle(invoker, invocation, e);
|
||||
} catch (RpcException e) {
|
||||
Tracer.trace(e);
|
||||
Tracer.traceEntry(e, interfaceEntry);
|
||||
Tracer.traceEntry(e, methodEntry);
|
||||
throw e;
|
||||
} finally {
|
||||
if (methodEntry != null) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode entranceNode = context.getEntranceNode();
|
||||
ResourceWrapper entranceResource = entranceNode.getId();
|
||||
assertEquals(Constants.CONTEXT_DEFAULT_NAME, entranceResource.getName());
|
||||
assertSame(EntryType.IN, entranceResource.getType());
|
||||
assertSame(EntryType.IN, entranceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(interfaceName, EntryType.OUT);
|
||||
Set<Node> childList = entranceNode.getChildList();
|
||||
|
|
@ -100,7 +100,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode interfaceNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper interfaceResource = interfaceNode.getId();
|
||||
assertEquals(DemoService.class.getName(), interfaceResource.getName());
|
||||
assertSame(EntryType.OUT, interfaceResource.getType());
|
||||
assertSame(EntryType.OUT, interfaceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(resourceName, EntryType.OUT);
|
||||
childList = interfaceNode.getChildList();
|
||||
|
|
@ -108,7 +108,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest {
|
|||
DefaultNode methodNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper methodResource = methodNode.getId();
|
||||
assertEquals(resourceName, methodResource.getName());
|
||||
assertSame(EntryType.OUT, methodResource.getType());
|
||||
assertSame(EntryType.OUT, methodResource.getEntryType());
|
||||
|
||||
// Verify curEntry
|
||||
Entry curEntry = context.getCurEntry();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode entranceNode = context.getEntranceNode();
|
||||
ResourceWrapper entranceResource = entranceNode.getId();
|
||||
assertEquals(resourceName, entranceResource.getName());
|
||||
assertSame(EntryType.IN, entranceResource.getType());
|
||||
assertSame(EntryType.IN, entranceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(interfaceName, EntryType.IN);
|
||||
Set<Node> childList = entranceNode.getChildList();
|
||||
|
|
@ -100,7 +100,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode interfaceNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper interfaceResource = interfaceNode.getId();
|
||||
assertEquals(DemoService.class.getName(), interfaceResource.getName());
|
||||
assertSame(EntryType.IN, interfaceResource.getType());
|
||||
assertSame(EntryType.IN, interfaceResource.getEntryType());
|
||||
|
||||
// As SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments());
|
||||
childList = interfaceNode.getChildList();
|
||||
|
|
@ -108,7 +108,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest {
|
|||
DefaultNode methodNode = (DefaultNode) childList.iterator().next();
|
||||
ResourceWrapper methodResource = methodNode.getId();
|
||||
assertEquals(resourceName, methodResource.getName());
|
||||
assertSame(EntryType.IN, methodResource.getType());
|
||||
assertSame(EntryType.IN, methodResource.getEntryType());
|
||||
|
||||
// Verify curEntry
|
||||
Entry curEntry = context.getCurEntry();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
|||
|
||||
import com.alibaba.csp.sentinel.AsyncEntry;
|
||||
import com.alibaba.csp.sentinel.EntryType;
|
||||
import com.alibaba.csp.sentinel.ResourceTypeConstants;
|
||||
import com.alibaba.csp.sentinel.SphU;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.param.GatewayParamParser;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
|
||||
|
|
@ -96,7 +97,8 @@ public class SentinelZuulPreFilter extends ZuulFilter {
|
|||
return r.getResourceMode() == resType;
|
||||
}
|
||||
});
|
||||
AsyncEntry entry = SphU.asyncEntry(resourceName, EntryType.IN, 1, params);
|
||||
AsyncEntry entry = SphU.asyncEntry(resourceName, ResourceTypeConstants.COMMON_API_GATEWAY,
|
||||
EntryType.IN, params);
|
||||
asyncEntries.push(entry);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ public class SentinelResourceAspect extends AbstractSentinelAspectSupport {
|
|||
}
|
||||
String resourceName = getResourceName(annotation.value(), originMethod);
|
||||
EntryType entryType = annotation.entryType();
|
||||
int resourceType = annotation.resourceType();
|
||||
Entry entry = null;
|
||||
try {
|
||||
entry = SphU.entry(resourceName, entryType, 1, pjp.getArgs());
|
||||
entry = SphU.entry(resourceName, resourceType, entryType, pjp.getArgs());
|
||||
Object result = pjp.proceed();
|
||||
return result;
|
||||
} catch (BlockException ex) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue