@Test public void testInvoke() { final Invoker invoker = mock(Invoker.class); when(invoker.getInterface()).thenReturn(DemoService.class); final Invocation invocation = mock(Invocation.class); Method method = DemoService.class.getMethods()[0]; when(invocation.getMethodName()).thenReturn(method.getName()); when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes()); final Result result = mock(Result.class); when(result.hasException()).thenReturn(false); when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> { verifyInvocationStructure(invoker, invocation); return result; }); filter.invoke(invoker, invocation); verify(invoker).invoke(invocation); Context context = ContextUtil.getContext(); assertNull(context); }
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = DubboUtils.getResourceName(invoker, invocation); interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT); methodEntry = SphU.entry(resourceName, EntryType.OUT); Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable e = 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.traceEntry(e, interfaceEntry); Tracer.traceEntry(e, methodEntry); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } }
SentinelDubboConsumerFilter implements Filter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = DubboUtils.getResourceName(invoker, invocation); interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT); methodEntry = SphU.entry(resourceName, EntryType.OUT); Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable e = 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.traceEntry(e, interfaceEntry); Tracer.traceEntry(e, methodEntry); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } } }
SentinelDubboConsumerFilter implements Filter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = DubboUtils.getResourceName(invoker, invocation); interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT); methodEntry = SphU.entry(resourceName, EntryType.OUT); Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable e = 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.traceEntry(e, interfaceEntry); Tracer.traceEntry(e, methodEntry); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } } SentinelDubboConsumerFilter(); }
SentinelDubboConsumerFilter implements Filter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = DubboUtils.getResourceName(invoker, invocation); interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT); methodEntry = SphU.entry(resourceName, EntryType.OUT); Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable e = 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.traceEntry(e, interfaceEntry); Tracer.traceEntry(e, methodEntry); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } } SentinelDubboConsumerFilter(); @Override Result invoke(Invoker<?> invoker, Invocation invocation); }
SentinelDubboConsumerFilter implements Filter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = DubboUtils.getResourceName(invoker, invocation); interfaceEntry = SphU.entry(invoker.getInterface().getName(), EntryType.OUT); methodEntry = SphU.entry(resourceName, EntryType.OUT); Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable e = 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.traceEntry(e, interfaceEntry); Tracer.traceEntry(e, methodEntry); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } } SentinelDubboConsumerFilter(); @Override Result invoke(Invoker<?> invoker, Invocation invocation);  }