Method, device and electronic equipment for switching micro-service registry center

By receiving client requests and processing them in sequence, the problem of complex and error-prone switching processes in microservice registry centers is solved, achieving efficient and accurate seamless switching.

CN119496826BActive Publication Date: 2025-11-28CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In existing technologies, the switching process of microservice registry centers is complex and error-prone, with low efficiency and accuracy.

Method used

By receiving the registry center switching request from the client, the microservices to be switched are divided and the registry center switching file is obtained. The microservices are then processed in sequence according to the registry center sequence and the microservice switching sequence, and the microservices are switched from the original registry center to the target registry center.

Benefits of technology

It reduces the complexity of switching microservice registry centers, improves the accuracy and efficiency of the switching process, and achieves seamless switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119496826B_ABST
    Figure CN119496826B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a switching method and device of a micro-service registration center and an electronic device, and belongs to the technical field of computers. The method comprises: receiving a registration center switching request sent by a client; obtaining a first micro-service that needs to be switched to a same target registration center, and obtaining a registration center switching file of the first micro-service; performing center sorting on at least one target registration center to obtain a registration center sequence, and performing switching sorting on the first micro-service that needs to be switched to the same target registration center to obtain a micro-service switching sequence; sequentially processing the at least one target registration center according to the registration center sequence, and switching the first micro-service from a current original registration center to an i-th target registration center according to the micro-service switching sequence corresponding to the i-th target registration center and based on the registration center switching file of the first micro-service, for the first micro-service in the i-th target registration center. Therefore, the present disclosure improves the accuracy and efficiency of switching the micro-service registration center.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer, and particularly relates to a switching method, device and electronic equipment of micro-service registration center. BACKGROUND

[0002] In the related art, the parameters of the registration center need to be reconfigured by manually writing and modifying the business source code to realize the switching of the micro-service registration center. However, the above method leads to a complex and error-prone switching process of the micro-service registration center. SUMMARY

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

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

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

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

[0007] According to a third aspect of embodiments of the present disclosure, an electronic device is provided, comprising: a processor; 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 registry as described in the first aspect.

[0008] According to a fourth aspect of embodiments of the present disclosure, a computer-readable storage medium is provided, and when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the switching method of the microservice registry as described in the first aspect.

[0009] According to a fifth aspect of embodiments of the present disclosure, a computer program product is provided, comprising a computer program, and when the computer program is executed by a processor, the switching method of the microservice registry as described in the first aspect is implemented.

[0010] The technical scheme provided by the embodiments of the present disclosure at least has the following beneficial effects: by receiving a registration center switching request sent by a client, the switching request including 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 of the first microservice, wherein the first microservice belongs to the same microservice cluster, center sorting the at least one target registration center, obtaining a registration center sequence, and switching sorting the first microservice to be switched to the same target registration center, obtaining 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, thereby, by obtaining the registration center switching file of the first microservice, 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, the complexity in the switching process of the microservice registration center is reduced, the accuracy and efficiency in the switching process of the microservice registration center are improved, and seamless switching of the microservice registration center is realized.

[0011] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0012] The accompanying drawings incorporated in the specification and forming a part of it, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure, and do not limit the present disclosure.

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

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

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

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

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

[0018] In order for those skilled 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 with reference to the drawings.

[0019] It should be noted that the terms "first", "second", and the like in the specification and claims of the present disclosure and the above-described drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation described in the following exemplary embodiments does not represent all implementations consistent with the present disclosure. Rather, 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 for analysis, stored data, displayed data, etc.) and signals involved in the present disclosure are authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards.

[0021] It should be noted that the acquisition, transmission, storage, use, processing, etc. of data in the technical solutions of the present disclosure comply with the relevant provisions of the relevant laws and regulations. In the embodiments of the present disclosure, some industry existing solutions may be mentioned, such as software, components, models, etc. They should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solutions of the present disclosure, but it does not mean that the applicant has or will necessarily use the solution.

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

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

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

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

[0026] The registration center is a "address book" in the micro-service architecture, and records the mapping relationship between the micro-service and the micro-service address.

[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 to-be-switched micro-service and the target registration center included in the switching request.

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

[0029] Optionally, the to-be-switched micro-service and the target registration center can be configured by the client to generate a registration center switching request, and after receiving the registration center switching request, the to-be-switched micro-service and the target registration center included in the switching request are obtained.

[0030] It should be noted that the number of to-be-switched micro-services is not limited in the present disclosure and can be set according to actual conditions. Optionally, the number of to-be-switched micro-services can be 4, for example: micro-service A, micro-service B, micro-service C and micro-service D; optionally, the number of to-be-switched micro-services can be 3, for example: micro-service A, micro-service B and micro-service C.

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

[0032] S102, at least one to-be-switched micro-service is divided, a first micro-service that needs to be switched to the same target registration center is obtained, and a registration center switching file of the first micro-service is obtained, wherein the first micro-service belongs to the same micro-service cluster.

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

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

[0035] In the embodiment of the present disclosure, the first description information of the first microservice and the second description information of the target registration center can be obtained, 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 second description information, wherein the target configuration data at least includes the start-up data and the running data of the target registration center, the registration center switching template of the microservice is obtained, the first description information, the second description information and the target configuration data are filled into the registration center switching template, and the registration center switching file of the first microservice is generated.

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

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

[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 to-be-switched microservice and the second description information of the target registration center, the first description information of the to-be-switched microservice and the second description information of the target registration center can be stored in the small relational database management system MySQLdb.

[0040] S103, the registration center sequence is obtained by sorting the at least one target registration center, and the first microservice to be switched to the same target registration center is sorted to obtain the microservice switching sequence.

[0041] Optionally, after the target registration center and the first microservice are acquired, at least one target registration center can be sorted according to the priority and load of the target registration center and the like, a registration center sequence is acquired, and the first microservice is sorted according to the dependency relationship and stability of the first microservice and the like, and a microservice switching sequence is acquired.

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

[0043] In S104, 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, 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.

[0044] In the embodiment of the present disclosure, the registration center switching file of the first microservice can be sent to the first microservice through the service gateway, and the first microservice is switched from the current original registration center to the i th target registration center.

[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, the first microservice (to-be-switched microservice B, to-be-switched microservice A) is switched from the current original registration center zookeeper to the target registration center Nacos based on the registration center switching file of the first microservice according to the microservice switching sequence corresponding to the target registration center Nacos {to-be-switched microservice B, to-be-switched microservice A}.

[0046] In summary, according to the switching method of the microservice registry provided by the embodiment of the present disclosure, by receiving the switching request of the registry sent by the client, the switching request includes at least one microservice to be switched and at least one target registry, the at least one microservice to be switched is divided, the first microservice to be switched to the same target registry is obtained, and the switching file of the first microservice to the registry is obtained, wherein the first microservice belongs to the same microservice cluster, the target registries are sorted, the sequence of the registries is obtained, the first microservice to be switched to the same target registry is sorted, the microservice switching sequence is obtained, the target registries are sequentially processed according to the sequence of the registries, for the first microservice in the i th target registry, the first microservice is switched from the current original registry to the i th target registry according to the microservice switching sequence corresponding to the i th target registry based on the switching file of the first microservice to the registry, wherein i is a natural number greater than or equal to 1. Thus, by obtaining the switching file of the first microservice to the registry, the first microservice is switched from the current original registry to the i th target registry according to the microservice switching sequence corresponding to the i th target registry based on the switching file of the first microservice to the registry, the complexity in the switching process of the microservice registry is reduced, the accuracy and efficiency in the switching process of the microservice registry are improved, and seamless switching of the microservice registry is achieved.

[0047] Figure 2 is a flowchart of the switching method of the microservice registry according to the second embodiment of the present disclosure.

[0048] As shown in Figure 2 , the switching method of the microservice registry according to the second embodiment of the present disclosure includes the following steps:

[0049] S201, receiving the switching request of the registry sent by the client, the switching request including at least one microservice to be switched and at least one target registry.

[0050] The related content of step S201 can be referred to the above-mentioned embodiments, which will not be repeated here.

[0051] As a possible implementation, on the basis of the above-mentioned embodiment, the specific process of dividing the at least one microservice to be switched to obtain the first microservice to be switched to the same target registry in step S102 includes steps S201-S202:

[0052] S202, determining the service type of the at least one service to be switched based on the first description information, and determining the center type of the target registry based on the second description information.

[0053] Optionally, after obtaining the first description information of the microservice to be switched, the attribute and function information of the microservice to be switched can be determined based on the first description information, so as to determine the service type of the microservice to be switched.

[0054] Optionally, after obtaining the second description information of the target registration center, the technology stack and capacity information of the target registration center can be determined based on the second description information, so as to determine the center type of the target registration center.

[0055] S203, according to the service type and the center type, dividing the at least one microservice to be switched, and obtaining the 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 according to the matching result, the at least one microservice to be switched is divided to obtain the first microservice to be switched to the same target registration center.

[0057] As a possible implementation manner, on the basis of the above embodiment, the specific process of dividing the at least one microservice to be switched to obtain the first microservice to be switched to the same target registration center in step S102 includes steps S204-S205:

[0058] S204, load sequencing of the at least one target registration center is performed to obtain a registration center target load sequence.

[0059] Optionally, the memory occupancy rate and the number of registered services of the target registration center and the like information can be obtained, the current load of the target registration center is comprehensively determined, and the target registration center is load sequenced to obtain the registration center target load sequence.

[0060] S205, 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 to obtain the first microservice to be switched to the same target registration center.

[0061] In the embodiment of the present disclosure, the microservice division strategy can be constructed according to the registration center load sequence and the description information of the microservice, the at least one microservice to be switched is divided according to the registration center target load sequence and the target description information according to the microservice division strategy, and the first microservice to be switched to the same target registration center is obtained.

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

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

[0064] Optionally, after receiving the registration center switching request, the registration center switching request can be parsed to obtain the first description information of the microservice to be switched and the 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 identification information (name), version information, URL information and port information of the target registration center.

[0067] S207, according to the second description information, selecting the 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 the start-up data and the running data of the target registration center.

[0068] In the embodiment of the present disclosure, the 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 is filtered according to the identification information, version information, uniform resource locator information and port information to determine the target configuration data.

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

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

[0071] The registration center switching template is pre-constructed and used to generate the registration center switching file, and the registration center switching template includes a plurality of configuration items to be configured.

[0072] Optionally, the filling area of the registration center switching template can be identified, the target filling area corresponding to the first description information, the second description information and the target configuration data is obtained, the first description information, the second description information and the target configuration data are filled into the registration center switching template according to the target filling area, and the registration center switching file is generated.

[0073] S209, at least one target registration center is sequentially processed according to the registration center sequence, for the first microservice in the ith target registration center, the first microservice is switched from the current original registration center to the ith target registration center according to the microservice switching sequence corresponding to the ith target registration center and based on the registration center switching file of the first microservice.

[0074] In summary, according to the microservice registration center switching method provided by the embodiment of the present disclosure, the registration center switching request sent by the client is received, the switching request includes at least one to-be-switched microservice and at least one target registration center, the service type of the at least one to-be-switched service is determined based on the first description information, the center type of the target registration center is determined based on the second description information, the at least one to-be-switched microservice is divided according to the service type and the center type, the first microservice that needs to be switched to the same target registration center is obtained, the at least one target registration center is load-sequenced to obtain the registration center target load sequence, the at least one to-be-switched microservice is divided according to the registration center target load sequence and the target description information of the at least one to-be-switched microservice, the first microservice that needs 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, 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 second description information, the registration center switching template of the microservice is obtained, the first description information, the second description information and the target configuration data are filled into the registration center switching template, the registration center switching file of the first microservice is generated, at least one target registration center is sequentially processed according to the registration center sequence, for the first microservice in the ith target registration center, the first microservice is switched from the current original registration center to the ith target registration center according to the microservice switching sequence corresponding to the ith target registration center and based on the registration center switching file of the first microservice. Thus, by filling the first description information, the second description information and the target configuration data into the registration center switching template, the registration center switching file of the first microservice is generated, the differences of various registration centers are shielded, the errors in the process of manually configuring the registration center switching parameters are solved, and the microservice is switched based on the registration center switching file, which reduces the complexity in the process of switching the microservice registration center and improves the accuracy and efficiency in the process of switching the microservice registration center.

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

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

[0077] In summary, according to the switching method of the microservice registry center provided by the embodiments of the present disclosure, the switching file of the registry center of the microservice is generated, the differences of various registry centers are shielded, the errors in the process of manually configuring the switching parameters of the registry center are solved, a large number of modifications of the business source code can be avoided, the switching of the registry center of the microservice is realized based on the switching file of the registry center, the complexity in the switching process of the microservice registry center is reduced, the accuracy and efficiency in the switching process of the microservice registry center are improved, and the seamless and transparent switching of the microservice registry center is realized.

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

[0079] As shown in Figure 4 The switching device 400 of the microservice registry center according to the embodiments of the present disclosure includes a receiving module 401, a first obtaining module 402, a second obtaining module 403 and a switching module 404.

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

[0081] The first obtaining 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 center, and obtain the switching file of the registry center of the first microservice, wherein the first microservice belongs to the same microservice cluster;

[0082] The second obtaining module 403 is configured to sort the at least one target registration center, obtain a registration center sequence, and sort the first microservice that needs to be switched to the same target registration center, and 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 switch the first microservice in the i th target registration center from a current original registration center to the i th target registration center according to the microservice switching sequence corresponding to the i th target registration center and based on the registration center switching file of the first microservice, where i is a natural number greater than or equal to 1.

[0084] In an embodiment of the present disclosure, the first obtaining module 402 is further configured to: obtain first description information of the first microservice and second description information of the target registration center; select target configuration data corresponding to the target registration center from a configuration data list of candidate registration centers according to the second description information, where the target configuration data at least includes start-up data and running data of the target registration center; obtain a registration center switching template of 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 of the first microservice.

[0085] In an embodiment of the present disclosure, the first obtaining module 402 is further configured to: perform filling area identification on the registration center switching template, obtain a target filling area corresponding to the first description information, the second description information and the target configuration data, 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, and generate the registration center switching file.

[0086] In an embodiment of the present disclosure, the first obtaining module 402 is further configured to: obtain 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 centers 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 an embodiment of the present disclosure, the first obtaining module 402 is further configured to: according to the identification information, select first target candidate configuration data matching the identification information from the configuration data list of the candidate registration center; and according to the version information, the uniform resource locator information and the port information, filter the first target candidate configuration data, and select the target configuration data from the first target candidate configuration data.

[0088] In an embodiment of the present disclosure, the first obtaining 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; and according to the service type and the center type, divide the at least one microservice to be switched, and obtain first microservices to be switched to the same target registration center.

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

[0090] In an embodiment of the present disclosure, the first obtaining module 402 is further configured to: perform load sorting on the at least one target registration center, and obtain a target load sequence of the registration center; and according to the target load sequence of the registration center and the target description information of the at least one microservice to be switched, divide the at least one microservice to be switched, and obtain first microservices to be switched to the same target registration center.

[0091] In an embodiment of the present disclosure, the first obtaining module 402 is further configured to: construct a microservice division strategy according to the target load sequence of the registration center and the description information of the microservice; and according to the target load sequence of the registration center and the target description information, divide the at least one microservice to be switched according to the microservice division strategy, and obtain first microservices to be switched to the same target registration center.

[0092] As to the apparatus in the above-mentioned embodiments, the specific manners in which various modules perform operations have been described in details in the embodiments of the method, and will not be described in details here.

[0093] In summary, the switching device of the microservice registry center provided by the embodiments of the present disclosure receives a registry center switching request sent by a client, the switching request includes at least one microservice to be switched and at least one target registry center, divides the at least one microservice to be switched, obtains a first microservice to be switched to the same target registry center, and obtains a registry center switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster, sorts the at least one target registry center, obtains a registry center sequence, and sorts the first microservice to be switched to the same target registry center, obtains a microservice switching sequence, processes the at least one target registry center in sequence according to the registry center sequence, for the first microservice in the i th target registry center, according to the microservice switching sequence corresponding to the i th target registry center, based on the registry center switching file of the first microservice, switches the first microservice from the current original registry center to the i th target registry center, wherein i is a natural number greater than or equal to 1. Thus, by obtaining the registry center switching file of the first microservice, according to the microservice switching sequence corresponding to the i th target registry center, based on the registry center switching file of the first microservice, the first microservice is switched from the current original registry center to the i th target registry center, the complexity in the switching process of the microservice registry center is reduced, the accuracy and efficiency in the switching process of the microservice registry center are improved, and seamless switching of the microservice registry center is achieved.

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

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

[0096] a memory 510 and a processor 520, a bus 530 connecting different components including the memory 510 and the processor 520, and the memory 510 stores a computer program, which, when executed by the processor 520, implements the switching method of the microservice registry center described in the embodiments of the present disclosure.

[0097] The bus 530 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. 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] Electronic device 500 typically includes a variety of computer system readable media. These media can be any available media that is located either internally or externally to electronic device 500, including both volatile and nonvolatile media, removable and non-removable media.

[0099] Storage 510 can also include memory in the form of computer system readable media, such as random access memory (RAM) 540 and / or cache memory 550. Electronic device 500 can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 560 can be provided for reading from and writing to a non-removable, non-volatile magnetic media (e.g., a "hard drive"). Figure 5 not shown, is typically provided as residual storage across electronic device 500, and can be used for storing data that is less frequently accessed. Although exemplary computing system 500 is shown with storage 510, this is not intended to be limiting. Storage 510 can also include removable storage and / or storage interface (not shown). Such storage interface would likewise, communicate with a removable storage port 512 in a manner similar to that Figure 5 not shown, is typically provided as residual storage across electronic device 500, and can be used for storing data that is less frequently accessed. Although exemplary computing system 500 is shown with storage 510, this is not intended to be limiting. Storage 510 can also include removable storage and / or storage interface (not shown). Such storage interface would likewise, communicate with a removable storage port 512 in a manner similar to that

[0100] Program / utility 580 having a set (at least one) of program modules 570 can be stored in, for example, storage 510 by way of example, and not limiting, such program modules include an operating system, one or more application programs, other program modules, and program data, each of which

[0101] Electronic device 500 can also communicate with one or more external devices 590 such as a keyboard or pointing device, a display 591, etc.; one or more devices that enable a user to interact with electronic device 500; and / or one or more devices that enable electronic device 500 to communicate with one or more other computing devices. Such communication can be via input / output (I / O) interfaces 592. Still yet, electronic device 500 can communicate with one or more networks such as a local area network (LAN), a general wide area network (WAN), and / or a public network (e.g., the Internet) through network adapter 593. As Figure 5As shown, network adapter 593 communicates with the other modules of electronic device 500 over bus 530. It should be appreciated that although not shown, other hardware and / or software modules could be used in conjunction with electronic device 500. These include, but are not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.

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

[0103] It should be noted that the implementation process and technical principles of the electronic device of the embodiment are referred to the foregoing explanation of the switching method of the microservice registry center of the embodiment of the disclosure, which will not be described here.

[0104] To sum up, the electronic device provided by the embodiment of the disclosure can execute the switching method of the microservice registry center as described above. By receiving the registry center switching request sent by the client, the switching request includes at least one microservice to be switched and at least one target registry center, the at least one microservice to be switched is divided, the first microservice to be switched to the same target registry center is obtained, and the registry center switching file of the first microservice is obtained. The first microservice belongs to the same microservice cluster. The target registry center is sorted, the registry center sequence is obtained, the first microservice to be switched to the same target registry center is sorted, the microservice switching sequence is obtained, the at least one target registry center is sequentially processed according to the registry center sequence, for the first microservice in the i-th target registry center, the first microservice is switched from the current original registry center to the i-th target registry center according to the microservice switching sequence corresponding to the i-th target registry center based on the registry center switching file of the first microservice, and i is a natural number greater than or equal to 1. Thus, by obtaining the registry center switching file of the first microservice, the first microservice is switched from the current original registry center to the i-th target registry center according to the microservice switching sequence corresponding to the i-th target registry center based on the registry center switching file of the first microservice, the complexity in the switching process of the microservice registry center is reduced, the accuracy and efficiency in the switching process of the microservice registry center are improved, and seamless switching of the microservice registry center is realized.

[0105] To implement the above-mentioned embodiments, the disclosure further provides a computer-readable storage medium.

[0106] The instructions in the computer readable storage medium are executed by the processor of the electronic device, so that the electronic device can implement the switching method of the micro-service registry 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, and an optical data storage device, etc.

[0107] In order to implement the above-mentioned embodiments, the present disclosure further provides a computer program product comprising a computer program, characterized in that the computer program is executed by a processor to implement the switching method of the micro-service registry center as described above.

[0108] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure following the general principles thereof and including such departures from the present disclosure that come within known, accepted, and / or customary practice in the art to which the present disclosure pertains. The specification and examples are to be regarded as illustrative 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 precise structures as herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the claims that follow.

Claims

1. A method for switching microservice registry centers, characterized in that, The method includes: Receive a registry center switching request sent by a client, wherein the switching request includes at least one microservice to be switched and at least one target registry center; The at least one microservice to be switched is divided, the first microservice that needs to be switched to the same target registry center is obtained, and the registry center switching file of the first microservice is obtained, wherein the first microservice belongs to the same microservice cluster; The at least one target registry center is sorted to obtain a registry center sequence, and the first microservice that needs to switch to the same target registry center is sorted to obtain a microservice switching sequence. The at least one target registry is processed sequentially according to the registry sequence. For the first microservice in the i-th target registry, the first microservice is switched from its current original registry to the i-th target registry according to the microservice switching sequence corresponding to the i-th target registry and based on the registry switch file of the first microservice. Here, i is a natural number greater than or equal to 1. The step of obtaining the registry center switching file for the first microservice includes: Obtain the first description information of the first microservice and the second description information of the target registry; Based on the second description information, target configuration data corresponding to the target registry is selected from the configuration data list of candidate registry centers, wherein the target configuration data includes at least the startup data and running data of the target registry center; Obtain the registry center switching template for the microservice, fill in the first description information, the second description information, and the target configuration data into the registry center switching template, and generate the registry center switching file for the first microservice.

2. The method according to claim 1, characterized in that, The step of filling the registration center switching template with the first description information, the second description information, and the target configuration data to generate the registration center switching file for the first microservice includes: The registration center switching template is used to identify the filling region, and the target filling region corresponding to the first description information, the second description information, and the target configuration data is obtained. 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.

3. The method according to claim 1, characterized in that, The step of selecting target configuration data corresponding to the target registry center from the configuration data list of candidate registry centers according to the second description information includes: Obtain the identification information, version information, Uniform Resource Locator information, and port information of the target registry from the second description information; The configuration data list of the candidate registry centers is filtered based on the identification information, the version information, the Uniform Resource Locator information, and the port information to determine the target configuration data.

4. The method according to claim 3, characterized in that, The step of filtering the configuration data list of candidate registration centers based on the identification information, the version information, the Uniform Resource Locator information, and the port information to determine the target configuration data includes: Based on the identification information, select the first target candidate configuration data that matches the identification information from the configuration data list of the candidate registry; Based on the version information, the Uniform Resource Locator (URL) information, and the port information, the first target candidate configuration data is filtered, and the target configuration data is selected from the first target candidate configuration data.

5. The method according to claim 1, characterized in that, The step of dividing the at least one microservice to be switched and obtaining the first microservice that needs to be switched to the same target registry center includes: Based on the first description information, the service type of the at least one service to be switched is determined, and based on the second description information, the center type of the target registry center is determined; Based on the service type and the center type, the at least one microservice to be switched is divided to obtain the first microservice that needs to be switched to the same target registry center.

6. The method according to claim 5, characterized in that, The step of dividing the at least one microservice to be switched according to the service type and the center type, and obtaining the first microservice that needs to be switched to the same target registry center, includes: Obtain at least one target service type supported by the center type; The service type is matched one by one with the at least one target service type. Based on the matching results, the at least one microservice to be switched is divided, and the first microservice that needs to be switched to the same target registry center is obtained.

7. The method according to claim 1, characterized in that, The step of dividing the at least one microservice to be switched and obtaining the first microservice that needs to be switched to the same target registry center includes: The load of the at least one target registry center is sorted to obtain the target load sequence of the registry centers; Based on the target load sequence of the registry center 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 the first microservice that needs to be switched to the same target registry center is obtained.

8. The method according to claim 7, characterized in that, The step of dividing the at least one microservice to be switched according to the load sequence of the registry center and obtaining the first microservice that needs to be switched to the same target registry center includes: Based on the load sequence of the registry center and the description information of the microservices, a microservice partitioning strategy is constructed; Based on the target load sequence of the registry center and the target description information, the at least one microservice to be switched is divided according to the microservice partitioning strategy to obtain the first microservice that needs to be switched to the same target registry center.

9. A switching device for a microservice registry, characterized in that, The device includes: The receiving module is configured to receive a registry center switching request sent by a client, the switching request including at least one microservice to be switched and at least one target registry center; The first acquisition module is configured to divide the at least one microservice to be switched, acquire the first microservice that needs to be switched to the same target registry center, and acquire the registry center switching file of the first microservice, wherein the first microservice belongs to the same microservice cluster. The second acquisition module is configured to sort the at least one target registry center to obtain a registry center sequence, and sort the first microservice that needs to switch to the same target registry center to obtain a microservice switching sequence. The switching module is configured to process the at least one target registry center sequentially according to the registry center sequence. For the first microservice in the i-th target registry center, the first microservice is switched from its current original registry center to the i-th target registry center according to the microservice switching sequence corresponding to the i-th target registry center and based on the registry center switching file of the first microservice, where i is a natural number greater than or equal to 1. The first acquisition module is configured to acquire first description information of the first microservice and second description information of the target registry center; Based on the second description information, target configuration data corresponding to the target registry is selected from the configuration data list of candidate registry centers, wherein the target configuration data includes at least the startup data and running data of the target registry center; Obtain the registry center switching template for the microservice, fill in the first description information, the second description information, and the target configuration data into the registry center switching template, and generate the registry center switching file for the first microservice.

10. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the microservice registry switching method as described in any one of claims 1-8.

11. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform a switching method for a microservice registry as described in any one of claims 1-8.

12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the switching method for the microservice registry as described in any one of claims 1-8.

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