Java Code Examples for com.alibaba.dubbo.rpc.RpcContext#getContext()

The following examples show how to use com.alibaba.dubbo.rpc.RpcContext#getContext() . 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: MonitorFilter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    if (invoker.getUrl().hasParameter(Constants.MONITOR_KEY)) {
        RpcContext context = RpcContext.getContext(); // 提供方必须在invoke()之前获取context信息
        long start = System.currentTimeMillis(); // 记录起始时间戮
        getConcurrent(invoker, invocation).incrementAndGet(); // 并发计数
        try {
            Result result = invoker.invoke(invocation); // 让调用链往下执行
            collect(invoker, invocation, result, context, start, false);
            return result;
        } catch (RpcException e) {
            collect(invoker, invocation, null, context, start, true);
            throw e;
        } finally {
            getConcurrent(invoker, invocation).decrementAndGet(); // 并发计数
        }
    } else {
        return invoker.invoke(invocation);
    }
}
 
Example 2
Source File: MonitorFilter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    if (invoker.getUrl().hasParameter(Constants.MONITOR_KEY)) {
        RpcContext context = RpcContext.getContext(); // 提供方必须在invoke()之前获取context信息
        long start = System.currentTimeMillis(); // 记录起始时间戮
        getConcurrent(invoker, invocation).incrementAndGet(); // 并发计数
        try {
            Result result = invoker.invoke(invocation); // 让调用链往下执行
            collect(invoker, invocation, result, context, start, false);
            return result;
        } catch (RpcException e) {
            collect(invoker, invocation, null, context, start, true);
            throw e;
        } finally {
            getConcurrent(invoker, invocation).decrementAndGet(); // 并发计数
        }
    } else {
        return invoker.invoke(invocation);
    }
}
 
Example 3
Source File: HttpRemoteInvocation.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public Object invoke(Object targetObject) throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    RpcContext context = RpcContext.getContext();
    context.setAttachments((Map<String, String>) getAttribute(dubboAttachmentsAttrName));

    String generic = (String) getAttribute(Constants.GENERIC_KEY);
    if (StringUtils.isNotEmpty(generic)) {
        context.setAttachment(Constants.GENERIC_KEY, generic);
    }
    try {
        return super.invoke(targetObject);
    } finally {
        context.setAttachments(null);

    }
}
 
Example 4
Source File: MonitorFilter.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        if (invoker.getUrl().hasParameter(Constants.MONITOR_KEY)) {
            RpcContext context = RpcContext.getContext(); // provider must fetch context before invoke() gets called
            String remoteHost = context.getRemoteHost();
            long start = System.currentTimeMillis(); // record start timestamp
            getConcurrent(invoker, invocation).incrementAndGet(); // count up
            try {
                Result result = invoker.invoke(invocation); // proceed invocation chain
                collect(invoker, invocation, result, remoteHost, start, false);
                return result;
            } catch (RpcException e) {
                collect(invoker, invocation, null, remoteHost, start, true);
                throw e;
            } finally {
                getConcurrent(invoker, invocation).decrementAndGet(); // count down
            }
        } else {
//            com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke
            return invoker.invoke(invocation);
        }
    }
 
Example 5
Source File: DubboSofaTracerFilter.java    From sofa-tracer with Apache License 2.0 6 votes vote down vote up
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    // do not record
    if ("$echo".equals(invocation.getMethodName())) {
        return invoker.invoke(invocation);
    }

    RpcContext rpcContext = RpcContext.getContext();
    // get appName
    if (StringUtils.isBlank(this.appName)) {
        this.appName = SofaTracerConfiguration
            .getProperty(SofaTracerConfiguration.TRACER_APPNAME_KEY);
    }
    // get span kind by rpc request type
    String spanKind = spanKind(rpcContext);
    Result result;
    if (spanKind.equals(Tags.SPAN_KIND_SERVER)) {
        result = doServerFilter(invoker, invocation);
    } else {
        result = doClientFilter(rpcContext, invoker, invocation);
    }
    return result;
}
 
Example 6
Source File: DubboSofaTracerFilter.java    From sofa-tracer with Apache License 2.0 6 votes vote down vote up
/**
 * set rpc server span tags
 * @param invoker
 * @param sofaTracerSpan
 */
private void appendRpcServerSpanTags(Invoker<?> invoker, SofaTracerSpan sofaTracerSpan) {
    if (sofaTracerSpan == null) {
        return;
    }
    RpcContext rpcContext = RpcContext.getContext();
    Map<String, String> tagsStr = sofaTracerSpan.getTagsWithStr();
    tagsStr.put(Tags.SPAN_KIND.getKey(), spanKind(rpcContext));
    String service = invoker.getInterface().getName();
    tagsStr.put(CommonSpanTags.SERVICE, service == null ? BLANK : service);
    String methodName = rpcContext.getMethodName();
    tagsStr.put(CommonSpanTags.METHOD, methodName == null ? BLANK : methodName);
    String app = rpcContext.getUrl().getParameter(Constants.APPLICATION_KEY);
    tagsStr.put(CommonSpanTags.REMOTE_HOST, rpcContext.getRemoteHost());
    tagsStr.put(CommonSpanTags.LOCAL_APP, app == null ? BLANK : app);
    tagsStr.put(CommonSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName());
    String protocol = rpcContext.getUrl().getProtocol();
    tagsStr.put(CommonSpanTags.PROTOCOL, protocol == null ? BLANK : protocol);
    tagsStr.put(CommonSpanTags.LOCAL_HOST, rpcContext.getRemoteHost());
    tagsStr.put(CommonSpanTags.LOCAL_PORT, String.valueOf(rpcContext.getRemotePort()));
}
 
Example 7
Source File: DubboSofaTracerFilter.java    From sofa-tracer with Apache License 2.0 6 votes vote down vote up
/**
 * set rpc client span tags
 * @param invoker
 * @param sofaTracerSpan
 */
private void appendRpcClientSpanTags(Invoker<?> invoker, SofaTracerSpan sofaTracerSpan) {
    if (sofaTracerSpan == null) {
        return;
    }
    RpcContext rpcContext = RpcContext.getContext();
    Map<String, String> tagsStr = sofaTracerSpan.getTagsWithStr();
    tagsStr.put(Tags.SPAN_KIND.getKey(), spanKind(rpcContext));
    String protocol = rpcContext.getUrl().getProtocol();
    tagsStr.put(CommonSpanTags.PROTOCOL, protocol == null ? BLANK : protocol);
    String service = invoker.getInterface().getName();
    tagsStr.put(CommonSpanTags.SERVICE, service == null ? BLANK : service);
    String methodName = rpcContext.getMethodName();
    tagsStr.put(CommonSpanTags.METHOD, methodName == null ? BLANK : methodName);
    tagsStr.put(CommonSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName());
    String app = rpcContext.getUrl().getParameter(Constants.APPLICATION_KEY);
    tagsStr.put(CommonSpanTags.LOCAL_APP, app == null ? BLANK : app);
    tagsStr.put(CommonSpanTags.REMOTE_HOST, rpcContext.getRemoteHost());
    tagsStr.put(CommonSpanTags.REMOTE_PORT, String.valueOf(rpcContext.getRemotePort()));
    tagsStr.put(CommonSpanTags.LOCAL_HOST, rpcContext.getLocalHost());
}
 
Example 8
Source File: Tracer.java    From dubbo-plus with Apache License 2.0 6 votes vote down vote up
private Span createProviderSideSpan() {
    RpcContext rpcContext = RpcContext.getContext();
    String traceId = rpcContext.getAttachment(DstConstants.DST_TRACE_ID);
    String spanId = rpcContext.getAttachment(DstConstants.DST_SPAN_ID);
    String parentSpanId = rpcContext.getAttachment(DstConstants.DST_PARENT_SPAN_ID);
    if (StringUtils.isNotEmpty(traceId)
            && StringUtils.isNotEmpty(spanId)) {//只需要判断traceId和spanid即可
        Span span = new Span();
        span.setId(spanId);
        span.setParentId(parentSpanId);
        span.setTraceId(traceId);
        span.setServiceName(getServiceName());
        span.setName(getMethodName());
        ContextHolder.setSpan(span);
    }

    return ContextHolder.getSpan();
}
 
Example 9
Source File: DubboHessianURLConnectionFactory.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public HessianConnection open(URL url) throws IOException {
    HessianConnection connection = super.open(url);
    RpcContext context = RpcContext.getContext();
    for (String key : context.getAttachments().keySet()) {
        connection.addHeader(Constants.DEFAULT_EXCHANGER + key, context.getAttachment(key));
    }

    return connection;
}
 
Example 10
Source File: DubboProviderInterceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private void recordRequest(SpanRecorder recorder, Object target, Object[] args) {
    final RpcInvocation invocation = (RpcInvocation) args[0];
    final RpcContext rpcContext = RpcContext.getContext();

    // Record rpc name, client address, server address.
    recorder.recordRpcName(invocation.getInvoker().getInterface().getSimpleName() + ":" + invocation.getMethodName());
    recorder.recordEndPoint(rpcContext.getLocalAddressString());
    if (rpcContext.getRemoteHost() != null) {
        recorder.recordRemoteAddress(rpcContext.getRemoteAddressString());
    } else {
        recorder.recordRemoteAddress("Unknown");
    }

    // If this transaction did not begin here, record parent(client who sent this request) information
    if (!recorder.isRoot()) {
        final String parentApplicationName = invocation.getAttachment(DubboConstants.META_PARENT_APPLICATION_NAME);
        if (parentApplicationName != null) {
            final short parentApplicationType = NumberUtils.parseShort(invocation.getAttachment(DubboConstants.META_PARENT_APPLICATION_TYPE), ServiceType.UNDEFINED.getCode());
            recorder.recordParentApplication(parentApplicationName, parentApplicationType);

            final String host = invocation.getAttachment(DubboConstants.META_HOST);
            if (host != null) {
                recorder.recordAcceptorHost(host);
            } else {
                // old version fallback
                final String estimatedLocalHost = getLocalHost(rpcContext);
                if (estimatedLocalHost != null) {
                    recorder.recordAcceptorHost(estimatedLocalHost);
                }
            }
        }
    }
    //clear attachments
    this.clearAttachments(rpcContext);
}
 
Example 11
Source File: Tracer.java    From dubbo-plus with Apache License 2.0 5 votes vote down vote up
private void setAttachment() {
    RpcContext rpcContext = RpcContext.getContext();
    String traceId = ContextHolder.getTraceId();
    rpcContext.setAttachment(DstConstants.DST_IS_SAMPLE,ContextHolder.isSample()+"");
    if (traceId != null) {
        rpcContext.setAttachment(DstConstants.DST_TRACE_ID, traceId);
    }
    Span span = ContextHolder.getSpan();
    if (span != null) {
        rpcContext.setAttachment(DstConstants.DST_SPAN_ID, span.getId());
        rpcContext.setAttachment(DstConstants.DST_PARENT_SPAN_ID, span.getParentId());
    }
}
 
Example 12
Source File: DubboParser.java    From brave with Apache License 2.0 5 votes vote down vote up
static boolean parseRemoteIpAndPort(Span span) {
  RpcContext rpcContext = RpcContext.getContext();
  InetSocketAddress remoteAddress = rpcContext.getRemoteAddress();
  if (remoteAddress == null) return false;
  return span.remoteIpAndPort(
      Platform.get().getHostString(remoteAddress),
      remoteAddress.getPort()
  );
}
 
Example 13
Source File: Tracer.java    From dubbo-plus with Apache License 2.0 5 votes vote down vote up
private String createProvideSideTraceId() {
    RpcContext rpcContext = RpcContext.getContext();
    String isSample = rpcContext.getAttachment(DstConstants.DST_IS_SAMPLE);
    if(StringUtils.isNotEmpty(isSample)){
        ContextHolder.setLocalSample(Boolean.valueOf(isSample));
    }
    String traceId = rpcContext.getAttachment(DstConstants.DST_TRACE_ID);
    if (StringUtils.isBlank(traceId)) {
        ContextHolder.setTraceId(GUId.singleton().nextId());
    } else {
        ContextHolder.setTraceId(traceId);
    }
    return ContextHolder.getTraceId();
}
 
Example 14
Source File: CicadaDubboFilter.java    From cicada with MIT License 5 votes vote down vote up
private void invokerBefore(final Invocation invocation, final Span span, final Endpoint endpoint, final long start) {
  final RpcContext context = RpcContext.getContext();
  if (context.isConsumerSide()) {
    if (span.isSample()) {
      tracer.clientSendRecord(span, endpoint, start);

      final RpcInvocation rpcInvocation = (RpcInvocation) invocation;
      rpcInvocation.setAttachment(TracerUtils.PARENT_SPAN_ID, span.getParentId());
      rpcInvocation.setAttachment(TracerUtils.SPAN_ID, span.getId());
      rpcInvocation.setAttachment(TracerUtils.TRACE_ID, span.getTraceId());
    }
  } else if (context.isProviderSide()) {
    tracer.serverReceiveRecord(span, endpoint, start);
  }
}
 
Example 15
Source File: AccessLogFilter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
    try {
        String accesslog = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
        if (ConfigUtils.isNotEmpty(accesslog)) {
            RpcContext context = RpcContext.getContext();
            String serviceName = invoker.getInterface().getName();
            String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
            String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
            StringBuilder sn = new StringBuilder();
            sn.append("[").append(new SimpleDateFormat(MESSAGE_DATE_FORMAT).format(new Date())).append("] ").append(context.getRemoteHost()).append(":").append(context.getRemotePort())
            .append(" -> ").append(context.getLocalHost()).append(":").append(context.getLocalPort())
            .append(" - ");
            if (null != group && group.length() > 0) {
                sn.append(group).append("/");
            }
            sn.append(serviceName);
            if (null != version && version.length() > 0) {
                sn.append(":").append(version);
            }
            sn.append(" ");
            sn.append(inv.getMethodName());
            sn.append("(");
            Class<?>[] types = inv.getParameterTypes();
            if (types != null && types.length > 0) {
                boolean first = true;
                for (Class<?> type : types) {
                    if (first) {
                        first = false;
                    } else {
                        sn.append(",");
                    }
                    sn.append(type.getName());
                }
            }
            sn.append(") ");
            Object[] args = inv.getArguments();
            if (args != null && args.length > 0) {
                sn.append(JSON.json(args));
            }
            String msg = sn.toString();
            if (ConfigUtils.isDefault(accesslog)) {
                LoggerFactory.getLogger(ACCESS_LOG_KEY + "." + invoker.getInterface().getName()).info(msg);
            } else {
                log(accesslog, msg);
            }
        }
    } catch (Throwable t) {
        logger.warn("Exception in AcessLogFilter of service(" + invoker + " -> " + inv + ")", t);
    }
    return invoker.invoke(inv);
}
 
Example 16
Source File: DefaultEchoService.java    From tech-weekly with Apache License 2.0 4 votes vote down vote up
public String echo(String message) {
    RpcContext rpcContext = RpcContext.getContext();
    return String.format("Echo [port : %d] :  %s",
            rpcContext.getLocalPort(),
            message);
}
 
Example 17
Source File: MonitorFilter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
private void collect(Invoker<?> invoker, Invocation invocation, Result result, RpcContext context, long start, boolean error) {
    try {
        // ---- 服务信息获取 ----
        long elapsed = System.currentTimeMillis() - start; // 计算调用耗时
        int concurrent = getConcurrent(invoker, invocation).get(); // 当前并发数
        String application = invoker.getUrl().getParameter(Constants.APPLICATION_KEY);
        String service = invoker.getInterface().getName(); // 获取服务名称
        String method = RpcUtils.getMethodName(invocation); // 获取方法名
        URL url = invoker.getUrl().getUrlParameter(Constants.MONITOR_KEY);
        Monitor monitor = monitorFactory.getMonitor(url);
        int localPort;
        String remoteKey;
        String remoteValue;
        if (Constants.CONSUMER_SIDE.equals(invoker.getUrl().getParameter(Constants.SIDE_KEY))) {
            // ---- 服务消费方监控 ----
            context = RpcContext.getContext(); // 消费方必须在invoke()之后获取context信息
            localPort = 0;
            remoteKey = MonitorService.PROVIDER;
            remoteValue = invoker.getUrl().getAddress();
        } else {
            // ---- 服务提供方监控 ----
            localPort = invoker.getUrl().getPort();
            remoteKey = MonitorService.CONSUMER;
            remoteValue = context.getRemoteHost();
        }
        String input = "", output = "";
        if (invocation.getAttachment(Constants.INPUT_KEY) != null) {
            input = invocation.getAttachment(Constants.INPUT_KEY);
        }
        if (result != null && result.getAttachment(Constants.OUTPUT_KEY) != null) {
            output = result.getAttachment(Constants.OUTPUT_KEY);
        }
        monitor.collect(new URL(Constants.COUNT_PROTOCOL,
                            NetUtils.getLocalHost(), localPort,
                            service + "/" + method,
                            MonitorService.APPLICATION, application,
                            MonitorService.INTERFACE, service,
                            MonitorService.METHOD, method,
                            remoteKey, remoteValue,
                            error ? MonitorService.FAILURE : MonitorService.SUCCESS, "1",
                            MonitorService.ELAPSED, String.valueOf(elapsed),
                            MonitorService.CONCURRENT, String.valueOf(concurrent),
                            Constants.INPUT_KEY, input,
                            Constants.OUTPUT_KEY, output));
    } catch (Throwable t) {
        logger.error("Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
    }
}
 
Example 18
Source File: MonitorFilter.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
private void collect(Invoker<?> invoker, Invocation invocation, Result result, RpcContext context, long start, boolean error) {
    try {
        // ---- 服务信息获取 ----
        long elapsed = System.currentTimeMillis() - start; // 计算调用耗时
        int concurrent = getConcurrent(invoker, invocation).get(); // 当前并发数
        String application = invoker.getUrl().getParameter(Constants.APPLICATION_KEY);
        String service = invoker.getInterface().getName(); // 获取服务名称
        String method = RpcUtils.getMethodName(invocation); // 获取方法名
        URL url = invoker.getUrl().getUrlParameter(Constants.MONITOR_KEY);
        Monitor monitor = monitorFactory.getMonitor(url);
        int localPort;
        String remoteKey;
        String remoteValue;
        if (Constants.CONSUMER_SIDE.equals(invoker.getUrl().getParameter(Constants.SIDE_KEY))) {
            // ---- 服务消费方监控 ----
            context = RpcContext.getContext(); // 消费方必须在invoke()之后获取context信息
            localPort = 0;
            remoteKey = MonitorService.PROVIDER;
            remoteValue = invoker.getUrl().getAddress();
        } else {
            // ---- 服务提供方监控 ----
            localPort = invoker.getUrl().getPort();
            remoteKey = MonitorService.CONSUMER;
            remoteValue = context.getRemoteHost();
        }
        String input = "", output = "";
        if (invocation.getAttachment(Constants.INPUT_KEY) != null) {
            input = invocation.getAttachment(Constants.INPUT_KEY);
        }
        if (result != null && result.getAttachment(Constants.OUTPUT_KEY) != null) {
            output = result.getAttachment(Constants.OUTPUT_KEY);
        }
        monitor.collect(new URL(Constants.COUNT_PROTOCOL,
                            NetUtils.getLocalHost(), localPort,
                            service + "/" + method,
                            MonitorService.APPLICATION, application,
                            MonitorService.INTERFACE, service,
                            MonitorService.METHOD, method,
                            remoteKey, remoteValue,
                            error ? MonitorService.FAILURE : MonitorService.SUCCESS, "1",
                            MonitorService.ELAPSED, String.valueOf(elapsed),
                            MonitorService.CONCURRENT, String.valueOf(concurrent),
                            Constants.INPUT_KEY, input,
                            Constants.OUTPUT_KEY, output));
    } catch (Throwable t) {
        logger.error("Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
    }
}
 
Example 19
Source File: AccessLogFilter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
    try {
        String accesslog = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
        if (ConfigUtils.isNotEmpty(accesslog)) {
            RpcContext context = RpcContext.getContext();
            String serviceName = invoker.getInterface().getName();
            String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
            String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
            StringBuilder sn = new StringBuilder();
            sn.append("[").append(new SimpleDateFormat(MESSAGE_DATE_FORMAT).format(new Date())).append("] ").append(context.getRemoteHost()).append(":").append(context.getRemotePort())
            .append(" -> ").append(context.getLocalHost()).append(":").append(context.getLocalPort())
            .append(" - ");
            if (null != group && group.length() > 0) {
                sn.append(group).append("/");
            }
            sn.append(serviceName);
            if (null != version && version.length() > 0) {
                sn.append(":").append(version);
            }
            sn.append(" ");
            sn.append(inv.getMethodName());
            sn.append("(");
            Class<?>[] types = inv.getParameterTypes();
            if (types != null && types.length > 0) {
                boolean first = true;
                for (Class<?> type : types) {
                    if (first) {
                        first = false;
                    } else {
                        sn.append(",");
                    }
                    sn.append(type.getName());
                }
            }
            sn.append(") ");
            Object[] args = inv.getArguments();
            if (args != null && args.length > 0) {
                sn.append(JSON.json(args));
            }
            String msg = sn.toString();
            if (ConfigUtils.isDefault(accesslog)) {
                LoggerFactory.getLogger(ACCESS_LOG_KEY + "." + invoker.getInterface().getName()).info(msg);
            } else {
                log(accesslog, msg);
            }
        }
    } catch (Throwable t) {
        logger.warn("Exception in AcessLogFilter of service(" + invoker + " -> " + inv + ")", t);
    }
    return invoker.invoke(inv);
}
 
Example 20
Source File: AccessLogFilter.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Override
public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
    try {
        String accesslog = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
        if (ConfigUtils.isNotEmpty(accesslog)) {
            RpcContext context = RpcContext.getContext();
            String serviceName = invoker.getInterface().getName();
            String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
            String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
            StringBuilder sn = new StringBuilder();
            sn.append("[").append(new SimpleDateFormat(MESSAGE_DATE_FORMAT).format(new Date())).append("] ").append(context.getRemoteHost()).append(":").append(context.getRemotePort())
                    .append(" -> ").append(context.getLocalHost()).append(":").append(context.getLocalPort())
                    .append(" - ");
            if (null != group && group.length() > 0) {
                sn.append(group).append("/");
            }
            sn.append(serviceName);
            if (null != version && version.length() > 0) {
                sn.append(":").append(version);
            }
            sn.append(" ");
            sn.append(inv.getMethodName());
            sn.append("(");
            Class<?>[] types = inv.getParameterTypes();
            if (types != null && types.length > 0) {
                boolean first = true;
                for (Class<?> type : types) {
                    if (first) {
                        first = false;
                    } else {
                        sn.append(",");
                    }
                    sn.append(type.getName());
                }
            }
            sn.append(") ");
            Object[] args = inv.getArguments();
            if (args != null && args.length > 0) {
                sn.append(JSON.toJSONString(args));
            }
            String msg = sn.toString();
            if (ConfigUtils.isDefault(accesslog)) {
                LoggerFactory.getLogger(ACCESS_LOG_KEY + "." + invoker.getInterface().getName()).info(msg);
            } else {
                log(accesslog, msg);
            }
        }
    } catch (Throwable t) {
        logger.warn("Exception in AcessLogFilter of service(" + invoker + " -> " + inv + ")", t);
    }
    return invoker.invoke(inv);
}