Dubbo application development (b) an overview of the relevant registration center dubbo

1. Registration Center Overview

In Dubbo micro-service system, the registry is one of the core components of a distributed environment .Dubbo registration and found that among micro-services, is the link between the distributed nodes via the registry. Its main role as follows:

  • Dynamically join. A service provider can move to the center by registering themselves exposed to other consumers, consumers disorder one by one to update the configuration file;
  • Dynamic discovery. Consumers may perceive a dynamic new configuration, routing rules and new service providers, without having to restart the service to make it take effect;
  • Dynamic Adjustment. Registry supports dynamic adjustment of parameters, new parameters automatically updates all associated service node;
  • Unified configuration. Avoid the local configuration inconsistencies cause configuration for each service.

Dubbo registries source code module in dubbo-register, which contains five sub-modules, as follows:

Module Name Module Description
dubbo-register-api It includes all registry and abstract API implementation class
dubbo-register-zookeeper Use as a zookeeper achieve registration center
dubbo-register-redis Redis use as an implementation registry
dubbo-register-default Dubbo based on the default memory implementation
dubbo-register-multicast Service registration and discovery multicast mode

2. Workflow

  • When the service starts, it will write its own metadata information to the registry, and it will subscribe configuration metadata;
  • Consumers can also write your own registry started as metadata, and subscribe to a service provider, routing and configuration metadata information;
  • Service Management Center (dubbo-admin), will also subscribe to all consumers, service providers, routing and configuration metadata information;
  • When all the service providers have to leave or join the new service provider, the registry service provider directory change occurs, the dynamic change notification message to consumers, service management center;
  • When a consumer initiates a service call, the call will be asynchronous, statistical information reported to the monitoring center (dubbo-monitor-simple).

mcIxZn.png

3.Zookeeper principles outlined

Zookeeper registry is a tree structure, the type of each node into the node persistent, lasting order of nodes, the nodes and temporary provisional order of nodes.

  • Persistent node: The node is not lost ensure service registration, registration center will restart exist;
  • Persistent order of nodes: a node on the basis of characteristics of persistent increases the ability of the sequence of nodes;
  • Temporary node: After registration service connection is lost or overtime session, the registered node will automatically be removed;
  • Temporary order of nodes: Based on the characteristics of the temporary node node increases the ability of the order.

Dubbo use Zookeeper as the registry, it will only create lasting temporary nodes and nodes are two kinds of created order is not required.

Early zookeeper dubbo tree is as follows:

+ /dubbo

+ -- servicce 

       +--providers

       +--consumers

      +--routers

    +--configurators

4. The tree structure relationship

The root node (1) the center of the tree is registered packet, following a plurality of service interfaces, packets from a user configuration values ​​<dubbo: register> group attribute;

(2) the service interface contains four types subdirectories are providers, consumers, routes, configurators, this path is the persistent node;

(3) the service provider directory (/ dubbo / service / providers) contains the following interfaces multiple service URL metadata information;

(4) customer service directory (/ dubbo / service / consumers) contains the following consumer interface has multiple URL metadata information;

(5) routing configuration directory (/ dubbo / service / routes) contains the following URL routing strategy more consumers metadata information.

(6) Dynamic configuration directory (/ dubbo / service / configurators) comprising a plurality of the following consumer information for metadata from the URL policy.

Enable registry in Dubbo can refer to the following way:

<beans>
<!--适用于Zookeeper一个集群有多个节点,多个IP和端口用逗号分隔-->
   <dubbo:registry protocol="zookeeper" address="ip:port,ip:port" />
 <!--适用于Zookeeper一个集群有多个节点,多个IP和端口用竖线分隔-->
  <dubbo:registry protocol="zookeeper" address="ip:port|ip:port" />
</beans>

Guess you like

Origin www.cnblogs.com/charlypage/p/11407521.html