Java Code Examples for com.alipay.sofa.rpc.filter.FilterInvoker#getConfig()
The following examples show how to use
com.alipay.sofa.rpc.filter.FilterInvoker#getConfig() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HystrixFilter.java From sofa-rpc with Apache License 2.0 | 6 votes |
@Override public boolean needToLoad(FilterInvoker invoker) { AbstractInterfaceConfig config = invoker.getConfig(); // 只支持 consumer 侧 if (!isConsumerSide(config)) { if (LOGGER.isWarnEnabled(config.getAppName())) { LOGGER.warnWithApp(config.getAppName(), "HystrixFilter is not allowed on provider, interfaceId: {}", config.getInterfaceId()); } return false; } if (!isHystrixEnabled(config)) { return false; } if (!isHystrixOnClasspath()) { if (LOGGER.isWarnEnabled(config.getAppName())) { LOGGER .warnWithApp(config.getAppName(), "HystrixFilter is disabled because 'com.netflix.hystrix:hystrix-core' does not exist on the classpath"); } return false; } return true; }
Example 2
Source File: AbstractSofaRpcFilter.java From Sentinel with Apache License 2.0 | 5 votes |
@Override public boolean needToLoad(FilterInvoker invoker) { AbstractInterfaceConfig<?, ?> config = invoker.getConfig(); String enabled = config.getParameter(SentinelConstants.SOFA_RPC_SENTINEL_ENABLED); if (StringUtils.isNotBlank(enabled)) { return Boolean.parseBoolean(enabled); } return RpcConfigs.getOrDefaultValue(SentinelConstants.SOFA_RPC_SENTINEL_ENABLED, true); }
Example 3
Source File: ParameterFilter.java From sofa-rpc-boot-projects with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { if (invoker.getConfig() instanceof ProviderConfig) { providerParameters = invoker.getConfig().getParameters(); } else { consumerParameters = invoker.getConfig().getParameters(); } return invoker.invoke(request); }
Example 4
Source File: ProviderTracerFilter.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { SofaTracerSpan serverSpan = null; try { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); serverSpan = sofaTraceContext.getCurrentSpan(); if (serverSpan != null) { RpcInternalContext context = RpcInternalContext.getContext(); serverSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); serverSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); serverSpan.setTag(RpcSpanTags.REMOTE_IP, context.getRemoteHostName()); // 客户端地址 // 从请求里获取ConsumerTracerFilter额外传递的信息 serverSpan.setTag(RpcSpanTags.REMOTE_APP, (String) request.getRequestProp(HEAD_APP_NAME)); serverSpan.setTag(RpcSpanTags.PROTOCOL, (String) request.getRequestProp(HEAD_PROTOCOL)); serverSpan.setTag(RpcSpanTags.INVOKE_TYPE, (String) request.getRequestProp(HEAD_INVOKE_TYPE)); ProviderConfig providerConfig = (ProviderConfig) invoker.getConfig(); serverSpan.setTag(RpcSpanTags.LOCAL_APP, providerConfig.getAppName()); serverSpan.setTag(RpcSpanTags.SERVER_THREAD_POOL_WAIT_TIME, (Number) context.getAttachment(RpcConstants.INTERNAL_KEY_PROCESS_WAIT_TIME)); } return invoker.invoke(request); } finally { if (serverSpan != null) { serverSpan.setTag(RpcSpanTags.SERVER_BIZ_TIME, (Number) RpcInternalContext.getContext().getAttachment(RpcConstants.INTERNAL_KEY_IMPL_ELAPSE)); } } }