Switching method and device of micro-service registration center and electronic equipment

By receiving the client's registration center switching request, dividing the microservices to be switched, and sorting the registration center and microservices according to the sequence, the problem of low switching efficiency and accuracy of microservice registration centers in the existing technology is solved, and seamless Switch.

CN119496826AActive Publication Date: 2025-02-21CHINA CONSTRUCTION BANK +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411492504.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-02-21
Estimated Expiration
2044-10-24

AI Technical Summary

Technical Problem

In the prior art, the switching process of microservice registration centers is low in efficiency and accuracy, and requires manual writing and modification of business source code, resulting in complex and error-prone processes.

Method used

By receiving the client's registration center switching request, dividing the microservices to be switched, obtaining the first microservices and their registration center switching files that need to be switched to the same target registration center, sorting the registration center and microservices, and processing them in sequence, Implement the switch between microservices from the original registration center to the target registration center.

Benefits of technology

It reduces the complexity of the switching process of the microservice registration center, improves the accuracy and efficiency of the switching, and realizes seamless switching of the microservice registration center.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119496826A_ABST
    Figure CN119496826A_ABST
Patent Text Reader

Abstract

The invention relates to a switching method and device of a micro-service registration center and electronic equipment, and belongs to the technical field of computers. Comprising the following steps: receiving a registration center switching request sent by a client; obtaining a first micro-service needing to be switched to the same target registration center, and obtaining a registration center switching file of the first micro-service; center sorting is carried out on at least one target registration center to obtain a registration center sequence, switching sorting is carried out on first micro-services needing to be switched to the same target registration center, and a micro-service switching sequence is obtained; performing sequential processing on the at least one target registration center according to the registration center sequence, and for a first micro-service in the ith target registration center, switching a sequence according to a micro-service corresponding to the ith target registration center, and switching the first micro-service from the current original registration center to the ith target registration center based on the registration center switching file of the first micro-service. Therefore, the accuracy and the efficiency of switching the micro-service registration center are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a switching method, device and electronic device for a microservice registration center. Background Art

[0002] In the related art, it is often necessary to manually write and modify the business source code and reconfigure the parameters of the registration center to achieve the switching of the microservice registration center. However, the above method makes the switching process of the microservice registration center more complicated and prone to errors. Summary of the invention

[0003] The present disclosure provides a switching method, device, electronic device, computer-readable storage medium, and computer program product for a microservice registration center, so as to at least solve the problem of low efficiency and accuracy in the switching process of the microservice registration center in the related art.

[0004] The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a switching method for a microservice registration center is provided, the method comprising: receiving a registration center switching request sent by a client, the switching request comprising at least one microservice to be switched and at least one target registration center; dividing the at least one microservice to be switched, obtaining a first microservice to be switched to the same target registration center, and obtaining a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster; performing center sorting on the at least one target registration center to obtain a registration center sequence, and performing switching sorting on the first microservice to be switched to the same target registration center to obtain a microservice switching sequence; sequentially processing the at least one target registration center according to the registration center sequence, for the first microservice in the i-th target registration center, according to the microservice switching sequence corresponding to the i-th target registration center, based on the registration center switching file of the first microservice, switching the first microservice from the current original registration center to the i-th target registration center, wherein i is a natural number greater than or equal to 1.

[0006] According to a second aspect of an embodiment of the present disclosure, a switching device for a microservice registration center is provided, the device comprising: a receiving module, configured to receive a registration center switching request sent by a client, the switching request comprising at least one microservice to be switched and at least one target registration center; a first acquisition module, configured to divide the at least one microservice to be switched, obtain a first microservice to be switched to the same target registration center, and obtain a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster; a second acquisition module, configured to perform center sorting on the at least one target registration center, obtain a registration center sequence, and perform switching sorting on the first microservice to be switched to the same target registration center, and obtain a microservice switching sequence; a switching module, configured to sequentially process the at least one target registration center according to the registration center sequence, and for a first microservice in an i-th target registration center, according to the microservice switching sequence corresponding to the i-th target registration center, based on the registration center switching file of the first microservice, switch the first microservice from the current original registration center to the i-th target registration center, wherein i is a natural number greater than or equal to 1.

[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the switching method of the microservice registration center as described in the first aspect.

[0008] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the switching method of the microservice registration center as described in the first aspect.

[0009] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the switching method of the microservice registration center as described in the first aspect.

[0010] The technical solution provided by the embodiment of the present disclosure brings at least the following beneficial effects: by receiving a registration center switching request sent by a client, the switching request includes at least one microservice to be switched and at least one target registration center, dividing the at least one microservice to be switched, obtaining a first microservice to be switched to the same target registration center, and obtaining a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster, performing center sorting on at least one target registration center, obtaining a registration center sequence, and performing switching sorting on the first microservice to be switched to the same target registration center, obtaining a microservice switching sequence, sequentially processing at least one target registration center according to the registration center sequence, and for the i-th target registration center, performing a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster, performing a registration center switching file for the first microservice, and obtaining a registration center sequence, and ... The first microservice in the center switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1. Therefore, the present disclosure obtains the registration center switching file of the first microservice, switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, thereby reducing the complexity of the switching process of the microservice registration center, improving the accuracy and efficiency of the switching process of the microservice registration center, and realizing seamless switching of the microservice registration center.

[0011] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0013] Figure 1 It is a flowchart of a switching method of a microservice registration center according to the first embodiment of the present disclosure.

[0014] Figure 2 4 is a flow chart of a switching method of a microservice registration center according to the second embodiment of the present disclosure.

[0015] Figure 3 4 is a flow chart of a switching method of a microservice registration center according to the third embodiment of the present disclosure.

[0016] Figure 4 4 is a block diagram of a switching device of a microservice registration center according to the first embodiment of the present disclosure.

[0017] Figure 5It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0018] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0019] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0020] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.

[0021] It should be noted that the acquisition, transmission, storage, use, and processing of data in the technical solution of the present disclosure are in compliance with the relevant provisions of relevant laws and regulations. In the embodiments of the present disclosure, certain software, components, models, and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present disclosure, but it does not mean that the applicant has or will necessarily use the solution.

[0022] Figure 1 It is a flowchart of a switching method of a microservice registration center according to the first embodiment of the present disclosure.

[0023] like Figure 1 As shown, the switching method of the microservice registration center in the first embodiment of the present disclosure includes the following steps:

[0024] S101, receiving a registration center switching request sent by a client, where the switching request includes at least one microservice to be switched and at least one target registration center.

[0025] Among them, microservices is a software architecture pattern that splits a large application into a group of small, relatively independent service units, each of which focuses on performing a specific function or task.

[0026] Among them, the registration center is the "address book" in the microservice architecture, which records the mapping relationship between microservices and microservice addresses.

[0027] In the embodiment of the present disclosure, by receiving the registration center switching request sent by the client, the participation request can be parsed to obtain the microservice to be switched and the target registration center included in the switching request.

[0028] The microservice to be switched refers to any microservice that needs to switch the registration center, and the target registration center refers to the registration center after the microservice to be switched switches the registration center.

[0029] Optionally, the microservice to be switched and the target registry center may be configured by the client to generate a registry center switching request. After receiving the registry center switching request, the microservice to be switched and the target registry center included in the switching request are obtained.

[0030] It should be noted that the present disclosure does not limit the number of microservices to be switched, and can be set according to actual conditions. Optionally, the number of microservices to be switched can be 4, for example: microservice A, microservice B, microservice C, and microservice D; Optionally, the number of microservices to be switched can be 3, for example: microservice A, microservice B, and microservice C.

[0031] It should be noted that the present disclosure does not limit the setting of the target registration center, and it can be set according to actual conditions. Optionally, the target registration center can be Zookeeper, Nacos and Eureka.

[0032] S102, divide at least one microservice to be switched, obtain a first microservice that needs to be switched to the same target registration center, and obtain a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster.

[0033] In the embodiment of the present disclosure, after obtaining the service to be switched and the target registration center, at least one microservice to be switched can be divided to obtain a first microservice to be switched to the same target registration center, wherein the first microservice belongs to the same cluster.

[0034] For example, for microservices A and B to be switched in microservice cluster 1, and microservices C and D to be switched in microservice cluster 2, if the target registration center of microservices A and B to be switched is Nacos, microservices A and B to be switched are divided into a group as the first microservice to switch to Nacos; if the target registration center of microservices C and D to be switched is Eureka, microservices C and D to be switched are divided into a group as the first microservice to switch to Eureka.

[0035] In an embodiment of the present disclosure, first description information of a first microservice and second description information of a target registration center may be obtained. According to the second description information, target configuration data corresponding to the target registration center may be selected from a configuration data list of candidate registration centers, wherein the target configuration data includes at least startup data and operation data of the target registration center. A registration center switching template of the microservice may be obtained, and the first description information, the second description information, and the target configuration data may be filled into the registration center switching template to generate a registration center switching file for the first microservice.

[0036] Optionally, after receiving the registration center switching request, the registration center switching request may be parsed to obtain first description information of the microservice to be switched and second description information of the target registration center.

[0037] The first description information of the microservice to be switched includes, but is not limited to, identification information (name), version information, Uniform Resource Locator (URL) information and port information of the microservice to be switched.

[0038] The second description information of the target registration center includes but is not limited to the identification information (name), version information, URL information and port information of the target registration center.

[0039] Further, after obtaining the first description information of the microservice to be switched and the second description information of the target registry, the first description information of the microservice to be switched and the second description information of the target registry can be stored in a small relational database management system MySQLdb.

[0040] S103, performing center sorting on at least one target registration center to obtain a registration center sequence, and performing switching sorting on the first microservice that needs to be switched to the same target registration center to obtain a microservice switching sequence.

[0041] Optionally, after obtaining the target registration center and the first microservice, at least one target registration center can be sorted according to information such as the priority and load of the target registration center to obtain a registration center sequence, and the first microservice can be switched according to information such as the dependency and stability of the first microservice to obtain a microservice switching sequence.

[0042] For example, for microservices A and B to be switched belonging to microservice cluster 1, and microservices C and D to be switched belonging to microservice cluster 2, if microservices A and B to be switched are the first microservices that need to be switched to the target registration center Nacos, and microservices C and D to be switched are the first microservices that need to be switched to the target registration center Eureka, in this case, the target registration center is Nacos and Eureka, and the target registration centers Nacos and Eureka are sorted by center to obtain a registration center sequence of {Nacos, Eureka}, and microservices A and B to be switched that need to be switched to the target registration center Nacos are switched and sorted to obtain a microservice switching sequence of {microservice B to be switched, microservice A to be switched}, and microservices C and D to be switched that need to be switched to the target registration center Eureka are switched and sorted to obtain a microservice switching sequence of {microservice C to be switched, microservice D to be switched}.

[0043] S104: sequentially process at least one target registration center according to the registration center sequence, and for a first microservice in the i-th target registration center, switch the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1.

[0044] In the disclosed embodiment, the registration center switching file of the first microservice may be sent to the first microservice through the service gateway, so as to switch the first microservice from the current original registration center to i target registration centers.

[0045] For example, if i is 1 and the original registration center of the first microservice is zookeeper, the registration center sequence is {Nacos, Eureka}, for the first microservice in the first target registration center Nacos, according to the microservice switching sequence {microservice B to be switched, microservice A to be switched} corresponding to the target registration center Nacos, based on the registration center switching file of the first microservice, the first microservice (microservice B to be switched, microservice A to be switched) is switched from the current original registration center zookeeper to the target registration center Nacos.

[0046] In summary, according to the switching method of the microservice registration center provided by the embodiment of the present disclosure, by receiving the registration center switching request sent by the client, the switching request includes at least one microservice to be switched and at least one target registration center, dividing the at least one microservice to be switched, obtaining the first microservice to be switched to the same target registration center, and obtaining the registration center switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster, performing center sorting on at least one target registration center, obtaining the registration center sequence, and performing switching sorting on the first microservice to be switched to the same target registration center, obtaining the microservice switching sequence, sequentially processing at least one target registration center according to the registration center sequence, and for the i-th target registration center, performing a registration center switching operation on the first microservice. The first microservice in the center switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1. Therefore, the present disclosure obtains the registration center switching file of the first microservice, switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, thereby reducing the complexity of the switching process of the microservice registration center, improving the accuracy and efficiency of the switching process of the microservice registration center, and realizing seamless switching of the microservice registration center.

[0047] Figure 2 4 is a flow chart of a switching method of a microservice registration center according to the second embodiment of the present disclosure.

[0048] like Figure 2 As shown, the switching method of the microservice registration center in the second embodiment of the present disclosure includes the following steps:

[0049] S201, receiving a registration center switching request sent by a client, where the switching request includes at least one microservice to be switched and at least one target registration center.

[0050] For the relevant contents of step S201, please refer to the above embodiment, which will not be described again here.

[0051] As a possible implementation method, based on the above implementation, the specific process of dividing at least one microservice to be switched in step S102 and obtaining the first microservice to be switched to the same target registration center includes steps S201 to S202:

[0052] S202: Determine a service type of at least one service to be switched based on the first description information, and determine a center type of a target registration center based on the second description information.

[0053] Optionally, after obtaining the first description information of the microservice to be switched, information such as properties and functions of the microservice to be switched may be determined based on the first description information to determine the service type of the microservice to be switched.

[0054] Optionally, after the second description information of the target registry is obtained, information such as the technology stack and capacity of the target registry may be determined based on the second description information to determine the center type of the target registry.

[0055] S203: Divide at least one microservice to be switched according to the service type and the center type, and obtain a first microservice to be switched to the same target registration center, wherein the first microservice belongs to the same microservice cluster.

[0056] In the embodiment of the present disclosure, after obtaining the center type, at least one target service type supported by the center type can be obtained, the service type is matched with the at least one target service type one by one, and at least one microservice to be switched is divided according to the matching result, and the first microservice that needs to be switched to the same target registration center is obtained.

[0057] As a possible implementation method, based on the above implementation, the specific process of dividing at least one microservice to be switched in step S102 and obtaining the first microservice to be switched to the same target registration center includes steps S204 to S205:

[0058] S204: sort the load of at least one target registration center to obtain a registration center target load sequence.

[0059] Optionally, information such as the memory occupancy rate and the number of registered services of the target registry center may be obtained to comprehensively determine the current load of the target registry center, and the load of the target registry center may be sorted to obtain a target load sequence of the registry center.

[0060] S205: Divide at least one microservice to be switched according to the target load sequence of the registration center and the target description information of at least one microservice to be switched, and obtain a first microservice that needs to be switched to the same target registration center.

[0061] In the disclosed embodiment, a microservice partitioning strategy can be constructed based on the registration center load sequence and the description information of the microservices. Based on the registration center target load sequence and the target description information, at least one microservice to be switched is partitioned according to the microservice partitioning strategy to obtain the first microservice that needs to be switched to the same target registration center.

[0062] As a possible implementation method, based on the above implementation, the specific process of obtaining the registration center switching file of the first microservice in step S102 includes steps S206 to S208:

[0063] S206: Obtain first description information of the first microservice and second description information of the target registration center.

[0064] Optionally, after receiving the registration center switching request, the registration center switching request may be parsed to obtain first description information of the microservice to be switched and second description information of the target registration center.

[0065] The first description information of the microservice to be switched includes, but is not limited to, identification information (name), version information, URL information, and port information of the microservice to be switched.

[0066] The second description information of the target registration center includes but is not limited to the identification information (name), version information, URL information and port information of the target registration center.

[0067] S207: Select target configuration data corresponding to the target registration center from the configuration data list of the candidate registration centers according to the second description information, wherein the target configuration data at least includes startup data and operation data of the target registration center.

[0068] In an embodiment of the present disclosure, identification information, version information, uniform resource locator information and port information of the target registration center can be obtained from the second description information, and the configuration data list of the candidate registration center can be screened based on the identification information, version information, uniform resource locator information and port information to determine the target configuration data.

[0069] Optionally, based on the identification information, first target candidate configuration data matching the identification information can be selected from the configuration data list of the candidate registration center, the first target candidate configuration data can be screened based on the version information, uniform resource locator information and port information, and the target configuration data can be selected from the first target candidate configuration data.

[0070] S208, obtaining a registration center switching template for a microservice, filling the first description information, the second description information and the target configuration data into the registration center switching template, and generating a registration center switching file for the first microservice.

[0071] The registration center switching template is pre-built and used to generate a registration center switching file. The registration center switching template includes multiple items to be configured.

[0072] Optionally, the registration center switching template can be identified for filling areas, and the target filling areas corresponding to the first description information, the second description information and the target configuration data can be obtained. According to the target filling areas, the first description information, the second description information and the target configuration data can be filled into the registration center switching template to generate a registration center switching file.

[0073] S209: sequentially process at least one target registry according to the registry sequence, and for the first microservice in the i-th target registry, switch the first microservice from the current original registry to the i-th target registry based on the registry switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registry.

[0074] In summary, according to the switching method of the microservice registration center provided by the embodiment of the present disclosure, a registration center switching request sent by a client is received, the switching request includes at least one microservice to be switched and at least one target registration center, based on the first description information, the service type of at least one service to be switched is determined, and based on the second description information, the center type of the target registration center is determined, at least one microservice to be switched is divided according to the service type and the center type, and a first microservice to be switched to the same target registration center is obtained, the load of at least one target registration center is sorted, and a registration center target load sequence is obtained, and at least one microservice to be switched is divided according to the registration center target load sequence and the target description information of at least one microservice to be switched, and the first microservice to be switched to the same target registration center is obtained, the first description information of the first microservice and the second description information of the target registration center are obtained, and according to the second description information, the target configuration data corresponding to the target registration center is selected from the configuration data list of the candidate registration center According to the present invention, a registration center switching template for a microservice is obtained, the first description information, the second description information and the target configuration data are filled into the registration center switching template, a registration center switching file for the first microservice is generated, and at least one target registration center is sequentially processed according to the registration center sequence. For the first microservice in the i-th target registration center, according to the microservice switching sequence corresponding to the i-th target registration center, based on the registration center switching file of the first microservice, the first microservice is switched from the current original registration center to the i-th target registration center. Therefore, the present invention generates a registration center switching file for the first microservice by filling the first description information, the second description information and the target configuration data into the registration center switching template, shielding the differences between the various registration centers, solving the errors in the process of manually configuring the registration center switching parameters, and switching the registration center of the microservice based on the registration center switching file, reducing the complexity of the switching process of the microservice registration center, and improving the accuracy and efficiency of the switching process of the microservice registration center.

[0075] The specific process of the switching method of the microservice registration center provided by the embodiment of the present disclosure is explained below.

[0076] For example, Figure 3 As shown, by using spring boot as an integrated application for the web server container, the integrated application generates a registration center switching request by configuring the description information of the microservice to be switched and the description information of the target registration center, obtains the target configuration data from the registration center middleware (Zookeeper, Nacos and Eureka), and fills the description information of the microservice to be switched, the description information of the target registration center and the target configuration data into the registration center switching template to generate a registration center switching file. The microservice information to be switched, the target registration center information and the registration center switching file can be stored in the MySQLdb database to achieve data persistence. The registration center switching file is distributed to the microservice to be switched through the microservice gateway, and the microservice to be switched is switched from the current original registration center to the target registration center. The specific process can be referred to the above embodiment and will not be repeated here.

[0077] In summary, according to the switching method of the microservice registration center provided by the embodiment of the present disclosure, by generating a registration center switching file for the microservice, the differences between the various registration centers are shielded, the errors in the manual configuration of the registration center switching parameters are solved, and a large number of modifications to the business source code can be avoided. The registration center of the microservice is switched based on the registration center switching file, which reduces the complexity of the switching process of the microservice registration center, improves the accuracy and efficiency of the switching process of the microservice registration center, and realizes seamless and transparent switching of the microservice registration center.

[0078] Figure 4 4 is a block diagram of a switching device of a microservice registration center according to the first embodiment of the present disclosure.

[0079] like Figure 4 As shown, the switching device 400 of the microservice registration center of the embodiment of the present disclosure includes: a receiving module 401, a first acquisition module 402, a second acquisition module 403 and a switching module 404.

[0080] The receiving module 401 is configured to receive a registration center switching request sent by a client, wherein the switching request includes at least one microservice to be switched and at least one target registration center;

[0081] The first acquisition module 402 is configured to divide the at least one microservice to be switched, obtain a first microservice to be switched to the same target registry, and obtain a registry switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster;

[0082] The second acquisition module 403 is configured to perform center sorting on the at least one target registration center to obtain a registration center sequence, and perform switching sorting on the first microservices that need to be switched to the same target registration center to obtain a microservice switching sequence;

[0083] The switching module 404 is configured to sequentially process the at least one target registration center according to the registration center sequence, and for a first microservice in the i-th target registration center, according to the microservice switching sequence corresponding to the i-th target registration center, based on the registration center switching file of the first microservice, switch the first microservice from the current original registration center to the i-th target registration center, where i is a natural number greater than or equal to 1.

[0084] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: obtain first description information of the first microservice and second description information of the target registry; select target configuration data corresponding to the target registry from a configuration data list of candidate registry centers according to the second description information, wherein the target configuration data at least includes startup data and running data of the target registry; obtain a registry center switching template for a microservice, fill in the first description information, the second description information and the target configuration data into the registry center switching template, and generate a registry center switching file for the first microservice.

[0085] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: identify the filling area of ​​the registration center switching template, obtain the target filling area corresponding to the first description information, the second description information and the target configuration data, and fill the first description information, the second description information and the target configuration data into the registration center switching template according to the target filling area to generate the registration center switching file.

[0086] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: obtain the identification information, version information, uniform resource locator information and port information of the target registration center from the second description information; and filter the configuration data list of the candidate registration center according to the identification information, the version information, the uniform resource locator information and the port information to determine the target configuration data.

[0087] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: select, according to the identification information, first target candidate configuration data that matches the identification information from the configuration data list of the candidate registration center; filter the first target candidate configuration data according to the version information, the uniform resource locator information and the port information, and select the target configuration data from the first target candidate configuration data.

[0088] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: determine the service type of the at least one service to be switched based on the first description information, and determine the center type of the target registration center based on the second description information; divide the at least one microservice to be switched according to the service type and the center type, and obtain the first microservice that needs to be switched to the same target registration center.

[0089] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: acquire at least one target service type supported by the center type; match the service type with the at least one target service type one by one, and according to the matching result, divide the at least one microservice to be switched, and acquire the first microservice that needs to be switched to the same target registration center.

[0090] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: sort the load of the at least one target registration center to obtain a registration center target load sequence; divide the at least one microservice to be switched according to the registration center target load sequence and the target description information of the at least one microservice to be switched, and obtain the first microservice that needs to be switched to the same target registration center.

[0091] In one embodiment of the present disclosure, the first acquisition module 402 is further configured to: construct a microservice partitioning strategy based on the registration center load sequence and the description information of the microservice; and divide the at least one microservice to be switched according to the microservice partitioning strategy for the registration center target load sequence and the target description information, and obtain the first microservice that needs to be switched to the same target registration center.

[0092] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0093] In summary, the switching device of the microservice registration center provided by the embodiment of the present disclosure receives a registration center switching request sent by a client, the switching request includes at least one microservice to be switched and at least one target registration center, divides the at least one microservice to be switched, obtains the first microservice to be switched to the same target registration center, and obtains the registration center switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster, performs center sorting on at least one target registration center, obtains the registration center sequence, and performs switching sorting on the first microservice to be switched to the same target registration center, obtains the microservice switching sequence, sequentially processes at least one target registration center according to the registration center sequence, and for the i-th target registration center, performs switching sorting on the first microservice to be switched to the same target registration center, obtains the microservice switching sequence, sequentially processes at least one target registration center according to the registration center sequence, and for the i-th target registration center, performs switching sorting on the first microservice to be switched to the same target registration center, obtains the microservice switching sequence, and performs switching sorting on the first microservice to be switched to the same target registration center, obtains the microservice switching sequence, and performs switching sorting on the first microservice to be switched to the same target registration center, obtains the microservice switching sequence, and performs switching sorting on the first microservice to be switched to the same target registration center, and ... The first microservice in mind switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1. Therefore, the present disclosure obtains the registration center switching file of the first microservice, switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, thereby reducing the complexity of the switching process of the microservice registration center, improving the accuracy and efficiency of the switching process of the microservice registration center, and realizing seamless switching of the microservice registration center.

[0094] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment.

[0095] like Figure 5 As shown, the electronic device 500 includes:

[0096] The memory 510 and the processor 520, a bus 530 connecting different components (including the memory 510 and the processor 520), the memory 510 stores a computer program, and when the processor 520 executes the program, the switching method of the microservice registration center described in the embodiment of the present disclosure is implemented.

[0097] Bus 530 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0098] The electronic device 500 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 500, including volatile and non-volatile media, removable and non-removable media.

[0099] The memory 510 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 540 and / or cache memory 550. The electronic device 500 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 560 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 530 via one or more data medium interfaces. The memory 510 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0100] A program / utility 580 having a set (at least one) of program modules 570 may be stored, for example, in the memory 510, such program modules 570 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 570 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0101] The electronic device 500 may also communicate with one or more external devices 590 (e.g., keyboard, pointing device, display 591, etc.), one or more devices that enable a user to interact with the electronic device 500, and / or any device that enables the electronic device 500 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 592. Furthermore, the electronic device 500 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 593. Figure 5As shown, the network adapter 593 communicates with other modules of the electronic device 500 via the bus 530. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0102] The processor 520 executes various functional applications and data processing by running the programs stored in the memory 510 .

[0103] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the switching method of the microservice registration center of the embodiment of the present disclosure, which will not be repeated here.

[0104] In summary, the electronic device provided by the embodiment of the present disclosure can execute the switching method of the microservice registration center as described above, by receiving a registration center switching request sent by a client, the switching request includes at least one microservice to be switched and at least one target registration center, dividing the at least one microservice to be switched, obtaining a first microservice to be switched to the same target registration center, and obtaining a registration center switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster, performing center sorting on at least one target registration center, obtaining a registration center sequence, and performing switching sorting on the first microservice to be switched to the same target registration center, obtaining a microservice switching sequence, sequentially processing at least one target registration center according to the registration center sequence, and for the first The first microservice in the i-th target registration center switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1. Therefore, the present disclosure obtains the registration center switching file of the first microservice, switches the first microservice from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, thereby reducing the complexity of the switching process of the microservice registration center, improving the accuracy and efficiency of the switching process of the microservice registration center, and realizing seamless switching of the microservice registration center.

[0105] In order to implement the above embodiments, the present disclosure also proposes a computer-readable storage medium.

[0106] When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can implement the switching method of the microservice registration center as described above. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0107] In order to implement the above embodiments, the present disclosure further provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the switching method of the microservice registration center as described above is implemented.

[0108] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0109] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A switching method for a microservice registration center, characterized in that: The method comprises: Receive a registration center switching request sent by a client, where the switching request includes at least one microservice to be switched and at least one target registration center; Divide the at least one microservice to be switched, obtain a first microservice to be switched to the same target registration center, and obtain a registration center switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster; Performing center sorting on the at least one target registration center to obtain a registration center sequence, and performing switching sorting on the first microservice that needs to be switched to the same target registration center to obtain a microservice switching sequence; The at least one target registration center is sequentially processed according to the registration center sequence, and for a first microservice in the i-th target registration center, the first microservice is switched from the current original registration center to the i-th target registration center based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the i-th target registration center, where i is a natural number greater than or equal to 1.

2. The method according to claim 1, characterized in that The obtaining of the registration center switching file of the first microservice includes: Obtain first description information of the first microservice and second description information of the target registration center; According to the second description information, select target configuration data corresponding to the target registration center from the configuration data list of the candidate registration center, wherein the target configuration data at least includes startup data and operation data of the target registration center; Obtain a registration center switching template for a microservice, fill the first description information, the second description information, and the target configuration data into the registration center switching template, and generate a registration center switching file for the first microservice.

3. The method according to claim 2, characterized in that The step of filling the first description information, the second description information, and the target configuration data into the registration center switching template to generate a registration center switching file for the first microservice includes: Identify the filling area of ​​the registration center switching template, and obtain the target filling area corresponding to the first description information, the second description information and the target configuration data According to the target filling area, the first description information, the second description information and the target configuration data are filled into the registration center switching template to generate the registration center switching file.

4. The method according to claim 2, characterized in that: The selecting, according to the second description information, target configuration data corresponding to the target registration center from a configuration data list of candidate registration centers includes: Acquire identification information, version information, uniform resource locator information and port information of the target registration center from the second description information; The configuration data list of the candidate registration center is screened according to the identification information, the version information, the uniform resource locator information and the port information to determine the target configuration data.

5. The method according to claim 4, characterized in that The step of screening the configuration data list of the candidate registration center according to the identification information, the version information, the uniform resource locator information and the port information to determine the target configuration data includes: According to the identification information, selecting first target candidate configuration data matching the identification information from the configuration data list of the candidate registration center; The first target candidate configuration data is screened according to the version information, the uniform resource locator information and the port information, and the target configuration data is selected from the first target candidate configuration data.

6. The method according to claim 2, characterized in that The dividing the at least one microservice to be switched to obtain a first microservice to be switched to the same target registration center includes: Determine the service type of the at least one service to be switched based on the first description information, and determine the center type of the target registration center based on the second description information; According to the service type and the center type, the at least one microservice to be switched is divided, and a first microservice to be switched to the same target registration center is obtained.

7. The method according to claim 6, characterized in that The dividing the at least one microservice to be switched according to the service type and the center type, and obtaining the first microservice to be switched to the same target registration center, includes: Obtain at least one target service type supported by the center type; The service type is matched with the at least one target service type one by one, and according to the matching result, the at least one microservice to be switched is divided to obtain a first microservice to be switched to the same target registration center.

8. The method according to claim 2, characterized in that: The dividing the at least one microservice to be switched to obtain a first microservice to be switched to the same target registration center includes: Performing load sorting on the at least one target registration center to obtain a registration center target load sequence; According to the registration center target load sequence and the target description information of the at least one microservice to be switched, the at least one microservice to be switched is divided, and a first microservice to be switched to the same target registration center is obtained.

9. The method according to claim 8, characterized in that The dividing the at least one microservice to be switched according to the registration center load sequence to obtain a first microservice to be switched to the same target registration center includes: Build a microservice partitioning strategy based on the registry center load sequence and microservice description information; With respect to the registration center target load sequence and the target description information, the at least one microservice to be switched is divided according to the microservice division strategy, and a first microservice to be switched to the same target registration center is obtained.

10. A switching device for a microservice registration center, characterized in that: The device comprises: A receiving module is configured to receive a registration center switching request sent by a client, wherein the switching request includes at least one microservice to be switched and at least one target registration center; A first acquisition module is configured to divide the at least one microservice to be switched, acquire a first microservice to be switched to the same target registry, and acquire a registry switching file for the first microservice, wherein the first microservice belongs to the same microservice cluster; The second acquisition module is configured to perform center sorting on the at least one target registration center to obtain a registration center sequence, and perform switching sorting on the first microservices that need to be switched to the same target registration center to obtain a microservice switching sequence; The switching module is configured to sequentially process the at least one target registration center according to the registration center sequence, and for a first microservice in the i-th target registration center, according to the microservice switching sequence corresponding to the i-th target registration center, based on the registration center switching file of the first microservice, switch the first microservice from the current original registration center to the i-th target registration center, wherein i is a natural number greater than or equal to 1.

11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instruction to implement the switching method of the microservice registration center as described in any one of claims 1-9.

12. A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the switching method of the microservice registration center according to any one of claims 1 to 9.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the switching method of the microservice registration center according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Fusion method and device of multiple registration centers

    CN114640657A

  • Unified access rule-based multi-registration center micro-service discovery method and system

    CN115514805A

  • Micro-service platform core component management method and device, equipment and storage medium

    CN116578305A

  • Service calling system, method and device, electronic equipment and storage medium

    CN118200399A