Abstract: the original source http://www.iocoder.cn/Dubbo/good-collection/ “taro source” welcome to reprint, retain the, thank you!

  • 1. [Taro] Fine Dubbo principle and source code column
  • 2. [Lao Xu] RPC column
  • 3. [Fat] Dubbo source code analysis
  • 4. [MR_QI] Dubbo source code parsing
  • 5.【 Yang Wubing 】Dubbo source code analysis
  • 666. The eggs

πŸ™‚πŸ™‚πŸ™‚ follow ** wechat official number: ** Have welfare:

  1. RocketMQ/MyCAT/Sharding-JDBC all source code analysis article list
  2. RocketMQ/MyCAT/Sharding-JDBC δΈ­ζ–‡ 解 决 source GitHub address
  3. Any questions you may have about the source code will be answered carefully. Even do not know how to read the source can also ask oh.
  4. New source code parsing articles are notified in real time. It’s updated about once a week.
  5. Serious source communication wechat group.

1. [Taro] Fine Dubbo principle and source code column

  • Author: Taro
  • Only updated in my knowledge planet, welcome to join us to discuss Dubbo source code and implementation.
    • So far 600+ players have joined…
    • Progress: 69+ papers have been completed, with an estimated total of 75+ papers, with a completion rate of 92%.
  • The version of Dubbo is 2.6.X

1.1 directory

  • Debugging Environment Setup
    • Dubbo source code Analysis – Debugging environment construction
  • Project Structure Overview
    • Dubbo Source Code Analysis — Project Structure Overview
  • Configure the Configuration
    • Dubbo source Code Parsing — APPLICATION of API Configuration (1)
    • Dubbo Source Code Parsing — API Configuration part 2: Service Providers
    • Dubbo Source Code Parsing — API Configuration part 3: Service Consumers
    • Dubbo source Code Analysis — Attribute Configuration
    • Dubbo source Code Parsing — XML Configuration
    • [] Dubbo source code parsing — Annotation configuration
    • [] Dubbo source code parsing — External Configuration
    • [] Dubbo source code parsing – automatic assembly
  • Core Process Overview
    • Dubbo source code Analysis — Core Process Overview
  • Extension mechanism SPI
    • Dubbo source Code Analysis — Extension mechanism SPI
  • The thread pool
    • Dubbo source Code Analysis — Thread Pool
  • Service exposure Export
    • Dubbo Source Code Analysis — Service Exposure (1) Local Exposure (Injvm)
    • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)
  • Service reference Refer
    • Dubbo Source Code Analysis — Service References (1) Local References (Injvm)
    • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)
  • Registry
    • Dubbo source code analysis – Zookeeper client
    • Dubbo Source Code Analysis — Registry 1 Abstract API
    • Dubbo source Code Analysis – Registry (2) Zookeeper
    • Dubbo Source Code Analysis – Registry (3) Redis
    • Complete Dubbo Source Code Analysis — Simple for Registry 4
    • Source Code Analysis of Dubbo – For Multicast (5)
  • Dynamic Compile
    • Dubbo Source Code Analysis – Dynamic Compilation (PART 1) : Javassist
    • Dubbo source Code analysis – Dynamic Compilation (ii) JDK
  • Dynamic Proxy
    • Dubbo Source Code Analysis – Dynamic Proxy part 1: Javassist
    • Dubbo source Code analysis – Dynamic Proxy (ii) JDK
    • Dubbo source Code Analysis – Dynamic Proxy (3) local Stub Stub
  • Service Invoke
    • Dubbo source Code Analysis — Service Invocation (1) Local Invocation (Injvm)
    • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [1] Communication Implementation
    • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [2] Synchronous Call
    • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [3] Asynchronous Call
    • Dubbo [4] Parameter Callback (Dubbo)
    • Dubbo Source Code Parsing — Remote Invocation (HTTP) for Service Invocation (PART 3)
    • Dubbo Source Code Parsing — Service Call (4) Remote Call (Hessian)
    • Dubbo source Code parsing — Service Invocation (5) Remote Invocation (Webservice)
    • Dubbo Source Code Parsing — Remote Invocation (REST) for Service Invocation (PART 6)
    • Dubbo Source Code Parsing — Remote Invocation (RMI) for Service Invocation (7)
    • Dubbo Source Code Parsing — Service Calls (8) Remote Calls (Redis)
    • Dubbo Source Code Parsing — Remote Invocation of Service Invocation (9) (Memcached)
    • Dubbo Source Code Parsing — Service Calls (10) Remote Calls (Thrift)
  • Call features
    • Dubbo Source Code Parsing – Echo Testing for Call Feature 1
    • “Complete Dubbo source parsing — Generalization References to Call Features (II)”
    • Dubbo Source Code Parsing — Generalization implementation of Call Feature (3)
  • Filter Filter
    • Dubbo source code parsing — ClassLoaderFilter (1)
    • Dubbo: ContextFilter (ContextFilter)
    • Dubbo source code parsing — AccessLogFilter (3)
    • Dubbo Source Code Analysis – ActiveLimitFilter && ExecuteLimitFilter
    • Dubbo source code analysis – Filter (5) TimeoutFilter
    • Dubbo source code analysis – Filter (6) DeprecatedFilter
    • Dubbo source code analysis – Filter (7) ExceptionFilter
    • Dubbo source code analysis – Filter (8) TokenFilter
    • Dubbo source code Analysis – Filter (9) TpsLimitFilter
    • Dubbo Source Code Analysis – CacheFilter (10)
    • Dubbo source Code Analysis — ValidationFilter (11)
  • The NIO server
    • Dubbo Source Code Analysis – NIO Server (1) Abstract API
    • Dubbo source code Analysis – NIO Server (2) Transport Layer
    • Dubbo source Code Analysis – NIO Server (3) Telnet Layer
    • NIO Server (4) Exchange Layer
    • Dubbo source analysis – NIO Server (5) Buffer Layer
    • Dubbo source code Analysis – NIO Server (6) Netty4 Implementation
    • Dubbo source code Analysis – NIO Server (7) Netty3 Implementation
    • Dubbo source code Analysis – NIO Server (8) Mina1 implementation
    • Analysis of Dubbo source code – NIO Server part 9: Implementation of Grizzly
  • P2P server
    • Dubbo source code analysis — P2P server
  • The HTTP server
    • Dubbo source Code Analysis – HTTP server
  • Serialization Serialization
    • Dubbo Source Code Analysis – Serialization (I) of the Overall implementation
    • Dubbo source code analysis – Serialization (ii) Dubbo implementation
    • Dubbo source code analysis – Serialization (3) Kryo implementation
  • Service Container Container
    • Dubbo: Service Container
  • Clusters are fault-tolerant clusters
    • Dubbo Source Code Parsing — Cluster Fault Tolerance (1) abstract API
    • Dubbo source code parsing – Cluster fault tolerance (2) Cluster implementation
    • Dubbo source Code parsing – Cluster Fault Tolerance (3) Directory Implementation
    • Dubbo source code parsing – Cluster Fault Tolerance (4) Loadbalance Implementation
    • Dubbo source Code Analysis — Cluster Fault Tolerance (5) : The Implementation of a Merger
    • Dubbo: A Configuration for Dubbo
    • Dubbo source Code parsing — Cluster Fault Tolerance (7) Router Implementation
    • Mock Implementation for Cluster Fault Tolerance (8)
  • Elegant downtime
    • Dubbo source code parsing — Elegant downtime
  • Log adapter
    • Dubbo source code parsing – Log adaptation
  • State examination (mmse)
    • Dubbo Source Code parsing – State Check
  • Monitoring Center
    • TODO waits for the new version
  • Management center Admin
    • TODO waits for the new version
  • O&m command QOS
    • TODO is a little bit easier, so I’ll write it down in the future
  • Link Tracing Tracing
    • SkyWalking source code Analysis — Agent plugin (2) Dubbo

Ps:

  • The dots represent completed;
  • The little squares represent future plans completed
  • Chung hwa-hyun is not considering writing

1.2 Dubbo User Guide

In this section, we will “fine Dubbo source code analysis” and “Dubbo user guide” to do a mapping, convenient for you to directly find the specific source code implementation of the function of interest. Of course, if there is not in place, welcome to give me a message as if corrected.

【<2> Quick start 】

Dubbo uses a full Spring configuration mode to transparently access applications without any API intrusion. You only need to load Dubbo’s configuration with Spring. Dubbo is loaded based on Spring’s Schema extension.

If you don’t want to use Spring configuration, you can call it through the API.

Corresponding source code analysis article:

  • Dubbo source code Analysis – Debugging environment construction

[<5.1> XML Configuration]

For details on XML configuration items, see Configuration Reference manual. If you do not want to use The Spring configuration and want to invoke it through the API, see: API Configuration. To learn how to use the configuration, see quick Start.

Corresponding source code analysis article:

  • Dubbo source Code Parsing — XML Configuration

[<5.2> Attribute Configuration]

If the common configuration is simple without multiple registries, protocols, etc., or if you want multiple Spring containers to share the configuration, you can use dubo.properties as the default configuration.

Dubbo will automatically load Dubbo. Properties in the root directory of the classpath, which can be changed by JVM startup parameter -ddubbo.properties.file=xxx.properties. 1

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Attribute Configuration

[<5.3> API Configuration]

API properties and configuration items one to one, the meaning, please see: configuration reference manual, such as: ApplicationConfig. Elegantly-named setName (” XXX “) corresponding to the < dubbo: application name = “XXX” / > 1

Corresponding source code analysis article:

  • Dubbo source Code Parsing — APPLICATION of API Configuration (1)
  • Dubbo Source Code Parsing — API Configuration part 2: Service Providers
  • Dubbo Source Code Parsing — API Configuration part 3: Service Consumers

[<5.4> Annotation Configuration]

Required version 2.5.7 or later

Corresponding source code analysis article:

  • [] Dubbo source code parsing — Annotation configuration

[<6.1> Check at startup]

Dubbo checks whether dependent services are available at startup. If not, an exception will be thrown to prevent Spring initialization from being completed so that problems can be detected early when it goes online. By default, check=”true”.

Check =”false” can be used to turn off checks, for example, if some services do not care during testing, or if cyclic dependencies occur and one party must be started first.

In addition, if your Spring container is lazy to load, or if your API is programmed to delay referencing services, turn check off. Otherwise, if the service is temporarily unavailable, an exception will be thrown and a null reference will be obtained. If check=”false”, the reference will always be returned, and when the service is restored, it will be connected automatically.

  • Note that the service provider failed to register and the checking function was not enabled. This point, the author has been misunderstood.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Registry 1 Abstract API

[<6.2> Cluster fault tolerance]

When a cluster invocation fails, Dubbo provides multiple fault tolerance schemes. By default, failover retry is used.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Cluster Fault Tolerance (1) abstract API
  • Dubbo source code parsing – Cluster fault tolerance (2) Cluster implementation
  • Dubbo source Code parsing – Cluster Fault Tolerance (3) Directory Implementation

【<6.3> Load Balancing 】

Dubbo provides multiple balancing policies for cluster load balancing. The default policy is random random call.

You can extend the load balancing policy by yourself. For details, see Extending load Balancing

Corresponding source code analysis article:

  • Dubbo source code parsing – Cluster Fault Tolerance (4) Loadbalance Implementation

【<6.4> Thread model 】

If the logic for event processing is done quickly and no new I/O requests are made, such as just marking an id in memory, it is faster to process directly on the I/O thread because of reduced thread pool scheduling.

However, if the event processing logic is slow or new I/O requests, such as database queries, need to be sent to the thread pool. Otherwise, the I/O thread blocks and cannot receive other requests.

If an I/O thread processes an event and a new I/O request is initiated during the event processing, for example, a login request is initiated during a connection event, a deadlock may be raised exception is reported, but the deadlock is not true.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Thread Pool

[<6.5> Directly connected provider]

In the development and testing environment, often need to bypass the registry, testing only designated service provider, this time may need A point-to-point direct, point-to-point straight mode, will be in the service interface, ignore the registry provider list, A point-to-point interface configuration, does not affect the B interface list was obtained from the registry.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)

[<6.6> Subscription only]

For development testing purposes, it is common to share a registry of all services available offline, where a registered service provider under development may affect consumer performance.

You can have service provider developers test services under development by direct connection, only subscribing to services that may depend on other services, without registering services under development.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Local Exposure of Service References (I) (Injvm)

[<6.7> Registration only]

If you have two mirrored environments, two registries, one service is deployed in only one of them, the other is not yet deployed, and other applications in both registries need to rely on this service. At this point, the service provider can only register the service to another registry, rather than subscribing to the service from another registry.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Local Exposure of Service References (I) (Injvm)

[<6.8> Static Service]

In cases where you want to manually manage the online and offline management of service providers, you need to mark the registry as non-dynamically managed.

Corresponding source code analysis article:

  • Dubbo source Code Analysis – Registry (2) Zookeeper
  • Dubbo Source Code Analysis – Registry (3) Redis

[<6.9> Multi-protocol]

Dubbo allows you to configure multiple protocols, support different protocols on different services or support multiple protocols simultaneously on the same service.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service Exposure (1) Local Exposure (Injvm)
  • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)

[<6.10> Multi-registry]

Dubbo supports simultaneous registration of the same service in multiple registries, registration of different services in different registries, and even simultaneous reference of the same service registered in different registries. In addition, the registry supports custom extensions.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service Exposure (1) Local Exposure (Injvm)
  • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)
  • Dubbo Source Code Analysis — Service References (1) Local References (Injvm)
  • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)

[<6.11> Service Grouping]

When an interface has multiple implementations, it can be distinguished by a group.

  • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)
  • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)

【<6.12> Multiple versions 】

When an interface is implemented and an incompatible upgrade occurs, the version number can be used for transition. Services with different version numbers do not reference each other.

You can follow these steps to perform version migration:

  1. During low-stress periods, upgrade half of the providers to the new version first
  2. Then upgrade all customers to the new version
  3. Then upgrade the remaining half of the providers to the new version

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)
  • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)
  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [2] Synchronous Call

[<6.13> Group aggregation]

Group and return result 1, such as menu service, the same interface, but there are multiple implementations, distinguished by group, now the consumer needs to call from each group return result, merge result return, so that the implementation of aggregation menu items.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Cluster Fault Tolerance (5) : The Implementation of a Merger

[<6.14> Parameter verification]

Parameter validation function 1 is implemented based on JSR303. Users only need to identify validation annotations of the JSR303 standard and implement validation 2 by declaring filters.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — ValidationFilter (11)

[<6.15> Result cache]

Result cache 1, used to speed up access to hot data, and Dubbo provides declarative cache to reduce user caching effort 2.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – CacheFilter (10)

[<6.16> Generalized citation]

The generalized interface invocation method is mainly used when the client does not have API interfaces and model class elements. All POJOs in parameters and return values are represented by Map. It is usually used for framework integration, for example, to achieve a universal service testing framework that can invoke all service implementations through GenericService.

Corresponding source code analysis article:

  • “Complete Dubbo source parsing — Generalization References to Call Features (II)”

[<6.17> Generalization implementation]

The generic interface approach is mainly used when there is no API interface and model class element on the server side. All POJOs in parameters and return values are represented by Map. It is commonly used for framework integration, such as implementing a generic remote service Mock framework that can handle all service requests by implementing the GenericService interface.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Generalization implementation of Call Feature (3)

【<6.18> Echo test 】

Echo test is used to check whether the service is available. Echo test is performed according to the normal request flow to test whether the whole call is smooth and can be used for monitoring.

All services automatically implement the EchoService interface. You only need to force any service reference to be converted to EchoService.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing – Echo Testing for Call Feature 1

【<6.19> Context 】

The context holds the environment information required during the current invocation. All configuration information is converted to URL parameters. For details, see the corresponding URL parameters column in the Schema Configuration Reference.

The RpcContext is a temporary state logger of a ThreadLocal. The state of the RpcContext changes when an RPC request is received or initiated. For example, if A calls B and B calls C, RpcContext records the information of B dialed by A before B dialed C, and RpcContext records the information of C dialed by B after B dialed C.

Corresponding source code analysis article:

  • Dubbo: ContextFilter (ContextFilter)

[<6.20> Implicit parameter]

Parameters can be passed implicitly between the service consumer and provider via setAttachment and getAttachment on the RpcContext. 1

Corresponding source code analysis article:

  • Dubbo: ContextFilter (ContextFilter)

【<6.21> Asynchronous call 】

NIO based on non-blocking implementation of parallel invocation, the client does not need to start multithreading to complete the parallel invocation of multiple remote services, relatively less overhead multithreading. 1

Corresponding source code analysis article:

  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [3] Asynchronous Call

【<6.22> Local call 】

The local call uses injVM, a pseudo-protocol that does not open ports, does not initiate remote calls, and is only directly associated within the JVM, but performs Dubbo’s Filter chain.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Service Invocation (1) Local Invocation (Injvm)

[<6.23> Parameter callback]

A parameter callback works the same way as a call to a local callback or listener; you simply declare in Spring’s configuration file which parameter is of type callback. Dubbo will generate a reverse proxy based on long connections so that client logic 1 can be invoked from the server side. Refer to the sample code in the Dubbo project.

Corresponding source code analysis article:

  • Dubbo [4] Parameter Callback (Dubbo)

[<6.24> Event Notification]

Oninvoke, onReturn, and onThrow are triggered before, after, and when an exception occurs. You can configure which method of which class to be notified when an event occurs.

Corresponding source code analysis article:

  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [3] Asynchronous Call

[<6.25> Local stub]

After remote service, the client is usually left with the interface and the implementation is all on the server side, but the provider sometimes wants to perform part of the logic on the client side as well, for example: The client generates a Proxy instance, passes the Proxy to Stub 1 through its constructor, and then exposes the Stub to the user. The Stub can decide whether to invoke the Proxy or not.

Corresponding source code analysis article:

  • Dubbo source Code Analysis – Dynamic Proxy (3) local Stub Stub

[<6.26> Local Camouflage]

Local masquerade 1 is commonly used for service degradation, such as a validation service, where the client does not throw an exception when all service providers fail, but returns authorization failure through Mock data.

Corresponding source code analysis article:

  • Mock Implementation for Cluster Fault Tolerance (8)

[<6.27> Delayed exposure]

If your service needs time to warm up, such as initializing the cache, waiting for relevant resources to be in place, etc., use delay for delay exposure.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — API Configuration part 2: Service Providers

[<6.28> Concurrency control]

Limit each method of com.foo.BarService to no more than 10 concurrent server executions (or threads in the pool)

Limit the sayHello method of com.foo.BarService to no more than 10 concurrent server executions (or threads in the pool)

Limit each method of com.foo.BarService to no more than 10 concurrent (or connection hogging) requests per client

Limit the sayHello method of com.foo.BarService to no more than 10 concurrent execution (or connection hogging requests) per client

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – ActiveLimitFilter && ExecuteLimitFilter
  • Dubbo source code parsing – Cluster Fault Tolerance (4) Loadbalance Implementation

[<6.29> Connection control]

Limit the number of connections accepted by the server to 10:

Limit the number of client connections to 10 2:

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – ActiveLimitFilter && ExecuteLimitFilter

[<6.30> Delayed connection]

Delayed connections are used to reduce the number of long connections. When a call is made, the long connection is created. 1

Corresponding source code analysis article:

  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [1] Communication Implementation

[<6.31> Sticky connection]

Sticky connections are used for stateful services so that clients always make calls to the same provider as possible, unless that provider dies and then connects to another.

Sticky connections automatically enable delayed connections to reduce the number of long connections.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Cluster Fault Tolerance (1) abstract API

[<6.32> token validation]

Controlling permissions in the registry to decide whether to issue a token to a consumer through token authentication prevents consumers from bypassing the registry to access providers, and the registry provides flexibility to change authorization without modifying or upgrading the provider

Corresponding source code analysis article:

  • Dubbo source code analysis – Filter (8) TokenFilter

[<6.33> Routing Rules]

Routing rule 1 determines the target server for a dubbo service invocation. It is divided into conditional routing rules and scripted routing rules, and supports extensible 2.

Corresponding source code analysis article:

  • Dubbo source Code parsing — Cluster Fault Tolerance (7) Router Implementation

[<6.34> Configuration Rules]

Write dynamic configuration override rule 1 to the registry. This function is typically performed by a page in the monitoring center or governance center.

Corresponding source code analysis article:

  • Dubbo: A Configuration for Dubbo

[<6.35> Service degradation]

You can use service degradation function 1 to temporarily mask an error non-critical service and define the return policy after degradation.

Corresponding source code analysis article:

  • Mock Implementation for Cluster Fault Tolerance (8)

[<6.36> Graceful stop]

Dubbo uses JDK ShutdownHook to implement graceful shutdown, so if the user uses kill -9 PID or other forced shutdown commands, graceful shutdown will not be performed, only if the user passes kill PID.

Corresponding source code analysis article:

  • Dubbo source code parsing — Elegant downtime

【<6.37> Host Binding 】

Default host IP address search order:

  • throughLocalHost.getLocalHost()Gets the local address.
  • If it is127. *And the loopback IP address, scan for each nic and obtain the NIC IP address.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — API Configuration part 2: Service Providers

<6.38> Log Adaptation

Since 2.2.1, Dubbo has built in log4j, SLF4J, JCL, JDK and other logging frameworks. You can also display and configure log output policies in the following ways:

  1. The command line
  2. indubbo.propertiesSpecified in the
  3. indubbo.xmlIn the configuration

Corresponding source code analysis article:

  • Dubbo source code parsing – Log adaptation

[<6.39> Access log]

If you want to log every request, you can enable access logging, similar to Apache’s access logging. Note: The amount of logs is large. Please pay attention to the disk capacity.

Corresponding source code analysis article:

  • Dubbo source code parsing — AccessLogFilter (3)

[<6.40> Service Container]

The service container is a standalone startup, because the background service does not need the functions of a Web container such as Tomcat or JBoss. If you use the Web container to load the service provider, it will add complexity and waste resources.

The service container is just a simple Main method that loads a simple Spring container to expose the service.

The load content of the service container can be extended, with built-in spring, Jetty, Log4j, etc., and can be extended through container extension points. The configuration is set in the -d parameter of the Java command or in dubo.properties.

Corresponding source code analysis article:

  • Dubbo: Service Container

<6.41> ReferenceConfig cache

The ReferenceConfig instance is heavy, encapsulates connections to the registry as well as to the provider, and requires caching. Otherwise, repeated generation of ReferenceConfig can cause performance problems and memory and connection leaks. It’s easy to ignore this problem when programming in API mode.

Therefore, since version 2.4.0, Dubbo provides a simple utility class called ReferenceConfigCache for caching ReferenceConfig instances.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — API Configuration part 3: Service Consumers

【<6.42> Distributed transactions 】

Distributed transactions are implemented based on JTA/XA specification 1.

Two-phase commit:

At present, this function is not implemented, the following is recommended reading:

  • RocketMQ Source Code Analysis – Transaction Messages
  • Sharding-jdbc Source Code Analysis — Distributed Transactions (PART 1) best Effort Type
  • MyCAT Source Code Analysis — XA Distributed Transaction
  • Tcc-transaction Source code Analysis — Collection
  • Happylifeplat-TCC source code parsing — Fine collection
  • Myth Source Code Parsing — A Collection of fine Works

<6.43> Thread stack automatic dump

When the business thread pool is full, we need to know what resources, conditions, threads are waiting for to find bottlenecks or outliers in the system. Dubbo uses Jstack to automatically export the thread stack to preserve the scene for troubleshooting

Default policy:

  • The export path, the user home directory identified by user.home
  • Export interval. The minimum export interval is allowed every 10 minutes

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Thread Pool

【 < 6.44 > Netty4 】

Dubbo 2.5.6 adds support for the Netty4 communication module

Corresponding source code analysis article:

  • Dubbo source code Analysis – NIO Server (6) Netty4 Implementation

【<8> Schema Configuration Reference Manual 】

This section uses XML Config 1 to list all configuration items 2. For details about other configuration methods, see attribute Configuration, Annotation Configuration, AND API Configuration.

Corresponding source code analysis article:

  • Dubbo source Code Parsing — XML Configuration

【 < 9.1 > dubbo: / /]

The default Dubbo protocol uses a single long connection and NIO asynchronous communication, which is suitable for small data volume and large concurrent service invocation, and the number of service consumer machines is much larger than the number of service provider machines.

Conversely, the default Dubbo protocol is not suitable for services that transmit large amounts of data, such as files and videos, unless the request volume is very low.

Corresponding source code analysis article:

  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [1] Communication Implementation
  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [2] Synchronous Call
  • Dubbo source code parsing — Service Call (2) Remote Call (Dubbo) [3] Asynchronous Call
  • Dubbo [4] Parameter Callback (Dubbo)

【 < 9.2 > the rmi: / /]

RMI protocol uses JDK standard java.rmi.* implementation, using blocking short connection and JDK standard serialization.

Note: There is a deserialization security risk 3 if you are using RMI to provide services to external access 1 and your application relies on the old Common-Collections package 2.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Remote Invocation (RMI) for Service Invocation (7)

【 < 9.3 > hessian: / /]

Hessian 1 protocol is used to integrate Hessian services. Hessian uses Http communication and Servlet to expose the service. Dubbo province embedded Jetty is implemented as a server.

Dubbo’s Hessian protocol interoperates with the native Hessian service, that is:

  • The provider exposes the service using Dubbo’s Hessian protocol, and the consumer invokes it directly using the standard Hessian interface
  • Or the provider exposes the service using the standard Hessian and the consumer invokes it using Dubbo’s Hessian protocol.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Service Call (4) Remote Call (Hessian)

“< 9.4 > http://”

HTTP form based remote call protocol, using Spring HttpInvoker implementation 1

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Remote Invocation (HTTP) for Service Invocation (PART 3)

【 < 9.5 > webservice: / /]

Remote call protocol based on WebService, frontend-simple and Transports – HTTP based on Apache CXF 1 implementation 2.

Can interoperate with native WebService services, that is:

  • The provider exposes the service with Dubbo’s WebService protocol, and the consumer invokes it directly with the standard WebService interface.
  • Or the provider exposes the service with a standard WebService and the consumer invokes it with Dubbo’s WebService protocol.

Corresponding source code analysis article:

  • Dubbo source Code parsing — Service Invocation (5) Remote Invocation (Webservice)

【 < 9.6 > thrift: / /]

The thrift protocol dubbo currently supports 1 is an extension of thrift’s native protocol 2, adding some additional headers, such as Service name, Magic Number, etc.

Using the Dubbo Thrift protocol also requires the compiler of thrift’s IDL compiler to generate Java code, which will be enhanced in future releases.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Service Calls (10) Remote Calls (Thrift)

【 < 9.7 > the memcached: / /]

RPC protocol 2 based on memcached 1.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Remote Invocation of Service Invocation (9) (Memcached)

【 < 9.8 > redis: / /]

RPC protocol 2 based on Redis 1.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Service Calls (8) Remote Calls (Redis)

【 < 9.9 > rest: / /]

The corresponding document is

  • Developing RESTful Remoting in Dubbo.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Remote Invocation (REST) for Service Invocation (PART 6)

【<10.1> Multicast Registry 】

Multicast registries do not need to start any central node, as long as the broadcast address is the same, they can discover each other.

  1. The provider broadcasts its own address at startup
  2. The consumer broadcasts the subscription request when it starts
  3. When the provider receives a subscription request, unicast its own address to the subscriber, if setunicast=false, broadcast to subscribers
  4. When the consumer receives the provider’s address, it connects to the address for an RPC call.

Multicast is limited by the network structure and is only suitable for small-scale applications or development. Multicast address range: 224.0.0.0 to 239.255.255.255

Corresponding source code analysis article:

  • Source Code Analysis of Dubbo – For Multicast (5)

[<10.2> ZooKeeper Registry]

Zookeeper is a subproject of Apacahe Hadoop. It is a tree directory service that supports change push and is suitable for Dubbo service registry. It has high industrial intensity and can be used in production environment.

Corresponding source code analysis article:

  • Dubbo source code analysis – Zookeeper client
  • Dubbo Source Code Analysis — Registry 1 Abstract API
  • Dubbo source Code Analysis – Registry (2) Zookeeper

[<10.3> Redis Registry]

Registry 2 based on the Redis 1 implementation.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – Registry (3) Redis

[<10.4> Simple Registry]

The Simple registry itself is a generic Dubbo service that reduces third-party dependencies and makes overall communication consistent.

Corresponding source code analysis article:

  • Complete Dubbo Source Code Analysis — Simple for Registry 4

【<11> Telnet Command Reference Manual 】

Starting with version 2.0.5, Dubbo supports mirroring service governance through Telnet commands.

Corresponding source code analysis article:

  • Dubbo source Code Analysis – NIO Server (3) Telnet Layer

[<12> Online O&M command -QOS]

Dubbo 2.5.8 refactored the Telnet module with new Telnet command support.

Corresponding source code analysis article:

TODO

dubbo-ops

1.3 Dubbo Development Guide

In this section, we will “fine Dubbo source code analysis” and “Dubbo development guide” to do a mapping, convenient for you to directly find the specific source code implementation of the function of interest. Of course, if there is not in place, welcome to give me a message as if corrected.

【<1> source code construction 】

Code check out branch build build source code JAR package IDE support

Corresponding source code analysis article:

  • Dubbo source code Analysis – Debugging environment construction

【<2> Frame design 】

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Project Structure Overview
  • Dubbo source code Analysis — Core Process Overview

[<3> Extension point loading]

Dubbo’s extension point loading is enhanced from the JDK standard Service Provider Interface (SPI) extension point discovery mechanism.

Dubbo improves on the following issues with the JDK standard SPI:

  • The JDK’s standard SPI instantiates all implementations of extension points at once, which is time-consuming to initialize if there is an extension implementation, but wasteful of resources to load without it.
  • If the extension point fails to load, you will not even get the name of the extension point. For example: The JDK standard ScriptEngine, passedgetName()Get the name of the script type, but if RubyScriptEngine fails to load the RubyScriptEngine class because the jruby.jar on which it depends does not exist, this failure is eaten and does not match Ruby. When the user executes the Ruby script, The fact that the club does not support Ruby is not the real reason for the failure.
  • Added support for extension points IoC and AOP, where one extension point can directly setter for injection of other extension points.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Extension mechanism SPI

[<5.1> Protocol Extension]

RPC protocol extension to encapsulate remote call details.

Contract:

  • When the user callsrefer()The returnedInvokerThe object’sinvoke()Method, the protocol needs to be executed accordingly with the URL remoteexport()The incomingInvokerThe object’sinvoke()Methods.
  • Among them,refer()The returnedInvokerImplemented by protocol, which is usually required hereInvokerTo send a remote request,export()The incomingInvokerImplemented by the framework and passed in, the protocol doesn’t need to care.

Note:

  • The protocol does not care about transparent proxy of the business interface toInvokerIs centered by the outer layerInvokerConvert to a business interface.
  • The protocol does not have to be TCP network communication, such as file sharing, IPC interprocess communication, etc.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service Exposure (1) Local Exposure (Injvm)
  • Dubbo Source Code Analysis – Service Exposure (2) remote Exposure (Dubbo)
  • Dubbo Source Code Analysis — Service References (1) Local References (Injvm)
  • Dubbo Source Code Analysis — Service Reference (2) Remote Reference (Dubbo)

[<5.2> Call interception extension]

The service provider and service consumer invoke procedural interception. Most of the functionality of Dubbo itself is implemented based on this extension point. This interception is executed each time a remote method is executed.

Convention:

  • User-defined filter comes after built-in filter by default.
  • Special valuesdefaultRepresents the position where the default extension point is inserted. Such as:filter="xxx,default,yyy"Said,xxxBefore the default filter,yyyAfter the default filter.
  • Special symbols-, indicating deletion. Such as:filter="-foo1", delete add default extension pointfoo1. Such as:filter="-default"To add all default extension points.
  • When both the Provider and service filter are configured at the same time, all filters are accumulated instead of overwriting. Such as:<dubbo:provider filter="xxx,yyy"/> ε’Œ <dubbo:service filter="aaa,bbb" />,xxx.yyy.aaa.bbbWill take effect. To override, configure:<dubbo:service filter="-xxx,-yyy,aaa,bbb" />

Corresponding source code analysis article:

  • Dubbo source code parsing — ClassLoaderFilter (1)
  • Dubbo: ContextFilter (ContextFilter)
  • Dubbo source code parsing — AccessLogFilter (3)
  • Dubbo Source Code Analysis – ActiveLimitFilter && ExecuteLimitFilter
  • Dubbo source code analysis – Filter (5) TimeoutFilter
  • Dubbo source code analysis – Filter (6) DeprecatedFilter
  • Dubbo source code analysis – Filter (7) ExceptionFilter
  • Dubbo source code analysis – Filter (8) TokenFilter
  • Dubbo source code Analysis – Filter (9) TpsLimitFilter
  • Dubbo Source Code Analysis – CacheFilter (10)
  • Dubbo source Code Analysis — ValidationFilter (11)

【<5.3> Reference listener extension 】

This event is triggered when there is a service reference.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service References (1) Local References (Injvm)

【<5.4> Expose monitor extension 】

This event is triggered when a service is exposed.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis — Service Exposure (1) Local Exposure (Injvm)

[<5.5> Cluster Expansion]

When there are multiple service providers, organize the multiple service providers into a cluster and masquerade as one provider.

Corresponding source code analysis article:

  • Dubbo Source Code Parsing — Cluster Fault Tolerance (1) abstract API
  • Dubbo source code parsing – Cluster fault tolerance (2) Cluster implementation

[<5.6> Route Extension]

Call from one of the service providers.

  • There was a problem with the official documentation, screening all matching result sets from multiple service providers.

Corresponding source code analysis article:

  • Dubbo source Code parsing — Cluster Fault Tolerance (7) Router Implementation

【<5.7> Load Balancing expansion 】

Call from one of the service providers

Corresponding source code analysis article:

  • Dubbo source code parsing – Cluster Fault Tolerance (4) Loadbalance Implementation

[<5.8> Merge result extension]

Merge returns results for group aggregation.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Cluster Fault Tolerance (5) : The Implementation of a Merger

[<5.9> Registry Expansion]

Responsible for service registration and discovery.

Corresponding source code analysis article:

  • Dubbo source code analysis – Zookeeper client
  • Dubbo Source Code Analysis — Registry 1 Abstract API
  • Dubbo source Code Analysis – Registry (2) Zookeeper
  • Dubbo Source Code Analysis – Registry (3) Redis
  • Complete Dubbo Source Code Analysis — Simple for Registry 4
  • Source Code Analysis of Dubbo – For Multicast (5)

[<5.10> Monitoring Center Expansion]

Responsible for service call times and call time monitoring.

Corresponding source code analysis article:

TODO

<5.11> Extension point loading extension

The load container for the extension point itself, which can be loaded from different containers.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Extension mechanism SPI

[<5.12> Dynamic Proxy Extension]

Transform the Invoker interface into a business interface.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – Dynamic Proxy part 1: Javassist
  • Dubbo source Code analysis – Dynamic Proxy (ii) JDK

[<5.13> Compiler extensions]

Java code compiler, used to dynamically generate bytecode, speed up calls.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – Dynamic Compilation (PART 1) : Javassist
  • Dubbo source Code analysis – Dynamic Compilation (ii) JDK

[<5.14> Message distribution extension]

Channel information dispatcher that specifies the thread pool model.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – NIO Server (1) Abstract API

[<5.15> Thread pool expansion]

The service provider threading implements the policy of creating a thread in the thread pool to execute the service provider business logic when the server receives a request.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — Thread Pool

【<5.16> Serialized extension 】

Converting an object into a byte stream for network transmission, and converting a byte stream into an object for restoration upon receipt of byte stream data.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – Serialization (I) of the Overall implementation
  • Dubbo source code analysis – Serialization (ii) Dubbo implementation
  • Dubbo source code analysis – Serialization (3) Kryo implementation

[<5.17> Network Transmission Expansion]

Remote communication server and client transmission implementation.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – NIO Server (1) Abstract API
  • Dubbo source code Analysis – NIO Server (2) Transport Layer

[<5.18> Information Exchange Extension]

Based on the transport layer, request-Response information exchange semantics are realized.

Corresponding source code analysis article:

  • NIO Server (4) Exchange Layer

【<5.19> Network Expansion 】

Peer-to-peer network node networker.

Corresponding source code analysis article:

  • Source Code Analysis of Dubbo – For Multicast (5)

【<5.20> Telnet command extension 】

All servers support Telnet access for human intervention.

Corresponding source code analysis article:

  • Dubbo source Code Analysis – NIO Server (3) Telnet Layer

【<5.21> Status Check Extension 】

Check the status of the resources that the service depends on. This status check can be used in both Telnet status and the hosting status page.

Corresponding source code analysis article:

TODO

[<5.22> Container Extension]

Service container extension for customizing load content.

Corresponding source code analysis article:

  • Dubbo: Service Container

【<5.23> Page Extension 】

Peer-to-peer network node networker.

  • There is a problem with the official documentation. It should be a request handler, sort of like a Servlet.

Corresponding source code analysis article:

TODO

[<5.24> Cache extension]

The cache returns the result with the request parameter as the key.

Corresponding source code analysis article:

  • Dubbo Source Code Analysis – CacheFilter (10)

[<5.25> Validate extension]

Parameter validation extension point.

Corresponding source code analysis article:

  • Dubbo source Code Analysis — ValidationFilter (11)

[<5.26> Log Adaptation extension]

Log output ADAPTS to extension points.

Corresponding source code analysis article:

  • Dubbo source code parsing – Log adaptation

1.4 Dubbo O&M Guide

Dubbo Operation and Maintenance Guide, there is no need for mapping.

2. [Lao Xu] RPC column

  • Author: Lao Xu
  • Blog: https://www.cnkirito.moe/categories/RPC/
  • Directory:
    • Simple Understanding of RPC Implementation Principle
    • An In-depth Understanding of RPC serialization — Kryo
    • An In-depth Understanding of RPC serialization — Summary
    • In-depth Understanding of RPC dynamic Proxies
    • In-depth Understanding of RPC transport
    • Using asynchronous RPC Interfaces in Motan
    • In-depth Understanding of RPC protocols
    • Service Registration and Discovery for an In-depth Understanding of RPC
    • In-depth Understanding of RPC clustering
    • From Cross-language Invocation to Dubbo2.js
    • Summary of Dubbo Mesh Optimization of Tianchi Middleware Competition (QPS from 1000 to 6850)

3. [Fat] Dubbo source code analysis

  • Author: Fat Chao
  • Blog: http://www.jianshu.com/u/f7daa458b874
  • Directory:
    • Dubbo Source Code Analysis — Cluster Fault-tolerant Architecture Design
    • Dubbo source code parsing — Directory
    • Dubbo source code parsing — Router
    • Dubbo source code parsing — Cluster
    • Dubbo – LoadBalance
    • Dubbo Source code Parsing – Service Exposure Principles
    • Dubbo source Code parsing — Local Exposure
    • Dubbo source code parsing – Remote Exposure
    • Dubbo source code parsing – Zookeeper connection
    • Dubbo: Zookeeper creates a node
    • Dubbo Source Code Parsing – Service Exposure Summary
    • Dubbo source code: Zookeeper Subscription
    • Dubbo Source Code Parsing: Service Degradation in Logical Layer Design
    • Dubbo Source Code analysis — Simple Principles and Integration with Spring
    • Dubbo Source Code parsing — Principles of Service Reference

4. [MR_QI] Dubbo source code parsing

  • Author: MR_QI
  • Blog: https://my.oschina.net/qixiaobo025/blog or http://qixiaobo.site/tags/dubbo/
  • Directory:
    • Dubbo Source Code Series: Filter Prehistory
    • Dubbo Source Code Series: The Current Life of Filter
    • Why Dubbo’s declarative cache Doesn’t Work!!
    • Dubbo Elegant Service Demotion: Stub and Echo Service
    • Dubbo serialized hessian2
    • Dubbo Exception Handling
    • Dubbo Custom Exception Message Length Solution
    • Dubbo Client Returns a Custom Exception
    • Dubbo timeout control source code analysis
    • Dubbo’s Telnet Implementation
    • Fst Deserialization failure
    • Dubbo Configuration Direct Connection

5. 【 Yang Wubing 】Dubbo source code analysis

  • Author: Yang Wubing
  • Blog: https://my.oschina.net/ywbrj042/blog
  • Directory:
    • Dubbo Source Code Analysis Series — Introduction to Project Engineering Structure
    • Dubbo Source Code Analysis Series — Dubbo-RPC-API Module source Code Analysis
    • Dubbo Source Code Analysis series — Dubbo-Rpc-default module source code Analysis
    • Dubbo Source Code Analysis Series — DUbbo SPI mechanism source analysis
    • Dubbo Source Code Analysis Series — Dubbo SPI Mechanism Adaptive Adpative Class Analysis
    • Dubbo Source Code Analysis series — Dubbo-Cluster module source code Analysis
    • Dubbo Source Code Analysis Series — Dubbo-Register-API Module source Code Analysis
    • “Dubbo Typical Protocol, Transport Component, serialization Method combined Performance Comparison Test”
    • Dubbo Core Process Analysis
    • “Problems with HashMap Locking in hessian Serialization Factories in Dubbo Services in High Concurrency Scenarios”
    • “Principles and Practices of Distributed Services Framework” — Chapter 5 Protocol Stack Reading Notes

666. Contributions are welcome