CN110730197B - Service discovery method and system - Google Patents

Service discovery method and system Download PDF

Info

Publication number
CN110730197B
CN110730197B CN201810783952.3A CN201810783952A CN110730197B CN 110730197 B CN110730197 B CN 110730197B CN 201810783952 A CN201810783952 A CN 201810783952A CN 110730197 B CN110730197 B CN 110730197B
Authority
CN
China
Prior art keywords
service
calling
port number
deployment
providing end
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810783952.3A
Other languages
Chinese (zh)
Other versions
CN110730197A (en
Inventor
樊宇
邱鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810783952.3A priority Critical patent/CN110730197B/en
Publication of CN110730197A publication Critical patent/CN110730197A/en
Application granted granted Critical
Publication of CN110730197B publication Critical patent/CN110730197B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a service discovery method and a service discovery system, and relates to the technical field of computers. One embodiment of the method comprises the following steps: receiving a service inquiry request sent by a deployment end; inquiring corresponding service in a registration service list according to the service inquiry request, and returning address data of a service providing end of the service to a deployment end; the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service. The implementation mode can be suitable for a complex service calling environment, and has the advantages of light weight and simple and flexible configuration.

Description

Service discovery method and system
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a service discovery method and system.
Background
At present, many applications and systems are organized by adopting a multi-server and multi-instance mode, the applications and the applications need to be called through interfaces among networks, and the discovery and the call of the service among the interfaces are realized through an additional third-party remote procedure call framework.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art: because the calling mode, interface type and operating system environment of the test execution machine are very different in the calling environment of the test execution machine, the environment of the test execution machine has relative temporary property, so that the conventional service discovery method is difficult to perform service configuration management, good support can not be provided for service discovery of the test execution machine, and management can not be performed for some generalized applications, such as database examples needed in the test environment. Meanwhile, in a test environment, the call data volume among services is small, the call times are also small, and the information of interfaces, methods, data requests and the like of the services, which are provided by a server and a caller, is clear, and in the scene, the existing service discovery method is too redundant, complex in configuration and inflexible.
Therefore, there is a need for a service discovery method and system that is lightweight, simple and flexible to configure, and capable of adapting to a complex service invocation environment.
Disclosure of Invention
In view of this, the embodiment of the invention provides a service discovery method and a service discovery system, which are applicable to a complex service call environment and have the advantages of light weight and simple and flexible configuration.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a service discovery method including:
receiving a service inquiry request sent by a deployment end;
inquiring corresponding service in a registration service list according to the service inquiry request, and returning address data of a service providing end of the service to a deployment end;
the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service.
Further, the registration service list maintains ip, port number, service identifier, occupied state and available state of a service providing end of the service, and address data of the service providing end includes: ip and port number of the service provider, the service query request includes: the identity of the service(s),
The step of inquiring the corresponding service in the registration service list according to the service inquiry request and returning the address data of the service providing end of the service to the deployment end comprises the following steps:
and inquiring the service which has the same service identifier and is in an unoccupied state and an available state in the registered service list according to the service identifier, and returning the ip and the port number of the service providing end of the service to the deployment end.
Further, the service discovery method provided by the embodiment of the invention further comprises the following steps:
receiving a service registration request sent by a service providing end, wherein the service registration request comprises: ip, port number and service identifier of the service providing end;
judging whether the registered service list has the service, if so, updating the service into an occupied state and an available state, otherwise, adding an ip, a port number and a service identifier of a service providing end of the service into the registered service list, and setting the service into an unoccupied state and an available state.
Further, the service discovery method provided by the embodiment of the invention further comprises the following steps:
receiving an occupied state change request of a specified service sent by a service providing end, and updating the specified service into an occupied state, wherein the service providing end sends the occupied state change request of the specified service when starting to execute the called specified service;
Receiving an unoccupied state change request of a designated service sent by a service providing end, and updating the designated service to an unoccupied state, wherein the service providing end sends the unoccupied state change request of the designated service when executing the designated service which is called;
and receiving a request for changing the unavailable state of the specified service sent by the service providing end, and updating the specified service into the unavailable state, wherein the service providing end sends the request for changing the unavailable state of the specified service when the service providing end is closed.
Further, the service discovery method provided by the embodiment of the invention further comprises the following steps:
at a set time, the following steps are performed for each available state service in the registered service list:
and sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
Further, the service discovery method provided by the embodiment of the invention further comprises the following steps:
the deployment end obtains the service identification of the service calling end;
sending a service inquiry request comprising the service identifier, and receiving an ip and a port number of a service provider obtained according to the service identifier inquiry;
And writing the ip and the port number of the service providing end into a call configuration file of the service calling end so that the service calling end can call the service.
Optionally, the service calling end is configured with a script file for writing the ip and the port number of the service providing end into a calling configuration file of the service calling end, the script file name is a designated service identifier, and the deployment end obtains the designated service identifier of the service calling end by reading the script file name;
the writing the ip and the port number of the service providing end into the call configuration file of the service calling end comprises the following steps:
the deployment end calls the script file and transmits the script file into the ip and port number of the service providing end, and the service providing end address in the call configuration file is modified into the ip and port number of the transmitted service providing end, so that the service calling end can call the service of the service providing end through the service providing end address.
Further, the service discovery method provided by the embodiment of the invention further comprises the following steps:
when the service calling end is started, the calling configuration file is loaded, and the service is called for the service providing end by using the ip and the port number of the service providing end.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is also provided a service discovery system including: the system comprises a deployment end, a registration end, a service providing end and a service calling end;
The registration end comprises:
the receiving module is used for receiving a service query request sent by the deployment end;
the query module is used for querying corresponding service in the registration service list according to the service query request and returning address data of a service providing end of the service to the deployment end;
the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service.
Further, the registration service list maintains ip, port number, service identifier, occupied state and available state of a service providing end of the service, and address data of the service providing end includes: ip and port number of the service provider, the service query request includes: the identity of the service(s),
the query module is further configured to query, according to the service identifier, a service that has the same service identifier and is in an unoccupied state and an available state in the registered service list, and return an ip and a port number of a service provider of the service to a deployment end.
Further, the receiving module is further configured to receive a service registration request sent by the service provider, where the service registration request includes: ip, port number and service identifier of the service providing end;
The query module is further configured to determine whether the registered service list has the service, if yes, update the service to an occupied state and an available state, and if not, add an ip, a port number, and a service identifier of a service provider of the service to the registered service list, and set the service to an unoccupied state and an available state.
Further, the receiving module is further configured to receive an occupied state change request, an unoccupied state change request, and an unavailable state change request of the designated service sent by the service providing end;
the inquiry module is further configured to update the specified service to an occupied state after the receiving module receives the occupied state change request, update the specified service to an unoccupied state after the receiving module receives the unoccupied state change request, and update the specified service to an unavailable state after the receiving module receives the unavailable state change request;
the service providing end sends the occupied state change request of the appointed service when the appointed service is started to be executed, sends the unoccupied state change request of the appointed service when the appointed service is completed to be executed, and sends the unavailable state change request of the appointed service when the appointed service is closed.
Further, the query module is further configured to perform, for each service in the registered service list in the available state, the following steps at a set time:
and sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
Further, the deployment end is configured to obtain a service identifier of the service calling end, then send a service query request including the service identifier, receive an ip and a port number of the service providing end obtained according to the service identifier query, and write the ip and the port number of the service providing end into a call configuration file of the service calling end, so that the service calling end can call the service.
Further, the service calling end is configured with a script file for writing the ip and port number of the service providing end into a calling configuration file of the service calling end, the script file name is a designated service identifier, and the deployment end acquires the designated service identifier of the service calling end by reading the script file name;
the deployment end is further used for calling the script file and transmitting the script file into the ip and the port number of the service providing end, and modifying the address of the service providing end in the calling configuration file into the ip and the port number of the transmitted service providing end, so that the service calling end can call the service of the service providing end through the address of the service providing end.
Further, when the service calling end is started, the calling configuration file is loaded, and the service is called for the service providing end by using the ip and the port number of the service providing end.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is also provided a service discovery electronic device, including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the service discovery method provided by the present invention.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is also provided a computer-readable medium having stored thereon a computer program, characterized in that the program when executed by a processor implements the service discovery method provided by the present invention.
The service discovery method and the system provided by the invention are not influenced by the limitation of the network port due to the adoption of the http request mode, and can also operate on the public network. The http request mode is adopted to register, inquire and detect services, thereby realizing the independence of development language and frames and being not influenced by the calling mode of actual service codes. The service discovery can be realized by writing a small amount of codes, the realization is easy, the use mode is flexible, and the method can be combined with the existing remote procedure call mode. The service provider and the service caller do not need to pay attention to the configuration related to service discovery, but only need to pay attention to the service codes. The registration end only plays a role of a bridge between the service providing end and the service calling end, the service is not participated in execution when being actually called, the pressure of the registration end is greatly reduced, and the registration end is convenient to horizontally expand due to the fact that the registration end adopts a web and database form. The mechanism of the registration end is also convenient for expanding functions, such as shielding operation, service statistics, service isolation of different environments and the like, and has strong expansibility. The scheme can also be combined with a relevant deployment technology with a test environment, so that a good test experience degree is achieved, for example, the occupied ports on the same server can not be occupied by other applications.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a service discovery method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an application flow of a service discovery method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of a service discovery system provided by an embodiment of the invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 5 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
An embodiment of the present invention provides a service discovery method, as shown in fig. 1, including: step S101 and step S102.
In step S101, a service query request sent by a deployment end is received. In step S102, a corresponding service is queried in the registration service list according to the service query request, and address data of a service provider of the service is returned to the deployment end. The address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service.
In the present invention, the above-described step S101 and step S102 may be configured to be implemented on the registration side. As shown in fig. 2, the service discovery method provided by the present invention may be implemented through an interaction process between a deployment end, a registration end, a service providing end, and a service calling end. In the interaction process of each end in the embodiment of the invention, the sent request can be an http request, and the interaction of each end is realized through the http request and the response, so that the service discovery is completed. The deployment end, the registration end, the service providing end and the service calling end can be deployed on the web server, the function of the deployment end can be realized through a deployment program, and the deployment program can be configured on the registration end, the service providing end or the service calling end.
The service discovery method provided by the invention is not influenced by the limitation of the network port because of adopting an http request mode, and can also run on the public network. The http request mode is adopted to register, inquire and detect services, thereby realizing the independence of development language and frames and being not influenced by the calling mode of actual service codes.
In one embodiment of the present invention, ip, port number, service identifier, occupied state and available state of a service provider, which maintains a service in a registration service list, address data of the service provider includes: the ip and port number of the service provider, the service query request includes: service identification.
In step S102, the process of querying the corresponding service in the registration service list according to the service query request and returning the address data of the service provider of the service to the deployment end specifically includes: and inquiring the service which has the same service identifier in the registered service list and is in an unoccupied state and an available state according to the service identifier, and returning the ip and the port number of the service providing end of the service to the deployment end.
In one embodiment of the present invention, the registry executing the above process may be an automatically configured registry service and a database, where the database has six important fields, including IP, port number, service identifier, occupancy status, availability status, and server environment information of the service provider server, and the fields are optional fields, and are a composite field composed of keys-values, for recording the running environment information required by the service.
The registration terminal provides a service providing terminal inquiry service, which is used for inquiring available unoccupied service providing terminal information to the service calling terminal for use. The service returns all available service lists under all service identifiers, and a service calling end selects one or more single-point services from the service lists to call, wherein the calling form of the single points is similar to the distributed calling of a cluster.
In one embodiment, the service discovery method provided by the invention further comprises the following steps: receiving a service registration request sent by a service providing end, wherein the service registration request comprises: ip, port number and service identification of the service provider.
Judging whether the registered service list has the service, if so, updating the service into an occupied state and an available state, otherwise, adding the ip, the port number and the service identifier of the service providing end of the service into the registered service list, and setting the service into an unoccupied state and an available state.
In one embodiment, after the service provider web server is started, after the service provider application is successfully started, providing relevant service provider information to the registration end through an initialization method of the server, namely sending a service registration http request, including the IP of the server, port information of provider service, and service identification (for performing service matching discovery), wherein other service information is not required to be provided, usually the service provider and the service call end are the same item, and metadata of a service interface is not required to be provided. The service calling end is directly connected with the service providing end through the IP and the port by a web http request.
In the present invention, the service provider registers for a new service. When registering a service, if the registered service list already contains the service, that is, the service already exists, the new service is in an occupied state when the registration is attempted again.
When the registration end service receives the service initialization request of the service providing end, the IP and the port number of the service providing end are analyzed, if the IP address does not exist, the IP address is inserted into the database of the registration end, otherwise, the server information is not inserted, and the state of the server is updated to be unoccupied state and available state.
In one embodiment, the service discovery method provided by the invention further comprises the following steps:
and receiving an occupied state change request of the designated service sent by the service providing end, and updating the designated service into an occupied state, wherein the service providing end sends the occupied state change request of the designated service when starting to execute the called designated service.
Receiving an unoccupied state change request of a designated service sent by a service providing end, and updating the designated service to an unoccupied state, wherein the service providing end sends the unoccupied state change request of the designated service when executing the designated service which is called.
And receiving a request for changing the unavailable state of the specified service sent by the service providing end, and updating the specified service into the unavailable state, wherein the service providing end sends the request for changing the unavailable state of the specified service when the service providing end is closed.
The registration terminal provides a service provider occupancy state change service for changing the service state when starting to call the service and ending to call the service. When the service provider starts executing the called service, the registration end state changing service is called to change the current single-point service into the occupied state. When the service provider finishes executing the called service, the registration end state changing service is called to change the current single-point service into the unoccupied state.
The registration terminal provides a service providing terminal available state changing service for changing the service into an unavailable state when the service is unavailable. When the service provider closes the service (including restarting), the service provider can change the service from the available state to the unavailable state.
In one embodiment, the service discovery method provided by the invention further comprises the following steps:
at a set time, the following steps are performed for each available service in the registered service list:
And sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
The service provider provides a common web interface service for detecting the survival state of the service provider. The registration side provides a timing scanning task for periodically detecting the availability of the service provider, and for single-point use scenarios such as execution machine, the execution machine is often increased or decreased and the IP address is changed, and the service provider is not available, so that the task is used for completing the functions. All available state servers are first obtained from the registry database (the unavailable state server does not need to detect because it initializes to available state after the service is started successfully). And traversing all the servers in the available state, if the servers can be normally called, not changing the available state, and if the servers are wrong or overtime during calling, indicating that the service is unavailable, and calling the available state of the service providing end to change the service into the unavailable state.
In one embodiment, the service discovery method provided by the invention further comprises the following steps:
The deployment end obtains the service identifier of the service calling end, then sends a service inquiry request comprising the service identifier, and receives the ip and port number of the service providing end obtained according to the service identifier inquiry, and further writes the ip and port number of the service providing end into a calling configuration file of the service calling end so that the service calling end can call the service. The service calling end can call the service in the mode of http request or in the mode of instant remote procedure call.
In the invention, the function of the deployment end can be realized by a deployment program, and the deployment program can be configured on the service providing end and the service calling end.
In the scheme, when the service calling end is deployed, the deployment end modifies IP and port configuration items in the service calling end, wherein the configuration modification method can be a method of designating a corresponding script file in a deployment package applied by the service calling end and calling back the corresponding script file by the deployment end so as to achieve the purpose of dynamically discovering the service. If the number of service providing ends and server invokers in the target IP is larger than a preset threshold value, the deployment process is terminated, and the excessive and overrun number of applications is prompted to deployment personnel by feedback.
When the service providing end application is deployed, if the ports of the registered service exist on the same server, the deployment process is terminated, and the deployment personnel are fed back to prompt that the application ports are occupied. When the service providing end application is deployed, a script file in the deployment package is called, and the script file can check whether the service is available or not and send server IP, port, service identification, server environment information and the like.
When the service is deployed, firstly, the server environment information in the script file in the deployment package is detected, if the corresponding server environment information item can be installed, the deployment end can call the installation method in the script file to install the corresponding server environment information, and if the corresponding server environment information item cannot be installed, the deployment process is exited, and the server is fed back to deployment personnel to select a correct test executor server.
In one embodiment of the present invention, the service calling end is configured with a script file for writing the ip and port number of the service providing end into the call configuration file of the service calling end, the script file name is a specified service identifier, and the deployment end obtains the specified service identifier of the service calling end by reading the script file name.
The process of writing the ip and port number of the service providing end into the call configuration file of the service calling end specifically comprises the following steps: the deployment end calls the script file and transmits the script file to the ip and the port number of the service provider, and modifies the address of the service provider in the call configuration file into the ip and the port number of the transmitted service provider, so that the service provider can call the service of the service provider through the address of the service provider.
The script file may be configured in a deployment package of the service invocation side application. The deployment package may include a directory of script files for modifying server configuration information, the script files being for modifying service provider configuration information related to the service caller configuration file. The script file name is a service identifier, the script has two entries, namely an IP address and a port number, when the deployment script is deployed, a plurality of script files are detected in the script catalog, different script file names represent different service identifiers, the unique test identifiers are used for inquiring the IP and port information of the corresponding service to the registration terminal, then the script files corresponding to the unique test identifiers are called and the corresponding entries are transmitted, and the script files can modify the service provider information in the corresponding configuration files to complete the service discovery process.
In one embodiment, the service discovery method provided by the invention further comprises the following steps: when the service calling end is started, a calling configuration file is loaded, and the service is called for the service providing end by using the ip and the port number of the service providing end.
Before deployment, the deployment end calls the service of inquiring the designated service identifier and the server environment information meeting the conditions of the registration end to obtain the available service providing end, obtains the IP and port information to write into the corresponding configuration file of the application, and if the available service is not inquired, the deployment end reports errors and exits to feed back to deployment personnel.
When the application to which the service calling end belongs is started, a corresponding configuration file is loaded, the IP and port information is obtained and combined with calling information required by the known actual service to form an actual http web request, and the service is directly called by the service providing end.
By including the IP and port information, the service calling end can also implement service calling in an instant mode through other approaches such as remote procedure call, etc. according to the information, so that the instant technology is conveniently combined, and only the registration end is utilized to discover the service providing end.
The service discovery method provided by the invention can be suitable for complex service calling environments and has the advantages of light weight and simple and flexible configuration. The method is not influenced by the limitation of network ports due to the adoption of an http request mode, and can also run on the public network. The method adopts http request mode to register, inquire and detect service, realizes the independence of development language and frame, and is not influenced by the calling mode of actual service codes. The service discovery can be realized by writing a small amount of codes, the realization is easy, the use mode is flexible, and the method can be combined with the existing remote procedure call mode. The service provider and the service caller do not need to pay attention to the configuration related to service discovery, but only need to pay attention to the service codes. The registration end only plays a role of a bridge between the service providing end and the service calling end, the service is not participated in execution when being actually called, the pressure of the registration end is greatly reduced, and the registration end is convenient to horizontally expand due to the fact that the registration end adopts a web and database form. The mechanism of the registration end is also convenient for expanding functions, such as shielding operation, service statistics, service isolation of different environments and the like, and has strong expansibility. The scheme can also be combined with a relevant deployment technology with a test environment, so that a good test experience degree is achieved, for example, the occupied ports on the same server can not be occupied by other applications.
The embodiment of the present invention further provides a service discovery system, as shown in fig. 3, the system 300 includes: deployment side 301, registration side 302, service provider side 303, and service caller side 304.
The registration side 302 includes: a receiving module 3021 and a querying module 3022.
The receiving module 3021 is configured to receive a service query request sent by a deployment end. The query module 3022 is configured to query a corresponding service in the registration service list according to the service query request, and return address data of a service provider of the service to the deployment end. The address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service.
In the present invention, ip, port number, service identifier, occupied state and available state of a service provider of a service are maintained in a registration service list, and address data of the service provider includes: the ip and port number of the service provider, the service query request includes: the identity of the service(s),
the query module is further used for querying the service which has the same service identifier and is in the unoccupied state and the available state in the registered service list according to the service identifier, and returning the ip and the port number of the service providing end of the service to the deployment end.
In the present invention, the receiving module is further configured to receive a service registration request sent by the service provider, where the service registration request includes: ip, port number and service identifier of the service providing end;
the query module is further configured to determine whether the service exists in the registration service list, if yes, update the service to an occupied state and an available state, and if not, add ip, port number, and service identifier of a service provider of the service to the registration service list, and set the service to an unoccupied state and an available state.
In the invention, the receiving module is further used for receiving the occupied state change request, the unoccupied state change request and the unavailable state change request of the designated service sent by the service providing end;
the inquiry module is further used for updating the appointed service into an occupied state after the receiving module receives the occupied state change request, updating the appointed service into an unoccupied state after the receiving module receives the unoccupied state change request, and updating the appointed service into an unavailable state after the receiving module receives the unavailable state change request;
the service providing end sends the occupied state change request of the appointed service when starting to execute the appointed service, sends the unoccupied state change request of the appointed service when completing to execute the appointed service, and sends the unavailable state change request of the appointed service when closing.
In the present invention, the query module is further configured to perform the following steps for each service in the registered service list in the set time:
and sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
In the invention, the deployment end is used for acquiring the service identifier of the service calling end, then sending a service inquiry request comprising the service identifier, receiving the ip and the port number of the service providing end obtained according to the service identifier inquiry, and writing the ip and the port number of the service providing end into the calling configuration file of the service calling end so that the service calling end can call the service.
In the invention, a service calling end is configured with a script file for writing an ip and a port number of a service providing end into a calling configuration file of the service calling end, the script file name is a specified service identifier, and a deployment end acquires the specified service identifier of the service calling end by reading the script file name;
the deployment end is further used for calling the script file and transmitting the script file into the ip and the port number of the service provider, and modifying the address of the service provider in the calling configuration file into the ip and the port number of the transmitted service provider, so that the service calling end can call the service of the service provider through the address of the service provider.
In the invention, when the service calling end is started, a calling configuration file is loaded, and the service is called for the service providing end by using the ip and the port number of the service providing end.
Fig. 4 illustrates an exemplary system architecture 400 in which a service discovery method or service discovery system of embodiments of the invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 is used as a medium to provide communication links between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 405 via the network 404 using the terminal devices 401, 402, 403 to receive or send messages or the like. Various communication client applications can be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 405 may be a server that provides various services, for example, a background management server that receives a service query request sent by a deployment end and returns the address data to the deployment end.
It should be noted that, the service discovery method provided in the embodiment of the present invention is generally executed by the server 405, and accordingly, each end of the service discovery system is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, there is illustrated a schematic diagram of a computer system 500 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input section 506 including a keyboard, a mouse, and the like; an output portion 507 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as needed so that a computer program read therefrom is mounted into the storage section 508 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 509, and/or installed from the removable media 511. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 501.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a receiving module and a querying module. The names of these modules do not constitute a limitation on the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
receiving a service inquiry request sent by a deployment end;
inquiring corresponding service in a registration service list according to the service inquiry request, and returning address data of a service providing end of the service to a deployment end;
the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (16)

1. A service discovery method, comprising:
receiving a service inquiry request sent by a deployment end;
inquiring corresponding service in a registration service list according to the service inquiry request, and returning address data of a service providing end of the service to a deployment end;
the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service, the service calling end is deployed by the deployment end, and when the service calling end is deployed by the deployment end, the address data is written into the calling configuration file of the service calling end by modifying configuration items in the calling configuration file;
the registration service list maintains ip, port number, service identifier, occupied state and available state of a service providing end of a service, and address data of the service providing end comprises: ip and port number of the service provider, the service query request includes: the identity of the service(s),
inquiring corresponding service in the registration service list according to the service inquiry request, and returning address data of a service providing end of the service to a deployment end comprises the following steps: and inquiring the service which has the same service identifier and is in an unoccupied state and an available state in the registered service list according to the service identifier, and returning the ip and the port number of the service providing end of the service to the deployment end.
2. The method as recited in claim 1, further comprising:
receiving a service registration request sent by a service providing end, wherein the service registration request comprises: ip, port number and service identifier of the service providing end;
judging whether the registered service list has the service, if so, updating the service into an occupied state and an available state, otherwise, adding an ip, a port number and a service identifier of a service providing end of the service into the registered service list, and setting the service into an unoccupied state and an available state.
3. The method as recited in claim 1, further comprising:
receiving an occupied state change request of a specified service sent by a service providing end, and updating the specified service into an occupied state, wherein the service providing end sends the occupied state change request of the specified service when starting to execute the called specified service;
receiving an unoccupied state change request of a designated service sent by a service providing end, and updating the designated service to an unoccupied state, wherein the service providing end sends the unoccupied state change request of the designated service when executing the designated service which is called;
And receiving a request for changing the unavailable state of the specified service sent by the service providing end, and updating the specified service into the unavailable state, wherein the service providing end sends the request for changing the unavailable state of the specified service when the service providing end is closed.
4. The method as recited in claim 1, further comprising:
at a set time, the following steps are performed for each available state service in the registered service list:
and sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
5. The method as recited in claim 1, further comprising:
the deployment end obtains the service identification of the service calling end;
sending a service inquiry request comprising the service identifier, and receiving an ip and a port number of a service provider obtained according to the service identifier inquiry;
and writing the ip and the port number of the service providing end into a call configuration file of the service calling end so that the service calling end can call the service.
6. The method according to claim 5, wherein the service calling terminal is configured with a script file for writing an ip and a port number of the service providing terminal into a calling configuration file of the service calling terminal, the script file name is a specified service identifier, and the deployment terminal obtains the specified service identifier of the service calling terminal by reading the script file name;
Writing the ip and port number of the service providing end into a call configuration file of a service calling end comprises:
the deployment end calls the script file and transmits the script file into the ip and port number of the service providing end, and the service providing end address in the call configuration file is modified into the ip and port number of the transmitted service providing end, so that the service calling end can call the service of the service providing end through the service providing end address.
7. The method as recited in claim 1, further comprising:
when the service calling end is started, the calling configuration file is loaded, and the service is called for the service providing end by using the ip and the port number of the service providing end.
8. A service discovery system, comprising: the system comprises a deployment end, a registration end, a service providing end and a service calling end;
the registration end comprises:
the receiving module is used for receiving a service query request sent by the deployment end;
the query module is used for querying corresponding service in the registration service list according to the service query request and returning address data of a service providing end of the service to the deployment end;
the address data is used for writing a calling configuration file of the service calling end by the deployment end so that the service calling end can call the service, the service calling end is deployed by the deployment end, and when the service calling end is deployed by the deployment end, the address data is written into the calling configuration file of the service calling end by modifying configuration items in the calling configuration file;
The registration service list maintains ip, port number, service identifier, occupied state and available state of a service providing end of a service, and address data of the service providing end comprises: ip and port number of the service provider, the service query request includes: the identity of the service(s),
the query module is further configured to query, according to the service identifier, a service that has the same service identifier and is in an unoccupied state and an available state in the registered service list, and return an ip and a port number of a service provider of the service to a deployment end.
9. The system of claim 8, wherein the receiving module is further configured to receive a service registration request sent by a service provider, the service registration request comprising: ip, port number and service identifier of the service providing end;
the query module is further configured to determine whether the registered service list has the service, if yes, update the service to an occupied state and an available state, and if not, add an ip, a port number, and a service identifier of a service provider of the service to the registered service list, and set the service to an unoccupied state and an available state.
10. The system of claim 8, wherein the receiving module is further configured to receive an occupied state change request, an unoccupied state change request, and an unavailable state change request of a specified service sent by the service provider;
the inquiry module is further configured to update the specified service to an occupied state after the receiving module receives the occupied state change request, update the specified service to an unoccupied state after the receiving module receives the unoccupied state change request, and update the specified service to an unavailable state after the receiving module receives the unavailable state change request;
the service providing end sends the occupied state change request of the appointed service when the appointed service is started to be executed, sends the unoccupied state change request of the appointed service when the appointed service is completed to be executed, and sends the unavailable state change request of the appointed service when the appointed service is closed.
11. The system of claim 8, wherein the query module is further configured to, at a set time, perform the following steps for each available state service in the list of registered services:
And sending a detection request for detecting the address availability of the specified service to a service provider of the specified service, and updating the specified service to be in an unavailable state if an error or timeout is returned.
12. The system of claim 8, wherein the deployment side is configured to obtain a service identifier of the service invocation side, then send a service query request including the service identifier, receive an ip and a port number of the service provider side obtained according to the service identifier query, and write the ip and the port number of the service provider side into a call configuration file of the service invocation side, so that the service invocation side can invoke the service.
13. The system according to claim 8, wherein the service calling terminal is configured with a script file for writing an ip and a port number of the service providing terminal into a calling configuration file of the service calling terminal, the script file name is a specified service identifier, and the deployment terminal obtains the specified service identifier of the service calling terminal by reading the script file name;
the deployment end is further used for calling the script file and transmitting the script file into the ip and the port number of the service providing end, and modifying the address of the service providing end in the calling configuration file into the ip and the port number of the transmitted service providing end, so that the service calling end can call the service of the service providing end through the address of the service providing end.
14. The system of claim 8, wherein the service calling terminal loads the calling configuration file when starting up, and uses the ip and port number of the service providing terminal to call the service to the service providing terminal.
15. A service discovery electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-7.
16. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-7.
CN201810783952.3A 2018-07-17 2018-07-17 Service discovery method and system Active CN110730197B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810783952.3A CN110730197B (en) 2018-07-17 2018-07-17 Service discovery method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810783952.3A CN110730197B (en) 2018-07-17 2018-07-17 Service discovery method and system

Publications (2)

Publication Number Publication Date
CN110730197A CN110730197A (en) 2020-01-24
CN110730197B true CN110730197B (en) 2023-08-08

Family

ID=69217421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810783952.3A Active CN110730197B (en) 2018-07-17 2018-07-17 Service discovery method and system

Country Status (1)

Country Link
CN (1) CN110730197B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111404759B (en) * 2020-04-17 2022-03-04 腾讯科技(深圳)有限公司 Service detection method, rule configuration method, related device and medium
CN112925628A (en) * 2021-03-29 2021-06-08 建信金融科技有限责任公司 Service management method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102427451A (en) * 2011-12-06 2012-04-25 宁波电业局 Method and system for acquiring service application
CN102571550A (en) * 2010-12-30 2012-07-11 北京亿阳信通软件研究院有限公司 General information interaction platform and method
CN103188204A (en) * 2011-12-27 2013-07-03 腾讯科技(深圳)有限公司 Service control method and system in open platform
CN105141452A (en) * 2015-08-07 2015-12-09 北京思特奇信息技术股份有限公司 High-performance service system and method based on CXF
CN106708547A (en) * 2015-11-12 2017-05-24 卓望数码技术(深圳)有限公司 Service plug-in management method and system
WO2017185961A1 (en) * 2016-04-26 2017-11-02 中兴通讯股份有限公司 Method and apparatus for processing service discovery
CN108055248A (en) * 2017-11-30 2018-05-18 平安科技(深圳)有限公司 Remote invocation method, server and storage medium based on dubbo frames

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102571550A (en) * 2010-12-30 2012-07-11 北京亿阳信通软件研究院有限公司 General information interaction platform and method
CN102427451A (en) * 2011-12-06 2012-04-25 宁波电业局 Method and system for acquiring service application
CN103188204A (en) * 2011-12-27 2013-07-03 腾讯科技(深圳)有限公司 Service control method and system in open platform
CN105141452A (en) * 2015-08-07 2015-12-09 北京思特奇信息技术股份有限公司 High-performance service system and method based on CXF
CN106708547A (en) * 2015-11-12 2017-05-24 卓望数码技术(深圳)有限公司 Service plug-in management method and system
WO2017185961A1 (en) * 2016-04-26 2017-11-02 中兴通讯股份有限公司 Method and apparatus for processing service discovery
CN107317830A (en) * 2016-04-26 2017-11-03 中兴通讯股份有限公司 A kind of processing method and processing device of service discovery
CN108055248A (en) * 2017-11-30 2018-05-18 平安科技(深圳)有限公司 Remote invocation method, server and storage medium based on dubbo frames

Also Published As

Publication number Publication date
CN110730197A (en) 2020-01-24

Similar Documents

Publication Publication Date Title
US11157304B2 (en) System for peering container clusters running on different container orchestration systems
CN109547570B (en) Service registration method, device, registration center management equipment and storage medium
US10757197B2 (en) Self-extending cloud
CN106888233B (en) Data updating system and method
RU2670794C2 (en) Method and system for forming flexible node on local or distributed computing systems
US8185624B2 (en) Efficient on-demand provisioning of servers for specific software sets
US20150067167A1 (en) Hot pluggable extensions for access management system
CN112860451A (en) Multi-tenant data processing method and device based on SaaS
US20150242200A1 (en) Re-configuration in cloud computing environments
CN114189525B (en) Service request method and device and electronic equipment
US20130227153A1 (en) Computer-implemented method, computer system and computer readable medium
US20170033980A1 (en) Agent manager for distributed transaction monitoring system
US9986057B2 (en) UI framework support for portal systems
CN110730197B (en) Service discovery method and system
CN109828830B (en) Method and apparatus for managing containers
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN109218338B (en) Information processing system, method and device
CN111240760B (en) Application publishing method, system, storage medium and equipment based on registry
US11381665B2 (en) Tracking client sessions in publish and subscribe systems using a shared repository
US20220345517A1 (en) Unified application management for heterogeneous application delivery
CN114925066A (en) Data processing method and device, electronic equipment and storage medium
CN112559001B (en) Method and device for updating application
CN112202605A (en) Service configuration method, device, equipment and storage medium
CN110750424A (en) Resource inspection method and device
CN112579247A (en) Method and device for determining task state

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant