记录一次 Dubbo + SpringCloud 请求链路堆栈异常解析

记录一次 Dubbo + SpringCloud 请求链路堆栈异常解析
Caused by: java.lang.IllegalArgumentException: Unknown class to load com.pinganwj.supv.base.ribbon.rule.DevBestAvailableRule for class interface com.netflix.loadbalancer.IRule named uc-service

throw new IllegalArgumentException("Unknown class to load " + className + " for class " + clazz + " named " + name);

【1】请求线程、线程池管理线程执行请求任务
at java.util.concurrent.ThreadPoolExecutor.runWorker() 
  执行Worker任务
at java.util.concurrent.ThreadPoolExecutor$Worker.run() 
  线程池执行器 私有内部类实现Runnable
at java.lang.Thread.run() 
  原生线程实现类

【2】Dubbo RPC服务调用
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke()
  @Activate(group = {"provider"})
  public class ExceptionFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.pinganwj.dubbo.filter.DubboAuthenticationFilter.invoke()
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke()
  @Activate(group = {"provider", "consumer"})
  public class MonitorFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke()
  @Activate(group = {"provider"})
  public class TimeoutFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke() 
  链路追踪过滤器执行invoke
  @Activate(group = {"provider"})
  public class TraceFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke()
  @Activate(group = {"provider"},order = -10000)
  public class ContextFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke()
  @Activate(group = {"provider"},order = -20000)
  public class GenericFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke()
  @Activate(group = {"provider"},order = -30000)
  public class ClassLoaderFilter implements Filter {}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke()
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke() 
  对应过滤器执行invoke
  @Activate(group = {"provider"},order = -110000)
  public class EchoFilter implements Filter{}
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke() 
  协议过滤器包装类
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(ExchangeChannel channel, Object message) 
  RPC协议 答复
  package com.alibaba.dubbo.remoting.exchange.support;
  public abstract class ExchangeHandlerAdapter extends TelnetHandlerAdapter implements ExchangeHandler {
    public ExchangeHandlerAdapter() {
    }
    public Object reply(ExchangeChannel channel, Object msg) throws RemotingException {
      return null;
    }
  }
  public class DubboProtocol {
    private ExchangeHandler requestHandler = new ExchangeHandlerAdapter() { //请求处理器
      public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
        1).Invocation inv = (Invocation)message;
        2).Invoker invoker = DubboProtocol.this.getInvoker(channel, inv); 获取Invoker
        3).进行方法的校验
        4).return invoker.invoke(inv); 进行invoke执行
      }
    };
  }
  //Protocol实现
  com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol 采用NIO复用单一长连接,并使用线程池并发处理请求,减少握手和加大并发效率,性能较好(推荐使用)
  com.alibaba.dubbo.rpc.protocol.thrift.ThriftProtocol
  //Invoker实现
  com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(ExchangeChannel channel, Request req) 
  Header交换处理器 处理请求
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(Channel channel, Object message) 
  Header交换处理器 接收数据
  扩展Java NIO框架 Transporter 传输
    com.alibaba.dubbo.remoting.transport.netty.NettyClient(Channel) 出身Jboss JBoss的NIO框架,性能较好(推荐使用)
    com.alibaba.dubbo.remoting.transport.mina.MinaClient(Channel) 出身Apache 老牌NIO框架,稳定
    com.alibaba.dubbo.remoting.transport.grizzly.GrizzlyClient(Channel) 出身Sun Sun的NIO框架,应用于GlassFish服务器中
    com.alibaba.dubbo.remoting.transport.netty.NettyChannel
    com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeChannel
  首先是channel转换 由 NettyChannel=>HeaderExchangeChannel, 然后转换(message instanceof Request)请求数据, 然后处理请求。
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(Channel channel, Object message) 
  远程传输 解码处理器 接收数据进行解码处理
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run() 
  远程传输 请求(网络IO)分发 通道事件实现Runnable 线程执行任务

【3】Spring容器对服务进行Bean生命周期管理
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate()
  BeanFactory通过反射初始化factoryBean,这就是IOC;
  BeanFactory通过构造器或者Setter方法对factoryBean进行依赖关系管理,这就是DI;
  这里的逻辑是 BeanFactory通过反射执行factoryBean的某方法,这就是通过反射进行Method调用。

【4】IOC,DI底层利用java的反射原理
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  sun访问native方法
at sun.reflect.NativeMethodAccessorImpl.invoke() 
  sun原生方法访问invoke
at sun.reflect.DelegatingMethodAccessorImpl.invoke() 
  sun委托代理方法访问invoke
at java.lang.reflect.Method.invoke() 
  java反射执行invoke调用method

【5】
at org.springframework.cloud.netflix.ribbon.PropertiesFactory.get() 
  配置工厂获取配置
at org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration.ribbonRule() 
  Ribbon客户端负载均衡路由规则
at org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration$$EnhancerBySpringCGLIB$$f71a5808.CGLIB$ribbonRule$5(<generated>)
  
at org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration$$EnhancerBySpringCGLIB$$f71a5808$$FastClassBySpringCGLIB$$25ee82ac.invoke(<generated>)
  
at org.springframework.cglib.proxy.MethodProxy.invokeSuper()
  SpringCGLIB 的 MethodProxy
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept() 
  Enhancer增强者 Bean方法拦截器 ConfigurationClassEnhancer 的静态内部类 BeanMethodInterceptor 的 intercept 方法
at org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration$$EnhancerBySpringCGLIB$$f71a5808.ribbonRule(<generated>)
  RibbonClientConfiguration 通过 SpringCGLIB 来进行动态代理增强 ribbonRule 方法

总结
1).java多线程
  java.lang.Thread => 线程
  java.util.concurrent.ThreadPoolExecutor => 并发包线程池执行器
2).dubbo:
  com.alibaba.dubbo.remoting.transport => DecodeHandler dispatcher.ChannelEventRunnable 
    远程传输 请求分发IO通道事件任务 解码处理器接受请求
  com.alibaba.dubbo.remoting.exchange => support.header.HeaderExchangeHandler 
    远程交换 Header交换处理器
  com.alibaba.dubbo.monitor => support.MonitorFilter 
    监控模块 监控过滤器
  com.alibaba.dubbo.rpc.protocol => ProtocolFilterWrapper$1 dubbo.filter.TraceFilter dubbo.DubboProtocol$1 
    RPC协议
  com.alibaba.dubbo.rpc.filter => ExceptionFilter TimeoutFilter ContextFilter GenericFilter ClassLoaderFilter EchoFilter 
    RPC过滤器
3).springframework.beans
  org.springframework.beans.factory => Spring容器对服务进行Bean生命周期管理
4).java反射
  java.lang.reflect => Method 方法反射执行
  sun.reflect => 调用原生方法访问实现
5).springframework:
  org.springframework.cloud.netflix.ribbon => SpringCloud Netflix Ribbon 负载均衡 客户端配置通过CGLIB增强
  org.springframework.context.annotation => Spring Context Annotation 注解增强 通过CGLIB
  org.springframework.cglib.proxy => Spring CGLIB 动态代理
  org.springframework.cloud.netflix.ribbon => SpringCloud Netflix Ribbon 负载均衡 路由规则 加载配置文件

转载于:https://my.oschina.net/shaochuan/blog/2209020

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值