A service registration method and an Apache Dubbo system

By parsing the attribute parameters of a URL in the Apache Dubbo system to determine if it is the last URL of the same type, and generating metadata to send to the service registry when necessary, the problem of low service registration and discovery efficiency is solved, and a more efficient service registration and discovery process is achieved.

CN113536159BActive Publication Date: 2025-11-04HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010291514.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-14
Publication Date
2025-11-04
Estimated Expiration
2040-04-14

AI Technical Summary

Technical Problem

In the Apache Dubbo system, a sharp increase in communication with the service registry in a short period of time leads to low efficiency in service registration and discovery, severe network congestion, and affects system availability.

Method used

By parsing the attribute parameters of the URL in the service registration and discovery module, it is determined whether it is the last URL of the same type. If it is, metadata is generated and cached; otherwise, the URL itself is cached. After the last URL generates metadata, it is sent to the service registry center.

Benefits of technology

It reduced service queue waiting time, improved service registration and discovery efficiency, alleviated network congestion, and enhanced system availability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113536159B_ABST
    Figure CN113536159B_ABST
Patent Text Reader

Abstract

A service registration method and an Apache Dubbo system, the method comprising: a service registration and discovery module obtaining a first URL and parsing the first URL to determine that the first URL is a first type of URL and an attribute value of a first attribute parameter of the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, the service registration and discovery module caches the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and a first type of URL cached before the first URL reaches the service registration and discovery module, the service registration and discovery module generates the metadata and sends the metadata to a service registry. By using the above method, the service registration and discovery efficiency can be improved by generating metadata of multiple URLs of the same type and sending the metadata to the service registry.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the computer technical field, and particularly relates to a service registration method and an Apache Dubbo system. BACKGROUND

[0002] With the development of the Internet, the scale of the system is expanding, and the distributed service architecture becomes the first choice for building large-scale applications. Apache Dubbo is an open source Java RPC framework, and the service automatic registration and discovery function provided by Apache Dubbo can help users quickly build a distributed service discovery and service remote calling system.

[0003] At present, the service registration and discovery mode supported by Apache Dubbo only supports registration and discovery one by one, as shown in the following table. Figure 1 As shown in the table, N1 service provider type URLs are registered with the service registry one by one, and N2 service consumer type URLs are registered and discovered with the service registry one by one. Due to the sharp increase in communication with the service registry in a short period of time, the service queue that needs to be registered and discovered is too long, which easily causes network congestion, and the service registration and discovery efficiency is low. At the same time, the network pressure of the service registry is too large, and even individual service registries may be down, thereby triggering load migration and causing greater network congestion. Such a chain reaction easily makes the entire service registry finally unavailable, which seriously affects the system availability. SUMMARY

[0004] The embodiments of the present application provide a service registration method and an Apache Dubbo system, which are used to solve the problem of low service registration and discovery efficiency caused by the sharp increase in communication with the service registry in a short period of time.

[0005] In a first aspect, the embodiments of the present application provide a service registration method, which is applied to an Apache Dubbo system. The method comprises the following steps: a service registration and discovery module obtains a first URL and parses the first URL to determine that the first URL is a first type of URL and the attribute value of the first attribute parameter of the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, the service registration and discovery module caches the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and the first type of URL cached before the first URL arrives at the service registration and discovery module, the service registration and discovery module generates metadata of the first URL and the first type of URL cached before the first URL arrives at the service registration and discovery module, and sends the metadata to a service registry.

[0006] Therefore, by sending a plurality of URL generation metadata of the same type to the service registry center, the service queue waiting time can be reduced, the service registration and discovery efficiency can be improved, the network congestion can be alleviated, and the problem of low service registration and discovery efficiency caused by a sharp increase in communication with the service registry center in a short time can be solved.

[0007] In a possible design, when the first URL is not the last first type URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL; when the first URL is the last first type URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL together with the first type URL cached before the first URL arrives at the service registration and discovery module.

[0008] By analyzing the parameter value of the first attribute parameter of the first URL, whether the first URL is the last first type URL registered to the service registry center can be determined, and then the service discovery end can determine the URL of the same type and generate metadata of all the same type URL.

[0009] In a possible design, the attribute values of the first attribute parameters corresponding to the M-1 first type URLs cached before the first URL arrives at the service registration and discovery module indicate that the service registration and discovery module caches the corresponding URLs, the first URL is the Mth first type URL that arrives at the service registration and discovery module, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL together with the first type URL cached before the first URL arrives at the service registration and discovery module, and M is a positive integer greater than or equal to 2; or, the first URL is the Nth first type URL that arrives at the service registration and discovery module, N < M, N is a positive integer, and the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL.

[0010] By analyzing the parameter value of the first attribute parameter of the first URL, whether the first URL is the last first type URL in the M first type URLs can be determined, and then the service discovery end can generate metadata of a plurality of same type URLs.

[0011] In a possible design, when the attribute value of the first attribute parameter of the first URL is a first preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL; when the attribute value of the first attribute parameter of the first URL is a second preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first type of URL cached before the first URL arrives at the service registration and discovery module, from the first URL; the first preset value is different from the second preset value.

[0012] In a possible design, the first attribute parameter is a string type attribute parameter newly added in a service configuration file of the system.

[0013] In a possible design, the first type is a service provider or a service consumer.

[0014] In a possible design, the first URL is obtained by parsing a first object, and the first object is at least one of an XML document, an interface definition configuration file, an API, and an annotation.

[0015] In a second aspect, an embodiment of the present application provides an Apache Dubbo system, the system comprising a client and a service registry center, the client comprising a service configuration module and a service registration and discovery module, wherein: the service configuration module is configured to parse a first object to generate a plurality of URLs, configure an attribute value of a first attribute parameter for each URL in the plurality of URLs, and input the plurality of configured URLs to the service registration and discovery module in sequence; the service discovery module is configured to parse a first URL, determine that the first URL is a URL of a first type and that an attribute value of a first attribute parameter of the first URL, the first URL being any one of the plurality of configured URLs; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, cache the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first type of URL cached before the first URL arrives at the service registration and discovery module, from the first URL, generate the metadata of the first type of URL cached before the first URL arrives at the service registration and discovery module, from the first URL, and send the metadata to the service registry center; and the service registry center is configured to parse the metadata, and obtain the first URL and the first type of URL cached before the first URL arrives at the service registration and discovery module.

[0016] In a possible design, when the first URL is not the last first-type URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module caches the first URL; and when the first URL is the last first-type URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module generates metadata of the first URL and the first-type URLs cached before the first URL arrives at the service registry discovery module.

[0017] In a possible design, the attribute values of the first attribute parameters of the M-1 first-type URLs cached before the first URL arrives at the service registry discovery module indicate that the service registry discovery module caches the corresponding URLs, the first URL is the Mth first-type URL that arrives at the service registry discovery module, and the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module generates metadata of the first URL and the first-type URLs cached before the first URL arrives at the service registry discovery module, where M is a positive integer greater than or equal to 2; or the first URL is the Nth first-type URL that arrives at the service registry discovery module, the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module caches the first URL, and N is a positive integer less than M.

[0018] In a possible design, when the attribute value of the first attribute parameter of the first URL is a first preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module caches the first URL; and when the attribute value of the first attribute parameter of the first URL is a second preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registry discovery module generates metadata of the first URL and the first-type URLs cached before the first URL arrives at the service registry discovery module; the first preset value is different from the second preset value.

[0019] In a possible design, the first attribute parameter is a string-type attribute parameter newly added in a service configuration file of the system; and the service configuration module is configured to configure, based on the service configuration file, the attribute value of the first attribute parameter for each URL in the plurality of URLs.

[0020] In a possible design, the first type is a service provider or a service consumer.

[0021] In a possible design, the first object is at least one of an XML document, an interface definition configuration file, an API, and an annotation.

[0022] It should be understood that the technical effects of the second aspect and the various designs in the second aspect can be referred to the technical effects of the corresponding designs in the first method and the first aspect, and the repeated parts will not be repeated.

[0023] Thirdly, this application also provides an apparatus including a processor and a memory; the memory is used to store computer execution instructions; the processor is used to execute the computer execution instructions stored in the memory to cause the communication apparatus to perform the method described in the first aspect.

[0024] Fourthly, this application also provides an apparatus including a processor and an interface circuit; the interface circuit is configured to receive code instructions and transmit them to the processor; the processor executes the code instructions to perform the method described in the first aspect.

[0025] Fifthly, this application provides a chip coupled to a memory in an electronic device, such that the chip, during operation, calls program instructions stored in the memory to execute the method of the first aspect.

[0026] Sixthly, this application also provides a readable storage medium that stores instructions that, when executed, enable the method described in the first aspect to be implemented.

[0027] In a seventh aspect, this application also provides a computer program product containing a program that, when run on a computer, causes the computer to perform the method described in the first aspect. Attached Figure Description

[0028] Figure 1 This is a schematic diagram of service registration in the background art of this application;

[0029] Figure 2 This is a schematic diagram of the structure of an Apache Dubbo system according to an embodiment of this application;

[0030] Figure 3 This is a flowchart outlining a service registration method as described in an embodiment of this application.

[0031] Figure 4 This is a flowchart illustrating the specific process of service registration in the embodiments of this application;

[0032] Figure 5 In the embodiments of this application, and Figure 4 The corresponding service registration diagram. Detailed Implementation

[0033] The embodiments of this application will now be described with reference to the accompanying drawings.

[0034] Apache Dubbo is a high-performance open source Java RPC distributed service framework. The core functions of Apache Dubbo include interface-oriented remote procedure call, cluster fault tolerance and load balancing, and service automatic registration and discovery. Apache Dubbo uses a layered architecture pattern to achieve maximum decoupling between layers and abstract services into two roles: service providers (services) and service consumers (references). Among them, the service provider registers its own service to the service registry. The service consumer subscribes to the service from the service registry, and the service registry returns the address list of the service provider to the service consumer. The service consumer selects a service provider from the returned address list for calling, and if the calling fails, selects another service provider for calling.

[0035] In order to solve the problem of low service registration and discovery efficiency caused by a sharp increase in communication with the service registry in a short time. The embodiment of the application is applied to an Apache Dubbo system, as shown in the figure, the system comprises a client 210 and a service registry 220, wherein the client 210 comprises a service registration and discovery module 211 and a service configuration module 212, and the type of the client 210 can be a service provider or a service consumer. Figure 2

[0036] The service configuration module 212 is configured to parse the first object to generate a plurality of uniform resource locators (URLs), configure an attribute value of a first attribute parameter for each of the plurality of URLs, and input the plurality of configured URLs to the service registration and discovery module 211 in sequence.

[0037] The service registration and discovery module 211 is configured to parse the first URL, determine that the first URL is a URL of a first type and an attribute value of a first attribute parameter of the first URL, and the first URL is any one of the plurality of configured URLs; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module 211 caches the first URL, the service registration and discovery module 211 caches the first URL; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module 211 generates metadata of the first URL and the URL of the first type cached before the first URL reaches the service registration and discovery module 211, the service registration and discovery module 211 generates metadata of the first URL and the URL of the first type cached before the first URL reaches the service registration and discovery module 211, and sends the metadata to the service registry 220.

[0038] The service registry 220 is configured to parse the metadata and obtain the first URL and the URL of the first type cached before the first URL reaches the service registration and discovery module 211.​

[0039] It should be understood that the number of service registration centers 220 can be one or more. Therefore, the plurality of URLs of the metadata are the same type of URLs registered to the same service registration center. In addition, the embodiments of the present application do not limit how the service registration center 220 parses and processes the metadata.

[0040] The first attribute parameter is a newly added string type attribute parameter in the service configuration file of the system. For example, the service configuration file is dubbo.xsd, and the first attribute parameter can be configured for serviceType and referenceType by modifying dubbo.xsd. For example, the first attribute parameter can be last, and the default value of the first attribute parameter can be "false".

[0041] For example, the following is part of the code included in dubbo.xsd, and the first attribute parameter can be added based on the following format.

[0042]

[0043]

[0044] Further, the service configuration module 212 configures the attribute value of the first attribute parameter for each URL in the plurality of URLs according to the service configuration file.

[0045] The first type is a service provider or a service consumer. The first object is at least one of an extensible markup language (XML) document, an interface definition configuration file (-Ddubbo.properties.file), an application programming interface (API), and an annotation. It should be understood that the above-mentioned possible forms of the first object are only examples and are not limited by the present application.

[0046] The interface definition configuration file and the XML are both text documents, which means that the file formats are different, and both can be used to parse the URL.

[0047] Example 1: The following is part of the code included in the XML, and from the following code, it can be known that the application name is demo-provider (i.e., the first type is a service provider), and the registration address, protocol name, and port number.

[0048] <dubbo:application name="demo-provider" / >

[0049] <dubbo:registry address="zookeeper: / / 127.0.0.1:2181" / >

[0050] <dubbo:protocol name="dubbo" port="20890" / >

[0051] As shown in the following code included in the XML, the application name is demo-consumer (i.e., the first type is a service consumer), and the registration group and address are indicated.

[0052] <dubbo:application name="demo-consumer" / >

[0053] <dubbo:registry group="aaa" address="zookeeper: / / 127.0.0.1:2181" / >

[0054] It should be understood that in the Apache Dubbo system, the client can also include other modules to implement other functions of the Apache Dubbo system, which are not limited in the present application.

[0055] Further, as shown in Figure 3 The present application provides a service registration method, which is applied to an Apache Dubbo system, and the method comprises the following steps:

[0056] Step 300: A service registration and discovery module obtains a first URL.

[0057] Step 310: The service registration and discovery module parses the first URL to determine that the first URL is a URL of a first type and the attribute value of the first attribute parameter of the first URL. When the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, the service registration and discovery end executes step 320A; when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and a URL of the first type cached before the first URL reaches the service registration and discovery module, the service registration and discovery end executes step 320B.

[0058] Step 320A: When the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, the service registration and discovery module caches the first URL.

[0059] The service registration and discovery module continues to obtain other URLs and repeats steps 300 and 310.

[0060] Step 320B: When the attribute value of the first attribute parameter of the first URL indicates that the service registration discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration discovery module, the service registration discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration discovery module.

[0061] Step 330: The service registration discovery end sends the metadata to the service registration center.

[0062] The design of the attribute value of the first attribute parameter of the first URL can include, but is not limited to, the following two ways:

[0063] In one possible design, when the first URL is not the last first type of URL registered to the service registration center, the attribute value of the first attribute parameter of the first URL indicates that the service registration discovery module caches the first URL. When the first URL is the last first type of URL registered to the service registration center, the attribute value of the first attribute parameter of the first URL indicates that the service registration discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration discovery module.

[0064] With the above design, by parsing the parameter value of the first attribute parameter of the first URL, it can be determined whether the first URL is the last first type of URL registered to the service registration center, and then the service discovery end can determine the same type of URL and generate metadata of all the same type of URL.

[0065] Exemplarily, the first type of URL registered to the same service registration center can only have one URL as the last first type of URL registered to the service registration center, the attribute value of the first attribute parameter of the URL indicates that the service registration discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration discovery module, and the attribute value of the first attribute parameter of the first type of URL cached before the first URL arrives at the service registration discovery module indicates that the service registration discovery module caches the corresponding URL.

[0066] In another possible design, the attribute values of the first attribute parameters of the M-1 first type URLs cached before the first URL reaches the service registration discovery module indicate that the service registration discovery module caches the corresponding URLs, the first URL is the Mth first type URL reaching the service registration discovery module, and the attribute value of the first attribute parameter of the first URL indicates that the service registration discovery module generates metadata of the first URL and the first type URLs cached before the first URL reaches the service registration discovery module, where M is a positive integer greater than or equal to 2; or the first URL is the Nth first type URL reaching the service registration discovery module, N < M, N is a positive integer, and the attribute value of the first attribute parameter of the first URL indicates that the service registration discovery module caches the first URL.

[0067] With the above design, the attribute value of the first attribute parameter of the first URL is parsed to determine whether the first URL is the last one of the M first type URLs, and metadata of multiple same type URLs can be generated by the service discovery end.

[0068] For example, when the value of M is 100, the attribute value of the first attribute parameter corresponding to the 1st first type URL indicates that the service registration discovery module caches the 1st first type URL, the attribute value of the first attribute parameter corresponding to the 2nd first type URL indicates that the service registration discovery module caches the 2nd first type URL,..., the attribute value of the first attribute parameter corresponding to the 99th first type URL indicates that the service registration discovery module caches the 99th first type URL, and the 100th first type URL indicates that the service registration discovery module generates metadata of the 100 first type URLs and the 100th first type URL.

[0069] In addition, the value of M can be changed according to user needs and actual URL numbers, etc. For example, when the initial value of M is 100, the attribute values of the first attribute parameters corresponding to the 1st first type URL to the 99th first type URL indicate that the service registration discovery module caches the corresponding first type URLs, and the 100th first type URL indicates that the service registration discovery module generates metadata of the 100 first type URLs and the 100th first type URL. If the number of URLs to be registered increases sharply in a short time, the value of M can be adjusted, for example, the value of M can be adjusted to 1000, the attribute values of the first attribute parameters corresponding to the 1st first type URL to the 999th first type URL indicate that the service registration discovery module caches the corresponding first type URLs, and the 1000th first type URL indicates that the service registration discovery module generates metadata of the 1000 first type URLs and the 1000th first type URL.

[0070] In addition, when M = 1, the above design is also compatible with the prior art solution.

[0071] It should be understood that, in addition to the attribute value of the first attribute parameter indicating that the service registration and discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration and discovery module, the first URL cached before the first URL arrives at the service registration and discovery module also needs to satisfy that the URL is directed to the same service registry.

[0072] Further, when the attribute value of the first attribute parameter of the first URL is a first preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL. When the attribute value of the first attribute parameter of the first URL is a second preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL from the first type of URL cached before the first URL arrives at the service registration and discovery module. The first preset value and the second preset value are different.

[0073] For example, the first attribute parameter can be last, and the default value of the first attribute parameter can be "false", i.e., the first preset value is "false", and the second preset value is "true".

[0074] In an example, when the first URL is not the last first type of URL registered to the service registry, the attribute value of the last attribute of the first URL is the default value "false". When the first URL is the last first type of URL registered to the service registry, the attribute value of the last attribute of the first URL is "true".

[0075] In another example, when the first URL is the Nth first type of URL that arrives at the service registration and discovery module, N < M, the attribute value of the last attribute of the first URL is the default value "false". When the first URL is the Mth first type of URL that arrives at the service registration and discovery module, the attribute value of the last attribute of the first URL is "true".

[0076] It should be understood that the first preset value and the second preset value herein are only examples, and other forms of preset values can also be used, which are not limited in the present application.

[0077] Therefore, by sending the plurality of URL generation metadata of the same type to the service registry center, the service queue waiting time can be reduced, the service registration and discovery efficiency can be improved, the network congestion can be alleviated, and the problem of low service registration and discovery efficiency caused by the sharp increase in the communication with the service registry center in a short time can be solved.

[0078] As shown in Figure 4 and Figure 5 In the following examples, the service configuration module obtains N1 service provider type URLs and N2 service consumer type URLs, and it is assumed that there is one service registry center, N1 and N2 are positive integers, N1 can be equal to N2, and N1 can not be equal to N2.

[0079] S401: Modify the service configuration file (dubbo.xsd) of Apache Dubbo, and add a last attribute of string type for the service provider type and the service consumer type, and the default value of the attribute is "false".

[0080] Exemplarily, the administrator can actively modify the service configuration file (dubbo.xsd) of Apache Dubbo.

[0081] S402: The service configuration module obtains a plurality of URLs by at least one of but not limited to parsing XML, -Ddubbo.properties.file, API, and annotation provided by Apache Dubbo, and configures the last attribute for each URL.

[0082] S403: The service configuration module inputs the plurality of configured URLs to the service registration and discovery module in sequence.

[0083] S404: The service registration and discovery module parses the attribute value of the last attribute of each URL input by the service configuration module, and determines whether the attribute value of the last attribute of the URL is "true". If it is determined that the attribute value of the last attribute of the URL is "true", S406 is executed, otherwise, S405 is executed.

[0084] S405: When the attribute value of the last attribute of the URL is "false", the service registration and discovery module classifies and caches the URL.

[0085] And return to S404, the service registration and discovery module continues to parse the attribute value of the last attribute of other URLs input by the service configuration module.

[0086] S406: When the attribute value of the last attribute of the URL is "true", the service registration and discovery module generates a metadata according to the cached URL of the same type as the URL and the URL.

[0087] Exemplarily, as shown in Figure 5 URLs of N1 service provider types are used to generate service provider metadata, and URLs of N2 service consumer types are used to generate service consumer metadata.

[0088] S407: The service registration and discovery module sends the metadata to the service registry.

[0089] S408: The service registry receives and parses the metadata, and stores the parsed result.

[0090] The service registry can obtain the cached URL of the same type as the URL and the URL by parsing the metadata.

[0091] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and when the computer program runs on a computer, the computer executes the method shown in each of the above embodiments.

[0092] The method provided by the embodiments of the present application can be implemented by software, hardware, firmware or any combination thereof, in whole or in part. When implemented by software, the method can be implemented in the form of a computer program product, in whole or in part. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user equipment or other programmable apparatus. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid state disk (SSD)), etc.

[0093] The above embodiments are only used to describe the technical solutions of the present application in detail, but the above embodiments are only used to help understand the method of the embodiments of the present application, and should not be understood as a limitation of the embodiments of the present application. Changes or replacements that can be easily thought of by those skilled in the art should be covered within the protection scope of the embodiments of the present application.

Claims

1. A service registration method characterized by comprising: The method is applied to an Apache Dubbo system, and the method comprises: A service registration and discovery module obtains a first uniform resource locator (URL); The service registration and discovery module parses the first URL, determines that the first URL is a first type of URL and an attribute value of a first attribute parameter of the first URL, and the first attribute parameter is a newly-added attribute parameter of a string type in a service configuration file of the system; When the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, the service registration and discovery module caches the first URL; When the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and a first type of URL cached before the first URL arrives at the service registration and discovery module, the service registration and discovery module generates the metadata of the first URL and the first type of URL cached before the first URL arrives at the service registration and discovery module, and sends the metadata to a service registry center.

2. The method of claim 1, wherein, When the first URL is not the last first type of URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL; When the first URL is the last first type of URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and a first type of URL cached before the first URL arrives at the service registration and discovery module.

3. The method of claim 1, wherein, Attribute values of first attribute parameters corresponding to M-1 first type of URLs cached before the first URL arrives at the service registration and discovery module indicate that the service registration and discovery module caches the corresponding URLs, the first URL is an Mth first type of URL arriving at the service registration and discovery module, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and a first type of URL cached before the first URL arrives at the service registration and discovery module, and M is a positive integer greater than or equal to 2; Alternatively, the first URL is an Nth first type of URL arriving at the service registration and discovery module, N is less than M, N is a positive integer, and the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL.

4. The method according to any one of claims 1 to 3, characterized in that, When the attribute value of the first attribute parameter of the first URL is a first preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL; When the attribute value of the first attribute parameter of the first URL is a second preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and the first type of URL cached before the first URL reaches the service registration and discovery module. The first preset value is different from the second preset value.

5. The method according to any one of claims 1 to 4, characterized in that, The first type is a service provider or a service consumer.

6. The method according to any one of claims 1 to 5, wherein, The first URL is obtained by parsing a first object, and the first object is at least one of an extensible markup language (XML) document, an interface definition configuration file, an application programming interface (API), and an annotation.

7. An Apache Dubbo system characterized in that, The system includes a client and a service registry center, and the client includes a service configuration module and a service registration and discovery module. The service configuration module is configured to parse a first object to generate a plurality of URLs, configure an attribute value of a first attribute parameter for each URL in the plurality of URLs, and sequentially input the plurality of configured URLs to the service registration and discovery module, wherein the first attribute parameter is a newly added attribute parameter of a string type in a service configuration file of the system. The service registration and discovery module is configured to parse a first URL, determine that the first URL is a first type of URL and an attribute value of a first attribute parameter of the first URL, and cache the first URL when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, wherein the first URL is any one of the plurality of configured URLs. The service registration and discovery module is configured to generate metadata of the first URL and the first type of URL cached before the first URL reaches the service registration and discovery module when the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates the metadata, and send the metadata to the service registry center.

8. The system of claim 7, wherein, The service registry center is configured to parse the metadata to obtain the first URL and the first type of URL cached before the first URL reaches the service registration and discovery module. When the first URL is not the last first type of URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL. When the first URL is the last first type of URL registered to the service registry center, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and the first type of URL cached before the first URL reaches the service registration and discovery module.

9. The system of claim 7, wherein, The attribute values of the first attribute parameters of M-1 first type URLs cached before the first URL reaches the service registration and discovery module indicate that the service registration and discovery module caches the corresponding URLs, the first URL is the Mth first type URL reaching the service registration and discovery module, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and the first type URLs cached before the first URL reaches the service registration and discovery module, M is a positive integer greater than or equal to 2; Or, the first URL is the Nth first type URL reaching the service registration and discovery module, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL, N < M, and N is a positive integer.

10. The system of any of claims 7-9, wherein, When the attribute value of the first attribute parameter of the first URL is a first preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module caches the first URL. When the attribute value of the first attribute parameter of the first URL is a second preset value, the attribute value of the first attribute parameter of the first URL indicates that the service registration and discovery module generates metadata of the first URL and the first type URLs cached before the first URL reaches the service registration and discovery module. The first preset value and the second preset value are different.

11. The system of any of claims 7-10, wherein, The service configuration module is configured to configure the attribute value of the first attribute parameter for each URL in the plurality of URLs based on the service configuration file.

12. The system of any of claims 7-11, wherein, The first type is a service provider or a service consumer.

13. The system of any of claims 7-12, wherein, The first object is at least one of an XML document, an interface definition configuration file, an API, and an annotation.

14. A chip, characterized by The chip is coupled with a memory in an electronic device, so that the chip invokes program instructions stored in the memory during runtime to implement the method of any one of claims 1 to 6.

15. A computer-readable storage medium, characterized in that, The computer readable storage medium includes program instructions that, when executed on a device, cause the device to perform the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dubbo distributed cluster system architecture method based on nginx load balancing

    CN105554160A