Dubbo 源码分析 00 代码结构概述 && 核心流程

基于dubbo 最新分支 3.x-dev

总共1648个类, 代码行数19万+ 

下面看下各个包的核心功能

dubbo-cluster :  dubbo集群相关,包括:负载均衡, 集群容错,路由,分组聚合等。集群的地址列表可以是静态配置的,也可以是由注册中心下发。

dubbo-common : 公共逻辑模块,提供工具类和通用模型。

dubbo-compatible:兼容性测试使用

dubbo-config:  dubbo配置模块

   dubbo-config-api ,实现了 API 配置 和 属性配置 功能。

   dubbo-config-spring ,实现了 XML 配置 和 注解配置 功能。

dubbo-configcenter:使用外部的配置中心

目前支持携程apollo,HashiCorp的consul,阿里的Nacos,zookeeper等

dubbo-container : 容器模块,是一个 Standlone 的容器,以简单的 Main 加载 Spring 启动,因为服务通常不需要 Tomcat/JBoss 等 Web 容器的特性,没必要用 Web 容器去加载服务

dubbo-demo : 快速启动示例

dubbo-dependencies:依赖的zookeeper的一些jar包

dubbo-distribution: dubbo发布发布相关

dubbo-filter: 包括缓存过滤器,参数验证过滤器

dubbo-metadata-report :dubbo的元数据中心

dubbo-monitor : 监控相关

dubbo-plugin : qos插件,提供在线运维命令

dubbo-registry: 服务的注册与发现

dubbo-remoting: 

  • dubbo-remoting-zookeeper ,相当于 Zookeeper Client ,和 Zookeeper Server 通信。
  • dubbo-remoting-api , 定义了 Dubbo Client 和 Dubbo Server 的接口
  • 实现 dubbo-remoting-api
    • dubbo-remoting-grizzly ,基于 Grizzly 实现。
    • dubbo-remoting-http ,基于 Jetty 或 Tomcat 实现。
    • dubbo-remoting-mina ,基于 Mina 实现。
    • dubbo-remoting-netty ,基于 Netty 3 实现。
    • dubbo-remoting-netty4 ,基于 Netty 4 实现。
    • dubbo-remoting-p2p ,P2P 服务器。注册中心 dubbo-registry-multicast 项目的使用该项目。

dubbo-rpc : 抽象了各种协议,以及动态代理,支持的协议如下

dubbo-serialization : 序列化,支持fastjson、hessian2、jdk、kryo等

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    在 RPC 中,Protocol 是核心层,也就是只要有 Protocol + Invoker + Exporter 就可以完成非透明的 RPC 调用,然后在 Invoker 的主过程上 Filter 拦截点。

    而 Cluster 是外围概念,所以 Cluster 的目的是将多个 Invoker 伪装成一个 Invoker,这样其它人只要关注 Protocol 层 Invoker 即可,加上 Cluster 或者去掉 Cluster 对其它层都不会造成影响,因为只有一个提供者时,是不需要 Cluster 的。

    Proxy 层封装了所有接口的透明化代理,而在其它层都以 Invoker 为中心,只有到了暴露给用户使用时,才用 Proxy 将 Invoker 转成接口,或将接口实现转成 Invoker,也就是去掉 Proxy 层 RPC 是可以 Run 的,只是不那么透明,不那么看起来像调本地服务一样调远程服务。

  而 Remoting 实现是 Dubbo 协议的实现,如果你选择 RMI 协议,整个 Remoting 都不会用上。Remoting 内部再划为 Transport 传输层和 Exchange 信息交换层,Transport 层只负责单向消息传输,是对 Mina, Netty, Grizzly 的抽象,它也可以扩展 UDP 传输;而 Exchange 层是在传输层之上封装了 Request-Response 语义

调用链

发布了331 篇原创文章 · 获赞 1 · 访问量 3501

猜你喜欢

转载自blog.csdn.net/kuaipao19950507/article/details/103829650