@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { String application = invoker.getUrl().getParameter(Constants.APPLICATION_KEY); if (application != null) { RpcContext.getContext().setAttachment(DubboUtils.DUBBO_APPLICATION_KEY, application); } return invoker.invoke(invocation); } }
@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); }
public Result wrapResultForProvider(Invoker<?> invoker, Invocation invocation, String propagatedBy, boolean attachRequired) { try { RpcResult result = (RpcResult) invoker.invoke(invocation); if (result.hasException()) { return this.createErrorResultForProvider(result.getException(), propagatedBy, attachRequired); } else { return this.convertResultForProvider(result, propagatedBy, attachRequired); } } catch (Throwable rex) { return this.createErrorResultForProvider(rex, propagatedBy, attachRequired); } }
public Result wrapResultForProvider(Invoker<?> invoker, Invocation invocation, String propagatedBy, boolean attachRequired) { try { RpcResult result = (RpcResult) invoker.invoke(invocation); if (result.hasException()) { return this.createErrorResultForProvider(result.getException(), propagatedBy, attachRequired); } else { return this.convertResultForProvider(result, propagatedBy, attachRequired); } } catch (Throwable rex) { return this.createErrorResultForProvider(rex, propagatedBy, attachRequired); } }
@Override public EasyTransResult invoke(EasyTransFilterChain filterChain, Map<String,Object> header, EasyTransRequest<?, ?> request) { Result dubboInvoke = null; if(localInvocation instanceof RpcInvocation){ Object[] arguments = localInvocation.getArguments(); Object[] argReq = (Object[]) arguments[2]; argReq[0] = request; dubboInvoke = localInvoker.invoke(localInvocation); }else{ throw new RuntimeException("Do not support,please extend it"); } EasyTransResult easyTransResult = new EasyTransResult(); easyTransResult.setValue(dubboInvoke.getValue()); easyTransResult.setException(dubboInvoke.getException()); return easyTransResult; } }
@Override public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException { if (RpcContext.getContext().isConsumerSide()) { RpcContext.getContext().setAttachment(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId()); } return invoker.invoke(invocation); } }
attachments.put(RemoteCoordinator.class.getName(), transactionCoordinator.getIdentifier()); RpcResult result = (RpcResult) invoker.invoke(invocation);
attachments.put(RemoteCoordinator.class.getName(), transactionCoordinator.getIdentifier()); RpcResult result = (RpcResult) invoker.invoke(invocation);
public Result consumerInvokeForTCC(Invoker<?> invoker, Invocation invocation) throws RpcException, RemotingException { CompensableBeanRegistry beanRegistry = CompensableBeanRegistry.getInstance(); CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory(); RemoteCoordinator compensableCoordinator = (RemoteCoordinator) beanFactory.getCompensableNativeParticipant(); Map<String, String> attachments = invocation.getAttachments(); attachments.put(RemoteCoordinator.class.getName(), compensableCoordinator.getIdentifier()); RpcResult result = (RpcResult) invoker.invoke(invocation); Object value = result.getValue(); if (CompensableServiceFilter.InvocationResult.class.isInstance(value)) { CompensableServiceFilter.InvocationResult wrapped = (CompensableServiceFilter.InvocationResult) value; result.setValue(null); result.setException(null); if (wrapped.isFailure()) { result.setException(wrapped.getError()); } else { result.setValue(wrapped.getValue()); } } return result; }
public Result consumerInvokeForTCC(Invoker<?> invoker, Invocation invocation) throws RpcException, RemotingException { CompensableBeanRegistry beanRegistry = CompensableBeanRegistry.getInstance(); CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory(); RemoteCoordinator compensableCoordinator = (RemoteCoordinator) beanFactory.getCompensableNativeParticipant(); Map<String, String> attachments = invocation.getAttachments(); attachments.put(RemoteCoordinator.class.getName(), compensableCoordinator.getIdentifier()); RpcResult result = (RpcResult) invoker.invoke(invocation); Object value = result.getValue(); if (CompensableServiceFilter.InvocationResult.class.isInstance(value)) { CompensableServiceFilter.InvocationResult wrapped = (CompensableServiceFilter.InvocationResult) value; result.setValue(null); result.setException(null); if (wrapped.isFailure()) { result.setException(wrapped.getError()); } else { result.setValue(wrapped.getValue()); } // String propagatedBy = (String) wrapped.getVariable(RemoteCoordinator.class.getName()); // String identifier = compensableCoordinator.getIdentifier(); } return result; }
@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(); } } } }
try { this.beforeConsumerInvokeForSVC(invocation, request, response); result = (RpcResult) invoker.invoke(invocation);
try { this.beforeConsumerInvokeForSVC(invocation, request, response); result = (RpcResult) invoker.invoke(invocation);
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { DubboEasyTransRpcProviderImpl instance = DubboEasyTransRpcProviderImpl.getInstance(); if(checkEasyTransRequest(invocation)){ EasyTransRequest<?, ?> easyTransRequest = (EasyTransRequest<?, ?>) ((Object[])invocation.getArguments()[2])[0]; @SuppressWarnings("unchecked") Map<String,Object> header = (Map<String,Object>) ((Object[])invocation.getArguments()[2])[1]; BusinessIdentifer businessIdentifer = ReflectUtil.getBusinessIdentifer(easyTransRequest.getClass()); EasyTransFilterChain filterChain = instance.getFilterChainFactory().getFilterChainByFilters(businessIdentifer.appId(), businessIdentifer.busCode(), (String)(invocation.getArguments()[0]),instance.getFilters()); filterChain.addFilter(new EasyTransFilterAdapter(invoker, invocation)); EasyTransResult result; try { result = filterChain.invokeFilterChain(header,easyTransRequest); } catch (Exception e) { LOG.error("RPC EasyTrans FilterChain execute Error!",e); throw e; } if(result.hasException()){ return new RpcResult(result.getException()); }else{ return new RpcResult(result.getValue()); } }else{ return invoker.invoke(invocation); } }
methodEntry = SphU.entry(resourceName, EntryType.IN, 1, invocation.getArguments()); Result result = invoker.invoke(invocation); if (result.hasException()) { Tracer.trace(result.getException());
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (omegaContext != null) { invocation.getAttachments().put(GLOBAL_TX_ID_KEY, omegaContext.globalTxId()); invocation.getAttachments().put(LOCAL_TX_ID_KEY, omegaContext.localTxId()); } if (omegaContext != null && omegaContext.globalTxId() != null) { LOG.debug("Added {} {} and {} {} to dubbo invocation", new Object[] {GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId()}); } else { LOG.debug("Cannot inject transaction ID, as the OmegaContext is null or cannot get the globalTxId."); } if (invoker != null) { return invoker.invoke(invocation); } return null; } }
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (omegaContext != null) { String globalTxId = invocation.getAttachment(GLOBAL_TX_ID_KEY); if (globalTxId == null) { LOG.debug("Cannot inject transaction ID, no such omega context global id: {}", GLOBAL_TX_ID_KEY); } else { omegaContext.setGlobalTxId(globalTxId); omegaContext.setLocalTxId(invocation.getAttachment(LOCAL_TX_ID_KEY)); LOG.debug("Added {} {} and {} {} to omegaContext", new Object[] {GLOBAL_TX_ID_KEY, omegaContext.globalTxId(), LOCAL_TX_ID_KEY, omegaContext.localTxId()}); } invocation.getAttachments().put(GLOBAL_TX_ID_KEY, null); invocation.getAttachments().put(LOCAL_TX_ID_KEY, null); } else { LOG.debug("Cannot inject transaction ID, as the OmegaContext is null."); } try { if (invoker != null) { return invoker.invoke(invocation); } else { return null; } } finally { if (omegaContext != null) { omegaContext.clear(); } } } }
@Override public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException { Tracer tracer = JbootOpentracingManager.me().getTracer(); if (tracer == null) { return invoker.invoke(inv); } return processRefererTrace(tracer, invoker, inv); }