dubbo源码阅读笔记--暴露服务时序

本文许多内容来源于http://dubbo.io/Developer+Guide-zh.htm#DeveloperGuide-zh-%E8%B0%83%E7%94%A8%E9%93%BE,感谢作者的分享。

dubbo的整体架构图中包含了很多内容,这里只分析服务暴露部分。

针对服务暴露,对上面的图做了些简化

时序图

分成六个阶段,下面分别列出每个阶段的调用堆栈。

1 初始化接口invoker

JavassistProxyFactory.getInvoker(T, Class<T>, URL) line: 40
StubProxyFactoryWrapper.getInvoker(T, Class<T>, URL) line: 104
ProxyFactory$Adpative.getInvoker(Object, Class, URL) line: not available
ServiceBean<T>(ServiceConfig<T>).exportLocal(URL) line: 516
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 469
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

2 初始化exporter

DubboExporter<T>.<init>(Invoker<T>, String, Map<String,Exporter<?>>) line: 36
DubboProtocol.export(Invoker<T>) line: 240
ProtocolFilterWrapper.export(Invoker<T>) line: 55
ProtocolListenerWrapper.export(Invoker<T>) line: 56
Protocol$Adpative.export(Invoker) line: not available
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 495
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

3 初始化server

DubboProtocol.createServer(URL) line: 318
DubboProtocol.openServer(URL) line: 308
DubboProtocol.export(Invoker<T>) line: 258
ProtocolFilterWrapper.export(Invoker<T>) line: 55
ProtocolListenerWrapper.export(Invoker<T>) line: 56
Protocol$Adpative.export(Invoker) line: not available
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 495
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

4 绑定transporter

NettyTransporter.bind(URL, ChannelHandler) line: 33
Transporter$Adpative.bind(URL, ChannelHandler) line: not available
Transporters.bind(URL, ChannelHandler...) line: 48
HeaderExchanger.bind(URL, ExchangeHandler) line: 41
Exchangers.bind(URL, ExchangeHandler) line: 63
DubboProtocol.createServer(URL) line: 329
DubboProtocol.openServer(URL) line: 308
DubboProtocol.export(Invoker<T>) line: 258
ProtocolListenerWrapper.export(Invoker<T>) line: 56
ProtocolFilterWrapper.export(Invoker<T>) line: 55
Protocol$Adpative.export(Invoker) line: not available
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 495
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

5 初始化codec

NettyServer(AbstractEndpoint).<init>(URL, ChannelHandler) line: 47
NettyServer(AbstractServer).<init>(URL, ChannelHandler) line: 59
NettyServer.<init>(URL, ChannelHandler) line: 63
NettyTransporter.bind(URL, ChannelHandler) line: 33
Transporter$Adpative.bind(URL, ChannelHandler) line: not available
Transporters.bind(URL, ChannelHandler...) line: 48
HeaderExchanger.bind(URL, ExchangeHandler) line: 41
Exchangers.bind(URL, ExchangeHandler) line: 63
DubboProtocol.createServer(URL) line: 329
DubboProtocol.openServer(URL) line: 308
DubboProtocol.export(Invoker<T>) line: 258
ProtocolListenerWrapper.export(Invoker<T>) line: 56
ProtocolFilterWrapper.export(Invoker<T>) line: 55
Protocol$Adpative.export(Invoker) line: not available
RegistryProtocol.doLocalExport(Invoker<T>) line: 153
RegistryProtocol.export(Invoker<T>) line: 107
ProtocolListenerWrapper.export(Invoker<T>) line: 54
ProtocolFilterWrapper.export(Invoker<T>) line: 53
Protocol$Adpative.export(Invoker) line: not available
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 489
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

6 初始化channelHandler

AllChannelHandler(WrappedChannelHandler).<init>(ChannelHandler, URL) line: 47	//------------6
AllChannelHandler.<init>(ChannelHandler, URL) line: 32
AllDispatcher.dispatch(ChannelHandler, URL) line: 32
Dispatcher$Adpative.dispatch(ChannelHandler, URL) line: not available
ChannelHandlers.wrapInternal(ChannelHandler, URL) line: 40
ChannelHandlers.wrap(ChannelHandler, URL) line: 33
NettyServer.<init>(URL, ChannelHandler) line: 63	//------------------5
NettyTransporter.bind(URL, ChannelHandler) line: 33	//-------------------4
Transporter$Adpative.bind(URL, ChannelHandler) line: not available
Transporters.bind(URL, ChannelHandler...) line: 48
HeaderExchanger.bind(URL, ExchangeHandler) line: 41
Exchangers.bind(URL, ExchangeHandler) line: 63
DubboProtocol.createServer(URL) line: 329	//----------------------3
DubboProtocol.openServer(URL) line: 308
DubboProtocol.export(Invoker<T>) line: 258
ProtocolFilterWrapper.export(Invoker<T>) line: 55
ProtocolListenerWrapper.export(Invoker<T>) line: 56
Protocol$Adpative.export(Invoker) line: not available
RegistryProtocol.doLocalExport(Invoker<T>) line: 153
RegistryProtocol.export(Invoker<T>) line: 107
ProtocolFilterWrapper.export(Invoker<T>) line: 53
ProtocolListenerWrapper.export(Invoker<T>) line: 54	//------------------2
Protocol$Adpative.export(Invoker) line: not available
ServiceBean<T>(ServiceConfig<T>).doExportUrlsFor1Protocol(ProtocolConfig, List<URL>) line: 489	//-------------1
ServiceBean<T>(ServiceConfig<T>).doExportUrls() line: 285
ServiceBean<T>(ServiceConfig<T>).doExport() line: 246
ServiceBean<T>(ServiceConfig<T>).export() line: 145

时间: 2024-07-29 22:18:51

dubbo源码阅读笔记--暴露服务时序的相关文章

dubbo源码阅读笔记--服务调用时序

上接dubbo源码阅读笔记--暴露服务时序,继续梳理服务调用时序,下图右面红线流程. 整理了调用时序图 分为3步,connect,decode,invoke. 连接 AllChannelHandler.connected(Channel) line: 38 HeartbeatHandler.connected(Channel) line: 47 MultiMessageHandler(AbstractChannelHandlerDelegate).connected(Channel) line:

【Dubbo源码阅读系列】服务暴露之远程暴露

引言 什么叫 远程暴露 ?试着想象着这么一种场景:假设我们新增了一台服务器 A,专门用于发送短信提示给指定用户.那么问题来了,我们的 Message 服务上线之后,应该如何告知调用方服务器,服务器 A 提供了 Message 功能?那么我们是不是可以把目前已提供的服务暴露在一个地方,让调用方知道某台机器提供了某个特定功能?带着这样的假设,我们今天就来聊聊 Dubbo 服务暴露之远程暴露!! 服务远程暴露 先回顾一下上篇文章,上篇文章我们聊到了 ServiceConfig 的 export() 方

Dubbo源码阅读笔记2

### 消费方初始化 消费方初始化的入口在ReferenceConfig类的get方法 前面基本和服务方的初始化一致 public class ReferenceConfig<T> extends AbstractReferenceConfig { private static final long serialVersionUID = -5864351140409987595L; private static final Protocol refprotocol = ExtensionLoa

Dubbo源码阅读笔记3

### 扩展点加载(ExtensionLoader) 每一种类型的扩展点都有一个ExtensionLoader实例 变量说明 public class ExtensionLoader<T> { // dubbo服务扫描目录 private static final String SERVICES_DIRECTORY = "META-INF/services/"; // dubbo扩展点配置扫描目录(自定义扩展时使用此目录) private static final Stri

Dubbo源码阅读笔记4

### 发布服务到本地 发布本地服务的代码在ServiceConfig.doExportUrlsFor1Protocol方法里 主要代码如下 // 通过动态代理工厂生成实现类调用器Invoker, Invoker相当于动态代理类 Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, url); // 只是将代理和配置放到一起 DelegateProviderMetaDataInvoker wrappe

【Dubbo源码阅读系列】之远程服务调用(上)

今天打算来讲一讲 Dubbo 服务远程调用.笔者在开始看 Dubbo 远程服务相关源码的时候,看的有点迷糊.后来慢慢明白 Dubbo 远程服务的调用的本质就是动态代理模式的一种实现.本地消费者无须知道远程服务具体的实现,消费者和提供者通过代理类来进行交互!! 一.JAVA 动态代理 简单看一段代码回顾一下动态代理: public class MyInvocationHandler implements InvocationHandler{ private Object object; publi

CI框架源码阅读笔记3 全局函数Common.php

从本篇开始,将深入CI框架的内部,一步步去探索这个框架的实现.结构和设计. Common.php文件定义了一系列的全局函数(一般来说,全局函数具有最高的加载优先权,因此大多数的框架中BootStrap引导文件都会最先引入全局函数,以便于之后的处理工作). 打开Common.php中,第一行代码就非常诡异: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 上一篇(CI框架源码阅读笔记2 一切的入口 index

源码阅读笔记 - 1 MSVC2015中的std::sort

大约寒假开始的时候我就已经把std::sort的源码阅读完毕并理解其中的做法了,到了寒假结尾,姑且把它写出来 这是我的第一篇源码阅读笔记,以后会发更多的,包括算法和库实现,源码会按照我自己的代码风格格式化,去掉或者展开用于条件编译或者debug检查的宏,依重要程度重新排序函数,但是不会改变命名方式(虽然MSVC的STL命名实在是我不能接受的那种),对于代码块的解释会在代码块前(上面)用注释标明. template<class _RanIt, class _Diff, class _Pr> in

IOS测试框架之:athrun的InstrumentDriver源码阅读笔记

athrun的InstrumentDriver源码阅读笔记 作者:唯一 athrun是淘宝的开源测试项目,InstrumentDriver是ios端的实现,之前在公司项目中用过这个框架,没有深入了解,现在回来记录下. 官方介绍:http://code.taobao.org/p/athrun/wiki/instrumentDriver/ 优点:这个框架是对UIAutomation的java实现,在代码提示.用例维护方面比UIAutomation强多了,借junit4的光,我们可以通过junit4的