Service registration discovery method, device, computer equipment and storage medium
By establishing a service identity mapping relationship between the distributed development platform and the cluster management platform, the compatibility problem between different service registration and discovery mechanisms is solved, and the seamless operation of the application on the cluster management platform is achieved, taking into account the advantages of both.
Patent Information
- Application Number
- CN202310145337.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-06
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-02-06
AI Technical Summary
There are problems with incompatibility between different service registration and discovery mechanisms, which leads to applications developed based on distributed development platforms that cannot be directly run on the cluster management platform, and it is necessary to abandon the related ecosystem of distributed development platforms.
By establishing a mapping relationship of service identifiers between the distributed development platform and the cluster management platform, and using the first registration component and the second registration component to realize cross-platform service discovery, the service discovery request sent by the client determines the corresponding second service identifier in the first registration component, and obtains the virtual address from the second registration component, and the client runs the cluster management service without perception.
The compatibility between the distributed development platform and the cluster management platform is achieved, allowing applications developed based on the distributed development platform to run on the cluster management platform, taking into account the advantages of both, providing convenience and high scalability.
Smart Images

Figure CN116260861B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service registration and discovery method, apparatus, computer equipment, storage medium, and computer program product. Background Art
[0002] With the development of technology, service registration and discovery technology has emerged. After the service is started, it registers with the service registration center and registers its own service information with the service registration center. When the service consumer wants to call the service, it obtains the service provider address from the service registration center to call the service.
[0003] There are currently several commonly used service registration and discovery technologies, such as Spring Cloud and Kubernetes. However, the ecosystems corresponding to different service registration and discovery mechanisms vary significantly, leading to compatibility issues in service registration and discovery. Summary of the Invention
[0004] Based on this, it is necessary to provide a service registration and discovery method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the compatibility between different service registration and discovery mechanisms in order to address the above technical issues.
[0005] This application provides a service registration and discovery method. The method includes:
[0006] Configuring an application developed based on a distributed development platform as a distributed development service, and registering the distributed development service in a first registration component adapted to the distributed development platform;
[0007] Configure the application as a cluster management service, obtain a virtual address corresponding to the cluster management service, and register the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address;
[0008] In the first registration component, a mapping relationship is established between a first service identifier of the distributed development service and a second service identifier of the cluster management service;
[0009] When a service discovery request sent by a client corresponding to the application is obtained, determining a second service identifier corresponding to the first service identifier based on the first service identifier carried in the service discovery request and a mapping relationship in the first registration component;
[0010] Obtaining a virtual address corresponding to the cluster management service from the second registration component based on the second service identifier;
[0011] The virtual address is returned to the client corresponding to the application that sends the service discovery request, so that the client runs the cluster management service based on the virtual address.
[0012] This application also provides a service registration discovery device. The device includes:
[0013] A distributed development service registration module is used to configure an application developed based on a distributed development platform as a distributed development service and register the distributed development service in a first registration component adapted to the distributed development platform;
[0014] A cluster management service registration module is used to configure the application as a cluster management service, obtain a virtual address corresponding to the cluster management service, and register the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address;
[0015] A service mapping relationship establishment module, configured to establish, in the first registration component, a mapping relationship between a first service identifier of a distributed development service and a second service identifier of a cluster management service;
[0016] A service discovery request response module is configured to, upon receiving a service discovery request sent by a client corresponding to an application, determine a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier carried in the service discovery request and the first registration component;
[0017] A virtual address acquisition module, configured to acquire a virtual address corresponding to the cluster management service from the second registration component based on the second service identifier;
[0018] The virtual address return module is used to return the virtual address to the client corresponding to the application that sends the service discovery request, so that the client runs the cluster management service based on the virtual address.
[0019] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned service registration and discovery method when executing the computer program.
[0020] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned service registration and discovery method when executed by a processor.
[0021] A computer program product includes a computer program, which implements the steps of the above-mentioned service registration and discovery method when executed by a processor.
[0022] The above-mentioned service registration and discovery method, apparatus, computer equipment, storage medium and computer program product configure the application developed based on the distributed development platform as a distributed development service, and register the distributed development service in the first registration component adapted to the distributed development platform. The application is configured as a cluster management service, and the virtual address corresponding to the cluster management service is obtained. Based on the virtual address, the cluster management service is registered in the second registration component corresponding to the cluster management platform. A mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established in the first registration component. When a service discovery request sent by the client corresponding to the application is obtained, the second service identifier corresponding to the first service identifier is determined based on the first service identifier carried in the service discovery request and the mapping relationship in the first registration component. The virtual address corresponding to the cluster management service is obtained from the second registration component based on the second service identifier, so that the client runs the cluster management service based on the virtual address. In this way, a mapping relationship between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service is established in the first registration component. When a service discovery request corresponding to an application is obtained, the second service identifier corresponding to the first service identifier is determined through the first service identifier carried in the service discovery request and the mapping relationship in the first registration component. That is, the cluster management service corresponding to the distributed discovery service is determined, and the virtual address corresponding to the cluster management service is returned. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, that is, improving the compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform.
[0023] This application provides a service registration and discovery method. The method includes:
[0024] A service discovery request carrying a first service identifier corresponding to a distributed development service is sent to a server, so that the server determines a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted to the distributed development platform, and obtains a virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier; wherein the first registration component registers a distributed development service configured for the application, and the second registration component registers a cluster management service configured for the application, the cluster management service is registered in the second registration component based on the virtual address obtained by the configuration, and the first registration component includes a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service;
[0025] Run the cluster management service based on the virtual address returned by the server.
[0026] This application also provides a service registration discovery device. The device includes:
[0027] A service discovery request sending module, configured to send a service discovery request carrying a first service identifier corresponding to a distributed development service to a server, so that the server determines a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted to the distributed development platform, and obtains a virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier; wherein the first registration component registers a distributed development service configured for the application, and the second registration component registers a cluster management service configured for the application, the cluster management service is registered in the second registration component based on the virtual address obtained by the configuration, and the first registration component includes a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service;
[0028] The cluster management service running module is used to run the cluster management service based on the virtual address returned by the server.
[0029] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned service registration and discovery method when executing the computer program.
[0030] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned service registration and discovery method when executed by a processor.
[0031] A computer program product includes a computer program, which implements the steps of the above-mentioned service registration and discovery method when executed by a processor.
[0032] The service registration and discovery method, apparatus, computer device, storage medium, and computer program product described above send a service discovery request carrying a first service identifier corresponding to a distributed development service to a server. The server then determines the second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted for the distributed development platform. The server then retrieves the virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier. The corresponding cluster management service is then run based on the virtual address returned by the server. Thus, a mapping relationship is established in the first registration component between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service. Upon receiving a service discovery request corresponding to an application, the server determines the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier carried in the service discovery request and the first registration component. This determines the cluster management service corresponding to the distributed discovery service and returns the virtual address corresponding to the cluster management service. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, thereby improving compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform. The service discovery process is completely transparent and imperceptible to clients corresponding to the distributed development service. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is an application environment diagram of a service registration and discovery method in one embodiment;
[0034] Figure 2 A schematic diagram of a process flow of a service registration and discovery method in one embodiment;
[0035] Figure 3 A schematic diagram of a cluster management service registration process in one embodiment;
[0036] Figure 4 A flowchart of a service registration and discovery method according to another embodiment;
[0037] Figure 5 Schematic diagram of the workflow of the first registration component in one embodiment;
[0038] Figure 6 A schematic diagram of the workflow of a service registration and discovery method in one embodiment;
[0039] Figure 7 A structural block diagram of a service registration and discovery device in one embodiment;
[0040] Figure 8 It is a structural block diagram of a service registration and discovery device in another embodiment;
[0041] Figure 9 It is a structural block diagram of a service registration and discovery device in another embodiment;
[0042] Figure 10 It is a structural block diagram of a service registration and discovery device in another embodiment;
[0043] Figure 11 is a diagram of the internal structure of a computer device in one embodiment;
[0044] Figure 12 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0046] The service registration discovery method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart TVs, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers. The terminal 102 and the server 104 can be directly or indirectly connected via wired or wireless communication, and this application is not limited here.
[0047] The client corresponding to an application is a terminal on which the application is installed. The terminal with the application installed communicates with the server corresponding to the application. The server configures the application developed based on the distributed development platform as a distributed development service and registers the distributed development service with a first registration component adapted for the distributed development platform. The server configures the application as a cluster management service, obtains the virtual address corresponding to the cluster management service, and registers the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address. In the first registration component, the server establishes a mapping relationship between a first service identifier of the distributed development service and a second service identifier of the cluster management service. The terminal sends a service discovery request carrying the first service identifier corresponding to the distributed development service to the server. Upon receiving the service discovery request from the terminal corresponding to the application, the server determines the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier carried in the service discovery request and the first registration component. Based on the second service identifier, the server obtains the virtual address corresponding to the cluster management service from the second registration component and returns the virtual address to the terminal corresponding to the application that sent the service discovery request. The terminal runs the cluster management service based on the virtual address returned by the server.
[0048] In one embodiment, Figure 2 As shown, a service registration discovery method is provided, which is described by taking the method applied to a server as an example. The service registration discovery method includes the following steps:
[0049] Step S202: configuring the application developed based on the distributed development platform as a distributed development service, and registering the distributed development service in a first registration component adapted to the distributed development platform.
[0050] A distributed development platform provides easy-to-deploy and easy-to-maintain distributed system infrastructure development capabilities. It offers developers tools for quickly building common patterns in distributed systems, such as service registry discovery, configuration centers, intelligent routing, and control buses. This platform simplifies the development of distributed system infrastructure and applications, facilitating application development. A distributed development service is a service that configures applications developed on the distributed development platform according to the platform's corresponding service configuration methods.
[0051] The first registration component refers to a component that is compatible with the service registration and discovery functions in the distributed development platform. It is used to receive service registration requests or service discovery requests corresponding to distributed development services, implement registration or discovery of distributed development services, and save the mapping relationship between distributed development services and cluster management services. When receiving a service discovery request corresponding to a distributed development service, it returns relevant information of the corresponding cluster management service based on the mapping relationship.
[0052] For example, both the distributed development platform and the cluster management platform provide corresponding service registration and discovery functions, and many of the functions provided by the distributed development platform overlap with those of the cluster management platform. Both platforms can manage and maintain services running on their respective platforms. Compared to the cluster management platform, the distributed development platform is more convenient in application development. At the same time, compared to the distributed development platform, the cluster management platform can provide more complete and mature basic functions. Therefore, by developing applications based on the distributed development platform, configuring the applications as services and deploying them on the cluster management platform, one can simultaneously enjoy the convenience brought by the distributed development platform for development and the high scalability and maintainability of the cluster management platform as an infrastructure. However, there are incompatibility issues between the distributed development platform and the cluster management platform in service registration and discovery. If services are to be run on the cluster management platform, the relevant ecosystem of the distributed management platform must be abandoned. Therefore, it is necessary to resolve the compatibility issues between the distributed development platform and the cluster management platform in service registration and discovery so that applications developed based on the distributed development platform can run on the cluster management platform without modifying the code.
[0053] The server obtains an application developed based on the distributed development platform and application information corresponding to the application. Using a service configuration method corresponding to the distributed development platform, the server generates a first service configuration file corresponding to the application based on the application information. Based on the first service configuration file corresponding to the application, the server performs a service deployment operation on the application to obtain a distributed development service. The server then sends the service information corresponding to the distributed development service to a first registration component adapted for the distributed development platform for service registration, thereby registering the distributed development service with the first registration component.
[0054] Step S204: configure the application as a cluster management service, obtain a virtual address corresponding to the cluster management service, and register the cluster management service in a second registration component corresponding to the cluster management platform based on the virtual address.
[0055] Among them, the cluster management platform refers to an open source system used to automatically deploy, scale, and manage containerized applications. It provides an infrastructure platform for automatically deploying, scaling, and running application containers across host clusters, supports automated deployment, large-scale scalability, and application container management, and provides service registration and discovery capabilities based on the domain name system. Because the cluster management platform has powerful and comprehensive basic functions, using the cluster management platform as a service deployment platform can bring high scalability and maintainability, making service management and maintenance more convenient. Cluster management service refers to the service obtained by configuring applications developed based on the distributed development platform according to the service configuration method corresponding to the cluster management platform. The virtual address refers to the virtual IP address (Virtual Internet Protocol Address) generated by the cluster management platform for the cluster management service when the application is configured as a cluster management service in the cluster management platform. The second registration component refers to the service registration and discovery component corresponding to the cluster management platform, which is used to implement the service registration and discovery function in the cluster management platform.
[0056] Exemplarily, the server generates a second service configuration file corresponding to the application based on the application information and the service configuration method corresponding to the cluster management platform. Based on the second service configuration file corresponding to the application, the server performs a service deployment operation on the application, obtains the cluster management service, and obtains a virtual address generated for the cluster management service by the cluster management platform. The server registers the virtual address and second service identifier corresponding to the cluster management service in a second registration component corresponding to the cluster management platform.
[0057] Step S206: In the first registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established.
[0058] The first service identifier is an identifier corresponding to a distributed development service, and is used to distinguish different distributed development services. The second service identifier is an identifier corresponding to a cluster management service, and is used to distinguish different cluster management services.
[0059] Exemplarily, the server obtains a first service identifier corresponding to the distributed development service and a second service identifier corresponding to the cluster management service, establishes a mapping relationship between the first service identifier and the second service identifier, and records the mapping relationship in the first registration component.
[0060] Step S208: upon obtaining a service discovery request sent by the client corresponding to the application, determining a second service identifier corresponding to the first service identifier based on the first service identifier carried in the service discovery request and the mapping relationship in the first registration component.
[0061] The client corresponding to the application is the client that sends a service discovery request corresponding to the distributed development service to the server. A service discovery request is a request sent by the client to the server to obtain the distributed development service corresponding to the application.
[0062] Exemplarily, the server obtains a service discovery request sent by a client corresponding to the application, determines the first service identifier corresponding to the distributed development service carried in the service discovery request, determines the mapping relationship between the first service identifier and the second service identifier corresponding to the application in the first registration component based on the first service identifier, and then determines the second service identifier corresponding to the first service identifier. In this way, it is compatible with the original service discovery method of the distributed development platform, that is, based on the service discovery request carrying the first service identifier, the distributed development service is obtained from the first registration component. At the same time, in order to be compatible with the powerful basic functions of the cluster management platform, a mapping relationship between the first service identifier and the second service identifier is established. When the service discovery request carrying the first service identifier is obtained, the second service identifier corresponding to the first service identifier is determined based on the mapping relationship in the first registration component, and then the cluster management service is called according to the access process of the cluster management service in the cluster management platform.
[0063] Step S210: Acquire a virtual address corresponding to the cluster management service from the second registration component based on the second service identifier.
[0064] Exemplarily, the server determines, based on the second service identifier, in the second registration component, a virtual address corresponding to the second service identifier, that is, a virtual address of the cluster management service corresponding to the second service identifier.
[0065] Step S212: Return the virtual address to the client corresponding to the application that sent the service discovery request, so that the client runs the cluster management service based on the virtual address.
[0066] Exemplarily, the server sends the virtual address of the cluster management service corresponding to the first service identifier carried in the service discovery request to the client corresponding to the application that sent the service discovery request. After receiving the virtual address, the client calls the corresponding cluster management service based on the virtual address.
[0067] For the client corresponding to the distributed development application, the client sends a service discovery request corresponding to the distributed development service to the server, and the server returns the virtual address of the corresponding cluster management service to the client. The server determines the corresponding second service identifier in the mapping relationship in the first registration component based on the first service identifier carried in the service discovery request, and then obtains the virtual address of the cluster management service from the second component based on the second service identifier. The service discovery process is completely transparent and imperceptible to the client.
[0068] In the above-mentioned service registration and discovery method, an application developed based on a distributed development platform is configured as a distributed development service, and the distributed development service is registered with a first registration component adapted for the distributed development platform. The application is configured as a cluster management service, a virtual address corresponding to the cluster management service is obtained, and the cluster management service is registered with a second registration component corresponding to the cluster management platform based on the virtual address. A mapping relationship is established in the first registration component between a first service identifier of the distributed development service and a second service identifier of the cluster management service. Upon receiving a service discovery request from a client corresponding to the application, the second service identifier corresponding to the first service identifier is determined based on the first service identifier carried in the service discovery request and the mapping relationship in the first registration component. The virtual address corresponding to the cluster management service is obtained from the second registration component based on the second service identifier, so that the client runs the cluster management service based on the virtual address. Thus, a mapping relationship is established in the first registration component between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service. Upon receiving a service discovery request corresponding to the application, the second service identifier corresponding to the first service identifier is determined based on the mapping relationship between the first service identifier carried in the service discovery request and the first registration component, i.e., the cluster management service corresponding to the distributed discovery service is determined, and the virtual address corresponding to the cluster management service is returned. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, that is, improving the compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform.
[0069] It can be understood that this method improves the compatibility between different service registration and discovery mechanisms, that is, the compatibility between the distributed development platform and the cluster management platform. By creating a first registration component adapted to the distributed development platform, applications developed based on the distributed development platform can run on the cluster management platform without code modification. In other words, registration and discovery of distributed development services can be achieved on the cluster management platform. At the same time, it also ensures that the service registration and discovery mechanism obtained after compatibility combines the advantages of the distributed development platform and the cluster management platform. By performing service registration and discovery through the service registration and discovery mechanism obtained after compatibility, it is possible to obtain the convenience brought by the distributed development platform for application development, as well as the operational convenience and high scalability brought by the cluster management platform as a basic container manager and service deployment platform.
[0070] In one embodiment, Figure 3 As shown, configuring the application as a cluster management service, obtaining a virtual address corresponding to the cluster management service, and registering the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address include:
[0071] Step S302: Based on the application information corresponding to the application, the application is configured as a cluster management service, and a second service identifier and a virtual address corresponding to the cluster management service are obtained.
[0072] Step S304: register the second service identifier and the virtual address in a second registration component corresponding to the cluster management platform.
[0073] Step S306: Establish a mapping relationship between the second service identifier and the virtual address in a second registration component corresponding to the cluster management platform.
[0074] The application information refers to configuration information corresponding to the application, and the configuration information includes but is not limited to at least one of parameter information, storage path information, database information, and the like corresponding to the application.
[0075] Exemplarily, the server generates a second service configuration file corresponding to the application based on the application information and the service configuration method corresponding to the cluster management platform. Based on the second service configuration file corresponding to the application, the application is configured as a cluster management service, and a virtual address generated by the cluster management platform for the cluster management service and a second service identifier corresponding to the cluster management service are obtained. The virtual address and second service identifier corresponding to the cluster management service are recorded in a second registration component corresponding to the cluster management platform. A mapping relationship is then established between the second service identifier corresponding to the cluster management service and the virtual address, and the mapping relationship between the second service identifier and the virtual address is recorded in the second registration component.
[0076] In the above embodiment, the mapping relationship between the second service identifier corresponding to the cluster management service and the virtual address is recorded in the second registration component corresponding to the cluster management platform, so that the server can quickly determine the virtual address corresponding to the cluster management service in the second registration component based on the second service identifier corresponding to the cluster management service, thereby improving the efficiency of service registration discovery.
[0077] In one embodiment, in the first registration component, before establishing a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service, the service registration discovery method further includes:
[0078] After the application is configured as a cluster management service, the first registration component is notified, and the first registration component obtains the second service identifier of the cluster management service corresponding to the application from the second registration component.
[0079] For example, after the server configures the application as a cluster management service, the second service identifier and virtual address corresponding to the cluster management service will be recorded in the second registration component. At this time, the server notifies the first registration component in real time to obtain the second service identifier of the cluster management service corresponding to the application from the second registration component.
[0080] In the above embodiment, after the application is configured as a cluster management service, the first registration component is notified to obtain the second service identifier corresponding to the cluster management service, allowing the first registration component to promptly obtain the second service identifier corresponding to the application and establish a mapping relationship between the first service identifier and the second service identifier corresponding to the application. This ensures that the mapping relationship between the first service identifier and the second service identifier corresponding to the application is promptly generated in the first registration component, improving the efficiency of service registration discovery.
[0081] In one embodiment, before establishing a mapping relationship between a first service identifier of a distributed development service and a second service identifier of a cluster management service in the first registration component, the service registration discovery method further comprises: periodically obtaining data from the second registration component through the first registration component.
[0082] In the first registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established, including: when the first registration component obtains the second service identifier of the cluster management service corresponding to the application from the second registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established.
[0083] Exemplarily, the first registration component records the correspondence between the distributed development service and the first service identifier corresponding to the distributed development service, and the second registration component records the correspondence between the cluster management service and the second service identifier corresponding to the cluster management service. The server can determine the corresponding distributed management service in the first registration component based on the first service identifier, and determine the corresponding cluster management service in the second registration component based on the second service identifier. The server first determines the first service identifier for which no mapping relationship has been established in the first registration component, and determines the distributed development service corresponding to the first service identifier, and then determines the application corresponding to the first service identifier. Then, through the first registration component, the second service identifier of the cluster management service corresponding to the above-mentioned application is obtained from the second registration component at a predetermined time period. When the second service identifier of the cluster management service corresponding to the application is obtained from the second registration component through the first registration component, the server establishes a mapping relationship between the first service identifier of the distributed development service corresponding to the application and the second service identifier of the cluster management service corresponding to the application in the first registration component.
[0084] In the above embodiment, the first registration component periodically obtains data from the second registration component to obtain the second service identifier corresponding to the cluster management service corresponding to the application. After obtaining the second service identifier corresponding to the cluster management service, a mapping relationship between the first service identifier and the second service identifier is established in the first registration component. In this way, if the second service identifier cannot be obtained from the first registration component, the second service identifier can be obtained again the next time data is obtained from the second registration component according to a preset time period until the acquisition is successful. A mapping relationship between the first service identifier and the second service identifier is established in the first registration component. This avoids the situation where the mapping relationship cannot be established due to the failure to obtain the second service identifier, and can improve the stability and reliability of service registration discovery.
[0085] In one embodiment, the service registration discovery method further includes:
[0086] The service status of the cluster management service corresponding to the application is detected through the first registration component to obtain the current service status; when the current service status is different from the historical service status of the cluster management service in the first registration component, the historical service status in the first registration component is updated based on the current service status; the current service status of the cluster management service is published to each client corresponding to the application through the first registration component.
[0087] The service status refers to the operational status of the cluster management service, indicating whether the cluster management service is available. The current service status refers to the service status of the cluster management service during the current time period, as detected by the first registration component. The historical service status refers to the service status of the cluster management service during the current time period, as recorded in the first registration component.
[0088] Exemplarily, the server obtains the virtual address corresponding to the cluster management service from the second registration component through the second service identifier of the cluster management service corresponding to the application recorded in the first registration component, and detects the current service status corresponding to the cluster management service based on the virtual address corresponding to the cluster management service. For example, the service status can be available or unavailable. The current service status of the cluster management service is compared with the historical service status of the cluster management service recorded in the first registration component. When the current service status and the historical service status of the cluster management service are different, the historical service status of the cluster management service in the first registration component is updated based on the current service status. Once the service status corresponding to the cluster management service changes, the server determines the various clients corresponding to the application and publishes the current service status of the cluster management service to the various clients corresponding to the application through the first registration component.
[0089] In the above embodiment, the service status of the cluster management service corresponding to the application is detected by the first registration component, and the service status is recorded in the first registration component, so that the current situation of the cluster management service can be grasped in time, problems can be discovered in time, and the stability and reliability of service registration discovery can be enhanced.
[0090] In one embodiment, Figure 4 As shown, a service registration and discovery method is provided, which is described by taking the method applied to the client corresponding to the application developed based on the distributed development platform as an example. The service registration and discovery method includes the following steps:
[0091] In step S402, a service discovery request carrying the first service identifier corresponding to the distributed development service is sent to the server, so that the server determines the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier and the first registration component adapted to the distributed development platform, and obtains the virtual address corresponding to the cluster management service from the second registration component corresponding to the cluster management platform based on the second service identifier.
[0092] Among them, the first registration component registers a distributed development service configured for the application, and the second registration component registers a cluster management service configured for the application. The cluster management service is registered in the second registration component based on the virtual address obtained based on the configuration. The first registration component includes a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service.
[0093] Exemplarily, a client sends a service discovery request carrying a first service identifier corresponding to a distributed development application to a server. The server determines the second service identifier corresponding to the first service identifier based on the first service identifier corresponding to the distributed development service carried in the service discovery request and the mapping relationship between the first service identifier corresponding to the distributed development service in the first registration component and the second service identifier corresponding to the cluster management service. Based on the second service identifier, the server determines the virtual address of the cluster management service corresponding to the second service identifier in the second registration component, and finally sends the virtual address to the client.
[0094] It can be understood that the data processing process of the server can refer to the contents of the various embodiments of the aforementioned service registration and discovery method applied to the server, which will not be repeated here.
[0095] Step S404: running the cluster management service based on the virtual address returned by the server.
[0096] Exemplarily, after receiving the virtual address of the cluster management service returned by the server, the terminal calls the corresponding cluster management service based on the virtual address.
[0097] In the above-mentioned service registration and discovery method, a service discovery request carrying a first service identifier corresponding to a distributed development service is sent to a server. The server then determines the second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted for the distributed development platform. Based on the second service identifier, the server retrieves the virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform. Based on the virtual address returned by the server, the corresponding cluster management service is run. In this way, a mapping relationship is established in the first registration component between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service. Upon receiving a service discovery request corresponding to an application, the server determines the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier carried in the service discovery request and the first registration component. This determines the cluster management service corresponding to the distributed discovery service and returns the virtual address corresponding to the cluster management service. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, thereby improving compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform. The above-mentioned service discovery process is completely transparent and imperceptible to the client corresponding to the distributed development service.
[0098] In one embodiment, the service registration discovery method further includes:
[0099] The virtual address is stored locally; and based on the service status of the cluster management service published by the first registration component, the address status of the virtual address corresponding to the locally stored cluster management service is updated.
[0100] The address status is used to indicate whether the virtual address is available.
[0101] Exemplarily, the client stores the virtual address of the cluster management service returned by the server locally, and updates the address status of the virtual address corresponding to the locally stored cluster management service based on the service status of the cluster management service published by the first registered component. For example, the address status can be a valid state or an invalid state. When the service status is an available state, the corresponding address status is a valid state. When the service status is an unavailable state, the corresponding address status is an invalid state. When the address status of the virtual address corresponding to the locally stored cluster management service changes, the client generates a corresponding address status update prompt and displays the address status update prompt. The address status update prompt is used to inform the user that the address status of the virtual address has changed.
[0102] In the above embodiment, the virtual address is stored locally, so that the next time a client calls a service, it can directly obtain the virtual address corresponding to the service locally without having to initiate a service discovery request to the server again, which can improve the efficiency of service discovery. When the service status recorded in the first registration component changes, the current service status of the cluster management service is published to each client corresponding to the application. This allows the client to obtain the current service status of the cluster management service in a timely manner and update the address status of the locally stored virtual address, thereby improving the accuracy of the address status stored by the client.
[0103] In a specific embodiment, this solution can be used to improve the compatibility between Kubernetes and Spring Cloud in service registration and discovery, so that applications developed based on Spring Cloud can run on the Kubernetes platform without modifying the code.
[0104] Kubernetes is an open source system for automatically deploying, scaling, and managing containerized applications. It combines the containers that make up an application into logical units for easier management and service discovery. Kubernetes uses DNS (Domain Name System) as the service registration center, and each Kubernetes cluster runs a DNS service in the form of a Pod. A Kubernetes cluster is a group of node computers used to run containerized applications. A Pod is the smallest execution unit in Kubernetes, and a Pod encapsulates one or more applications. Services run on the Kubernetes platform, and applications run in containers, which are located within Pods. Containers provide standardized, portable packaging for applications, bundling the application code with related configuration files, libraries, and the dependencies required to run the application, allowing developers to seamlessly deploy applications across environments.
[0105] Spring Cloud is a comprehensive suite of microservice solutions or frameworks for building distributed microservice systems. While Spring Cloud's service registry and discovery hub and Kubernetes' DNS-based service registry and discovery can serve microservice applications running on their respective platforms, the two service registry and discovery mechanisms are incompatible. Microservices (or microservices architecture) are a cloud-native architectural approach that encompasses numerous small, loosely coupled, and independently deployable components or services within a single application. This architecture makes applications easier to scale and faster to develop.
[0106] Currently, developing microservice applications using cloud-native technologies has become a trend, and Kubernetes is the foundational platform for cloud-native applications. In the future, a large number of microservice applications will be developed using Java and based on the Spring Cloud ecosystem, but ultimately deployed and run on the Kubernetes platform, benefiting from the development convenience brought by the Spring Cloud ecosystem and the high scalability and maintainability of Kubernetes as an infrastructure. However, Spring Cloud's service registration and discovery center is completely different from the Kubernetes ecosystem, which uses DNS for service discovery. If Java developers want to run microservice applications on the Kubernetes platform, they will have to abandon the Spring Cloud ecosystem.
[0107] The service registration and discovery method of this application can be used to resolve the compatibility issues between Spring Cloud and Kubernetes in service registration and discovery. By developing a first registration component that adapts to the distributed development platform, applications developed based on the distributed development platform can run on the cluster management platform without code modification. Taking the service registration and discovery of the order application developed based on Spring Cloud as an example, the order application is an application used to manage order status and order database. The service registration and discovery method includes the following steps:
[0108] 1. Service Registration
[0109] like Figure 5 As shown, the server configures the order application (i.e., distributed development application) developed based on the distributed development platform (i.e., Spring Cloud) as the cluster management service (i.e., Kubernetes service) corresponding to the cluster management platform (i.e., Kubernetes). The virtual address (i.e., virtual IP) and the second service identifier (i.e., the service name of the cluster management service) corresponding to the cluster management service are obtained from the cluster management platform, and the virtual address and the second service identifier corresponding to the cluster management service are registered in the second registration component (i.e., CoreDNS, core domain name system) as records. The order application is registered in the first registration component (i.e., Register, registration component) according to the original service registration method in the distributed development platform, and the distributed development service (i.e., Spring Cloud service) corresponding to the order application and the first service identifier corresponding to the distributed management service are obtained.
[0110] 2. Establish mapping relationship
[0111] The first registration component obtains the second service identifier of the cluster management service corresponding to the order application from the second registration component, and establishes a mapping relationship between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service.
[0112] 3. Service Discovery
[0113] The client corresponding to the order application obtains the distributed development service from the first registration component according to the original service discovery method in the distributed development platform, that is, sends a service discovery request carrying the first service identifier corresponding to the distributed development service to the first registration component. Figure 6 As shown, after the distributed development service is registered in the first registration component, the server determines the second service identifier corresponding to the first service identifier based on the first service identifier carried in the service discovery request and the mapping relationship in the first registration component, and obtains the cluster management service from the second registration component based on the second service identifier, that is, determines the cluster management service corresponding to the distributed development service. The server finally returns the second service identifier and other information of the cluster management service corresponding to the order application, rather than related information that is not a development service. The server determines the virtual address corresponding to the second service identifier through the second registration component, and returns the virtual address of the cluster management service corresponding to the order application to the client. Based on the virtual address, the client forwards the service call request to the Pod in the cluster management platform through the proxy to obtain the corresponding cluster management service. When the user uses an application function in the order application through the client, the cluster management service corresponding to the order application responds to the application operation corresponding to the order application generated in the client, and completes the corresponding order data processing task or interface call task.
[0114] In the above embodiment, the compatibility issues between Spring cloud and Kubernetes in service registration and discovery are solved, so that microservice applications developed in Java language and based on Spring cloud can run on the Kubernetes platform without modifying the code. It not only obtains the convenience brought by the Spring cloud ecosystem to application development, but also obtains the high scalability and maintainability of Kubernetes as the basic setting. In addition, since the first registration component is compatible with the interface of the Spring cloud service registration and discovery center and saves the mapping relationship between the Spring cloud service and the Kubernetes service, it can achieve transparent access to the Spring cloud service on the Kubernetes platform. Specifically, when the client wants to access the distributed development service, what is obtained from the first registration component is the cluster management service corresponding to the order application, and then the service can be called according to the cluster management service access process. The above steps are completely transparent and imperceptible to the client requesting the distributed development service.
[0115] The above service registration and discovery method can not only be used to register and discover services for order applications, but can also be applied to other applications to register and discover services for other applications.
[0116] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0117] Based on the same inventive concept, the embodiments of the present application also provide a service registration and discovery device for implementing the aforementioned service registration and discovery method. The implementation solution provided by this device is similar to the implementation solution described in the aforementioned method. Therefore, the specific limitations in one or more service registration and discovery device embodiments provided below can be found in the above-mentioned limitations on the service registration and discovery method, and will not be repeated here.
[0118] In one embodiment, Figure 7 As shown, a service registration and discovery device is provided, including: a distributed development service registration module 702, a cluster management service registration module 704, a service mapping relationship establishment module 706, a service discovery request response module 708, a virtual address acquisition module 710 and a virtual address return module 712, wherein:
[0119] The distributed development service registration module 702 is used to configure the application developed based on the distributed development platform as a distributed development service, and register the distributed development service in a first registration component adapted to the distributed development platform.
[0120] The cluster management service registration module 704 is used to configure the application as a cluster management service, obtain a virtual address corresponding to the cluster management service, and register the cluster management service in a second registration component corresponding to the cluster management platform based on the virtual address.
[0121] The service mapping relationship establishing module 706 is used to establish a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service in the first registration component.
[0122] The service discovery request response module 708 is used to determine the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier carried in the service discovery request and the first registration component when obtaining the service discovery request sent by the client corresponding to the application.
[0123] The virtual address acquisition module 710 is configured to acquire the virtual address corresponding to the cluster management service from the second registration component based on the second service identifier.
[0124] The virtual address returning module 712 is configured to return the virtual address to the client corresponding to the application that sends the service discovery request, so that the client runs the cluster management service based on the virtual address.
[0125] The service registration and discovery device configures an application developed based on a distributed development platform as a distributed development service, registers the distributed development service with a first registration component adapted for the distributed development platform, configures the application as a cluster management service, obtains a virtual address corresponding to the cluster management service, and registers the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address. A mapping relationship is established in the first registration component between a first service identifier of the distributed development service and a second service identifier of the cluster management service. Upon receiving a service discovery request from a client corresponding to the application, the first registration component determines the second service identifier corresponding to the first service identifier based on the first service identifier carried in the service discovery request and the mapping relationship in the first registration component. Based on the second service identifier, the virtual address corresponding to the cluster management service is obtained from the second registration component, allowing the client to run the cluster management service based on the virtual address. Thus, a mapping relationship is established in the first registration component between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service. Upon receiving a service discovery request corresponding to the application, the first registration component determines the second service identifier corresponding to the first service identifier based on the mapping relationship in the first registration component, i.e., determines the cluster management service corresponding to the distributed discovery service, and returns the virtual address corresponding to the cluster management service. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, that is, improving the compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform.
[0126] In one embodiment, the cluster management service registration module 704 is further configured to:
[0127] Based on the application information corresponding to the application, the application is configured as a cluster management service, and a second service identifier and virtual address corresponding to the cluster management service are obtained; the second service identifier and virtual address are registered in a second registration component corresponding to the cluster management platform; and a mapping relationship between the second service identifier and the virtual address is established in the second registration component corresponding to the cluster management platform.
[0128] In one embodiment, Figure 8 As shown, the service registration discovery device also includes:
[0129] The second service identifier obtaining module 802 is used to notify the first registration component after configuring the application as the cluster management service, and obtain the second service identifier of the cluster management service corresponding to the application from the second registration component through the first registration component.
[0130] The second service identifier acquisition module 802 is further configured to:
[0131] Data is periodically obtained from the second registration component through the first registration component; in the first registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established, including: when the first registration component obtains the second service identifier of the cluster management service corresponding to the application from the second registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established.
[0132] The service status update module 804 is used to detect the service status of the cluster management service corresponding to the application through the first registration component to obtain the current service status; when the current service status is different from the historical service status of the cluster management service in the first registration component, the historical service status in the first registration component is updated based on the current service status; and the current service status of the cluster management service is published to each client corresponding to the application through the first registration component.
[0133] In one embodiment, Figure 9 As shown, a service registration discovery device is provided, including: a service discovery request sending module 902 and a cluster management service running module 904, wherein:
[0134] The service discovery request sending module 902 is used to send a service discovery request carrying the first service identifier corresponding to the distributed development service to the server, so that the server determines the second service identifier corresponding to the first service identifier based on the mapping relationship between the first service identifier and the first registration component adapted to the distributed development platform, and obtains the virtual address corresponding to the cluster management service from the second registration component corresponding to the cluster management platform based on the second service identifier; wherein, the first registration component is registered with the distributed development service configured for the application, and the second registration component is registered with the cluster management service configured for the application, and the cluster management service is registered in the second registration component based on the virtual address obtained by the configuration, and the first registration component includes the mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service.
[0135] The cluster management service running module 904 is used to run the cluster management service based on the virtual address returned by the server.
[0136] The service registration and discovery device sends a service discovery request carrying a first service identifier corresponding to a distributed development service to a server. The server then determines the second service identifier corresponding to the first service identifier based on a mapping between the first service identifier and a first registration component adapted for the distributed development platform. The server then retrieves the virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier. The corresponding cluster management service is then run based on the virtual address returned by the server. In this way, a mapping between the first service identifier corresponding to the distributed development service and the second service identifier corresponding to the cluster management service is established in the first registration component. Upon receiving a service discovery request corresponding to an application, the server determines the second service identifier corresponding to the first service identifier based on the mapping between the first service identifier carried in the service discovery request and the first registration component. This determines the cluster management service corresponding to the distributed discovery service and returns the virtual address corresponding to the cluster management service. This enables applications developed based on the distributed development platform to run on the cluster management platform, achieving compatibility between the distributed development platform and the cluster management platform, thereby improving compatibility between the service registration and discovery mechanisms corresponding to the distributed development platform and the cluster management platform. The service discovery process is completely transparent and imperceptible to clients corresponding to the distributed development service.
[0137] In one embodiment, Figure 10 As shown, the service registration discovery device also includes:
[0138] The address status updating module 1002 is configured to store the virtual address locally and update the address status of the virtual address corresponding to the cluster management service stored locally based on the service status of the cluster management service published by the first registration component.
[0139] Each module in the above-mentioned service registration and discovery device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each of the above modules.
[0140] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data such as virtual addresses, first service identifiers, and second service identifiers. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a service registration and discovery method is implemented.
[0141] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 12As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a service registration and discovery method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.
[0142] Those skilled in the art will understand that Figure 11 、 12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0143] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0144] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0145] In one embodiment, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of each of the above-described method embodiments.
[0146] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0147] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0148] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A service registration discovery method, characterized in that: Applied to a server, the method includes: Configuring an application developed based on a distributed development platform as a distributed development service, and registering the distributed development service in a first registration component adapted to the distributed development platform; Configuring the application as a cluster management service, obtaining a virtual address corresponding to the cluster management service, and registering the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address; After configuring the application as a cluster management service, notifying the first registration component, and obtaining a second service identifier of the cluster management service corresponding to the application from the second registration component through the first registration component; In the first registration component, establishing a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service; When a service discovery request sent by a client corresponding to the application is obtained, determining a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier carried in the service discovery request and the first registration component; Obtaining a virtual address corresponding to the cluster management service from the second registration component based on the second service identifier; The virtual address is returned to the client corresponding to the application that sends the service discovery request, so that the client runs the cluster management service based on the virtual address.
2. The method according to claim 1, characterized in that Configuring the application as a cluster management service, obtaining a virtual address corresponding to the cluster management service, and registering the cluster management service with a second registration component corresponding to a cluster management platform based on the virtual address includes: Based on the application information corresponding to the application, configuring the application as the cluster management service, and obtaining a second service identifier and a virtual address corresponding to the cluster management service; Registering the second service identifier and the virtual address in the second registration component corresponding to the cluster management platform; A mapping relationship between the second service identifier and the virtual address is established in the second registration component corresponding to the cluster management platform.
3. The method according to claim 1, characterized in that Configuring the application developed based on the distributed development platform as a distributed development service includes: Obtaining applications developed based on a distributed development platform and application information corresponding to the applications; Generate a first service configuration file corresponding to the application based on the application information using a service configuration method corresponding to the distributed development platform; Based on the first service configuration file corresponding to the application, a service deployment operation is performed on the application to obtain a distributed development service.
4. The method according to claim 1, wherein In the first registration component, before establishing a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service, the method further includes: Obtaining data from the second registration component periodically through the first registration component; The step of establishing, in the first registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service includes: When the first registration component obtains the second service identifier of the cluster management service corresponding to the application from the second registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service is established.
5. The method according to claim 1, wherein The method further comprises: Detecting the service status of the cluster management service corresponding to the application through the first registration component to obtain the current service status; When the current service state is different from the historical service state of the cluster management service in the first registration component, updating the historical service state in the first registration component based on the current service state; The current service status of the cluster management service is published to each client corresponding to the application through the first registration component.
6. A service registration discovery method, characterized in that: Applied to a client corresponding to an application developed based on a distributed development platform, the method includes: A service discovery request carrying a first service identifier corresponding to a distributed development service is sent to a server, so that the server determines a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted to a distributed development platform, and obtains a virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier; wherein the first registration component is registered with a distributed development service configured for the application, and the second registration component is registered with a cluster management service configured for the application, and the cluster management service is registered in the second registration component based on the virtual address obtained by configuration, and the first registration component includes a mapping between the first service identifier of the distributed development service and the second service identifier of the cluster management service. a mapping relationship; the process of establishing the mapping relationship includes: configuring an application developed based on a distributed development platform as a distributed development service, registering the distributed development service in a first registration component adapted to the distributed development platform; configuring the application as a cluster management service, obtaining a virtual address corresponding to the cluster management service, and registering the cluster management service in a second registration component corresponding to the cluster management platform based on the virtual address; after configuring the application as a cluster management service, notifying the first registration component, and obtaining a second service identifier of the cluster management service corresponding to the application from the second registration component through the first registration component; establishing a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service in the first registration component; The cluster management service is run based on the virtual address returned by the server.
7. The method according to claim 6, characterized in that The method further comprises: storing the virtual address locally; Based on the service status of the cluster management service published by the first registration component, the address status of the locally stored virtual address corresponding to the cluster management service is updated.
8. A service registration and discovery device, characterized in that: Applied to a server, the device includes: A distributed development service registration module, configured to configure an application developed based on a distributed development platform as a distributed development service, and register the distributed development service in a first registration component adapted to the distributed development platform; A cluster management service registration module, configured to configure the application as a cluster management service, obtain a virtual address corresponding to the cluster management service, and register the cluster management service with a second registration component corresponding to the cluster management platform based on the virtual address; A second service identifier acquisition module is configured to, after configuring the application as a cluster management service, notify the first registration component and obtain, from the second registration component through the first registration component, a second service identifier of the cluster management service corresponding to the application; A service mapping relationship establishing module, configured to establish, in the first registration component, a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service; a service discovery request response module, configured to, upon receiving a service discovery request sent by a client corresponding to the application, determine a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier carried in the service discovery request and the first registration component; A virtual address acquisition module, configured to acquire a virtual address corresponding to the cluster management service from the second registration component based on the second service identifier; The virtual address returning module is configured to return the virtual address to the client corresponding to the application that sends the service discovery request, so that the client runs the cluster management service based on the virtual address.
9. A service registration and discovery device, characterized in that: Applicable to a client corresponding to an application developed based on a distributed development platform, the device includes: A service discovery request sending module, configured to send a service discovery request carrying a first service identifier corresponding to a distributed development service to a server, so that the server determines a second service identifier corresponding to the first service identifier based on a mapping relationship between the first service identifier and a first registration component adapted to a distributed development platform, and obtains a virtual address corresponding to the cluster management service from a second registration component corresponding to the cluster management platform based on the second service identifier; wherein the first registration component is registered with a distributed development service configured for the application, and the second registration component is registered with a cluster management service configured for the application, and the cluster management service is registered in the second registration component based on the virtual address obtained by configuration, and the first registration component includes the first service identifier of the distributed development service and the second service identifier of the cluster management service. a mapping relationship between two service identifiers; a process for establishing the mapping relationship includes: configuring an application developed based on a distributed development platform as a distributed development service, and registering the distributed development service in a first registration component adapted to the distributed development platform; configuring the application as a cluster management service, obtaining a virtual address corresponding to the cluster management service, and registering the cluster management service in a second registration component corresponding to the cluster management platform based on the virtual address; after configuring the application as the cluster management service, notifying the first registration component, and obtaining the second service identifier of the cluster management service corresponding to the application from the second registration component through the first registration component; and establishing a mapping relationship between the first service identifier of the distributed development service and the second service identifier of the cluster management service in the first registration component; The cluster management service running module is used to run the cluster management service based on the virtual address returned by the server.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Service discovery and service registration method and device based on gateway
CN114697231A