dubbo Source Resolution spring Integrated dubbo Namespace Handler Configuration Parameters

Say in front
Starting from today's system for dubbo source code analysis, this article first introduces dubbo and spring integration related content, more source code analysis please pay attention to the "Tianhe Chat Architecture" public number.

Source code parsing
Dubbo's namespace parsing is this class, com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandler. The xml mode integrated with spring was introduced in the previous spring source parsing. All of them parse NamespaceHandler first, and look at the contents of Dubbo NamespaceHandler class first.

public class DubboNamespaceHandler extends NamespaceHandlerSupport {

    static {
//        Check Pack Conflict

    public void init() {
//        xml configuration resolution="
        registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
        registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
        registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
        registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
        registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
        registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
        registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
        registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
        registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
//        Annotation parsing < dubbo: annotation package = "/> XML configuration ="
        registerBeanDefinitionParser("annotation", new AnnotationBeanDefinitionParser());


Static blocks are used to check whether there is a DubboNamespaceHandler.class file with the same permission name. The init method parses the configuration registration of Application Config, ModuleConfig, Registry Config, MonitorConfig, ProvderConfig, ConsumerConfig, protocolConfig, Service Bean, RefrenceBean and reference types. To dubbo's bean definition in spring bean Factory. These configurations are performed by the bean definition parser DubboBean Definition Parser. Annotation-based method is parsed by Annotation Bean Definition Parser, a bean definition parser. Dubbo's provider and consumer also support annotation. Detailed information can be found in com.alibaba.dubbo.config.annotation.Service, com.alibaba.dubbo.config.annotation.Reference's configuration and <dubbo:service: The configuration in the < dubbo: reference XML tag is the same, parser parsing through bean definition will be resolved to spring bean factory bean definition.

Let's first look at what configuration attributes are in the application Config. The corresponding is the < dubbo: application XML tag

// application name
    private String name;

    // module version
    private String version;

    // application owner
    private String owner;

    // application's organization (BU)
    private String organization;

    // architecture layer
    private String architecture;

    // environment, e.g. dev, test or production
    private String environment;

    // Java compiler
    private String compiler;

    // logger
    private String logger;

    // registry centers
    private List<RegistryConfig> registries;

    // monitor center
    private MonitorConfig monitor;

    // is default or not
    private Boolean isDefault;

    // directory for saving thread dump thread stack save folder
    private String dumpDirectory;

    // whether to enable qos or not
    private Boolean qosEnable;

    // the qos port to listen
    private Integer qosPort;

    // should we accept foreign ip or not?
    private Boolean qosAcceptForeignIp;

    // customized parameters
    private Map<String, String> parameters;

This configuration is mainly aimed at the global configuration of the whole dubbo application. The chapter of priority and loading order service registration will be introduced separately after the analysis is completed, but it will not be expanded here.

name application names, provider s, and consumer s are not identical and are used in registries to compute dependencies between applications
Environment environment, useful in development and testing
compiler java bytecode compiler for dynamic class generation, optional jdk, javassist, default value javassist
logger log output mode, optional: slf4j,jcl,log4j,log4j2,jdk, default value slf4j
owner Application Leader for Service Governance
private List registries; this is the dubbo registry-related configuration
Dump Directory property, save thread stack file, corresponding to xml tag parameter dump.directory

Registry configuration, <dubbo:registry XML tag

public class RegistryConfig extends AbstractConfig {

    public static final String NO_AVAILABLE = "N/A";
    private static final long serialVersionUID = 5508512956753757169L;
    // register center address
    private String address;

    // username to login register center
    private String username;

    // password to login register center
    private String password;

    // default port for register center
    private Integer port;

    // protocol for register center
    private String protocol;

    // client impl
    private String transporter;

    private String server;

    private String client;

//    fault-tolerant
    private String cluster;

    private String group;

    private String version;

    // request timeout in milliseconds for register center registry timeout
    private Integer timeout;

    // session timeout in milliseconds for register center registry session timeout
    private Integer session;

    // file for saving register center dynamic list registry dynamic list saves files
    private String file;

    // wait time before stop stop stops waiting time
    private Integer wait;

    // When to check if register center is available when boot up checks whether the registry is available
    private Boolean check;

    // whether to allow dynamic service to register on the register center service allows dynamic registration to the registry
    private Boolean dynamic;

    // whether to export service on the register center allows registration services in the registry
    private Boolean register;

    // whether allow to subscribe service on the register center allows subscription to Registry Services
    private Boolean subscribe;

    // customized parameters
    private Map<String, String> parameters;

    // if it's default
    private Boolean isDefault;

Address registry address, corresponding to the xml tag address attribute
Username attribute corresponds to xml tag username attribute
Password attribute corresponds to xml tag password attribute
port attributes correspond to xml attributes
Zookeeper stand-alone, address can also use zookeeper://
protocol attributes, supporting dubbo, multicast, redis, zookeeper, and so on
transporter attribute, network transmission mode, optional netty, mina, grizzly, http, etc.
Server corresponds to < dubbo: protocol server attribute. The default Dubbo protocol is netty and http protocol is servlet.
Client corresponds to the <dubbo:protocol client attribute, and the default Dubbo protocol is netty.

Cluster fault-tolerant support, default value failover, failure automatic retry, corresponding to <dubbo:service,<dubbo:reference,<dubbo:provider,<dubbo:consumer tag cluster attribute, fault-tolerant mechanism has the following several kinds

Available uses available
failback failures are automatically restored, failure requests are recorded in the background and retransmitted regularly
failfast initiates only one call and immediately alerts for failure. It is generally used for non-idempotent operations.
failover fails to switch automatically, retries other servers, usually for read operations, and retries can cause greater latency
failsafe failures are safe, and exceptions are ignored directly. They are commonly used for logging.
forking calls a pair of servers in parallel and returns as soon as one is successful. It is usually used for real-time read operations, which wastes more service resources.
Group default value dubbo, service registration grouping, cross-group services will not affect each other, and can not call each other, suitable for environmental isolation
Timeout registry timeout
Files are used to store registry service provider file s from which service restart loads the registry
wait service shutdown waiting time

Check to check whether registered service providers are available, corresponding to <dubbo:registry,<dubbo:refrence,<dubbo:consumer tag check attribute, default value true

Whether the dynamic service is dynamically registered or not. If false, the service will be displayed as disable, and you need to enable it manually. You also need to disable the provider when it closes. Default value true

Whether the register is registered in the registry. If false, subscribe only and not register.
Whether subscribe subscribes from the registry. If it is false, only register, not subscribe.
Parameters custom parameters

Provider configuration corresponds to <dubbo:provider tag

public class ProviderConfig extends AbstractServiceConfig {
    private static final long serialVersionUID = 6913423882496634749L;

    // ======== protocol default values, it'll take effect when protocol's attributes are not set by default, which will take effect when protocol properties are not set========

    // service IP addresses (used when there are multiple network cards available)
    private String host;

    // service port
    private Integer port;

    // context path
    private String contextpath;

    // Thread pool thread pool type
    private String threadpool;

    // thread pool size (fixed size) number of threads
    private Integer threads;

    // IO thread pool size (fixed size) io thread number
    private Integer iothreads;

    // thread pool queue length queue length
    private Integer queues;

    // max acceptable connections provider maximum number of connections
    private Integer accepts;

    // protocol codec codec
    private String codec;

    // charset
    private String charset;

    // Maximum number of bytes transmitted by payload max length network
    private Integer payload;

    // buffer size
    private Integer buffer;

    // transporter
    private String transporter;

    // how information gets exchanged information exchange mode
    private String exchanger;

    // thread dispatching mode thread forwarding mode
    private String dispatcher;

    // networker
    private String networker;

    // server impl
    private String server;

    // client impl
    private String client;

    // supported telnet commands, separated with comma.
    private String telnet;

    // command line prompt
    private String prompt;

    // status check
    private String status;

    // wait time when stop stops waiting time
    private Integer wait;

host specifies service ip, which is used when multicard is used
Thread pool thread pool type specified, default fixed, optional fixed, cached
Threads specifies the number of threads in the thread pool, with a default value of 200
iothreads io threads, default cpu threads + 1
queues default value is 0. dubbo recommends that tasks be processed directly and not queued.
Acepts default value 9, maximum number of connections for service providers
Codc protocol coding and decoding support, default value dubbo
The length limit for payload requests and responses, in bytes, defaults to 8m
Buffer size of buffer network IO, default 8192
transporter attribute, network transmission mode, optional netty, mina, grizzly, http, etc., client and server can be set separately
Exchanger protocol converter, default value header, header Exchanger, corresponding to <dubbo:protocol,<dubbo:provider tag exchanger attribute

dispatcher thread forwarding model, all, connection, direct, execution, message, default value all
all messages are dispatched to the thread pool, including requests, responses, connection events, disconnection events, heartbeat monitoring, and so on.
connection queues disconnection events on io threads, executes them one by one in an orderly manner, and dispatches other messages to thread pools
All messages directed are not dispatched to the thread pool and are executed directly on the io thread
execution only requests messages to be dispatched to the thread pool, without response, response and other disconnection events, heartbeat detection and other messages, and executes directly on the io thread
Only request response messages are sent to thread pool, other connection disconnection events, heartbeat detection and other messages are executed directly on io threads.

Corresponding to <dubbo:provider,<dubbo:protocol tag dispatcher attribute

Network Connector, multicast Broadcast, file Reads host from file, Corresponding to <dubbo:provider,<dubbo:protocol network properties
server server protocol, dubbo protocol default value is netty, http protocol default value is servlet
Client-side protocol, Dubbo protocol default value netty, corresponding to < dubbo: provider, < dubbo: Ptotocol tag server, client attributes

Telnet commands supported by telnet

Status status check, default support
memory Memory Status Check
load Load Status Check
dubbo started with other status checks, spi was not added and needed to be extended by itself.
Registry Status Checker Service Registration Status Check
Server Status Checker server status check
Spring Status Checker Spring Container Status Check
ThreadPool Status Checker Thread Pool Status Check

wait service stop waiting time

cosumer configuration, correspondingdubbo:consumer,dubbo:refrence Label

public class ConsumerConfig extends AbstractReferenceConfig {

    private static final long serialVersionUID = 2827274711143680600L;

    // is default or not
    private Boolean isDefault;

    // networking framework client uses: netty, mina, etc. type of network communication middleware
    private String client;

    // consumer thread pool type: cached, fixed, limit, eager thread pool type
    private String threadpool;

    // Number of core threads in consumer threadpool core thread size consumer thread pool
    private Integer corethreads;

    // Number of threads in consumer thread pool thread size consumer thread pool
    private Integer threads;

    // Queue length of consumer threadpool queue size consumer thread pool
    private Integer queues;

Client client network communication components, netty, mina, etc.

Thread pool thread pool type
fixed java comes with thread pool
cached java has its own thread pool
limited threads only increase but not decrease

The thread pool increase strategy of eager java is that the number of core threads occupies the queue, and the queue is filled with the maximum number of threads that do not exceed the thread pool to create threads. The thread pool increase strategy of eager java is to add threads when current PoolSize < submitted TaskCount < maxPoolSize satisfies this condition, submitted Task Co. Unt is a counter extended by dubbo, which increases the count while executing the thread, and decreases the count after executing the thread.

Number of core threads in corethreads. This parameter is invalid for fixed thread pool. Number of core threads in fiexed type is the same as the maximum number of threads.
Maximum number of threads in threads thread pool
queues thread pool queue size

In the end
This analysis only represents personal views, for reference only.

Tags: Dubbo Attribute xml network

Posted on Tue, 27 Aug 2019 22:32:57 -0700 by pugisback