图内说明来源:dubbo 官网 http://dubbo.apache.org/zh-cn/docs/dev/design.html
dubbo Framework Design.jpg
Graphviz dot 源码 dubbo Framework Design.dot
代码语言:javascript复制digraph G{
// 设置字体防止乱码
fontname = "Microsoft YaHei"
// 默认方形
node [shape = "record", fontname = "Microsoft YaHei"]
// 默认空箭头
edge [fontname = "Microsoft YaHei"]
legend [label="{ (图例) 名称
| 说明
| 中心
| 拓展接口}"]
label="dubbo"
proxy -> cluster -> protocol -> exchange
subgraph cluster_remoting {
label="remoting"
exchange -> transport -> serialize
}
{
rank = same
config proxy
}
{
rank = same
registry cluster
}
{
rank = same
monitor protocol
}
config [label="{config 配置层
| 对外配置接口
| ServiceConfig, ReferenceConfig
| }"]
proxy [label="{proxy 服务代理层
| 服务接口透明代理,接口 Invoker 转换
| ServiceProxy
| ProxyFactory}"]
registry [label="{registry 注册中心层
| 封装服务地址的注册与发现
| URL
| RegistryFactory, Registry, RegistryService}"]
cluster [label="{cluster 路由层
| 封装多个提供者的路由及负载均衡,并桥接注册中心
| Invoker
| Cluster, Directory, Router, LoadBalance}"]
monitor [label="{monitor 监控层
| RPC 调用次数和调用时间监控
| Statistics
| MonitorFactory, Monitor, MonitorService}"]
protocol [label="{protocol 远程调用层
| 封装 RPC 调用
| Invocation, Result
| Protocol, Invoker, Exporter}" fillcolor="#FFD9CA" style=filled]
exchange [label="{exchange 信息交换层
| 封装请求响应模式,同步转异步
| Request, Response
| Exchanger, ExchangeChannel, ExchangeClient, ExchangeServer}"]
transport [label="{transport 网络传输层
| 抽象 mina 和 netty 为统一接口
| Message
| Channel, Transporter, Client, Server, Codec}"]
serialize [label="{serialize 数据序列化层
| 可复用的一些工具
|
| Serialization, ObjectInput, ObjectOutput, ThreadPool}"]
}
生成图片脚本 dubbo Framework Design.bat
代码语言:javascript复制echo off
SET dot=dot
if exist "C:Program Files (x86)Graphviz2.38bindot.exe" (
SET dot="C:Program Files (x86)Graphviz2.38bindot.exe"
) else if exist "D:Program Files (x86)Graphviz2.38bindot.exe" (
SET dot="D:Program Files (x86)Graphviz2.38bindot.exe"
)
if exist "%~n0.dot" (
SET file=%~n0.dot
) else if exist "%~n0.gv" (
SET file=%~n0.gv
)
%dot% "%file%" -Tsvg -o "%~n0.svg" || (
echo need install Graphviz
echo https://graphviz.gitlab.io/_pages/Download/Download_windows.html
pause
exit
)
%dot% "%file%" -Tjpg -o "%~n0.jpg"
PS:之前面试阿里没过,向面试官请教时他告诉我可以自己写个“简易dubbo”。 最近写了下,思路其实很简单,首先远程调用,所以要在服务端调起方法,调方法时反射需要接口名、方法名、参数类型、参数、那么把这些传过去就可以了,写完后果然有了更好的理解。