WO2021109640A1 - 一种注册方法及装置 - Google Patents

一种注册方法及装置 Download PDF

Info

Publication number
WO2021109640A1
WO2021109640A1 PCT/CN2020/111999 CN2020111999W WO2021109640A1 WO 2021109640 A1 WO2021109640 A1 WO 2021109640A1 CN 2020111999 W CN2020111999 W CN 2020111999W WO 2021109640 A1 WO2021109640 A1 WO 2021109640A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
registration
service provider
identifier
correspondence
Prior art date
Application number
PCT/CN2020/111999
Other languages
English (en)
French (fr)
Inventor
张伟
姜宇
孙宏伟
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021109640A1 publication Critical patent/WO2021109640A1/zh

Links

Images

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
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/50Network service management, e.g. ensuring proper service fulfilment according to agreements
    • H04L41/5041Network service management, e.g. ensuring proper service fulfilment according to agreements characterised by the time relationship between creation and deployment of a service
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/50Network service management, e.g. ensuring proper service fulfilment according to agreements
    • H04L41/5058Service discovery by the service manager
    • 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/56Provisioning of proxy services
    • H04L67/566Grouping or aggregating service requests, e.g. for unified processing

Definitions

  • This application relates to the computer field, in particular to a registration method and corresponding devices.
  • a distributed service framework usually includes the following roles: service provider, service consumer, and registry.
  • the service provider is the provider of the remote service
  • the service consumer is the service consumer that calls the remote service
  • the registry is used for registration.
  • discovery services are used for registration.
  • the service provider registers the service provided by the service provider with the registry at startup, and the service consumer can subscribe to the service provider’s service with the registry. After the registry receives the service consumer’s subscription request, the service provider’s The address is returned to the service consumer so that the service consumer can call the service according to the address of the service provider.
  • the registration center When registering the service provided by the service provider, the registration center needs to write the registration information of the service into the database.
  • the write cannot be written or the write fails due to network problems or problems with the database itself, the service provider cannot perceive when the registration can be successful, which causes the service provider's operational efficiency to decrease and affects the user experience.
  • This application provides a registration method, which can enable the service provider to perceive the success of the registration in time, improve the operation efficiency of the service provider, and thereby improve the user experience.
  • the application also provides corresponding devices, equipment, readable storage media, and computer program products.
  • this application provides a registration method that is applied to a registration center.
  • the registration center receives a service registration request sent by a service provider, and the service registration request carries the registration information of the service provider.
  • the registration of the service provider’s service can be performed based on the registration information. If a failure occurs during the execution of the registration, for example, when the connection between the registration center and the storage system is disconnected, the registration center still returns a registration success response to the service provider, and the service provider The user can perceive the registration success in a timely manner based on the registration success response, which can improve the operation efficiency of the service provider and improve the user experience.
  • the registration center can also store the registration information locally before the registration center returns a registration success response to the service provider.
  • the registration center can complete new service registration based on locally stored registration information when the network is unstable or the storage system is abnormal, which improves the registration success rate.
  • the registration information of the service provider includes the address of the service provider and the service identifier of the service provider, and the registration center is reporting to the service provider
  • the registration ID of the service is determined according to the service ID of the service provider, and then the registration information is stored in the storage system.
  • the registration center When a failure occurs during the execution of registration, for example, the connection between the registration center and the storage system is disconnected, and the storage information cannot be written into the storage system, the registration center locally stores the address of the service provider, the service ID, and the service registration ID and service The correspondence between the address of the provider (that is, the first correspondence) and the correspondence between the service registration identifier and the service identifier (that is, the second correspondence).
  • the registry can quickly match the address of the corresponding service provider based on the service identifier of the subscription service in the service subscription request, which improves the response efficiency of the registry.
  • the registration center can also monitor the connection status between the registration center and the storage system. If the connection between the registration center and the storage system is restored, The registration center can also store the address of the service provider, the service identifier, and the first and second correspondences in the storage system. By persistently storing the above information, the registration reliability can be guaranteed and the application based on the distributed service framework can be improved. The availability of the system.
  • the registration center also receives at least one service registration request, wherein the at least one service registration request may come from at least one service provider, the registration center
  • the service registration request may be received in the order in which the service registration request is received, and specifically may be the order of receipt time.
  • the registration center can store the service ID and the registration ID persistently , Improve storage resource utilization. Specifically, the registration center may write the service identifier and the second correspondence relationship into a local log file for storage in the order in which the service registration request is received.
  • the registration center also generates a data read cursor for the log file.
  • the data read cursor is used to record the position of the service identifier and the second correspondence in the log file. In this way, when the connection between the registration center and the storage system is restored, the registration The center can read the log file from the data reading position recorded by the data reading cursor, write the service ID and the second correspondence in the log file to the storage system for storage, and then the registration center updates the data reading of the data reading cursor record. position.
  • the registration center may also support compression of log files to save local storage space. Specifically, when the data reading cursor reaches the preset position, the registry can write the service identifier and the second correspondence after the data reading cursor into the backup file, and then delete the log file, and the registry can use the backup file as a new The log file for reading the service identifier and the second correspondence from the backup file, and writing the service identifier and the second correspondence to the storage system for storage.
  • the service identifier of the service provider can be any one of the service provider’s interface list and the characteristic value of the interface list or There are many types, among which, using the characteristic value of the interface list as the service identifier can reduce transmission overhead, speed up the transmission rate, and thereby improve registration efficiency.
  • the registration center can also obtain the interface list for subsequent registration. .
  • this application provides a registration device, the device comprising: a communication module and a registration module, the communication module is configured to receive a service registration request sent by a service provider, the service registration request carrying registration information of the service provider The registration module is configured to perform registration of the service of the service provider according to the registration information, and the communication module is also configured to return a registration success response to the service provider if a failure occurs during the execution of the registration.
  • the registration module is further configured to:
  • the registration information is stored locally before the registration success response is returned to the service provider.
  • the registration information of the service provider includes: the address of the service provider and the service identifier of the service provider;
  • the registration module is specifically used for:
  • the registration module is also used for:
  • the address of the service provider, the service identifier, and the first and second correspondences are stored locally, wherein the first correspondence includes the service information
  • the corresponding relationship between the registration identifier and the address of the service provider, and the second corresponding relationship is the corresponding relationship between the registration identifier of the service and the service identifier.
  • the registration module is further configured to:
  • the address of the service provider, the service identifier, and the first and second correspondences are stored in the storage system.
  • the communication module is specifically configured to:
  • the registration module is specifically used for:
  • the address of the service provider, the service identifier, and the first correspondence and the second correspondence are stored locally.
  • the registration module is specifically configured to:
  • the registration module is also used for:
  • the log file is read from the data reading position recorded by the data reading cursor, and the service identifier and the second correspondence in the log file are written into the The storage system performs storage and updates the data reading position recorded by the data reading cursor.
  • the apparatus further includes:
  • the compression module is configured to write the service identifier and the second correspondence after the data reading cursor into a backup file when the data reading cursor reaches a preset position, and delete the log file to remove The service identifier and the second correspondence relationship are read from the backup file, and the service identifier and the second correspondence relationship are written into the storage system for storage.
  • the service identifier of the service provider includes the service provider The interface list of and/or the characteristic value of the interface list;
  • the communication module is also used for:
  • the service identifier does not include the interface list, if the registration identifier determined according to the service identifier is a new identifier, the interface list is acquired.
  • the present application provides a computing device including a processor and a memory; the memory is used to store computer instructions; the processor is used to execute any of the first aspect or the first aspect according to the computer instructions.
  • the registration method in one possible implementation.
  • the present application provides a computer-readable storage medium having instructions stored in the computer-readable storage medium, which when run on a computer, cause the computer to execute the methods described in the above aspects.
  • this application provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the methods described in the above aspects.
  • FIG. 1 is a scene architecture diagram of the registration method in an embodiment of the application
  • FIG. 2 is a flowchart of the registration method in an embodiment of the application
  • FIG. 3 is a schematic diagram of writing registration information into a log file and a storage system in an embodiment of the application
  • FIG. 4 is a schematic structural diagram of a registration device in an embodiment of the application.
  • Fig. 5 is a schematic structural diagram of a computing device in an embodiment of the application.
  • the service provider is the provider of the remote service
  • the service consumer is the consumer (also called the caller) of the remote service.
  • the service consumer calls the service provider Services to achieve service consumption.
  • the computing device may include at least one service provider, and each service provider provides at least one service. Multiple service providers provide multiple services. In a distributed service framework, different service providers can provide the same service or the same service. In addition, the services provided by multiple service providers can also be partially the same.
  • the service consumer can consume at least one service provided by at least one service provider.
  • the service consumer can be an ordering service
  • the service provider can be a product detail service and a user service.
  • the ordering service obtains the price, color, and size of the product to be ordered by calling the product detail service. Attribute information, call the user service to obtain information such as the user's delivery address, and generate an order based on the above-mentioned product attribute information and delivery address information.
  • the registry is used to implement service registration and discovery. Specifically, the service provider registers its services with the registry at startup, and the service consumers subscribe to the registry for the services they need at startup, and the registry returns the address of the service provider to the service consumer for service Consumers make service calls.
  • the registry can return the address list of the service provider to the service consumer, and the service consumer selects a service provider based on the soft load balancing algorithm to call the service from the address list.
  • the registration center can also perform load balancing and return the address of the service provider to the service consumer, and the service consumer directly calls the service based on the address.
  • the service consumer can also cache the address or address list of the service provider returned by the service center. In this way, when the service center fails, the service consumer can also make service calls based on the service provider’s address in the cache, which can improve the overall The reliability of the application system.
  • the service provider, service consumer, and registry are deployed on at least one computing device.
  • the service provider, service consumer, and registration center may all be deployed on the same computing device, or they may be deployed on different computing devices.
  • the service provider, the service consumer, and the registration center can all be deployed in a virtual machine (virtual machine) or a different container (container) on at least one computing device, or they can be directly deployed on the computing device.
  • the computing device may be a terminal with a central processing unit (CPU) and/or a graphics processing unit (GPU).
  • the terminal includes but is not limited to a personal computer (PC), workstation, etc.
  • the computing device may also be a server with a CPU and/or GPU.
  • this application introduces the registration method provided by this application with service providers, service consumers, and registration centers located in different computing devices.
  • the registration method provided by this application includes but is not limited to being applied to the application environment as shown in FIG. 1.
  • the computing device 120 is connected to the computing device 140 and the computing device 160 respectively, the computing device 120 is also connected to the storage system 180, and the computing device 140 is connected to the computing device 160.
  • a registry 122 is deployed in the computing device 120, a service provider 142 is deployed in the computing device 140, and a service consumer 162 is deployed in the computing device 160.
  • the service provider 142 in the computing device 140 sends a service registration request to the registration center 122 in the computing device 120.
  • the service registration request carries the registration information of the service provider 142, and the registration center 122 in the computing device 120 responds to the registration information.
  • the registration center 122 in the computing device 120 determines the service registration identifier according to the service identifier of the service provider 142 in the registration information, and stores the registration information and the registration identifier in the storage system in association with each other. 180.
  • the registration center 122 in the computing device 120 When a failure occurs during the execution of registration, for example, the connection between the registration center 122 and the storage system 180 is disconnected, causing the registration information to fail to be written to the storage system 180, the registration center 122 in the computing device 120 locally stores the registration information, The registration success response is returned to the service provider 142.
  • the service consumer 162 in the computing device 160 may send a service subscription request to the registration center 122 in the computing device 120.
  • the service subscription request carries the service identifier of the subscription service, and the registration center 122 in the computing device 120 determines according to the service identifier.
  • the address of the corresponding service provider 142 returns the address of the service provider 142 to the service consumer 162 in the computing device 160.
  • the service consumer 162 in the computing device 160 can send a service call request to the service provider 142 in the computing device 140 according to the address of the service provider 142, and the service provider 142 can perform calculations based on the parameters carried in the service call request. The calculation result is then returned to the service consumer 162 in the computing device 160.
  • the method includes:
  • the service provider 142 sends a service registration request to the registration center 122.
  • the service registration request carries the registration information of the service provider 142.
  • the registration information of the service provider 142 includes at least the address of the service provider 142 and the service identifier of the service provider 142.
  • the service provider 142 registers, it needs to report the address of the service provider 142 and the service identifier of the service provided by the service provider 142 to the registration center 122 so that the service consumer 162 can follow the service provider 142 returned by the registration center 122
  • the address calls the service provided by the service provider 142.
  • the identification of the service provider 142 can uniquely identify the service provided by the service provider 142. Considering that the service provider 142 provides services to the outside world by providing an interface, the interface of the service provider 142 can be used to identify the service provided by the service provider 142. Therefore, the identification of the service provider 142 can be the service provider 142's identity. Interface list.
  • the transmission cost of the interface list of the service provider 142 is relatively high.
  • the service provider 142 can also determine the characteristic value of the interface list according to the interface list. For example, a hash algorithm can be used to perform the interface list. The hash value is calculated to obtain the characteristic value of the interface list.
  • the service provider 142 can use the characteristic value of the interface list as the identifier of the service provider 142, which can greatly reduce the transmission overhead.
  • the service identifier of the service provider 142 may include any one or more of the interface list of the service provider 142 and the characteristic values of the interface list.
  • the service identifier of the service provider 142 does not include the interface list, if the The registration identifier determined by the service identifier is a new identifier, that is, the service to be registered by the service provider 142 is a new service, and the registration center 122 may also obtain the interface list for subsequent registration.
  • the interface of the service provider 142 may have at least one version.
  • the service identifier may also include the interface version.
  • the service identification can be the interface list and the interface version of each interface in the interface list, and the service identification can also be the feature value calculated by the interface list and each interface version in the interface list.
  • the service identification can also be It is the interface list and the interface version of each interface in the interface list, and the characteristic value determined based on the interface list and the interface version.
  • the registration center 122 performs registration of the service of the service provider 142 according to the registration information.
  • the registration center 122 can determine the registration identifier of the service according to the service identifier of the service provider 142.
  • the registration identifier is used to identify all the services provided by the service provider 142, and then the registration center 122 corresponds to the registration identifier.
  • the registration information of is stored in the storage system 180, so as to realize the registration of the service of the service provider 142.
  • the registration center 122 can determine whether the service identifier already exists according to the service identifier of the service provider 142. If not, it indicates that the service provided by the service provider 142 is a new service, and the registration center 122 can be the service provider 142 The service assigns a registration identifier, and then the registration center 122 can associate the registration information with the registration identifier and store it in the storage system 180. If so, it means that the service provided by the service provider 142 is not a new service.
  • the association relationship of the registration identifier determines the registration identifier corresponding to the service provided by the service provider 142, and the registration center 122 can associate the address of the service provider 142 in the registration information with the registration identifier, and then store it in the storage system 180.
  • the storage system 180 may be a database or a database cluster.
  • the failure of the link between the registration center 122 and the storage system 180 or the abnormal process of the storage system 180 may cause the connection between the registration center 122 and the storage system 180 to be disconnected.
  • the connection between the registration center 122 and the storage system 180 is disconnected, it indicates that a failure occurs during the execution of the registration.
  • the registration center 122 can also store the registration information locally. In this way, the registration center 122 can still support service consumption based on the locally stored registration information.
  • the user 162 subscribes to this service, that is, the registration center 122 can still provide the service consumer 162 with the address of the service provider 142 based on the locally stored registration information.
  • the registration center 122 when the registration center 122 stores the registration information locally, it can specifically store the address and service identifier of the service provider 142 locally, and the correspondence between the service registration identifier and the address and service identifier of the service provider 142.
  • the registration center 122 can quickly determine the corresponding relationship based on the service ID of the subscription service in the service subscription request and the service registration ID and the address and service ID of the service provider 142.
  • the address of the service provider 142 corresponding to the service identifier improves the response efficiency of the registration center 122.
  • the registration center 122 when the registration center 122 stores the corresponding relationship between the registration identifier of the service and the address of the service provider 142, and the service identifier, it may also store the corresponding relationship between the registration identifier of the service and the address of the service provider 142, and the registration of the service respectively.
  • the corresponding relationship between the identifier and the service identifier The corresponding relationship between the registration identifier of the service and the address of the service provider 142 may be referred to as the first corresponding relationship, and the corresponding relationship between the registered identifier of the service and the service identifier may be referred to as the second corresponding relationship.
  • the registration center 122 may also store the service identifier and the second correspondence in the local when storing the registration information.
  • persistent storage is implemented, and the address of the service provider 142 and the first corresponding relationship are stored in a local cache.
  • the registration center 122 may store the address of the service provider 142 locally in the order in which the service registration request is received. , The service identifier and the first correspondence and the second correspondence.
  • the registration center 122 may write the service identification and the second correspondence into a local log file for storage in the order in which the service registration request is received.
  • the service registration request may be sorted according to the receiving time, and the receiving time is earlier.
  • the service registration requests are sorted first, and then the service identifiers in the sorted service registration requests and the second corresponding relationship corresponding to the service identifiers are written into the log file in turn, so as to realize the persistent storage of the registration identifiers and the corresponding service identifiers.
  • the registration center 122 may add the address of the service provider 142 and the first correspondence to the local cache in the order in which the service registration request is received, so as to realize the storage of the registration identifier and the address of the corresponding service provider 142.
  • the registration center 122 may also add the characteristic value of the interface list and the second correspondence to the cache, that is, the registration identifier and the characteristic value of the interface list corresponding to the registration identifier are added to the cache.
  • the cache when other service providers 142 perform service registration or service consumers 162 subscribe to services, they can quickly find the corresponding registration identifier through the above-mentioned corresponding relationship stored in the cache, and then quickly find the corresponding service provider 142 the address of.
  • the registry 122 can also disassemble the interface list of the service provider 142 into interface objects, and add the interface objects to the cache, so that the registry 122 can receive the service subscription request from the service consumer 162 , Quickly match the interface object corresponding to the service ID.
  • the registration center 122 returns a registration success response to the service provider 142.
  • the service provider 142 does not need to wait for the connection between the registration center 122 and the storage system 180 to be restored, and can sense the registration success in time, thereby improving the operation efficiency of the service provider 142. Improve user experience.
  • the registration center 122 when the registration center 122 returns a registration success response to the service provider 142, it can also carry a hit cache flag bit in the registration success response, where the hit cache flag bit can be set to true (for example, it can be set to 1 to indicate true ), in this way, when other service providers 142 that include the same service ID register with this registration center 122, the registration center 122 can directly return a registration success response based on the service ID, and add the address of the service provider 142 to the corresponding registration ID. Address list.
  • the registration center 122 can also monitor the connection status with the storage system 180. Specifically, the registration center 122 can monitor the connection status with the storage system 180 through a storage system connection monitoring thread, such as a database connection monitoring thread. When it is monitored that the connection between the registration center 122 and the storage system 180 is restored, the registration center 122 may also store the locally stored registration information in the storage system 180. Specifically, if the connection between the registration center 122 and the storage system 180 is restored, the registration center 122 may store the address of the service provider 142, the service identifier, and the first and second correspondences in the storage system 180.
  • a storage system connection monitoring thread such as a database connection monitoring thread.
  • connection between the registration center 122 and the storage system 180 is unstable, for example, the connection between the registration center 122 and the storage system 180 is intermittent.
  • the registration center 122 stores the registration information locally, it can also generate data to read The data reading cursor can be used to record the data reading position. In this way, when the connection with the storage system 180 is restored, the registration center 122 saves the locally stored registration information to the storage system 180 according to the data reading position.
  • the registration center 122 receives the service registration request in the order, such as service registration request 1, service registration request 2...service registration request n, n is a positive integer, and the service identifier in each service registration request
  • the second correspondence relationship corresponding to the service identification is written into the log file, where the second correspondence relationship represents the correspondence relationship between the registration identification and the service identification, and writing the service identification and the second correspondence relationship into the log file is equivalent to writing the registration identification And the corresponding service ID is written into the log file.
  • the registration center 122 also generates a data reading cursor for the above log file. As shown in FIG. 3, the data reading cursor is used to record the position of the service identifier and the second correspondence in the log file, which may Initialized to 0. When the connection between the registration center 122 and the storage system 180 is restored, the registration center 122 can read the data reading position recorded by the cursor from the data, that is, the position of the service identifier and the second correspondence in the log file , Read the log file, write the service identifier and the second correspondence in the log file into the storage system 180 for storage, and then update the data read recorded by the data read cursor Take the location.
  • each service can be provided by at least one service provider 142. Therefore, at least one service registration request received by the registration center 122 may include a service registration request that includes the same service identifier.
  • the service identifiers are the same, based on The registration ID determined by the service ID is also the same. Based on this, when the registration center 122 writes the corresponding service ID and registration ID into the log file, if the same service ID and the same registration ID exist, the merge process is performed , That is, only record once for the same service ID and the same registration ID.
  • the registration center 122 may also support compression of data in the log file. Specifically, when the data reading cursor reaches a preset position, the registration center 122 may write the service identifier and the second correspondence after the data reading cursor into a backup file, and then delete the log file. Use the backup file as a new log file to read the service identification and the second correspondence from the backup file, and write the service identification and the second correspondence to the storage system 180 storage. In this way, data compression in the log file can be achieved.
  • the size of the log file is 10000 megabytes (MByte, MB), and the preset position is set according to an empirical value, for example, it can be 5000MB.
  • the registration center 122 will log the file
  • the service identifier after 5000MB and the second correspondence are written into the backup file, and then the log file is deleted, and the backup file is used as a new log file.
  • the new log file is 5000MB, thus compressing the log file by 50%.
  • S212 The service consumer 162 sends a service subscription request to the registration center 122.
  • the service consumer 162 When the service consumer 162 connects to the registration center 122, it can send a service subscription request to the registration center 122 to subscribe to the service.
  • the service subscription request carries the service identifier of the subscription service.
  • the service subscription request may carry any one or more of the interface list of the subscription service or the characteristic values of the interface list.
  • the registration center 122 returns the address of the service provider 142 to the service consumer 162.
  • the registration center 122 may determine the address of the service provider 142 according to the service identifier of the subscription service, and then return the address of the service provider 142 to the service consumer 162 in response to the service subscription request.
  • the registration center 122 can determine the address of the service provider 142 by searching the first correspondence and the second correspondence.
  • the registration center 122 can determine the registration corresponding to the service identifier of the subscription service according to the second correspondence. Then, the registration center 122 determines the address of the service provider 142 corresponding to the registration identifier according to the first correspondence, thereby obtaining the address of the service provider 142 corresponding to the service identifier of the subscription service.
  • S216 The service consumer 162 sends a service invocation request to the service provider 142 according to the address of the service provider 142.
  • the remote service called by the service consumer 162 may be referred to as a target service.
  • the service call request carries the interface identifier and parameters of the target service.
  • the service consumer 162 can call at least one service of the service provider 142. Therefore, the above-mentioned service call request carries the interface identifier of at least one interface and the parameters corresponding to each interface.
  • S218 The remote service of the service provider 142 performs calculations according to the parameters in the service call request, and obtains the calculation results.
  • the remote service specifically refers to the remote service called by the service consumer 162, that is, the target service.
  • the target service When each target service is running, it performs calculations based on the parameters corresponding to the target service's interface to obtain the calculation result.
  • the target service can be an order search service.
  • the service consumer 162 sends a service call request to the service provider 142.
  • the service call request includes the interface identifier (interface 1 in this example) and time parameters (in this example).
  • the service provider 142 can run an order search service based on interface 1.
  • the order search service searches for all orders in 2019 according to time parameters to obtain search results, and the search results are the calculation results of the order search service.
  • S220 The service provider 142 invokes a service response to the service consumer 162.
  • the service call response includes the calculation result of the remote service.
  • the service consumer 162 can call at least one remote service, the calculation time required for each remote service may be different, that is, the time for each remote service to obtain the calculation result may be different. Therefore, in some cases, the service provider 142 may send the calculation result through at least one service call response.
  • S212 to S214 are an implementation manner for the service consumer 162 to subscribe to the service after the service registration is completed.
  • S216 to S220 are an implementation manner of service consumption.
  • service subscription and service consumption may also be implemented in other ways.
  • the execution order of S212 to S220 and S210 may be arbitrary, for example, it may be executed in parallel, or may be executed sequentially in a set order.
  • the foregoing S206 and S210 may also be implemented in other manners, which is not limited in this embodiment.
  • this application fails during the execution of the registration process, and still returns a registration success response to the service provider 142, which solves the problem that the service provider 142 cannot perceive when the registration is successful in the traditional registration method, which leads to the service provider 142 The problem of reduced operating efficiency and poor user experience.
  • the registration center 122 has the function of locally storing registration information. When the connection between the registration center 122 and the storage system 180 is disconnected, the registration center 122 saves the registration information locally. In this way, the new service can still be registered successfully, thus overcoming the registration.
  • the center 122 strongly relies on the write operation of the database, which causes the database itself to be abnormal or the network connection between the registry 122 and the database is abnormal. The new service cannot complete the registration problem, which improves the registration success rate and further improves the application system based on the distributed service framework. Availability and stability. ,
  • this application also supports capacity expansion of the storage system 180 to meet the capacity requirements of the application system.
  • the storage system 180 may include multiple database clusters, each database has a corresponding log file, and each log file is independent.
  • the registration center 122 receives the service registration request, it determines the service ID in the service registration request and the database cluster to which the corresponding registration ID is to be written. If the connection between the registration center 122 and the service database cluster is disconnected, the service ID And the corresponding registration identifier is written into the log file corresponding to the database cluster, thereby avoiding that the service identifiers and corresponding registration identifiers in all service registration requests are written into the same file and the file size is too large.
  • the registry 122 can read the registration ID and service ID from the log file corresponding to the service database cluster, and write the registration ID and service ID to the database cluster. This can avoid the need to skip the problem of not belonging to the registration ID and service ID of the database cluster, and can reduce the pressure of writing data in each database cluster.
  • the registration center 122 determines the service identifier in the service registration request and the database cluster to which the corresponding registration identifier is to be written, it can be specifically determined according to the service identifier in the service registration request. Specifically, when the service identifier includes the characteristic value of the interface list of the service provider 142, the registration center 122 may perform a modulo operation (mod) on the characteristic value of the interface list, and determine the service identifier and the corresponding registration identifier according to the result of the operation. The database cluster to write to.
  • mod modulo operation
  • the registration center 122 can determine the connection between the registration center 122 and the storage system 180 during the restart process State, if the connection between the registry 122 and the storage system 180 is still disconnected, the registry 122 starts the storage system connection monitoring thread, and when the connection between the registry 122 and the storage system 180 is restored, the registration information is read from the local and stored in the storage System 180.
  • the registry 122 When the registry 122 restarts and the registration information that has not been stored in the storage system 180 is stored locally, if the connection between the registry 122 and the storage system 180 has been restored, the registry 122 can also read the data recorded by the data reading cursor The location starts to read the log file and writes the service identifier and the second correspondence in the log file to the storage system 180. In addition, the registry 122 also reads the address of the service provider 142 from the cache and writes the first correspondence into the storage system 180. To the storage system 180, so as to store the local registration information in the storage system 180.
  • the registry 122 also adds the service identifier and the second correspondence to the cache, disassembles the interface list of the service provider 142 into interface objects and adds them to the cache, so as to provide subscriptions for the service consumer 162 based on the above-mentioned information stored in the cache. service.
  • the registration center 122 may be independent, or may exist in the form of a cluster.
  • all the registration centers 122 monitor changes in the address list corresponding to the registration identifier in the storage system 180 (specifically, a database or a database cluster).
  • the registration center 122 when an address addition event is received, the registration center 122 first searches the cache whether the corresponding registration identifier already exists, if it exists, then updates the address list corresponding to the registration identifier, if it does not exist, then according to the registration The identifier searches the storage system 180 for the address list corresponding to the registration identifier and the service identifier corresponding to the registration identifier, and adds the address list corresponding to the registration identifier and the service identifier corresponding to the registration identifier to the cache of the registry 122, At this time, if the service consumer 162 corresponding to the service identifier is connected to the registration center 122, an address change message is sent to the service consumer 162, and the address change message carries the address list of the service provider 142 corresponding to the service identifier .
  • the registration device is used to implement the registration center 122 as shown in FIG. 1, and the device 300 includes:
  • the communication module 310 is configured to receive a service registration request sent by the service provider 142, where the service registration request carries the registration information of the service provider 142;
  • the registration module 320 is configured to perform registration of the service of the service provider 142 according to the registration information
  • the communication module 310 is further configured to return a registration success response to the service provider 142 if a failure occurs during the execution of the registration.
  • the registration module 320 is further configured to:
  • the registration information is stored locally before the registration success response is returned to the service provider 142.
  • the registration information of the service provider 142 includes: the address of the service provider 142 and the service identifier of the service provider 142;
  • the registration module 320 is specifically configured to:
  • the registration module 320 is also used for:
  • the address of the service provider 142, the service identifier, and the first and second correspondences are stored locally, where the first correspondence includes the The corresponding relationship between the registration identifier of the service and the address of the service provider 142, and the second corresponding relationship is the corresponding relationship between the registration identifier of the service and the service identifier.
  • the registration module 320 is further configured to:
  • the storage system 180 stores the address of the service provider 142, the service identifier, and the first and second correspondences.
  • the communication module is specifically used for:
  • the registration module 320 is specifically configured to:
  • the address of the service provider 142, the service identifier, and the first correspondence and the second correspondence are stored locally.
  • the registration module 320 is specifically configured to:
  • the registration module 320 is also used for:
  • the log file is read from the data reading position recorded by the data reading cursor, and the service identifier and the second correspondence in the log file are written in the log file.
  • the storage system 180 performs storage and updates the data reading position recorded by the data reading cursor.
  • the device 300 further includes:
  • the compression module 330 is configured to, when the data reading cursor reaches a preset position, write the service identifier and the second correspondence after the data reading cursor into a backup file, and delete the log file to The service identifier and the second correspondence relationship are read from the backup file, and the service identifier and the second correspondence relationship are written into the storage system 180 for storage.
  • the service identifier of the service provider 142 includes an interface list of the service provider 142 and/or a characteristic value of the interface list;
  • the communication module 310 is also used for:
  • the service identifier does not include the interface list, if the registration identifier determined according to the service identifier is a new identifier, the interface list is acquired.
  • the registration device 300 may correspond to the method described in the embodiment of the present application, and the above-mentioned and other operations and/or functions of each module in the registration device 300 are used to implement the corresponding methods of each method in FIG. 2. For the sake of brevity, the process will not be repeated here.
  • modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physically separated. Modules can be located in one place or distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • connection relationship between the modules indicates that they have a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
  • FIG. 5 provides a computing device 400.
  • the computing device 400 may be a terminal or a server, and the computing device may be specifically used to implement the function of the registration apparatus 300 in the embodiment shown in FIG. 4 or the function of the registration center 122 shown in FIG. 1.
  • the computing device 400 includes a bus 401, a processor 402, a communication interface 403, and a memory 404.
  • the processor 402, the memory 404, and the communication interface 403 communicate through a bus 401.
  • the bus 401 may be a peripheral component interconnect standard (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only one thick line is used to represent in FIG. 5, but it does not mean that there is only one bus or one type of bus.
  • the communication interface 403 is used to communicate with the outside, such as receiving the conflict resolution result or receiving the source file of the collaborative processing page generated based on the conflict resolution result.
  • the processor 402 may be a central processing unit.
  • the memory 404 may include a volatile memory (volatile memory), such as a random access memory (RAM).
  • the memory 404 may also include non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory, hard disk drives (HDD), or solid state drives (solid state drives). , SSD).
  • the memory 404 stores executable code, and the processor 402 executes the executable code to execute the aforementioned registration method.
  • the functions required to execute the registration module 320 and the compression module 330 in FIG. 4 The software or program code is stored in the memory 404, the function of the communication module 310 is implemented through the communication interface 403, and the processor 402 is configured to execute instructions in the memory 404 and execute the registration method applied to the registration device 300.
  • the processor 402 may call the instructions stored in the memory 404 to perform the following operations:
  • a registration success response is returned to the service provider 142.
  • the computing device 400 may correspond to the registration apparatus 300 in the embodiment of the present application, and may correspond to the corresponding subject that executes the method shown in FIG. 2 in the embodiment of the present application, and the computing device 400
  • the above-mentioned and other operations and/or functions of each device in FIG. 2 are used to realize the corresponding process of each method in FIG. 2, and for the sake of brevity, they will not be repeated here.
  • the embodiment of the present application also provides a computer-readable storage medium, including instructions, which when run on the computing device 400, cause the computing device 400 to execute the above-mentioned registration method applied to the registration apparatus 300.
  • the embodiment of the present application also provides a computer program product.
  • the computing device 400 executes any one of the aforementioned registration methods.
  • the computer program product may be a software installation package.
  • the computer program product may be downloaded and executed on the computing device 400.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, training device, or data.
  • the center uses wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to transmit to another website, computer, training equipment, or data center.
  • the computer-readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a training device or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (Solid State Disk, SSD)).
  • a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape
  • an optical medium for example, a DVD
  • a semiconductor medium for example, a solid state disk (Solid State Disk, SSD)

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请提供了一种注册方法,包括:接收服务提供者发送的服务注册请求,服务注册请求携带有服务提供者的注册信息,根据注册信息执行对服务提供者的服务的注册,若所述注册的执行过程中发生失败,向服务提供者返回注册成功响应。如此可以使得服务提供者及时感知注册成功,提高了服务提供者的运营效率,进而提高了用户体验。

Description

一种注册方法及装置
本申请要求于2019年12月06日提交中国国家知识产权局、申请号为201911244685.3、发明名称为“一种注册方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机领域,尤其涉及一种注册方法以及对应的装置等。
背景技术
考虑到扩展性和可用性,越来越多的应用系统,尤其是大规模应用系统采用分布式服务框架实现。一个分布式服务框架通常包括以下角色:服务提供者、服务消费者以及注册中心,其中,服务提供者即远程服务的提供方,服务消费者即调用远程服务的服务消费方,注册中心用于注册和发现服务。
服务提供者在启动时向注册中心注册该服务提供者所提供的服务,服务消费者即可向注册中心订阅服务提供者的服务,注册中心接收服务消费者的订阅请求后,将服务提供者的地址返回给服务消费者,以便服务消费者根据服务提供者的地址进行服务调用。
注册中心在为服务提供者提供的服务注册时,需要将服务的注册信息写入数据库。当由于网络问题或者数据库自身问题导致无法写入或者写入失败时,服务提供者无法感知何时能够注册成功,如此导致服务提供者的运营效率降低,影响用户体验。
发明内容
本申请提供了一种注册方法,该方法可以使得服务提供者及时感知注册成功,提高了服务提供者的运营效率,进而提高了用户体验。本申请还提供了对应的装置、设备、可读存储介质以及计算机程序产品。
第一方面,本申请提供了一种注册方法,该方法应用于注册中心,具体地,注册中心接收服务提供者发送的服务注册请求,该服务注册请求携带有服务提供者的注册信息,注册中心可以根据该注册信息执行对服务提供者的服务的注册,若注册的执行过程中发生失败,例如注册中心与存储系统的连接断开时,注册中心仍向服务提供者返回注册成功响应,服务提供者能够基于该注册成功响应及时感知注册成功,如此可以提高服务提供者的运营效率,提高用户体验。
结合第一方面,在第一方面的第一种实现方式中,若注册的执行过程中发生失败,在注册中心向服务提供者返回注册成功响应之前,注册中心还可以在本地存储注册信息,如此,注册中心可以在网络不稳定或者存储系统异常情况下,也能够基于本地存储的注册信息完成新服务注册,提高了注册成功率。
结合第一方面的第一种实现方式,在第一方面的第二种实现方式中,服务提供者的注册信息包括服务提供者的地址和服务提供者的服务标识,注册中心在对服务提供者的服务 注册时,具体是根据服务提供者的服务标识确定服务的注册标识,然后将注册信息存储至存储系统。当注册的执行过程中发生失败,例如注册中心与存储系统的连接断开,导致存储信息无法写入存储系统时,注册中心在本地存储服务提供者的地址、服务标识以及服务的注册标识与服务提供者的地址的对应关系(即第一对应关系)和服务的注册标识与服务标识的对应关系(即第二对应关系)。
基于此,服务消费者在向注册中心发送服务订阅请求后,注册中心能够基于上述服务订阅请求中订阅服务的服务标识,快速匹配对应的服务提供者的地址,提高了注册中心的响应效率。
结合第一方面的第二种实现方式,在第一方面的第三种实现方式中,注册中心还可以对该注册中心与存储系统的连接状态进行监控,若注册中心与存储系统的连接恢复,则注册中心还可以在存储系统存储服务提供者的地址、服务标识以及第一对应关系和第二对应关系,通过对上述信息进行持久化存储可以保障注册可靠性,提高基于分布式服务框架的应用系统的可用性。结合第一方面的第二种实现方式,在第一方面的第四种实现方式中,注册中心还接收至少一个服务注册请求,其中,至少一个服务注册请求可以来自至少一个服务提供者,注册中心在本地存储服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系时,可以按照接收所述服务注册请求的顺序,具体可以是接收时间的先后顺序,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。这种顺序存储方式可以减小将上述信息转存至存储系统的资源开销,提高转存效率。
结合第一方面的第四种实现方式,在第一方面的第五种实现方式中,考虑到服务标识与注册标识发生变化的概率较低,注册中心可以对服务标识和注册标识进行持久化存储,提高存储资源利用率。具体地,注册中心可以按照接收服务注册请求的顺序,将服务标识和第二对应关系写入本地的日志文件进行存储。
进一步地,注册中心还针对日志文件生成数据读取游标,该数据读取游标用于记录服务标识和第二对应关系在日志文件中的位置,如此,注册中心与存储系统的连接恢复时,注册中心可以从数据读取游标记录的数据读取位置读取日志文件,将日志文件中的服务标识和第二对应关系写入存储系统进行存储,然后注册中心更新数据读取游标记录的数据读取位置。
显然,通过增加数据读取游标实时记录数据读取位置,可以实现根据注册中心与存储系统的连接状态实时地将本地存储的服务标识和第二对应关系存储至存储系统,对于网络不稳定的场景,仍然具有较高可用性。
结合第一方面的第五种实现方式,在第一方面的第六种实现方式中,注册中心还可以支持对日志文件进行压缩,以节省本地存储空间。具体地,当数据读取游标到达预设位置时,注册中心可以将数据读取游标之后的服务标识和第二对应关系写入备份文件,然后删除日志文件,注册中心可以将该备份文件作为新的日志文件,从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统进行存储。
结合第一方面的第二种实现方式至第六种实现方式中的任一种实现方式,服务提供者的服务标识可以是服务提供者的接口列表和接口列表的特征值中的任意一种或多种,其中, 采用接口列表的特征值作为服务标识可以减少传输开销,加快传输速率,进而提高注册效率。
需要说明的是,服务标识不包括接口列表时,例如服务标识为接口列表的特征值时,若根据该服务标识确定的注册标识为新标识,则注册中心还可以获取接口列表,以便后续注册使用。
第二方面,本申请提供一种注册装置,该装置包括:通信模块和注册模块,通信模块用于接收服务提供者发送的服务注册请求,该服务注册请求携带有所述服务提供者的注册信息,注册模块用于根据所述注册信息执行对所述服务提供者的服务的注册,通信模块还用于若所述注册的执行过程中发生失败,向所述服务提供者返回注册成功响应。
结合第二方面,在第二方面的第一种实现方式中,所述注册模块还用于:
所述注册的执行过程中发生失败之后,所述向所述服务提供者返回注册成功响应之前,在本地存储所述注册信息。
结合第二方面的第一种实现方式,在第二方面的第二种实现方式中,所述服务提供者的注册信息包括:所述服务提供者的地址和所述服务提供者的服务标识;
所述注册模块具体用于:
根据所述服务提供者的服务标识确定所述服务的注册标识;
将所述注册信息存储至存储系统;
所述注册模块还用于:
若与所述存储系统的连接断开,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系,其中,所述第一对应关系包括所述服务的注册标识与所述服务提供者的地址的对应关系,所述第二对应关系为所述服务的注册标识与所述服务标识的对应关系。
结合第二方面的第二种实现方式,在第二方面的第三种实现方式中,所述注册模块还用于:
若与所述存储系统的连接恢复,在所述存储系统存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
结合第二方面的第二种实现方式,在第二方面的第四种实现方式中,所述通信模块具体用于:
接收至少一个服务注册请求,所述至少一个服务注册请求来自至少一个服务提供者;
所述注册模块具体用于:
按照接收所述服务注册请求的顺序,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
结合第二方面的第四种实现方式,在第二方面的第五种实现方式中,所述注册模块具体用于:
按照接收所述服务注册请求的顺序,将所述服务标识和所述第二对应关系写入本地的日志文件进行存储;
所述注册模块还用于:
针对所述日志文件生成数据读取游标,所述数据读取游标用于记录所述服务标识和所 述第二对应关系在所述日志文件中的位置;
若与所述存储系统的连接恢复,从所述数据读取游标记录的数据读取位置读取所述日志文件,将所述日志文件中的所述服务标识和第二对应关系写入所述存储系统进行存储,更新所述数据读取游标记录的所述数据读取位置。
结合第二方面的第五种实现方式,在第二方面的第六种实现方式中,所述装置还包括:
压缩模块,用于当所述数据读取游标到达预设位置,将所述数据读取游标之后的所述服务标识和所述第二对应关系写入备份文件,删除所述日志文件,以从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统进行存储。
结合第二方面的第二种实现方式至第六种实现方式中的任一种实现方式,在第二方面的第七种实现方式中,所述服务提供者的服务标识包括所述服务提供者的接口列表和/或者所述接口列表的特征值;
所述通信模块还用于:
当所述服务标识不包括所述接口列表时,若根据所述服务标识确定的注册标识为新标识,获取所述接口列表。
第三方面,本申请提供一种计算设备,包括处理器和存储器;所述存储器,用于存储计算机指令;所述处理器,用于根据所述计算机指令执行如第一方面或第一方面任一种可能实现方式中的注册方法。
第四方面,本申请提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面所述的方法。
第五方面,本申请提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述各方面所述的方法。
本申请在上述各方面提供的实现方式的基础上,还可以进行进一步组合以提供更多实现方式。
附图说明
图1为本申请实施例中注册方法的场景架构图;
图2为本申请实施例中注册方法的流程图;
图3为本申请实施例中注册信息写入日志文件以及存储系统的示意图;
图4为本申请实施例中注册装置的一个结构示意图;
图5为本申请实施例中计算设备的一个结构示意图。
具体实施方式
下面结合附图,对本申请的实施例进行描述。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方 式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
本申请中,服务提供者(provider)是远程服务的提供方,服务消费者(consumer)是远程服务的消费方(也称作调用方),在具体实现时,服务消费者通过调用服务提供者的服务实现服务消费。
计算设备中可以包括至少一个服务提供者,每个服务提供者提供至少一种服务。多个服务提供者提供多个服务,在分布式服务框架中,不同的服务提供者可以提供相同的服务或者相同的服务,此外,多个服务提供者提供的服务也可以部分相同。服务消费者可以消费至少一个服务提供者提供的至少一种服务。例如,在电商系统中,服务消费者可以是下单服务,服务提供者可以是商品详情服务和用户服务,下单服务通过调用商品详情服务获取待下单商品的价格、颜色、尺寸等商品属性信息,调用用户服务获取用户的收货地址等信息,根据上述商品属性信息和收货地址信息生成订单。
服务消费者在调用服务提供者的服务时,需要知晓服务提供者的地址。服务提供者的地址具体是从注册中心(registry)查询得到的。其中,注册中心用于实现服务注册与发现。具体地,服务提供者在启动时向注册中心注册自己提供的服务,服务消费者在启动时向注册中心订阅自己所需的服务,注册中心向服务消费者返回服务提供者的地址,以供服务消费者进行服务调用。
需要说明,注册中心可以向服务消费者返回服务提供者的地址列表,服务消费者从地址列表中,基于软负载均衡算法选择一个服务提供者进行服务调用。当然,注册中心也可以进行负载均衡后,向服务消费者返回服务提供者的地址,服务消费者直接根据该地址进行服务调用。服务消费者还可以将服务中心返回的服务提供者的地址或地址列表进行缓存,如此,服务中心发生故障时,服务消费者也可以基于缓存中服务提供者的地址进行服务调用,如此可以提高整个应用系统的可靠性。
服务提供者、服务消费者、注册中心部署至少一个计算设备上。服务提供者、服务消费者、注册中心可以均部署在同一计算设备,也可以部署在不同的计算设备。此外,服务提供者、服务消费者、注册中心均可部署在至少一个计算设备上的虚拟机(virtual machine)或者不同容器(container)中,也可以直接部署在计算设备上。计算设备可以是具有中央处理器(central processing unit,CPU)和/或图形处理器(graphics processing unit,GPU)的终端,终端包括但不限于个人计算机(personal computer,PC)、工作站等。该计算设备也可以是具有CPU和/或GPU的服务器。
为了便于理解,本申请以服务提供者、服务消费者、注册中心分别位于不同的计算设备对本申请提供的注册方法进行介绍。
在实际应用时,本申请提供的注册方法包括但不限于应用于如图1所示的应用环境中。
如图1所示,计算设备120分别与计算设备140和计算设备160连接,计算设备120还与存储系统180连接,计算设备140与计算设备160连接。计算设备120中部署有注册中心122,计算设备140中部署有服务提供者142,计算设备160中部署有服务消费者162。
计算设备140中的服务提供者142向计算设备120中的注册中心122发送服务注册请 求,该服务注册请求中携带有服务提供者142的注册信息,计算设备120中的注册中心122根据该注册信息执行对服务提供者142的服务的注册,具体地,计算设备120中的注册中心122根据注册信息中服务提供者142的服务标识确定服务的注册标识,将注册信息与注册标识关联存储至存储系统180,当注册的执行过程中发生失败,例如注册中心122与存储系统180的连接断开,导致注册信息写入存储系统180失败时,计算设备120中的注册中心122在本地存储该注册信息,向服务提供者142返回注册成功响应。
计算设备160中的服务消费者162可以向计算设备120中的注册中心122发送服务订阅请求,该服务订阅请求中携带有订阅服务的服务标识,计算设备120中的注册中心122根据该服务标识确定对应的服务提供者142的地址,向计算设备160中的服务消费者162返回服务提供者142的地址。如此,计算设备160中的服务消费者162可以根据服务提供者142的地址向计算设备140中的服务提供者142发送服务调用请求,服务提供者142可以根据服务调用请求中携带的参数进行运算,然后将运算结果返回给计算设备160中的服务消费者162。
为了使得本申请的技术方案更加清楚、易于理解,下面将从服务提供者142、服务消费者162、注册中心122以及存储系统180交互的角度对本申请的注册方法的各个步骤进行详细介绍。
参见图2所示的注册方法的流程图,该方法包括:
S202:服务提供者142向注册中心122发送服务注册请求。
所述服务注册请求携带有所述服务提供者142的注册信息。服务提供者142的注册信息至少包括服务提供者142的地址和服务提供者142的服务标识。服务提供者142在进行注册时,需要向注册中心122上报服务提供者142的地址以及服务提供者142所提供的服务的服务标识,以便服务消费者162能够根据注册中心122返回的服务提供者142的地址调用服务提供者142所提供的服务。
服务提供者142的标识能够唯一标识该服务提供者142所提供的服务。考虑到服务提供者142是通过提供接口的方式对外提供服务,服务提供者142的接口可以用于标识服务提供者142所提供的服务,因此,服务提供者142的标识可以为服务提供者142的接口列表。
当服务提供者142存在多个接口时,服务提供者142的接口列表的传输开销较大,服务提供者142还可以根据接口列表确定接口列表的特征值,例如可以利用哈希算法对接口列表进行计算得到哈希值,从而获得接口列表的特征值,服务提供者142可以将接口列表的特征值作为服务提供者142的标识,如此可以大幅减少传输开销。
服务提供者142的服务标识可以包括服务提供者142的接口列表和接口列表的特征值的任意一种或多种,当服务提供者142的服务标识不包括所述接口列表时,若根据所述服务标识确定的注册标识为新标识,也即服务提供者142所要注册的服务为新服务,注册中心122还可以获取所述接口列表,以便后续注册时使用。
需要说明的是,服务提供者142的接口可以存在至少一个版本,为了区分不同版本的接口,服务标识还可以包括接口版本。具体地,服务标识可以是接口列表和接口列表中每个接口的接口版本,服务标识也可以是接口列表和接口列表中每个接口版本计算出的特征 值,在有些情况下,服务标识也可以是接口列表和接口列表中每个接口的接口版本以及基于接口列表和接口版本确定的特征值。
S204:注册中心122根据所述注册信息执行对所述服务提供者142的服务的注册。
在具体实现时,注册中心122可以根据服务提供者142的服务标识确定所述服务的注册标识,该注册标识用于标识该服务提供者142提供的所有服务,然后注册中心122将该注册标识对应的所述注册信息存储至存储系统180,从而实现对服务提供者142的服务的注册。
其中,注册中心122可以根据服务提供者142的服务标识确定该服务标识是否已存在,若否,则表征该服务提供者142提供的服务为新服务,注册中心122可以为该服务提供者142的服务分配注册标识,然后注册中心122可以将注册信息与注册标识进行关联,并存储至存储系统180,若是,则表征该服务提供者142提供的服务不是新服务,注册中心122可以根据服务标识与注册标识的关联关系确定该服务提供者142提供的服务对应的注册标识,注册中心122可以将注册信息中服务提供者142的地址与注册标识进行关联,然后存储至存储系统180即可。其中,存储系统180可以是数据库或者数据库集群。
S206:若所述注册的执行过程中发生失败,注册中心122在本地存储注册信息。
可以理解,注册中心122与存储系统180的链路故障、存储系统180的进程异常等情况下,均可以导致注册中心122与存储系统180的连接断开。当注册中心122与存储系统180的连接断开时,表征注册的执行过程中发生失败,注册中心122还可以在本地存储注册信息,如此,注册中心122仍然能够基于本地存储的注册信息支持服务消费者162对此服务进行订阅,即注册中心122仍然能够基于本地存储的注册信息向服务消费者162提供服务提供者142的地址。
为了实现服务注册,注册中心122在本地存储注册信息时,具体可以是在本地存储服务提供者142的地址、服务标识以及服务的注册标识与服务提供者142的地址、服务标识的对应关系,如此,服务消费者162向注册中心122发送服务订阅请求后,注册中心122可以基于服务订阅请求中订阅服务的服务标识以及服务的注册标识与服务提供者142的地址、服务标识的对应关系快速确定与该服务标识对应的服务提供者142的地址,提高了注册中心122的响应效率。
进一步地,注册中心122在存储服务的注册标识与服务提供者142的地址、服务标识的对应关系时,也可以分别存储服务的注册标识与服务提供者142的地址的对应关系,以及服务的注册标识与服务标识的对应关系。其中,服务的注册标识与服务提供者142的地址的对应关系可以称之为第一对应关系,服务的注册标识与服务标识的对应关系可以称之为第二对应关系。通过将上述对应关系分别进行存储,例如通过两张数据库表进行存储,可以提高查找效率,进而提高响应效率。
考虑到服务提供者142的地址发生变化的概率相对较高,而服务标识发生变化的概率相对较低,注册中心122在存储注册信息时,还可以将服务标识以及第二对应关系存储在本地的文件系统中,实现持久化存储,将服务提供者142的地址以及第一对应关系存储在本地的缓存中。
当注册中心122接收到至少一个服务注册请求,其中,至少一个服务注册请求来自至 少一个服务提供者142,注册中心122可以按照接收服务注册请求的顺序,在本地存储所述服务提供者142的地址、所述服务标识以及第一对应关系和第二对应关系。
具体地,注册中心122可以按照接收服务注册请求的顺序,将服务标识和第二对应关系写入本地的日志文件进行存储,具体可以是将服务注册请求按照接收时间进行排序,接收时间较早的服务注册请求排序靠前,然后将排序后的服务注册请求中的服务标识以及与该服务标识对应的第二对应关系依次写入日志文件,从而实现注册标识以及对应的服务标识持久化存储,此外,注册中心122可以按照接收服务注册请求的顺序,将服务提供者142的地址以及第一对应关系添加至本地的缓存中,从而实现注册标识以及对应的服务提供者142的地址的存储。
需要说明,服务标识包括接口列表的特征值时,注册中心122还可以将接口列表的特征值和第二对应关系也添加至缓存,即将注册标识以及与注册标识对应的接口列表的特征值添加至缓存中,如此,其他服务提供者142在进行服务注册或者服务消费者162订阅服务时,可以通过缓存中存储的上述对应关系快速查找到对应的注册标识,进而快速查找到对应的服务提供者142的地址。
进一步地,注册中心122还可以将服务提供者142的接口列表拆解为接口对象,并将该接口对象添加至缓存中,如此,注册中心122可以在接收到服务消费者162的服务订阅请求时,快速匹配与服务标识对应的接口对象。
S208:注册中心122向所述服务提供者142返回注册成功响应。
注册中心122通过向服务提供者142返回注册成功响应,如此,服务提供者142无需等待注册中心122与存储系统180的连接恢复,即可及时感知注册成功,从而提高服务提供者142的运营效率,提高用户体验。
在本实施例中,注册中心122向服务提供者142返回注册成功响应时,还可以在注册成功响应中携带命中缓存标志位,其中,命中缓存标志位可以设置为true(例如可以置1表征true),如此,包括相同服务标识的其他服务提供者142再向此注册中心122注册时,注册中心122可以直接根据服务标识返回注册成功响应,将该服务提供者142的地址添加到对应注册标识的地址列表中。
S210:若注册中心122与存储系统180的连接恢复,注册中心122在存储系统180存储注册信息。
注册中心122还可以监控与存储系统180的连接状态,具体地,注册中心122可以通过存储系统连接监控线程如数据库连接监控线程等监控与存储系统180的连接状态。当监控到注册中心122与存储系统180的连接恢复时,注册中心122还可以将本地存储的注册信息存储至存储系统180。具体地,若注册中心122与存储系统180的连接恢复,注册中心122可以在所述存储系统180存储所述服务提供者142的地址、所述服务标识以及第一对应关系和第二对应关系。
考虑到注册中心122与存储系统180的连接不稳定的情况,例如,注册中心122与存储系统180的连接时断时续的情况,注册中心122在本地存储注册信息时,还可以生成数据读取游标,该数据读取游标可以用于记录数据读取位置,如此,注册中心122在与存储系统180的连接恢复时,根据该数据读取位置将本地存储的注册信息保存至存储系统180 中。
具体请参见图3,注册中心122按照接收服务注册请求的顺序,如服务注册请求1、服务注册请求2……服务注册请求n的顺序,n为正整数,将各服务注册请求中的服务标识和该服务标识对应的第二对应关系写入日志文件,其中,第二对应关系表征注册标识与服务标识的对应关系,将服务标识和第二对应关系写入日志文件,即相当于将注册标识和对应的服务标识写入日志文件。
注册中心122针对上述日志文件还生成数据读取游标,如图3所示,该数据读取游标用于记录所述服务标识和所述第二对应关系在所述日志文件中的位置,其可以初始化为0,当注册中心122与存储系统180的连接恢复,注册中心122可以从所述数据读取游标记录的数据读取位置,即服务标识和第二对应关系在所述日志文件中的位置,读取所述日志文件,将所述日志文件中的所述服务标识和所述第二对应关系写入所述存储系统180进行存储,然后更新所述数据读取游标记录的所述数据读取位置。
需要说明的是,每个服务可以由至少一个服务提供者142提供,因此,注册中心122接收到的至少一个服务注册请求中可以存在包括相同服务标识的服务注册请求,当服务标识相同时,基于该服务标识确定的注册标识也是相同的,基于此,注册中心122在将具有对应关系的服务标识和注册标识写入日志文件时,若存在相同的服务标识以及相同的注册标识,则进行合并处理,即针对相同的服务标识以及相同的注册标识仅记录一次。
可以理解,注册中心122还可以支持对日志文件中的数据进行压缩。具体地,注册中心122可以在数据读取游标到达预设位置时,将所述数据读取游标之后的所述服务标识和所述第二对应关系写入备份文件,然后删除所述日志文件,将备份文件作为新的日志文件,以从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统180进行存储。如此,可以实现日志文件中的数据压缩。
为了便于理解,下面结合一具体示例对日志文件中的数据压缩过程进行说明。
在该示例中,日志文件的大小为10000兆字节(MByte,MB),预设位置根据经验值设置,例如可以是5000MB,当数据读取游标到达5000MB的位置时,注册中心122将日志文件中5000MB之后的服务标识和第二对应关系写入备份文件,然后删除日志文件,将备份文件作为新的日志文件,该新的日志文件为5000MB,如此将日志文件压缩了50%。
S212:服务消费者162向注册中心122发送服务订阅请求。
当服务消费者162连接至注册中心122时,可以向注册中心122发送服务订阅请求,以订阅服务。其中,服务订阅请求中携带有订阅服务的服务标识。例如服务订阅请求中可以携带订阅服务的接口列表或者接口列表的特征值中的任意一种或多种。
S214:注册中心122向服务消费者162返回服务提供者142的地址。
具体地,注册中心122可以根据订阅服务的服务标识确定服务提供者142的地址,然后响应于服务订阅请求,向服务消费者162返回服务提供者142的地址。其中,注册中心122确定服务提供者142的地址具体可以通过查找第一对应关系和第二对应关系实现,具体地,注册中心122可以根据第二对应关系,确定与订阅服务的服务标识对应的注册标识,然后注册中心122根据第一对应关系确定与注册标识对应的服务提供者142的地址,从而得到与订阅服务的服务标识对应的服务提供者142的地址。
S216:服务消费者162根据服务提供者142的地址向服务提供者142发送服务调用请求。
为了便于描述,可以将服务消费者162所调用的远程服务称之为目标服务。服务调用请求中携带目标服务的接口标识和参数。其中,服务消费者162可以调用服务提供者142的至少一个服务,因此,上述服务调用请求中携带至少一个接口的接口标识,以及与各接口对应的参数。
S218:服务提供者142的远程服务根据服务调用请求中参数进行运算,得到运算结果。
远程服务具体是指服务消费者162所调用的远程服务,也即目标服务。每个目标服务在运行时,根据该目标服务的接口对应的参数进行运算,从而得到运算结果。为了便于理解,结合具体示例进行说明。在电商系统中,目标服务可以是订单搜索服务,服务消费者162向服务提供者142发送服务调用请求,该服务调用请求中包括接口标识(该示例中为接口1)以及时间参数(该示例中为2019年),如此,服务提供者142可以基于接口1运行订单搜索服务,订单搜索服务根据时间参数搜索2019年内的所有订单,得到搜索结果,该搜索结果即为订单搜索服务的运算结果。
S220:服务提供者142向服务消费者162服务调用响应。
服务调用响应中包括远程服务的运算结果。考虑到服务消费者162可以调用至少一个远程服务,每个远程服务所需要的运算时间可以是不同的,即每个远程服务获得运算结果的时间可以是不同的。因此,在有些情况下,服务提供者142可以通过至少一条服务调用响应发送运算结果。
需要说明的是,图2所示实施例仅仅是本申请提供的注册方法的一种示意性实施方式,其中,S212至S214为服务注册完成后服务消费者162进行服务订阅的一种实现方式,S216至S220为服务消费的一种实现方式,在本申请其他可能的实施方式中,服务订阅和服务消费也可以通过其他方式实现。此外,S212至S220与S210的执行顺序可以是任意的,例如可以是并行执行,也可以是按照设定的顺序先后执行。在本申请其他可能的实施方式中,上述S206、S210也可以通过其他方式实现,本实施例对此不作限定。
通过上述内容的描述,本申请在注册的执行过程中发生失败,仍向服务提供者142返回注册成功响应,解决了传统注册方法中服务提供者142无法感知何时注册成功,进而导致服务提供者142运营效率降低,用户体验变差的问题。并且,注册中心122具有本地存储注册信息的功能,当注册中心122与存储系统180的连接断开时,注册中心122将注册信息保存在本地,如此,新服务仍能够注册成功,从而克服了注册中心122强依赖数据库的写入操作,导致数据库自身异常或者注册中心122与数据库的网络连接异常时新服务无法完成注册的问题,提高了注册成功率,进而提高了基于分布式服务框架的应用系统的可用性与稳定性。、
在一些可能的实现方式中,本申请还支持对存储系统180进行扩容,以满足应用系统对容量的需求。具体地,存储系统180中可以包括多个数据库集群,每个数据库具有对应的日志文件,每个日志文件是独立的。注册中心122在接收到服务注册请求时,确定该服务注册请求中的服务标识以及对应的注册标识所要写入的数据库集群,若注册中心122与 该服务库集群的连接断开,则将服务标识以及对应的注册标识写入该数据库集群对应的日志文件,从而避免所有服务注册请求中的服务标识以及对应的注册标识写入同一个文件导致文件体积过大。当注册中心122与该服务库集群的连接恢复时,注册中心122可以从该服务库集群对应的日志文件中读取注册标识和服务标识,并将该注册标识和服务标识写入该数据库集群,如此可以避免需要跳过不属于该数据库集群中注册标识和服务标识的问题,而且可以降低每个数据库集群的写入数据压力。
其中,注册中心122在确定服务注册请求中的服务标识以及对应的注册标识所要写入的数据库集群时,具体可以根据服务注册请求中的服务标识确定。具体地,服务标识中包括服务提供者142的接口列表的特征值时,注册中心122可以对上述接口列表的特征值进行取模运算(mod),根据运算结果确定服务标识以及对应的注册标识所要写入的数据库集群。
在图2所示实施例基础上,当注册中心122与存储系统180的连接未恢复时,若注册中心122发生重启,则注册中心122可以在重启过程中判断注册中心122与存储系统180的连接状态,若注册中心122与存储系统180的连接仍然断开,则注册中心122启动存储系统连接监控线程,并在注册中心122与存储系统180的连接恢复时,从本地读取注册信息存储至存储系统180中。
当注册中心122重启,本地还存储有未存储到存储系统180的注册信息时,若注册中心122与存储系统180的连接已恢复,则注册中心122还可以从数据读取游标记录的数据读取位置开始读取日志文件,将日志文件中的服务标识和第二对应关系写入至存储系统180,此外,注册中心122还从缓存中读取服务提供者142的地址和第一对应关系写入至存储系统180,从而实现将本地的注册信息存储到存储系统180。此外,注册中心122还将服务标识和第二对应关系添加至缓存,将服务提供者142的接口列表拆解为接口对象添加至缓存,以便基于缓存中存储的上述信息为服务消费者162提供订阅服务。
还需要说明的是,在实际应用时,注册中心122可以是独立的,也可以是以集群形式存在。当注册中心122以集群形式存在时,所有注册中心122监听存储系统180(具体可以是数据库或数据库集群)中注册标识对应的地址列表的变化情况。对于任意注册中心122,当接收到地址添加事件时,注册中心122先从缓存中查找对应的注册标识是否已存在,若存在,则更新该注册标识对应的地址列表,若不存在,则根据注册标识从存储系统180中查找该注册标识对应的地址列表以及该注册标识对应的服务标识,并将该注册标识对应的地址列表以及该注册标识对应的服务标识添加至该注册中心122的缓存中,此时,如果注册中心122连接有与该服务标识对应的服务消费者162,则向服务消费者162发送地址变更消息,该地址变更消息中携带该服务标识所对应的服务提供者142的地址列表。
需要说明的是,对于上述方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制。
本领域的技术人员根据以上描述的内容,能够想到的其他合理的步骤组合,也属于本申请的保护范围内。其次,本领域技术人员也应该熟悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本申请所必须的。
上文中结合图1至图3,详细描述了本申请所提供的注册方法,下面将结合图4至图5,描述根据本申请所提供的注册装置和设备。
参见图4所示的注册装置的结构示意图,该注册装置用于实现如图1中所示的注册中心122,该装置300包括:
通信模块310,用于接收服务提供者142发送的服务注册请求,所述服务注册请求携带有所述服务提供者142的注册信息;
注册模块320,用于根据所述注册信息执行对所述服务提供者142的服务的注册;
所述通信模块310,还用于若所述注册的执行过程中发生失败,向所述服务提供者142返回注册成功响应。
可选地,所述注册模块320还用于:
所述注册的执行过程中发生失败之后,所述向所述服务提供者142返回注册成功响应之前,在本地存储所述注册信息。
可选地,所述服务提供者142的注册信息包括:所述服务提供者142的地址和所述服务提供者142的服务标识;
所述注册模块320具体用于:
根据所述服务提供者142的服务标识确定所述服务的注册标识;
将所述注册信息存储至存储系统180;
所述注册模块320还用于:
若与所述存储系统180的连接断开,在本地存储所述服务提供者142的地址、所述服务标识以及第一对应关系和第二对应关系,其中,所述第一对应关系包括所述服务的注册标识与所述服务提供者142的地址的对应关系,所述第二对应关系为所述服务的注册标识与所述服务标识的对应关系。
可选地,所述注册模块320还用于:
若与所述存储系统180的连接恢复,在所述存储系统180存储所述服务提供者142的地址、所述服务标识以及第一对应关系和第二对应关系。
可选地,所述通信模块具体用于:
接收至少一个服务注册请求,所述至少一个服务注册请求来自至少一个服务提供者142;
所述注册模块320具体用于:
按照接收所述服务注册请求的顺序,在本地存储所述服务提供者142的地址、所述服务标识以及第一对应关系和第二对应关系。
可选地,所述注册模块320具体用于:
按照接收所述服务注册请求的顺序,将所述服务标识和所述第二对应关系写入本地的日志文件进行存储;
所述注册模块320还用于:
针对所述日志文件生成数据读取游标,所述数据读取游标用于记录所述服务标识和所述第二对应关系在所述日志文件中的位置;
若与所述存储系统180的连接恢复,从所述数据读取游标记录的数据读取位置读取所述日志文件,将所述日志文件中的所述服务标识和第二对应关系写入所述存储系统180进 行存储,更新所述数据读取游标记录的所述数据读取位置。
可选地,所述装置300还包括:
压缩模块330,用于当所述数据读取游标到达预设位置,将所述数据读取游标之后的所述服务标识和所述第二对应关系写入备份文件,删除所述日志文件,以从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统180进行存储。
可选地,所述服务提供者142的服务标识包括所述服务提供者142的接口列表和/或者所述接口列表的特征值;
所述通信模块310还用于:
当所述服务标识不包括所述接口列表时,若根据所述服务标识确定的注册标识为新标识,获取所述接口列表。
根据本申请实施例的注册装置300可对应于执行本申请实施例中描述的方法,并且注册装置300中的各个模块的上述和其它操作和/或功能分别为了实现图2中的各个方法的相应流程,为了简洁,在此不再赘述。
另外需说明的是,以上所描述的实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
图5提供了一种计算设备400。该计算设备400可以是终端或者是服务器,该计算设备具体可以用于实现上述图4所示实施例中注册装置300的功能或者上述图1所示的注册中心122的功能。计算设备400包括总线401、处理器402、通信接口403和存储器404。处理器402、存储器404和通信接口403之间通过总线401通信。总线401可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。通信接口403用于与外部通信,例如接收冲突消解结果或者接收基于冲突消解结果生成的协同处理页面的源文件等。
其中,处理器402可以为中央处理器。存储器404可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器404还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drives,HDD)或固态硬盘(solid state drives,SSD)。
存储器404中存储有可执行代码,处理器402执行该可执行代码以执行前述注册方法。
具体地,在实现图4所示实施例的情况下,且图4实施例中所描述的各模块为通过软件实现的情况下,执行图4中的注册模块320、压缩模块330功能所需的软件或程序代码存储在存储器404中,通信模块310功能通过通信接口403实现,处理器402用于执行存 储器404中的指令,执行应用于注册装置300的注册方法。
具体地,处理器402可以调用存储器404中存储的指令,执行以下操作:
接收服务提供者142发送的服务注册请求,所述服务注册请求携带有所述服务提供者142的注册信息;
根据所述注册信息执行对所述服务提供者142的服务的注册;
若所述注册的执行过程中发生失败,向所述服务提供者142返回注册成功响应。
应理解,根据本申请实施例的计算设备400可对应于本申请实施例中的注册装置300,并可以对应于执行根据本申请实施例中图2所示方法中的相应主体,并且计算设备400中的各个器件的上述和其它操作和/或功能分别为了实现图2中的各个方法的相应流程,为了简洁,在此不再赘述。
本申请实施例还提供了一种计算机可读存储介质,包括指令,当其在计算设备400上运行时,使得计算设备400执行上述应用于注册装置300的注册方法。
本申请实施例还提供了一种计算机程序产品,所述计算机程序产品被计算设备400执行时,所述计算设备400执行前述注册方法的任一方法。该计算机程序产品可以为一个软件安装包,在需要使用前述注册方法的任一方法的情况下,可以下载该计算机程序产品并在计算设备400上执行该计算机程序产品。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。
但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。
所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk, SSD))等。

Claims (18)

  1. 一种注册方法,其特征在于,所述方法包括:
    接收服务提供者发送的服务注册请求,所述服务注册请求携带有所述服务提供者的注册信息;
    根据所述注册信息执行对所述服务提供者的服务的注册;
    若所述注册的执行过程中发生失败,向所述服务提供者返回注册成功响应。
  2. 根据权利要求1所述的方法,其特征在于,所述注册的执行过程中发生失败之后,所述向所述服务提供者返回注册成功响应之前,所述方法还包括:
    在本地存储所述注册信息。
  3. 根据权利要求2所述的方法,其特征在于,所述服务提供者的注册信息包括:所述服务提供者的地址和所述服务提供者的服务标识;
    所述根据所述注册信息执行对所述服务提供者的服务的注册,包括:
    根据所述服务提供者的服务标识确定所述服务的注册标识;
    将所述注册信息存储至存储系统;
    若所述注册的执行过程中发生失败,在本地存储所述注册信息,包括:
    若与所述存储系统的连接断开,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系,其中,所述第一对应关系包括所述服务的注册标识与所述服务提供者的地址的对应关系,所述第二对应关系为所述服务的注册标识与所述服务标识的对应关系。
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:
    若与所述存储系统的连接恢复,在所述存储系统存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
  5. 根据权利要求3所述的方法,其特征在于,所述接收服务提供者发送的服务注册请求包括:
    接收至少一个服务注册请求,所述至少一个服务注册请求来自至少一个服务提供者;
    所述在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系包括:
    按照接收所述服务注册请求的顺序,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
  6. 根据权利要求5所述的方法,其特征在于,所述按照接收所述服务注册请求的顺序,在本地存储所述服务标识和第二对应关系包括:
    按照接收所述服务注册请求的顺序,将所述服务标识和第二对应关系写入本地的日志文件进行存储;
    所述方法还包括:
    针对所述日志文件生成数据读取游标,所述数据读取游标用于记录所述服务标识和所述第二对应关系在所述日志文件中的位置;
    若与所述存储系统的连接恢复,从所述数据读取游标记录的数据读取位置读取所述日志文件,将所述日志文件中的所述服务标识和所述第二对应关系写入所述存储系统进行存 储,更新所述数据读取游标记录的所述数据读取位置。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    当所述数据读取游标到达预设位置,将所述数据读取游标之后的所述服务标识和所述第二对应关系写入备份文件;
    删除所述日志文件,以从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统进行存储。
  8. 根据权利要求3至7任一项所述的方法,其特征在于,所述服务提供者的服务标识包括所述服务提供者的接口列表和/或者所述接口列表的特征值;
    当所述服务标识不包括所述接口列表时,若根据所述服务标识确定的注册标识为新标识,所述方法还包括:
    获取所述接口列表。
  9. 一种注册装置,其特征在于,所述装置包括:
    通信模块,用于接收服务提供者发送的服务注册请求,所述服务注册请求携带有所述服务提供者的注册信息;
    注册模块,用于根据所述注册信息执行对所述服务提供者的服务的注册;
    所述通信模块,还用于若所述注册的执行过程中发生失败,向所述服务提供者返回注册成功响应。
  10. 根据权利要求9所述的装置,其特征在于,所述注册模块还用于:
    所述注册的执行过程中发生失败之后,所述向所述服务提供者返回注册成功响应之前,在本地存储所述注册信息。
  11. 根据权利要求10所述的装置,其特征在于,所述服务提供者的注册信息包括:所述服务提供者的地址和所述服务提供者的服务标识;
    所述注册模块具体用于:
    根据所述服务提供者的服务标识确定所述服务的注册标识;
    将所述注册信息存储至存储系统;
    所述注册模块还用于:
    若与所述存储系统的连接断开,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系,其中,所述第一对应关系包括所述服务的注册标识与所述服务提供者的地址的对应关系,所述第二对应关系为所述服务的注册标识与所述服务标识的对应关系。
  12. 根据权利要求11所述的装置,其特征在于,所述注册模块还用于:
    若与所述存储系统的连接恢复,在所述存储系统存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
  13. 根据权利要求11所述的装置,其特征在于,所述通信模块具体用于:
    接收至少一个服务注册请求,所述至少一个服务注册请求来自至少一个服务提供者;
    所述注册模块具体用于:
    按照接收所述服务注册请求的顺序,在本地存储所述服务提供者的地址、所述服务标识以及第一对应关系和第二对应关系。
  14. 根据权利要求13所述的装置,其特征在于,所述注册模块具体用于:
    按照接收所述服务注册请求的顺序,将所述服务标识和所述第二对应关系写入本地的日志文件进行存储;
    所述注册模块还用于:
    针对所述日志文件生成数据读取游标,所述数据读取游标用于记录所述服务标识和所述第二对应关系在所述日志文件中的位置;
    若与所述存储系统的连接恢复,从所述数据读取游标记录的数据读取位置读取所述日志文件,将所述日志文件中的所述服务标识和第二对应关系写入所述存储系统进行存储,更新所述数据读取游标记录的所述数据读取位置。
  15. 根据权利要求14所述的装置,其特征在于,所述装置还包括:
    压缩模块,用于当所述数据读取游标到达预设位置,将所述数据读取游标之后的所述服务标识和所述第二对应关系写入备份文件,删除所述日志文件,以从所述备份文件中读取所述服务标识和所述第二对应关系,将所述服务标识和所述第二对应关系写入所述存储系统进行存储。
  16. 根据权利要求11至15任一项所述的装置,其特征在于,所述服务提供者的服务标识包括所述服务提供者的接口列表和/或者所述接口列表的特征值;
    所述通信模块还用于:
    当所述服务标识不包括所述接口列表时,若根据所述服务标识确定的注册标识为新标识,获取所述接口列表。
  17. 一种计算设备,其特征在于,包括:
    处理器和存储器;
    所述处理器,用于存储计算机指令;
    所述处理器,用于根据所述计算机指令执行如权利要求1至8任一项所述的方法。
  18. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行如权利要求1至8任一项所述的方法。
PCT/CN2020/111999 2019-12-06 2020-08-28 一种注册方法及装置 WO2021109640A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911244685.3A CN112929401B (zh) 2019-12-06 2019-12-06 一种注册方法及装置
CN201911244685.3 2019-12-06

Publications (1)

Publication Number Publication Date
WO2021109640A1 true WO2021109640A1 (zh) 2021-06-10

Family

ID=76161938

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/111999 WO2021109640A1 (zh) 2019-12-06 2020-08-28 一种注册方法及装置

Country Status (2)

Country Link
CN (1) CN112929401B (zh)
WO (1) WO2021109640A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114125035A (zh) * 2021-09-27 2022-03-01 烽火通信科技股份有限公司 一种大规模扩容场景下服务注册方法与装置
CN114500300A (zh) * 2022-01-07 2022-05-13 支付宝(杭州)信息技术有限公司 服务注册处理方法及装置
CN114598743A (zh) * 2022-03-17 2022-06-07 上海小度技术有限公司 一种服务发现方法、装置、电子设备及存储介质
CN115002185A (zh) * 2022-05-09 2022-09-02 北京城市网邻信息技术有限公司 数据的处理方法、装置、电子设备及存储介质
CN116319505A (zh) * 2023-02-10 2023-06-23 安芯网盾(北京)科技有限公司 路由分发方法及装置

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116388853B (zh) * 2023-04-26 2023-12-12 中国人民解放军32039部队 对多目标接力数传服务的注册认证方法和装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102520956A (zh) * 2011-12-19 2012-06-27 厦门游家网络有限公司 一种新型的数据存储方法及系统
CN107979659A (zh) * 2018-01-23 2018-05-01 深圳市天贝物联科技有限公司 基于域名的便捷访问方法、系统、电子设备及存储介质
US20190036985A1 (en) * 2017-07-26 2019-01-31 T-Mobile Usa, Inc. Server-managed notifications for maintaining registered state
CN110213401A (zh) * 2019-06-18 2019-09-06 四川新网银行股份有限公司 一种IPv6环境下的数据中心主机域名自动注册方法

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070162478A1 (en) * 2006-01-06 2007-07-12 Samsung Electronics Co., Ltd. Method of achieving service configurability within telecommunication devices
US9189768B2 (en) * 2007-05-31 2015-11-17 Amazon Technologies, Inc. Method and apparatus for providing fulfillment services
CN101242413B (zh) * 2008-01-30 2012-12-12 中国科学院计算技术研究所 同根多层nat网络中服务资源地址获取系统及方法
CN105141452A (zh) * 2015-08-07 2015-12-09 北京思特奇信息技术股份有限公司 一种基于cxf的高性能服务系统及方法
CN105450757A (zh) * 2015-12-02 2016-03-30 联动优势电子商务有限公司 一种服务管理方法及系统
CN107635022A (zh) * 2016-07-18 2018-01-26 华为软件技术有限公司 跨内外网服务访问方法和装置
CN107888551A (zh) * 2016-09-30 2018-04-06 北京神州泰岳软件股份有限公司 一种远程服务调用方法、装置和系统
CN108984316A (zh) * 2018-06-15 2018-12-11 广州视源电子科技股份有限公司 一种用于分布式数据处理的方法、装置、电子设备及计算机存储介质
CN109445853A (zh) * 2018-09-21 2019-03-08 深圳市买买提信息科技有限公司 一种回调请求统一处理方法及平台
CN109818959B (zh) * 2019-01-28 2021-05-28 心动网络股份有限公司 一种远程服务通信方法、服务器和系统
CN110311896B (zh) * 2019-05-28 2021-06-15 西南电子技术研究所(中国电子科技集团公司第十研究所) 机载平台服务注册中心系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102520956A (zh) * 2011-12-19 2012-06-27 厦门游家网络有限公司 一种新型的数据存储方法及系统
US20190036985A1 (en) * 2017-07-26 2019-01-31 T-Mobile Usa, Inc. Server-managed notifications for maintaining registered state
CN107979659A (zh) * 2018-01-23 2018-05-01 深圳市天贝物联科技有限公司 基于域名的便捷访问方法、系统、电子设备及存储介质
CN110213401A (zh) * 2019-06-18 2019-09-06 四川新网银行股份有限公司 一种IPv6环境下的数据中心主机域名自动注册方法

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114125035A (zh) * 2021-09-27 2022-03-01 烽火通信科技股份有限公司 一种大规模扩容场景下服务注册方法与装置
CN114125035B (zh) * 2021-09-27 2023-08-08 烽火通信科技股份有限公司 一种大规模扩容场景下服务注册方法与装置
CN114500300A (zh) * 2022-01-07 2022-05-13 支付宝(杭州)信息技术有限公司 服务注册处理方法及装置
CN114500300B (zh) * 2022-01-07 2024-04-05 支付宝(杭州)信息技术有限公司 服务注册处理方法及装置
CN114598743A (zh) * 2022-03-17 2022-06-07 上海小度技术有限公司 一种服务发现方法、装置、电子设备及存储介质
CN115002185A (zh) * 2022-05-09 2022-09-02 北京城市网邻信息技术有限公司 数据的处理方法、装置、电子设备及存储介质
CN116319505A (zh) * 2023-02-10 2023-06-23 安芯网盾(北京)科技有限公司 路由分发方法及装置

Also Published As

Publication number Publication date
CN112929401A (zh) 2021-06-08
CN112929401B (zh) 2023-12-19

Similar Documents

Publication Publication Date Title
WO2021109640A1 (zh) 一种注册方法及装置
CN107832100B (zh) 一种apk插件的加载方法及其终端
US10462250B2 (en) Distributed caching cluster client configuration
US20200288302A1 (en) Service Notification Method For Mobile Edge Host And Apparatus
CN112165482B (zh) 数据处理方法、装置、计算机设备及介质
CN110520844A (zh) 云管理平台、虚拟机管理方法及其系统
US11762600B2 (en) Data processing method, apparatus, and system
US20170155741A1 (en) Server, method, and system for providing service data
US20220107752A1 (en) Data access method and apparatus
WO2017157111A1 (zh) 防止内存数据丢失的的方法、装置和系统
WO2024078348A1 (zh) 应用移植环境下注册表操作的处理方法、装置和介质
WO2016095644A1 (zh) 数据库的高可用解决方法和装置
CN111240760B (zh) 基于注册中心的应用发布方法、系统、存储介质及设备
CN113704295A (zh) 业务请求的处理方法、系统及电子设备
CN101490667A (zh) 管理域状态信息的系统和方法
CN114117280A (zh) 页面静态资源使用方法、装置、终端设备及存储介质
CN110753082B (zh) 服务调用方法及终端设备
CN114116656A (zh) 数据处理方法及相关装置
WO2020151337A1 (zh) 分布式文件处理方法、装置、计算机设备以及存储介质
CN112711466A (zh) 悬挂事务巡检方法和装置、电子设备和存储介质
CN113542319A (zh) 用于Dubbo框架中的服务提供实体变更通知方法、装置及系统
CN114064194A (zh) 一种资源处理方法及装置
CN112804335B (zh) 数据处理方法、装置、计算机可读存储介质和处理器
WO2023143618A1 (zh) 读取数据的方法或写数据的方法及其相关系统
US20240089339A1 (en) Caching across multiple cloud environments

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20897101

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20897101

Country of ref document: EP

Kind code of ref document: A1