protected String getResourceName(Invoker<?> invoker, Invocation invocation) { StringBuilder buf = new StringBuilder(64); buf.append(invoker.getInterface().getName()) .append(":") .append(invocation.getMethodName()) .append("("); boolean isFirst = true; for (Class<?> clazz : invocation.getParameterTypes()) { if (!isFirst) { buf.append(","); } buf.append(clazz.getName()); isFirst = false; } buf.append(")"); return buf.toString(); } }
@Override public void referred(Invoker<?> invoker) throws RpcException { Class<?> interfaceClass = invoker.getInterface(); URL url = invoker.getUrl(); String group = url.getParameter(DubboSpringBootStarterConstants.GROUP); String version = url.getParameter(DubboSpringBootStarterConstants.VERSION); ClassIdBean classIdBean = new ClassIdBean(interfaceClass, group, version); SUBSCRIBEDINTERFACES_SET.add(classIdBean); }
@Override public void destroyed(Invoker<?> invoker) { Class<?> interfaceClass = invoker.getInterface(); URL url = invoker.getUrl(); String group = url.getParameter(DubboSpringBootStarterConstants.GROUP); String version = url.getParameter(DubboSpringBootStarterConstants.VERSION); ClassIdBean classIdBean = new ClassIdBean(interfaceClass, group, version); SUBSCRIBEDINTERFACES_SET.remove(classIdBean); } }
@Override @SuppressWarnings("unchecked") public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException { String methodName = invocation.getMethodName(); Class clazz = invoker.getInterface(); Class[] args = invocation.getParameterTypes(); Method method; Myth myth = null; try { method = clazz.getDeclaredMethod(methodName, args); myth = method.getAnnotation(Myth.class); } catch (NoSuchMethodException e) { e.printStackTrace(); } if (Objects.nonNull(myth)) { final MythTransactionContext mythTransactionContext = TransactionContextLocal.getInstance().get(); if (Objects.nonNull(mythTransactionContext)) { RpcContext.getContext() .setAttachment(CommonConstant.MYTH_TRANSACTION_CONTEXT, GsonUtils.getInstance().toJson(mythTransactionContext)); } } return invoker.invoke(invocation); }
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Entry interfaceEntry = null; Entry methodEntry = null; try { String resourceName = 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()) { // Record common exception. Tracer.trace(result.getException()); } return result; } catch (BlockException e) { return DubboFallbackRegistry.getConsumerFallback().handle(invoker, invocation, e); } catch (RpcException e) { Tracer.trace(e); throw e; } finally { if (methodEntry != null) { methodEntry.exit(); } if (interfaceEntry != null) { interfaceEntry.exit(); } } } }
invocationDef.setInterfaceClass(invoker.getInterface()); invocationDef.setMethodName(invocation.getMethodName()); invocationDef.setParameterTypes(invocation.getParameterTypes());
public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException { String methodName = invocation.getMethodName(); Class clazz = invoker.getInterface(); Class[] args = invocation.getParameterTypes(); final Object[] arguments = invocation.getArguments();
invocationDef.setInterfaceClass(invoker.getInterface()); invocationDef.setMethodName(invocation.getMethodName()); invocationDef.setParameterTypes(invocation.getParameterTypes());
try { String resourceName = getResourceName(invoker, invocation); String interfaceName = invoker.getInterface().getName(); ContextUtil.enter(resourceName, application); interfaceEntry = SphU.entry(interfaceName, EntryType.IN);
String service = invoker.getInterface().getSimpleName(); String method = RpcUtils.getMethodName(invocation); span.name(service + "/" + method);
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { ClassLoader ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(invoker.getInterface().getClassLoader()); try { return invoker.invoke(invocation); } finally { Thread.currentThread().setContextClassLoader(ocl); } }
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { ClassLoader ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(invoker.getInterface().getClassLoader()); try { return invoker.invoke(invocation); } finally { Thread.currentThread().setContextClassLoader(ocl); } }
public AbstractExporter(Invoker<T> invoker) { if (invoker == null) throw new IllegalStateException("service invoker == null"); if (invoker.getInterface() == null) throw new IllegalStateException("service type == null"); if (invoker.getUrl() == null) throw new IllegalStateException("service url == null"); this.invoker = invoker; }
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) { Invoker<?> invoker = exporter.getInvoker(); Method[] methods = invoker.getInterface().getMethods(); for (Method m : methods) { if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) { return m; } } return null; }
public void referred(Invoker<?> invoker) throws JahhanException { if (invoker.getUrl().getParameter(Constants.DEPRECATED_KEY, false)) { log.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl()); } }
public void referred(Invoker<?> invoker) throws RpcException { if (invoker.getUrl().getParameter(Constants.DEPRECATED_KEY, false)) { LOGGER.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl()); } }
public void referred(Invoker<?> invoker) throws RpcException { if (invoker.getUrl().getParameter(Constants.DEPRECATED_KEY, false)) { LOGGER.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl()); } }
@Override public void referred(Invoker<?> invoker) throws RpcException { if (invoker.getUrl().getParameter(Constants.DEPRECATED_KEY, false)) { LOGGER.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl()); } }
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }