CN113296968A - Address list updating method, device, medium and electronic equipment - Google Patents

Address list updating method, device, medium and electronic equipment Download PDF

Info

Publication number
CN113296968A
CN113296968A CN202010108888.6A CN202010108888A CN113296968A CN 113296968 A CN113296968 A CN 113296968A CN 202010108888 A CN202010108888 A CN 202010108888A CN 113296968 A CN113296968 A CN 113296968A
Authority
CN
China
Prior art keywords
address
address list
list
queue
service
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.)
Pending
Application number
CN202010108888.6A
Other languages
Chinese (zh)
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010108888.6A priority Critical patent/CN113296968A/en
Publication of CN113296968A publication Critical patent/CN113296968A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

The disclosure provides an address list updating method, an address list updating device, an address list updating medium and electronic equipment. The method comprises the following steps: sequentially receiving a to-be-processed address list corresponding to a service provider; determining a current latest address list to be processed according to the receiving sequence of the address list; and reading the latest address list through an address refreshing thread, and updating the locally stored available address list of the service provider according to the latest address list. According to the method and the device, the latest address list determined in the address list is read through the address refreshing thread, and the updating of the locally stored available address list is achieved. On one hand, when the update message of the address list is monitored, the refreshing times of the address list are reduced, the time delay of the address list is reduced, the real-time performance and the accuracy of the address list are ensured, and the service availability is further improved; on the other hand, the address list does not need to be refreshed frequently, the load of the address refreshing thread is reduced, and the effective refreshing efficiency of the address refreshing thread is improved.

Description

Address list updating method, device, medium and electronic equipment
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to an address list updating method, an address list updating apparatus, a computer-readable medium, and an electronic device.
Background
Communication data is transmitted between the service consumer and the service provider through the network. When a service consumer initiates a request to a service provider, the list of addresses of the service provider must be known first.
If the address lists of the network addresses of a plurality of service providers are continuously pushed in a period of time, the refresh thread of the service consumer updates the address list of the local cache successively according to the pushing sequence. This approach not only causes the address list in the local cache to be delayed and inaccurate, but also causes the refresh thread to be in a busy state for a long time, increases the load of the refresh thread, and is not suitable for a high availability scenario.
In view of the above, there is a need in the art to develop a new address list updating method.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present application and therefore may include information that does not constitute prior art known to a person of ordinary skill in the art.
Disclosure of Invention
The present disclosure is directed to an address list updating method, an address list updating apparatus, a computer readable medium, and an electronic device, so as to overcome the technical problems of frequent address list updating and delayed update of the latest address list, at least to a certain extent.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to an aspect of an embodiment of the present disclosure, there is provided an address list updating method, including: sequentially receiving a to-be-processed address list corresponding to a service provider; determining a current latest address list to be processed according to the receiving sequence of the address list; and reading the latest address list through an address refreshing thread, and updating a locally stored available address list of the service provider according to the latest address list.
According to an aspect of an embodiment of the present disclosure, there is provided an address list updating apparatus including: a list receiving module configured to sequentially receive a list of addresses to be processed corresponding to a service provider; the list determining module is configured to determine a current latest address list to be processed according to the receiving order of the address list; a list updating module configured to read the latest address list through an address refresh thread and update a locally stored available address list of the service provider according to the latest address list.
In some embodiments of the present disclosure, based on the above technical solutions, the list updating module includes: a list storage unit configured to store the latest address list in an address copy to be read corresponding to an address refresh thread; a list reading unit configured to read the latest address list from the address copy by the address refresh thread when the address refresh thread is in a ready state.
In some embodiments of the present disclosure, based on the above technical solutions, the list storage unit includes: a queue determination subunit configured to determine a task blocking queue corresponding to an address refresh thread and generate a task corresponding to the latest address list; and the task submitting subunit is configured to submit the task to the task blocking queue and store the latest address list in the address copy to be read corresponding to the address refreshing thread.
In some embodiments of the present disclosure, based on the above technical solutions, the list reading unit includes: the queue comparison subunit is configured to obtain the queue length of the task blocking queue and the queue capacity of the task blocking queue, and determine a queue comparison result of the queue length and the queue capacity; a result determination subunit configured to read, by the address refresh thread, the latest address list from the address copy when the queue comparison result is that the queue length is equal to the queue capacity.
In some embodiments of the present disclosure, based on the above technical solution, the queue capacity is 1, and the list reading unit includes: the length comparison subunit is configured to obtain the queue length of the task blocking queue and determine the length comparison result between the queue length and 1; a length result subunit configured to read, by the address refresh thread, the latest address list from the address copy when the length comparison result is that the queue length is equal to 1.
In some embodiments of the present disclosure, based on the above technical solution, the address list updating apparatus further includes: a task submission module configured to submit the task to the task blocking queue and determine a queue comparison result of the queue length and the queue capacity; a task discarding module configured to discard the task when the queue comparison result is that the queue length is equal to the queue capacity; and the task saving module is configured to save the task in the task blocking queue when the queue comparison result shows that the queue length is smaller than the queue capacity.
In some embodiments of the present disclosure, based on the above technical solutions, the list determining module includes: an identifier assigning unit configured to assign a corresponding list identifier to the address list according to a receiving order of the address list; the list queue unit is configured to store the address list and the list identification in a list queue to be read corresponding to an address refresh thread; and the identification determining unit is configured to determine a current to-be-processed latest address list according to the list identification in the list queue.
In some embodiments of the present disclosure, based on the above technical solutions, the list updating module includes: a thread ready unit configured to read the latest address list from the list queue through the address refresh thread when the address refresh thread is in a ready state; a thread running unit configured to maintain the running state of the address refresh thread when the address refresh thread is in the running state.
In some embodiments of the present disclosure, based on the above technical solutions, the list is identified as a version number, and the version number is allocated to the address list according to an increasing principle; the identification determination unit includes: a comparison sorting subunit configured to compare the version numbers and sort the version numbers according to a number comparison result; and the sequencing result subunit is configured to determine the maximum version number as the latest version number according to the sequencing result, and determine an address list corresponding to the latest version number as the latest address list to be processed currently.
In some embodiments of the present disclosure, based on the above technical solution, the address list updating apparatus further includes: an expiration determining module configured to determine the version numbers except the latest version number as an expiration version number, determine an address list corresponding to the expiration version number as an expiration address list, and determine the address list corresponding to the expiration version number as an expiration address list; a list discard module configured to discard the expired version number and the expired address list to update the list queue.
In some embodiments of the present disclosure, based on the above technical solutions, the list receiving module includes: the service calling unit is configured to acquire a service identifier of a service to be called and send a corresponding service query request according to the service identifier; and the request returning unit is configured to receive the to-be-processed address lists of the service providers which are sequentially returned according to the service inquiry request.
In some embodiments of the present disclosure, based on the above technical solution, the request returning unit includes: a request sending subunit, configured to determine a service provider corresponding to the service according to the service query request, and send a message subscription request corresponding to the service provider; a request receiving subunit configured to sequentially receive the pending address lists of the service providers corresponding to the message subscription request.
According to an aspect of the embodiments of the present disclosure, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements an address list updating method as in the above technical solutions.
According to an aspect of an embodiment of the present disclosure, there is provided an electronic apparatus including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the address list updating method as in the above technical solution via executing the executable instructions.
In the technical scheme provided by the embodiment of the disclosure, the latest address list determined in the address list is read by the address refreshing thread, so that the locally stored available address list is updated. On one hand, the refreshing times of the address list are reduced, the time delay of the address list is reduced, the real-time performance and the accuracy of the address list are ensured, and the service availability is further improved; on the other hand, when the address refreshing thread is busy, the address list does not need to be frequently refreshed, the load of the address refreshing thread is reduced, and the effective refreshing efficiency of the address refreshing thread is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty. In the drawings:
FIG. 1 is a flow diagram schematically illustrating steps in a method of obtaining a list of addresses in a remote procedure call scenario;
FIG. 2 is a flow chart illustrating steps of an address list updating method in the related art;
FIG. 3 is a flow chart schematically illustrating steps of a method of successively updating an address list in the related art;
FIG. 4 schematically illustrates an exemplary system architecture diagram to which the disclosed subject matter may be applied;
FIG. 5 schematically illustrates a flow chart of steps of an address list update method in some embodiments of the present disclosure;
FIG. 6 schematically illustrates a flow chart of steps of a method of receiving a list of addresses in some embodiments of the present disclosure;
FIG. 7 schematically illustrates a flow chart of steps of a method of further receiving a list of addresses in some embodiments of the present disclosure;
FIG. 8 schematically illustrates a flow chart of steps of a method of determining a list of up-to-date addresses in some embodiments of the present disclosure;
FIG. 9 schematically illustrates a flow chart of steps in a method of further determining a list of up-to-date addresses in some embodiments of the present disclosure;
FIG. 10 schematically illustrates a flow chart of steps of a method of updating a list queue in some embodiments of the present disclosure;
FIG. 11 schematically illustrates a flow chart of steps of a method of reading a most recent address list in some embodiments of the present disclosure;
FIG. 12 schematically illustrates a flow chart of steps of a method of storing a list of up-to-date addresses in some embodiments of the present disclosure;
FIG. 13 schematically illustrates a flow chart of steps of a method of determining a queue comparison result in some embodiments of the present disclosure;
FIG. 14 schematically illustrates a flow chart of steps of a method of determining a length comparison result in some embodiments of the present disclosure;
FIG. 15 schematically illustrates a flow chart of steps of a method of processing a task in some embodiments of the present disclosure;
FIG. 16 schematically illustrates a flow chart of steps of another method of reading a most recent address list in some embodiments of the present disclosure;
FIG. 17 schematically illustrates a flow chart of steps of an address list update method in an application scenario in some embodiments of the present disclosure;
FIG. 18 schematically illustrates a flow chart of steps of a first stage address list update method in some embodiments of the present disclosure;
FIG. 19 schematically illustrates a flow chart of steps of a second stage address list update method in some embodiments of the present disclosure;
FIG. 20 schematically illustrates a flow chart of steps of a third stage address list update method in some embodiments of the present disclosure;
FIG. 21 schematically illustrates a flow chart of steps of a fourth stage address list update method in some embodiments of the present disclosure;
FIG. 22 schematically illustrates a flow chart of steps of an address list update method of a fifth stage in some embodiments of the present disclosure;
FIG. 23 schematically illustrates a block diagram of an address list update apparatus in some embodiments of the present disclosure;
FIG. 24 schematically illustrates a structural schematic diagram of a computer system suitable for use with an electronic device embodying embodiments of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
In the related art in the field, updating the acquired address list is widely applied to a remote procedure call scenario. Fig. 1 is a flowchart illustrating steps of a method for obtaining an address list in a remote procedure call scenario, where as shown in fig. 1, a service provider, a service consumer, and a service registry are respectively deployed on different servers, and communication data between the service provider, the service consumer, and the service registry are transmitted through a network.
The service provider is configured to provide a service to the service consumer, and specifically, may provide a service to the service registry and publish the service. The service consumer is used for calling the service provided by the service provider, and specifically, searching the service registry for the required service. The service registration center is mainly responsible for service management and service state monitoring, and realizes registration, storage, pushing and the like of the service.
For example, a service of "obtaining other identification data of the patient according to a name" may be invoked for a data recording platform of the patient, correspondingly, a service provider may be a server or a server cluster of the data recording platform, a service registry may be a server that records an address list of the server or the server cluster of the data recording platform, and a service consumer may be a terminal that initiates the query service request; for the online bookstore system, a service of "purchasing books" XXX "may be called, correspondingly, the service provider may be a server or a server cluster of the online bookstore system, the service registration center may be a server recording an address list of the server or the server cluster of the online bookstore system, and the service consumer may be a terminal initiating the purchase service request; for a video website, a service of "subscribing to an update reminder message of a tv series" may be called, correspondingly, a service provider may be a server or a server cluster of the video website, a service registration center may be a server that records an address list of the server or the server cluster of the video website, and a service consumer may be a terminal that initiates the subscription request.
In step S110, the service provider transmits a service registration request to the service registry to register a server address of the service provider in the service registry.
In step S120, the service consumer subscribes from the service registry and acquires a server address corresponding to the service provider.
In step S130, the service consumer obtains the server address, and selects one service provider to send a Remote Procedure Call (RPC) request according to the corresponding load balancing policy.
In step S140, after receiving the RPC request, the service provider may extract the request parameters from the RPC request and perform corresponding processing. And further, returning a processing result to the service consumer.
The requirement for the service consumer to obtain the network address of the service provider is not always well met by the conventional address list update method. This problem is solved by configuring in advance an address list of network addresses of the service provider in the local configuration of the service consumer. However, the pre-configuration does not allow dynamic change capabilities for the address list of the service consumer. When a cluster multi-machine deployment mode is adopted to provide services, a service provider can expand or contract the capacity to cause the address list of the service provider to be changed, but the address list of a service consumer cannot be updated synchronously. Once a service consumer initiates a request according to a pre-configured address list, a network invocation error may result.
In addition, fig. 2 shows a flow chart of steps of an address list updating method in the related art, and as shown in fig. 2, a service registry is added between a service consumer and a service provider to implement decoupling. The service consumer does not need to configure the address list of the service provider locally but dynamically obtains the address list of the network address through the service registry. When a service provider starts a service, the service provider registers a network address of a corresponding server with a service registration center, and the service registration center can classify the registered network address into an address list according to a service name. Thus, each service corresponds to a list of addresses of service providers.
In step S210, the service consumer subscribes to an address list of network addresses of the service provider to the service registry.
In step S220, the service registry returns a list of addresses of service providers to the service consumer. And when the address list is updated, the service registration center can also push the updated address list to the service consumer.
In step S230, when the service consumer receives the returned address list, the address list is cached locally in order to facilitate the RPC request to the service provider.
In step S240, the refresh thread of the service consumer is started to listen to the address change message of the service registry. When the address list of the service registration center is updated, the updating thread monitors the address list pushed by the service registration center and automatically updates the new address list to the local cache.
In step S250, when the address list of the service registry is updated, the service registry pushes a new address list to the service consumer.
In step S260, when the updated address list is monitored by the subsequent refresh thread, the local cache may also be updated by the updated address list.
Before a service consumer initiates an RPC request to a service provider, a local cache address list is inquired, and one service provider instance is selected to send the request according to a corresponding load balancing strategy. When the service provider receives the remote procedure call request, the request parameters of the RPC request can be extracted, so that corresponding processing is carried out and a processing result is returned to the service consumer.
It can be seen that the refresh thread of the service consumer monitors that there is a new address list, and updates the address list synchronously and in a blocking manner, that is, the refresh thread updates the address list of the local cache gradually according to the receiving order.
Fig. 3 is a flowchart illustrating steps of a method for gradually updating address lists in the related art, and as shown in fig. 3, in step S310, the service registry frequently pushes N address lists, namely address list 1, address list 2, … … and address list N, within a period of time.
In step S320, the service address listener of the service consumer hears N address lists, such as address list 1, address list 2, … …, address list N, and the like. The service address refresh thread of the service consumer refreshes address list 1, address list 2, … …, and address list N one by one.
In step S330, the service address refresh thread of the service consumer refreshes address list 1 into the local cache. Moreover, since it takes a long time to process the address list 1 by the refresh thread, the address lists 2, … … and N are always blocked behind the address list 1, and the address lists 2, … … and N are all in a blocked state.
Therefore, on one hand, in the process that the address list 1 is processed all the time in the refresh line, the latest address list N cannot be updated to the local cache in time, so that the address list cached by the service consumer is delayed; on the other hand, even if the refresh thread has finished processing the address list 1, it is necessary to sequentially process the address list 2, the address lists 3, … …, and the address list N-1, and the time for refreshing the address list N to the local cache is further delayed, which makes it impossible to apply to a highly available scenario.
Based on the problems of the above schemes, the present disclosure provides an address list updating method, an address list updating apparatus, a computer readable medium, and an electronic device.
Preferably, the address list of the service provider is updated by using a cloud technology, so that the refreshing times of the service consumer can be reduced, and the refreshing efficiency of the address list is improved.
Fig. 4 shows an exemplary system architecture diagram to which the disclosed solution is applied.
As shown in fig. 4, the system architecture 400 may include a service consumer 410 and a service provider 420 serving a registry 430. The service consumer 410 may be one or more of terminal devices, or may be deployed on a server, and the service provider 420 and the service registry 430 are respectively deployed on different servers. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and a big data and artificial intelligence platform. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like. The terminal device and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
It should be understood that the number of servers in fig. 4 is merely illustrative, and may be implemented by a single server, a server cluster composed of a plurality of servers, or a cloud computing service center.
Specifically, the service consumer 410 may be an application, and the service provider 420 may be a cluster of servers for providing the service, provided that the application requires the service to be invoked for execution, and any one of the servers 440 in the cluster of servers may invoke the service. The server 440 of the service provider 420 calling the service may feed back a service calling result to the service consumer 410 so that the service consumer 410 may continue to execute the application according to the calling result.
In addition to this, a service registry 430 is used in the present application. When the service consumer 410 calls the service, the service registry 430 directly performs peer-to-peer communication with the server 440 in the service provider 420, and the service registry 430 is used for providing the address list of the server serving the service consumer 410, so that the service consumer 410 can select one server from the address list to call the service.
The service registration center 430 may record a correspondence between the service identifier and the address list according to the service registration request sent by the service provider 440. For example, if the service provider 420 is a cluster corresponding to a service, and all servers in the cluster can provide the service, then when a server in the service provider 420 registers with the service registry 430, the service registry 430 may determine that the servers in the service provider 420 all correspond to the same service, and may record the correspondence between the service name of the service and the network address of each server in the service provider 420. In the same principle, the service registration center 430 may register correspondence between service names of different services and network addresses of servers providing the services, respectively. Thus, the network addresses of the respective servers corresponding to the same service name may constitute an address list of the network addresses corresponding to the service name. Further, a service name and a corresponding address list may have a correspondence.
The service registry 430 stores an address list corresponding to a service name, which is a list of network addresses that can currently normally provide a service corresponding to the service name. If a part of the servers in the address list fails and is not available, or if the number of servers of the service provider is too large to be subjected to capacity reduction, the service registry 430 may delete the network addresses of the part of the servers from the address list. When the failed server recovers to work normally or the number of calls of the service provider is large and needs to be expanded, the service registry 430 may add the network addresses of the part of the service provider to the address list. To implement the refreshing of the address list, the service registry 430 maintains status monitoring and notification with the various servers in the service provider 420 so that the service registry 430 can know the status of the servers in the service provider 420 in time to notify the service consumer 410.
When invoking a service, the service consumer 410 may request the service registry 430 for an address list of a server corresponding to the service name of the service, where the request carries the service name of the service to be invoked. The service registry 430 may search the corresponding relationship according to the service name to obtain a corresponding address list, and feed back the address list to the service consumer 410.
The manner in which the service consumer 410 obtains the server list may be actively obtained, for example, when the service needs to be called, or periodically synchronize the address list of the service to be called by the service consumer 410; or passively acquired, the service registry 430 may actively push the list of addresses to the service consumer 410. For example, when the address list is updated, the service registry 430 may send the updated address list to the service consumer 410, preventing the occurrence of a situation where the called server is unavailable due to update lag.
The address list updating method provided by the embodiment of the present disclosure is generally performed by the service consumer 410, and accordingly, the address list updating apparatus is generally disposed in the server 410. However, it is easily understood by those skilled in the art that the address list updating method provided by the embodiment of the present disclosure may also be executed by the service provider 420 or the service registry 430, and accordingly, the address list updating apparatus may also be disposed in the service provider 420 or the service registry 430, which is not particularly limited in the exemplary embodiment.
For example, in one exemplary embodiment, a pending address list corresponding to the service provider 420 may be received in sequence from the service registry 430. And determining the latest address list to be processed currently according to the receiving order of the address list. The latest address list is read by an address refresh thread in the service consumer 410 and the locally stored available address list of the service provider 420 of the service consumer 410 is updated according to the latest address list, so that the service consumer 410 makes a service call according to the available address list.
The following describes an address list updating method, an address list updating apparatus, and an electronic device provided in the present disclosure in detail with reference to specific embodiments.
Fig. 5 schematically illustrates a flow chart of steps of an address list update method in some embodiments of the present disclosure. As shown in fig. 5, the address list updating method mainly includes the following steps:
step s510, receiving in sequence a list of addresses to be processed corresponding to a service provider.
And S520, determining the latest address list to be processed currently according to the receiving sequence of the address list.
And S530, reading the latest address list through an address refreshing thread, and updating the locally stored available address list of the service provider according to the latest address list.
In an exemplary embodiment of the present disclosure, the update of the locally stored available address list is implemented by the address refresh thread reading the latest address list determined in the address list. On one hand, the refreshing times of the address list are reduced, the time delay of the address list is reduced, the real-time performance and the accuracy of the address list are ensured, and the service availability is further improved; on the other hand, when the address refreshing thread is busy, the address list does not need to be frequently refreshed, the load of the address refreshing thread is reduced, and the effective refreshing efficiency of the address refreshing thread is improved.
The respective steps of the address list updating method are explained in detail below.
In step S510, a list of addresses to be processed corresponding to the service provider is sequentially received.
In exemplary embodiments of the present disclosure, a large complex business system may typically implement multiple services, and the implementation of each service may require the invocation of multiple different applications, thereby making the volume of service access difficult to predict. In order to ensure that a service system is not crushed by massive access and a high resource utilization rate is ensured, traditional applications start to migrate to a cloud server, except that a cloud host is adopted in an operation environment, a general technical architecture conforms to a distributed stateless architecture to realize elastic expansion and contraction of the applications on the cloud.
In distributed data processing, a service consumer and a service provider communicate using Remote Procedure Call (RPC). RPC is a way of requesting services from a remote computer program over a network without the need to know the underlying network technology. The RPC Protocol may assume the existence of some Transmission protocols, such as Transmission Control Protocol (TCP) or User Datagram Protocol (UDP), and carries information data between communication programs. In the Open System Interconnection (OSI) network communication model, RPC goes beyond the transport and application layers. RPC makes it easier to develop applications including network distributed multiprogrammers.
A distributed Service Framework (DSP for short) is a further encapsulation of an RPC Framework, RPC generally can only solve point-to-point remote communication between two processes, and the DSP Framework introduces an independent Service registration center in addition to the point-to-point remote communication Framework, so as to help a Service provider to register in the Service registration center and support a Service consumer to access an address list from the Service registration center.
When the service registration center pushes the address list of the service provider to the service consumer, the service consumer receives the address list. The address list may be an address list of network addresses, and preferably, the network addresses are Internet Protocol (IP) addresses. The IP address is the core of the entire Transmission Control Protocol (TCP)/IP Protocol suite, and also forms the basis of the internet. The IP is positioned at a network layer of the TCP/IP model, and information of various protocols of a transmission layer can be carried on the IP, such as TCP, UDP and the like; the IP packets may be placed at the link layer and transmitted via various technologies such as ethernet, token ring, etc. On one hand, the problem of the internet can be solved, and the interconnection and intercommunication of large-scale and heterogeneous networks are realized; on the other hand, the coupling relationship between the top network application and the underlying network technology can be segmented to facilitate the independent development of the two.
In an alternative embodiment, fig. 6 shows a flow chart of the steps of a method of receiving an address list, as shown in fig. 6, the method comprising at least the steps of: in step S610, a service identifier of a service to be invoked is obtained, and a corresponding service query request is sent according to the service identifier. Wherein the service identification may be a service name of a service to be invoked by the service consumer. For example, for a patient's data logging platform, the service may be "obtain other identity data of the patient according to name", and the corresponding service name is "query"; for the online bookstore system, when a user wants to buy a book, the service may be "buy book" XXX ", and the corresponding service name may be" buy "; for a service account corresponding to a video website, when a user requests to subscribe to an update reminding message of a certain tv series, the service may be "subscribe to an update message of the tv series" XX ", and a corresponding service name may be" subscribe ". After determining the service name, a service query request corresponding to the service name may be sent to the service registry. The service inquiry request carries the identification and the service name of the service consumer. The service name is used for determining an address list of a service provider corresponding to the service to be inquired in the service registry.
In step S620, a list of addresses to be processed of the service providers sequentially returned according to the service inquiry request is received. After receiving the service query request, the service registry may return the correspondence including the service name and the address list to the service consumer.
In an alternative embodiment, fig. 7 shows a flow chart of the steps of a method of further receiving an address list, which method comprises at least the following steps, as shown in fig. 7: in step S710, a service provider corresponding to the service is determined according to the service inquiry request, and a message subscription request corresponding to the service provider is transmitted. Upon receiving the service query request, the service provider may be determined from the address list. Further, the service consumer may send a message subscription request to the determined service provider. The message subscription request carries an identification of a service consumer and a correspondence between the service and an address list. The identifier of the service consumer is used for uniquely identifying the service consumer who initiates the message subscription request, and the corresponding relation is used for reserving a corresponding address list according to the service.
In step S720, a pending address list of the service provider corresponding to the message subscription request is sequentially received. When the service registration center receives the message subscription request, the address list is returned to the service consumer according to the updating condition of the server of the service provider corresponding to the service. Since the address lists of the service consumers are updated in real time, the address lists of a plurality of service providers may be returned in response to message subscription requests at different times. Moreover, since these address lists are returned in real time, these address lists are also all pending address lists that are not stored locally at the service consumer.
In the exemplary embodiment, the address list of the service provider corresponding to the service can be queried in the service registry through the service identifier, so that the message subscription of the service consumer is realized, and the accuracy, the practicability and the flexibility of message processing are improved.
In step S520, the latest address list to be currently processed is determined according to the receiving order of the address lists.
In an exemplary embodiment of the present disclosure, when the service consumer receives the returned address list of the service provider, the order in which the address list is received is determined at the same time to further determine the latest address list.
In an alternative embodiment, fig. 8 shows a flow chart of the steps of a method of determining a list of up-to-date addresses, as shown in fig. 8, the method comprising at least the steps of: in step S810, a corresponding list identification is assigned to the address list according to the receiving order of the address list. The receiving order of the address list may be a time sequence of receiving the address list, and the list identifier may be identification information uniquely identifying the address list, such as a version number corresponding to the address list. For example, the earlier the address list is received, the less numerical list identifier, such as a smaller version number, is assigned to the address list; the later the address list is received, the less numerical list identification, e.g. a larger version number, is assigned to the address list. In addition, other list identifiers or other allocation manners may be provided, and this exemplary embodiment is not particularly limited thereto.
In step S820, the address list and the list identifier are stored in the list queue to be read corresponding to the address refresh thread. After determining the list identification corresponding to the address list, a mapping relationship may be established between the two for common storage. In particular, the address list and the list identification may be stored in a list queue.
The list queue is a linear table storing address lists and list identifications. The data elements of the list queue may have an address list and a list identification. When storing in the list queue, the list queue allows only a delete operation at the front of the list queue and an insert operation, i.e., a store operation, at the back of the list queue. Thus, the list queue is a first-in-first-out linear table. And the list queue and the address refreshing thread have a corresponding relation. The address refresh thread may enable reading and refreshing of the list of addresses in the list queue to update the local cache of the service consumer.
In step S830, in the list queue, the latest address list to be currently processed is determined according to the list identifier. After the plurality of address lists and the list identifications are stored in the list queue, the latest address list in the plurality of address lists can be determined according to the list identifications, so that the address refreshing thread can refresh the address list conveniently.
In an alternative embodiment, the list is identified as a version number, the version number is assigned to the address list on an increasing basis, fig. 9 shows a flow chart of steps of a method for further determining the latest address list, as shown in fig. 9, the method at least comprises the following steps: in step S910, the version numbers are compared and sorted according to the number comparison result. The version number may be assigned to the address list according to the time when the address list is received and according to an increasing principle. Specifically, the first received address list has the earliest receiving time, and the version number assigned to the address list may be 1; the version number of the second received address list can be determined as 2 based on the version number of the first address list and by taking 1 as an increasing step; the version number of the third received address list can be determined to be 3 by taking 1 as an increasing step length on the basis of the version number of the second address list; … …, respectively; and so on. In addition, the version number may be in other forms, and this exemplary embodiment is not particularly limited thereto.
After assigning a version number to each address list, the sizes of the respective version numbers may be compared to obtain a number comparison result in view of the difference in the magnitude of the numbers between the version numbers. The version numbers may be sorted according to the number comparison result, and the sorting manner may be descending order or ascending order, which is not particularly limited in this exemplary embodiment.
In step S920, the maximum version number is determined as the latest version number according to the sorting result, and the address list corresponding to the latest version number is determined as the current latest address list to be processed. When the sorting result is that the version numbers are sorted in descending order, the first version number can be determined as the latest version number; when the sorting result is to arrange the version numbers in ascending order, the last version number may be determined as the latest version number. Further, according to the mapping relationship between the version number and the address list, the address list corresponding to the latest version number may be determined to be the latest address list. Also, the most recent address list is not already stored locally at the service consumer, and is therefore the current pending address list.
In the exemplary embodiment of the disclosure, when the list is identified as the version number, the latest address list can be determined through the comparison result of the version number, the determination mode is accurate and simple, and the practicability is extremely strong.
After the latest address list is determined, other address lists in the list queue can be determined according to the version number, so that further operation can be carried out to update the list queue.
In an alternative embodiment, fig. 10 shows a flow chart of the steps of a method of updating a list queue, as shown in fig. 10, the method comprising at least the steps of: in step S1010, a version number other than the latest version number is determined as an expired version number, and an address list corresponding to the expired version number is determined as an expired address list. After the latest version number is determined, the version number stored in the list queue includes two parts, namely the latest version number and the version number except the latest version number. The other version numbers are smaller than the latest version number, which indicates that the receiving time of the address list corresponding to the version numbers of the other version numbers is earlier than that of the latest address list. After determining the most recent address list, this portion of the address list is expired and need not be refreshed. Therefore, other version numbers except the latest version number are determined as overdue version numbers, and the address list corresponding to the overdue version numbers is determined as an overdue address list according to the mapping relation between the version numbers and the address list.
In step S1020, the expired version number and the expired address list are discarded to update the list queue. After the outdated version number and the list of outdated addresses are determined, the outdated version number and the list of outdated addresses may be discarded directly. Therefore, only the latest version number and the latest address list are stored in the list queue, and the list queue is updated.
In the exemplary embodiment, the determined expired version number and the expired address list are discarded, so that the storage space in the list queue is saved, and a data basis is provided for reducing the refresh times.
In step S530, the latest address list is read by the address refresh thread, and the locally stored available address list of the service provider is updated according to the latest address list.
In an exemplary embodiment of the present disclosure, after determining the latest address list, the latest address list may be read according to an address refresh thread. The address refresh thread can monitor the latest address list and read and refresh the latest address list to update the available address list of the local cache of the service consumer.
The steps of two methods of reading the latest address list are shown in fig. 11 and 16, respectively, as a flow chart. Wherein, fig. 11 is read from the address copy according to the identification information of the task block queue, and fig. 16 is read from the list queue storing the latest address list and the latest list identification.
In an alternative embodiment, fig. 11 shows a flow chart of the steps of a method of reading a list of up-to-date addresses, as shown in fig. 11, the method comprising at least the steps of: in step S1110, the latest address list is stored in the copy of the address to be read corresponding to the address refresh thread. The address copy is a local memory buffer of the service consumer and is used for storing a latest address list. And the address copy and the address refreshing thread have a corresponding relation. Thus, the most recent address list may be stored in the address copy in preparation for a subsequent read before the address refresh thread refreshes the most recent address list.
In an alternative embodiment, fig. 12 shows a flow chart of the steps of a method of storing a list of up-to-date addresses, as shown in fig. 12, the method comprising at least the steps of: in step S1210, a task block queue corresponding to the address refresh thread is determined, and a task corresponding to the latest address list is generated. The task blocking queue is a queue for loading tasks, and is equivalent to a storage space for caching the tasks. Therefore, when the latest address list is to be stored, a task corresponding to the latest address list may be generated to indicate that the latest address list is stored in the address copy. And because the task blocking queue and the address refreshing thread have a corresponding relation, the address refreshing thread can be identified to refresh the latest address list.
In step S1220, a task is submitted to the task block queue, and the latest address list is stored in the address copy to be read corresponding to the address refresh thread. When the task blocking queue receives the task, the task can be discarded or saved. It should be noted that the operation of the task block queue on the task does not affect the storage of the latest address list. Thus, after the task is submitted, the latest address list may be stored in the address copy.
In the exemplary embodiment, the determined task blocking queue can provide a refresh signal for the address refresh thread, so that the address refresh thread is prevented from being in a busy state for a long time, and the load of the address refresh thread is increased.
In step S1120, when the address refresh thread is in the ready state, the latest address list is read from the address copy by the address refresh thread. The newly created address refresh thread does not automatically start running, and must call the start () method of the address refresh thread. When the address refresh thread calls the start () method, indicating that the address refresh thread is started, the start () method can create the system resources for the address refresh thread to run, and schedule the address refresh thread to run the run () method. When the start () method returns, the address refresh thread is in the ready state.
In addition, after the address refresh thread processes the last latest address list, it can also be determined that the address refresh thread is in the ready state.
When the address refreshing thread is determined to be in the ready state, the time of a Central Processing Unit (CPU) can be obtained to run the address refreshing thread. Thus, the address refresh thread may read the most recent address list from the address copy.
In an alternative embodiment, fig. 13 shows a flow chart of the steps of a method of determining a queue comparison result, as shown in fig. 13, the method comprising at least the steps of: in step S1310, the queue length of the task block queue and the queue capacity of the task block queue are obtained, and a queue comparison result of the queue length and the queue capacity is determined. After the most recent address list is saved in the address copy, a determination may be made from the task block queue as to whether to read the most recent address list. Specifically, the determination is made by comparing the queue length and the queue capacity of the task block queue.
The queue capacity of the task blocking queue is a preset number of tasks that can be saved, such as 1, 2, and the like. Correspondingly, when the queue capacity is 1, the task blocking queue can store 1 task; when the queue capacity is 2, the task blocking queue may hold 2 tasks, which is not particularly limited in the present exemplary embodiment. The queue length may be the number of tasks currently held by the task block queue, e.g., 0, 1, 2, etc. Correspondingly, when the queue length is 0, the task blocks the task which is not stored in the queue currently; when the length of the queue is 1, the task blocking queue currently stores 1 task; when the queue length is 2, the task block queue currently holds 2 tasks.
And comparing the queue length with the queue capacity to obtain a queue comparison result. Specifically, the queue comparison result may be that the queue length is equal to the queue capacity, or may be that the queue length is smaller than the queue capacity.
In step S1320, when the queue comparison result is that the queue length is equal to the queue capacity, the latest address list is read from the address copy by the address refresh thread. And when the queue length is determined to be equal to the queue capacity according to the queue comparison result, the latest address list is stored in the address copy, and the address refreshing thread can read the latest address list from the address copy.
In the exemplary embodiment, whether the latest address list is read or not can be judged by comparing the queue capacity and the queue length, the judgment mode is simple, an accurate reading signal is provided for an address refreshing thread, and a basis is provided for address list updating.
More specifically, the queue capacity may be preset to 1 to determine whether to read the latest address list according to the known queue capacity.
In an alternative embodiment, the queue capacity is 1, and fig. 14 shows a flow chart of the steps of the method for determining the length comparison result, as shown in fig. 14, the method at least includes the following steps: in step S1410, the queue length of the task block queue is acquired, and the result of comparing the queue length with the length of 1 is determined. When the queue capacity is known as 1, only the queue length of the task blocking queue needs to be obtained. There are only two cases of this queue length being equal to 0 and equal to 1. Further, the queue lengths of the two cases may be compared with 1.
And comparing the queue length with the queue capacity to obtain a queue comparison result. Specifically, the queue comparison result may be that when the queue length is 1, the queue length is equal to the queue capacity; when the queue length is 0, the queue length may be smaller than the queue capacity.
In step S1420, when the length comparison result is that the queue length is equal to 1, the latest address list is read from the address copy by the address refresh thread. When the queue capacity is known to be 1, only the queue length needs to be compared to 1. If the queue length is also 1, it indicates that the latest address list is stored in the address copy, and the address refresh thread can read the latest address list from the address copy.
In the exemplary embodiment, whether the latest address list is read or not can be judged through the task blocking queue with the queue capacity of 1, the judgment mode is simple, an accurate reading signal is provided for an address refreshing thread, and a basis is provided for address list updating.
After determining the queue length and the queue capacity of the task blocking queue, a decision basis can be provided for selecting to discard or save when the task blocking queue receives the task.
In an alternative embodiment, fig. 15 shows a flow chart of steps of a method of processing a task, as shown in fig. 15, the method comprising at least the steps of: in step S1510, the task is submitted to the task block queue, and a queue comparison result of the queue length and the queue capacity is determined. After the task blocking queue receives the task, a queue comparison result of the task blocking queue can be obtained. Specifically, the queue comparison result may be that the queue length is equal to the queue capacity, or may be that the queue length is smaller than the queue capacity.
In step S1520, when the queue comparison result is that the queue length is equal to the queue capacity, the task is discarded. Since the queue capacity is the maximum number of tasks that can be held by the task blocking queue, when the queue length is equal to the queue capacity, indicating that the task blocking queue cannot hold other tasks, the task may be selected to be discarded.
In step S1530, when the queue comparison result indicates that the queue length is smaller than the queue capacity, the task is stored in the task block queue. Since the queue capacity is the maximum number of tasks that can be saved by the task block queue, when the queue length is smaller than the queue capacity, it indicates that the task block queue can also save the task, and the task can be selected to be received and saved in the task block queue.
In the exemplary embodiment, the processing method of the submitted task can be determined through the queue comparison result, other judgment modes are not required to be added, the workload of task processing operation is reduced, and the task processing efficiency is improved.
In an alternative embodiment, fig. 16 shows a flow chart of steps of another method for reading the latest address list, as shown in fig. 16, the method at least comprises the following steps: in step S1610, when the address refresh thread is in the ready state, the latest address list is read from the list queue by the address refresh thread. When the address refreshing thread is determined to be in the ready state, the time of the central processing unit CPU for running the address refreshing thread can be obtained. Thus, the address refresh thread may read the most recent address list from the queue list. Moreover, the latest list identifier corresponding to the latest address list may be discarded according to actual requirements, or the latest list identifier may be selected to be read together, which is not particularly limited in this exemplary embodiment.
In step S1620, when the address refresh thread is in the operating state, the operating state of the address refresh thread is maintained. If the address refresh thread starts executing the run () method, it indicates that the address refresh thread is in a running state. The running state indicates that the address refreshing thread is refreshing the last latest address list, so that the last latest address list is refreshed continuously only by keeping the running state of the address refreshing thread.
In the exemplary embodiment, the function of reading the latest address list is realized by judging the state of the address refresh thread, so that the address refresh thread is ensured to refresh only the latest address list without operating other address lists, the accuracy and the real-time performance of the latest address list are ensured, and the method is suitable for high-availability scenes.
After reading the latest address list, the refreshing operation of the address refreshing thread can realize the overwriting of the latest address list on the available address list so as to update the available address list stored locally by the service consumer.
The address list updating method provided in the embodiment of the present disclosure is described in detail below with reference to a specific application scenario.
Fig. 17 is a flowchart illustrating steps of an address list updating method in an application scenario, and as shown in fig. 17, in step S1710, the service registry may push an address list according to a service query request sent by a service consumer. The address list may include address list 1, address list 2, … …, address list N, and so on, for N address lists. The address list is snooped by a service address listener registered by the service consumer.
In step S1720, when the service address listener listens to the address list, a task is submitted to the task block queue. It is worth noting that the queue capacity of the task block queue is 1. Therefore, only when the queue length of the task blocking queue is 0, the task can be submitted successfully and stored in the task blocking queue; when the queue length of the task block queue is 1, i.e. equal to the queue capacity, the submitted task is discarded.
In step S1730, after submitting the task to the task block queue, the address list may be written into the address copy to overwrite the previously stored address list, so as to ensure that the latest address list is stored in the address copy.
In step S1740, the address refresh thread may pull the task from the task block queue to determine whether to read the latest address list in the address copy. When the queue length of the task blocking queue is 0, the task blocking queue indicates that no task is stored in the task blocking queue and is in a blocking state. When the queue length of the task blocking queue is 1, the address refreshing thread takes out the task from the queue and adjusts the queue length to 0.
In step S1750, after the address refresh thread fetches a task, the latest address list may be read from the address copy.
In step S1760, after the latest address list is read, the function of overwriting the locally stored available address list with the latest address list may be implemented through a refresh operation, so that the service consumer makes a call to the service provider according to the updated available address list.
Specifically, the address list updating method will be further described with reference to the address list 1, the address list 2, … …, and the address list 4 as examples.
FIG. 18 is a flowchart showing the steps of the address list updating method in the first stage, as shown in FIG. 18, the address refreshing thread fetches the task submitted in address list 1 from the task block queue, reads address list 1 from the address copy, and updates the available address list according to address list 1. To illustrate the processing manner of the subsequent address list, it is assumed that the time consumption of the refresh process of the address list 1 by the address refresh thread is long, and the refresh thread is always in the running state. At this time, since the task corresponding to the address list 1 has already been pulled from the task block queue, the length of the task block queue is 0. Also, address list 1 is still stored in the address copy.
Fig. 19 is a flowchart illustrating steps of the address list updating method in the second stage, as shown in fig. 19, when the address list 2 is pushed, the task corresponding to the address list 2 is submitted to the task blocking queue, and meanwhile, the address list 2 is written into the address copy to overwrite the address list 1 originally stored in the address copy. At this time, the queue length of the task block queue is updated from 0 to 1, and the address copy is updated to address list 2. Also, the address refresh thread is still processing address list 1.
Fig. 20 is a flowchart illustrating steps of the address list updating method in the third stage, and as shown in fig. 20, the address list 3 is pushed to submit the task corresponding to the address list 3 to the task block queue. However, since the job corresponding to the address list 2 is already stored in the job block queue, the length is 1 at this time, and the job corresponding to the address list 3 cannot be stored, and the job is discarded. While the address list 2 in the address copy is covered by the address list 3, only the address list 3 is saved in the address copy at this time. Also, the address refresh thread is still processing address list 1.
Fig. 21 is a flowchart illustrating a step of the address list updating method in the fourth stage, as shown in fig. 21, after the address list 4 is pushed, since the address refreshing thread is always in the blocking state for processing the address list 1, and does not go back to the task blocking queue to fetch the task, the submitted task corresponding to the address list 4 is discarded, and the address list 3 in the address copy is replaced with the address list 4, as the address list 4 and the address list 3 are processed in the same manner.
FIG. 22 is a flowchart illustrating the steps of the address list update method of the fifth stage, where the address refresh thread has processed address list 1, as shown in FIG. 22. Therefore, the address refresh thread will pull the task from the task block queue again. Since the task blocking queue stores the previously submitted task, and the queue length is 1, the address refreshing thread acquires the task, reads the address list 4 from the address copy, and refreshes the address list 4 to update the address list 4 into the available address list. Therefore, it is possible to finally hold the address list 4 in the address list, and only the address list 4 is refreshed.
Based on the application scenarios, the address list updating method provided by the embodiment of the disclosure reads the latest address list determined in the address list through the address refresh thread, so as to update the locally stored available address list. On one hand, the refreshing times of the address list are reduced, the time delay of the address list is reduced, the real-time performance and the accuracy of the address list are ensured, and the service availability is further improved; on the other hand, when the address refreshing thread is busy, the address list does not need to be frequently refreshed, the load of the address refreshing thread is reduced, and the effective refreshing efficiency of the address refreshing thread is improved.
It should be noted that although the various steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that these steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
The following describes an embodiment of an apparatus of the present disclosure, which may be used to perform the address list updating method in the above-described embodiment of the present disclosure. For details that are not disclosed in the embodiments of the apparatus of the present disclosure, please refer to the embodiments of the address list updating method described above in the present disclosure.
Fig. 23 schematically shows a block diagram of an address list updating apparatus in some embodiments of the present disclosure. As shown in fig. 23, the address list updating apparatus 2300 may mainly include: list reception module 2310, list determination module 2320, and list update module 2330.
A list receiving module 2310 configured to sequentially receive a list of addresses to be processed corresponding to a service provider; a list determining module 2320 configured to determine a latest address list to be currently processed according to a receiving order of the address lists; a list update module 2330 configured to read the latest address list via an address refresh thread and update a locally stored list of available addresses for the service provider in accordance with the latest address list.
In some embodiments of the disclosure, the list update module comprises: a list storage unit configured to store a latest address list in an address copy to be read corresponding to the address refresh thread; and the list reading unit is configured to read the latest address list from the address copy through the address refreshing thread when the address refreshing thread is in a ready state.
In some embodiments of the present disclosure, the list storage unit includes: a queue determination subunit configured to determine a task blocking queue corresponding to the address refresh thread and generate a task corresponding to the latest address list; and the task submitting subunit is configured to submit the task to the task blocking queue and store the latest address list in the address copy to be read corresponding to the address refreshing thread.
In some embodiments of the present disclosure, the list reading unit includes: the queue comparison subunit is configured to acquire the queue length of the task blocking queue and the queue capacity of the task blocking queue, and determine a queue comparison result of the queue length and the queue capacity; and the result determining subunit is configured to read the latest address list from the address copy through the address refreshing thread when the queue comparison result is that the queue length is equal to the queue capacity.
In some embodiments of the present disclosure, the queue capacity is 1, and the list reading unit includes: the length comparison subunit is configured to obtain the queue length of the task blocking queue and determine the length comparison result between the queue length and 1; and the length result subunit is configured to read the latest address list from the address copy through the address refreshing thread when the length comparison result is that the queue length is equal to one.
In some embodiments of the present disclosure, the address list updating apparatus further includes: the task submitting module is configured to submit tasks to the task blocking queue and determine a queue comparison result of the queue length and the queue capacity; a task discarding module configured to discard the task when the queue comparison result is that the queue length is equal to the queue capacity; and the task saving module is configured to save the task in the task blocking queue when the queue comparison result shows that the queue length is smaller than the queue capacity.
In some embodiments of the present disclosure, the list determination module comprises: an identifier assigning unit configured to assign a corresponding list identifier to the address list according to a receiving order of the address list; the list queue unit is configured to store the address list and the list identification in a list queue to be read corresponding to the address refresh thread; and the identification determining unit is configured to determine a latest address list to be currently processed according to the list identification in the list queue.
In some embodiments of the disclosure, the list update module comprises: the thread ready unit is configured to read a latest address list from the list queue through the address refreshing thread when the address refreshing thread is in a ready state; and the thread running unit is configured to keep the running state of the address refreshing thread when the address refreshing thread is in the running state.
In some embodiments of the present disclosure, the list is identified as a version number, which is assigned to the address list on an increasing basis; the identification determination unit includes: the comparison and sorting subunit is configured to compare the version numbers and sort the version numbers according to the number comparison result; and the sequencing result subunit is configured to determine that the maximum version number is the latest version number according to the sequencing result, and determine that the address list corresponding to the latest version number is the latest address list to be processed currently.
In some embodiments of the present disclosure, the address list updating apparatus further includes: an expiration determining module configured to determine a version number other than the latest version number as an expiration version number and determine an address list corresponding to the expiration version number as an expiration address list; and the list discarding module is configured to discard the expired version number and the expired address list so as to update the list queue.
In some embodiments of the present disclosure, the list receiving module comprises: the service calling unit is configured to acquire a service identifier of a service to be called and send a corresponding service query request according to the service identifier; and the request returning unit is configured to receive the to-be-processed address lists of the service providers which are sequentially returned according to the service inquiry request.
In some embodiments of the present disclosure, the request returning unit includes: a request sending subunit configured to determine a service provider corresponding to the service according to the service inquiry request, and send a message subscription request corresponding to the service provider; and the request receiving subunit is configured to sequentially receive the to-be-processed address lists of the service providers corresponding to the message subscription requests.
The specific details of the address list updating apparatus provided in each embodiment of the present disclosure have been described in detail in the corresponding method embodiment, and therefore are not described herein again.
FIG. 24 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present disclosure.
It should be noted that the computer system 2400 of the electronic device shown in fig. 24 is only an example, and should not bring any limitations to the functions and the scope of the application of the embodiments of the present disclosure.
As shown in fig. 24, the computer system 2400 includes a Central Processing Unit (CPU)2401, which can perform various appropriate actions and processes in accordance with a program stored in a Read-Only Memory (ROM) 2402 or a program loaded from a storage section 2408 into a Random Access Memory (RAM) 2403. In the RAM 2403, various programs and data necessary for system operation are also stored. The CPU 2401, ROM 2402, and RAM 2403 are connected to each other through a bus 2404. An Input/Output (I/O) interface 2405 is also connected to the bus 2404.
The following components are connected to I/O interface 2405: an input portion 2406 including a keyboard, a mouse, and the like; an output section 2407 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage portion 2408 including a hard disk and the like; and a communication section 2409 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 2409 performs communication processing via a network such as the internet. A driver 2410 is also connected to the I/O interface 2405 as needed. A removable medium 2411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 2410 as necessary, so that a computer program read out therefrom is installed into the storage portion 2408 as necessary.
In particular, the processes described in the various method flowcharts may be implemented as computer software programs, according to embodiments of the present disclosure. 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 illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via communications portion 2409, and/or installed from removable media 2411. The computer program executes various functions defined in the system of the present application when executed by a Central Processing Unit (CPU) 2401.
It should be noted that the computer readable medium shown in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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), a 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 present disclosure, 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 contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, wired, etc., or any suitable combination of the foregoing.
The flowchart 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 disclosure. 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.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (15)

1. An address list updating method, the method comprising:
sequentially receiving a to-be-processed address list corresponding to a service provider;
determining a current latest address list to be processed according to the receiving sequence of the address list;
and reading the latest address list through an address refreshing thread, and updating a locally stored available address list of the service provider according to the latest address list.
2. The address list updating method of claim 1, wherein reading the latest address list by an address refresh thread comprises:
storing the latest address list in an address copy to be read corresponding to an address refreshing thread;
and when the address refreshing thread is in a ready state, reading the latest address list from the address copy through the address refreshing thread.
3. The address list updating method according to claim 2, wherein the storing the latest address list in the copy of the address to be read corresponding to the address refresh thread comprises:
determining a task blocking queue corresponding to an address refreshing thread, and generating a task corresponding to the latest address list;
and submitting the task to the task blocking queue, and storing the latest address list in the address copy to be read corresponding to the address refreshing thread.
4. The address list updating method according to claim 3, wherein the reading the latest address list from the address copy by the address refresh thread comprises:
acquiring the queue length of the task blocking queue and the queue capacity of the task blocking queue, and determining a queue comparison result of the queue length and the queue capacity;
and when the queue comparison result shows that the queue length is equal to the queue capacity, reading the latest address list from the address copy through the address refreshing thread.
5. The address list updating method according to claim 4, wherein the queue capacity is 1;
the reading, by the address refresh thread, the latest address list from the address copy includes:
acquiring the queue length of the task blocking queue, and determining the length comparison result of the queue length and 1;
and when the length comparison result shows that the queue length is equal to 1, reading the latest address list from the address copy through the address refreshing thread.
6. The address list updating method of claim 4, wherein the method further comprises:
submitting the task to the task blocking queue, and determining a queue comparison result of the queue length and the queue capacity;
when the queue comparison result is that the queue length is equal to the queue capacity, discarding the task;
and when the queue comparison result shows that the queue length is smaller than the queue capacity, storing the task in the task blocking queue.
7. The address list updating method according to claim 1, wherein the determining a current latest address list to be processed according to the receiving order of the address list comprises:
distributing corresponding list identification to the address list according to the receiving sequence of the address list;
storing the address list and the list identification in a list queue to be read corresponding to an address refreshing thread;
and in the list queue, determining a current to-be-processed latest address list according to the list identification.
8. The address list updating method of claim 7, wherein reading the latest address list by an address refresh thread comprises:
when the address refreshing thread is in a ready state, reading the latest address list from the list queue through the address refreshing thread;
and when the address refreshing thread is in a running state, keeping the running state of the address refreshing thread.
9. The address list updating method of claim 7, wherein said list identifier is a version number, said version number being assigned to said address list on an increasing basis;
the determining of the current to-be-processed latest address list according to the list identifier includes:
comparing the version numbers and sequencing the version numbers according to the number comparison result;
and determining the maximum version number as the latest version number according to the sequencing result, and determining an address list corresponding to the latest version number as the current latest address list to be processed.
10. The address list updating method according to claim 9, wherein after said determining that the largest version number is the latest version number according to the sorting result, the method further comprises:
determining the version numbers except the latest version number as overdue version numbers, and determining an address list corresponding to the overdue version numbers as an overdue address list;
discarding the expired version number and the expired address list to update the list queue.
11. The address list updating method of claim 1, wherein said sequentially receiving pending address lists corresponding to service providers comprises:
acquiring a service identifier of a service to be called, and sending a corresponding service query request according to the service identifier;
and receiving the to-be-processed address lists of the service providers which are sequentially returned according to the service query requests.
12. The address list updating method according to claim 11, wherein the receiving the pending address list of the service provider sequentially returned according to the service inquiry request comprises:
determining a service provider corresponding to the service according to the service query request, and sending a message subscription request corresponding to the service provider;
and sequentially receiving the address lists to be processed of the service providers corresponding to the message subscription requests.
13. An address list updating apparatus, comprising:
a list receiving module configured to sequentially receive a list of addresses to be processed corresponding to a service provider;
the list determining module is configured to determine a current latest address list to be processed according to the receiving order of the address list;
a list updating module configured to read the latest address list through an address refresh thread and update a locally stored available address list of the service provider according to the latest address list.
14. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the address list updating method of any one of claims 1 to 12.
15. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the address list update method of any of claims 1 to 12 via execution of the executable instructions.
CN202010108888.6A 2020-02-21 2020-02-21 Address list updating method, device, medium and electronic equipment Pending CN113296968A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010108888.6A CN113296968A (en) 2020-02-21 2020-02-21 Address list updating method, device, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010108888.6A CN113296968A (en) 2020-02-21 2020-02-21 Address list updating method, device, medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN113296968A true CN113296968A (en) 2021-08-24

Family

ID=77318472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010108888.6A Pending CN113296968A (en) 2020-02-21 2020-02-21 Address list updating method, device, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113296968A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114900383A (en) * 2022-03-28 2022-08-12 青岛海尔科技有限公司 Interface processing method and device, electronic equipment and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114900383A (en) * 2022-03-28 2022-08-12 青岛海尔科技有限公司 Interface processing method and device, electronic equipment and computer readable storage medium
CN114900383B (en) * 2022-03-28 2024-04-19 青岛海尔科技有限公司 Interface processing method, device, electronic equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN107590001B (en) Load balancing method and device, storage medium and electronic equipment
US20210385290A1 (en) Method and system for providing high efficiency, bidirectional messaging for low latency applications
US8977673B2 (en) Information on availability of services provided by publish-subscribe service
US7831734B2 (en) Method and system for remote configuration of network devices
US8639786B2 (en) Consistency domains for replication in distributed computing
CN112039942A (en) Subscription and publishing method and server
US9038125B2 (en) Self identifying services in distributed computing
US9432449B2 (en) Managing connection failover in a load balancer
CN110580305B (en) Method, apparatus, system and medium for generating identifier
CN109783151B (en) Method and device for rule change
CN112118315A (en) Data processing system, method, device, electronic equipment and storage medium
WO2021051747A1 (en) Data update method, system and device, electronic device, and computer storage medium
CN115004673B (en) Message pushing method, device, electronic equipment and computer readable medium
CN113079098B (en) Method, device, equipment and computer readable medium for updating route
US20080235384A1 (en) Web service for coordinating actions of clients
CN114938395A (en) Service response method, device, equipment and storage medium
CN107844310B (en) Configuration information updating method and system
CN113296968A (en) Address list updating method, device, medium and electronic equipment
CN112769671B (en) Message processing method, device and system
US20230283695A1 (en) Communication Protocol for Knative Eventing's Kafka components
CN108833147B (en) Configuration information updating method and device
CN112448977A (en) System, method, apparatus and computer readable medium for assigning tasks
CN112187916B (en) Cross-system data synchronization method and device
CN114205354A (en) Event management system, event management method, server, and storage medium
CN113190624A (en) Asynchronous-to-synchronous calling method and device based on distributed cross-container

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