CN106453592B - Asynchronous call processing method, device and distributed system - Google Patents
Asynchronous call processing method, device and distributed system Download PDFInfo
- Publication number
- CN106453592B CN106453592B CN201610944766.4A CN201610944766A CN106453592B CN 106453592 B CN106453592 B CN 106453592B CN 201610944766 A CN201610944766 A CN 201610944766A CN 106453592 B CN106453592 B CN 106453592B
- Authority
- CN
- China
- Prior art keywords
- service
- node
- coordinator
- record
- processing result
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/51—Discovery or management thereof, e.g. service location protocol [SLP] or web services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the invention provides an asynchronous call processing method, asynchronous call processing equipment and a distributed system. The method is applied to a distributed system comprising a coordinator and at least two service nodes, wherein the service node requested by a client to provide service is a master node, and the service node called by the master node to complete the service is a slave node, and the method comprises the following steps: the method comprises the steps that a coordinator receives an asynchronous call request for a slave node, which is initiated by a master node based on a service requested by a client; the coordinator establishes a call record according to the asynchronous call request and calls the slave node to process the asynchronous call request; the coordinator receives the processing result sent by the slave node and records the processing result in the call record; the coordinator receives a processing result acquisition request sent by a service node which needs to use a processing result in a service requested by a client; and the coordinator acquires the processing result from the call record and sends the processing result to the service node needing to use the processing result. For improving the processing efficiency of a distributed system.
Description
Technical Field
The embodiment of the invention relates to the technical field of communication, in particular to an asynchronous call processing method, asynchronous call processing equipment and a distributed system.
Background
With the continuous development of computer technology, distributed systems are widely used. A plurality of nodes are arranged in the distributed system, and the nodes with different functions can be mutually called to complete preset functions.
In the prior art, in order to improve the processing efficiency of a distributed system, multiple threads are generally used to implement asynchronous calls between nodes, so that multiple nodes can run in parallel. Specifically, when one node needs to call other nodes, multiple threads can be started simultaneously to call other nodes respectively. However, when there is a dependency relationship between calls from one node to a plurality of other nodes, only serial processing is performed between the plurality of threads. For example, suppose that node 1 needs to call node 2 and node 3, and when node 1 calls node 3, node 1 needs to pass the processing result of node 2 as a parameter to node 3, so that node 1 can call node 3 only after node 2 obtains the processing result.
As can be seen from the above, in the prior art, when there is a dependency relationship between calls of one node to other nodes, only the calls can be processed in series, which results in low processing efficiency of the distributed system.
Disclosure of Invention
The embodiment of the invention provides an asynchronous call processing method, asynchronous call processing equipment and a distributed system, which are used for improving the processing efficiency of the distributed system.
In a first aspect, an embodiment of the present invention provides an asynchronous call processing method, which may be applied to a distributed system including a coordinator and at least two service nodes. The service node which is requested by the client to provide the service is the master node, and the service node which is called by the master node to complete the service is the slave node.
After the master node receives the service requested by the client, the master node transmits an asynchronous call request including a node identification of the slave node to be called to the coordinator. And the coordinator establishes a call record of the call according to the asynchronous call request and calls the slave node corresponding to the node identifier to process the asynchronous call request. After the slave node completes the processing of the asynchronous call request, the slave node sends the processing result to the coordinator, so that the coordinator records the processing result in the call record. And when other slave nodes called by the master node in the service need to use the processing result, sending a processing result acquisition request to the coordinator to acquire the processing result from the coordinator.
In the above process, a coordinator is provided in the distributed system, so that the service nodes can make mutual calls through the coordinator. The coordinator can also cache the processing result of each service node in one service to the asynchronous call request. In this way, when the call of the master node to the second slave node depends on the call result of the master node to the first slave node, the master node does not need to wait for the call result of the first slave node when the master node calls the second slave node. When the master node calls the second slave node, the master node sends the identification information corresponding to the processing result of the first slave node to the second slave node, so that the second slave node can obtain the processing result in the coordinator according to the identification information corresponding to the processing result, the master node can call a plurality of interdependent slave nodes in parallel, and the processing efficiency of the distributed system is improved.
In a possible embodiment, after the coordinator has created the call record, the coordinator may further configure identification information for searching the call record, send the identification information to the master node, and send the identification information to a slave node called by the master node in the service and needing to use the processing result. In this way, it can be ensured that the slave node that needs to use the processing result can obtain the processing result in the coordinator according to the identification information.
In another possible implementation manner, the processing result acquisition request sent to the coordinator by the node that needs to use the processing result may also carry identification information. Accordingly, the coordinator can obtain the processing result from the call record through the following feasible implementation manners: the coordinator searches the calling record according to the identification information and judges whether a processing result exists in the calling record or not;
if yes, the coordinator obtains a processing result. If not, the coordinator adds the identifier of the node needing to use the processing result into the waiting list, acquires the processing result when the processing result exists in the call record, and moves the identifier of the node needing to use the processing result out of the waiting list.
In this embodiment, when a service node that needs to use the processing result needs to obtain the processing result and the processing result does not exist in the call record, the coordinator adds the identifier of the service node that needs to use the processing result to the waiting list. Therefore, when the processing result exists in the call record, the coordinator can send the processing result to the service node needing to use the processing result in the first time, so that the coordinator can quickly feed back the processing result to the service node needing to use the processing result, and further the processing efficiency of the distributed system is high.
In another possible implementation, the call record created by the coordinator may further include a call identifier for identifying the call. Accordingly, the coordinator may construct the identification information for searching the call record according to two possible implementation manners as follows:
one possible implementation is: the coordinator directly takes the calling identifier as the identification information for searching the calling record. Another possible implementation: and constructing a handle object based on the call identification as the identification information for searching the call record.
In another possible implementation manner, after the coordinator receives a service creation request sent by the master node based on the service requested by the client, a service record including a record for searching for the service for the current service may be created according to the service creation request, and the service identifier may be sent to the master node. Therefore, the asynchronous call request initiated by the main node can carry the service identifier, so that the coordinator can create the call record in the service record according to the service identifier when creating the call record.
In this embodiment, a service is indicated by a service identification, and all call records within a service are created under that service. Therefore, the distributed system can monitor and manage the call records in the service conveniently.
Optionally, the coordinator may construct the identification information for searching the call record through two possible implementation manners as follows:
one possible implementation is: the coordinator combines the service identifier and the call identifier as identification information for searching the call record. Therefore, when the call record is searched according to the identification information, the service record can be determined according to the service identification, and then the call record is determined in the service record according to the call identification, so that the efficiency of obtaining the call record is high.
Another possible implementation: the coordinator constructs a handle object based on the service identifier and the call identifier as identification information for finding the call record. Because the handle object usually occupies a small space, the transmission efficiency can be improved when the call identifier is transmitted.
In another possible embodiment, the service record and the call record may be tree-structured. The tree structure takes the service record as a root node, and the call record is a child node hung under the root node. The calling records in one service are stored in a tree structure form, so that the distributed system can monitor and manage all the calling records in all the services conveniently, and the service management efficiency is improved.
In a second aspect, an embodiment of the present invention provides an asynchronous call processing method, which is applied to a distributed system including a coordinator and at least two service nodes. The service node which is requested by the client to provide the service is the master node, and the service node which is called by the master node to complete the service is the slave node.
When the client requests service from the master node, the master node determines the slave node to be called according to the service requested by the client, and sends an asynchronous calling request for calling the first slave node to the coordinator. The coordinator calls the first slave node according to the asynchronous call request to process the asynchronous call request and records the processing result of the first slave node on the asynchronous call request; the first slave node is one of the determined slave nodes needing to be called. The master node further identifies a second slave node which needs to use the processing result of the first slave node for the asynchronous call request in the slave nodes needing to be called according to the dependency relationship among the slave nodes needing to be called, the master node calls the second slave node, and the second slave node is instructed to obtain the processing result of the first slave node for the asynchronous call request from the coordinator in the process of calling the second slave node.
In the above process, a coordinator is provided in the distributed system, so that the service nodes can make mutual calls through the coordinator. Meanwhile, the coordinator can also cache the processing result of each service node in one service to the asynchronous call request. In this way, when the call of the master node to the second slave node depends on the call result of the master node to the first slave node, the master node does not need to wait for the call result of the first slave node when the master node calls the second slave node. When the master node calls the second slave node, the master node sends the identification information corresponding to the processing result of the first slave node to the second slave node, so that the second slave node can obtain the processing result in the coordinator according to the identification information corresponding to the processing result, the master node can call a plurality of interdependent slave nodes in parallel, and the processing efficiency of the distributed system is improved.
In a possible implementation manner, before the master node determines a node to be called according to a service initiated by a client, the master node further sends a service creation request to the coordinator based on the service requested by the client, so that the coordinator creates a service record of the service according to the service creation request, where the service record includes a service identifier used for searching the service record, and after the coordinator creates the service record, the coordinator sends the service identifier to the master node. In this way, the service identification and the identification of the first slave node may be included in the asynchronous call request sent by the master node to the coordinator.
Optionally, after the master node sends an asynchronous call request for calling the first slave node to the coordinator, the master node receives identification information, which is sent by the coordinator and used for searching for a call record corresponding to the asynchronous call request. Accordingly, the master node may send the identification information to the second slave node, so that the second slave node obtains, in the coordinator, a processing result of the first slave node on the asynchronous call request according to the identification information.
In this process, a service is indicated by a service identification, and all call records within a service are created under the service. Therefore, the distributed system can monitor and manage the call records in the service conveniently. Meanwhile, the coordinator can quickly find the calling record through the identification information and quickly acquire a processing result in the calling record.
In a third aspect, an embodiment of the present invention provides a coordinator, where the coordinator may perform the method described in any one of the first aspect. The coordinator may be implemented by software and/or hardware. Optionally, the coordinator may include a receiving module, a processing module and a sending module, and execute the method according to any one of the first aspect through each module.
In a fourth aspect, an embodiment of the present invention provides a service node, where the service node may execute the method of any one of the second aspects. The service node may be implemented in software and/or hardware. Optionally, the service node may include a receiving module, a processing module and a sending module, and execute the method according to any one of the second aspect through each module.
In a fifth aspect, an embodiment of the present invention provides a coordinator, where the coordinator may perform the method according to any one of the first aspect. The coordinator may include a receiver, a processor, a transmitter, and a memory for storing an application program, and the processor may read and execute the application program in the memory.
In a sixth aspect, an embodiment of the present invention provides a service node, where the service node may perform the method according to any one of the first aspect. The service node may include a receiver, a processor, a transmitter, and a memory for storing an application program, and the processor may read and execute the application program in the memory.
In a seventh aspect, an embodiment of the present invention provides a distributed system, where the distributed system includes the coordinator according to the fifth aspect and the service node according to the sixth aspect.
According to the asynchronous call processing method, the asynchronous call processing equipment and the distributed system, a coordinator is arranged in the distributed system, so that service nodes can be mutually called through the coordinator. The coordinator can also cache the processing result of each service node in one service to the asynchronous call request. In this way, when the call of the master node to the second slave node depends on the call result of the master node to the first slave node, the master node does not need to wait for the call result of the first slave node when the master node calls the second slave node. When the master node calls the second slave node, the master node sends the identification information corresponding to the processing result of the first slave node to the second slave node, so that the second slave node can obtain the processing result in the coordinator according to the identification information corresponding to the processing result, the master node can call a plurality of interdependent slave nodes in parallel, and the processing efficiency of the distributed system is improved.
Drawings
FIG. 1 is a schematic diagram of an application scenario of an asynchronous calling method provided in the present invention;
FIG. 2 is a first flowchart of an asynchronous call processing method according to the present invention;
FIG. 3 is a flowchart illustrating a method for a coordinator to obtain processing results according to the present invention;
FIG. 4 is a second flowchart illustrating an asynchronous call processing method according to the present invention;
FIG. 5 is a schematic diagram of a tree structure provided by the present invention;
FIG. 6 is a schematic diagram of a coordinator according to the present invention;
FIG. 7 is a first schematic structural diagram of a service node according to the present invention;
FIG. 8 is a second schematic structural diagram of a service node provided in the present invention;
FIG. 9 is a schematic diagram of a hardware structure of the coordinator provided in the present invention;
FIG. 10 is a first diagram illustrating a hardware structure of a service node according to the present invention;
fig. 11 is a schematic diagram of a hardware structure of a service node provided in the present invention.
Detailed Description
Fig. 1 is a schematic view of an application scenario of the asynchronous calling method provided by the present invention, please refer to fig. 1, which includes a distributed system 101 and a client 102, where the distributed system 101 includes a coordinator 1011 and a plurality of service nodes (respectively denoted as 1012-1 to 1012-2). Each service node may provide services to the client 102 individually or may provide services to the client 102 in common with other service nodes. In the present application, in the process of one service node (master node) providing service to the client 102, the serving node may make calls to other serving nodes (slave nodes) through the coordinator 1011 and the results of the processing cached by the coordinator 1011, which, on the one hand, when the call by the master node to the second slave node depends on the result of the call by the master node to the first slave node, when the master node calls the second slave node, the master node does not need to wait for the calling result of the first slave node, when the master node calls the second slave node, only the identification information corresponding to the processing result of the first slave node needs to be sent to the second slave node, so that the second slave node can obtain the processing result in the coordinator according to the identification information corresponding to the processing result, and then the main node can call a plurality of interdependent slave nodes in parallel, and the processing efficiency of the distributed system is improved.
In the present application, a service node requested by a client to provide a service is referred to as a master node, and a service node called by the master node to complete the service is referred to as a slave node, where the master node and the slave node are relative concepts, and one service node may be the master node or a slave service node of another service node.
The technical means shown in the present application will be described in detail below with reference to specific examples. It should be noted that the following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 2 is a first flowchart of an asynchronous call processing method provided by the present invention, please refer to fig. 2, where the method may include:
s201, the main node determines the slave nodes needing to be called according to the service requested by the client.
In an actual application process, when a client needs to obtain a service in a distributed system, the client requests a master node corresponding to the service in the distributed system to provide the service, and in a process that the master node processes the service requested by the client, the master node may need to call other nodes (slave nodes) in the distributed system to complete the service requested by the client.
When the main node needs to call other nodes in the distributed system, the main node determines the slave nodes needing to be called according to the service requested by the client. Optionally, the master node may determine the slave node that needs to be invoked according to the type of the sub-service included in the service, for example, a correspondence between the type of the sub-service and the slave node may be stored in the master node, so that the master node may determine the slave node that needs to be invoked according to the correspondence and the type of the sub-service.
S202, the main node sends an asynchronous call request to the coordinator, and the asynchronous call request comprises the node identification of the slave node to be called.
S203, the coordinator establishes the call record of the call according to the asynchronous call request.
In one service, each asynchronous call request corresponds to a call record, the call record may store a processing result corresponding to the asynchronous call request, optionally, the call record may further store an identifier of a requesting node (master node) and an identifier of a requested node (slave node) corresponding to the asynchronous call request, and in an actual application process, content included in the call record may be determined according to actual needs.
S204, the coordinator constructs identification information used for searching the call record.
Optionally, the call record created by the coordinator may include a call identifier for identifying the call, and correspondingly, the coordinator may directly use the call identifier as identifier information for searching for the call record, or construct a handle object based on the call identifier as identifier information for searching for the call record.
S205, the coordinator sends the identification information to the main node.
And S206, the coordinator calls the slave node to process the asynchronous call request.
After the coordinator receives the asynchronous call request of the master node, the coordinator obtains the identifier of the slave node needing to be called in the asynchronous call request, and calls the slave node corresponding to the identifier of the slave node to process the asynchronous call request according to the identifier of the slave node needing to be called. Optionally, the coordinator may generate a call instruction for the slave node according to the asynchronous call request, and the call instruction carries content information in the asynchronous call request, and the coordinator sends the call instruction to the slave node, so that the slave node processes the asynchronous call request according to the call instruction.
It should be noted that S203-S205 and S206 may be executed simultaneously or sequentially, and in an actual application process, the execution order of S203-S205 and S206 may be set according to actual needs, which is not limited in this invention.
And S207, the slave node sends the processing result to the coordinator.
After the coordinator calls the slave node, the slave node processes the asynchronous call request to obtain a processing result corresponding to the asynchronous call request, and sends the obtained processing result to the coordinator.
And S208, recording the processing result in the call record by the coordinator.
S209, in the process that the master node calls other slave nodes in the current service, when the other slave nodes called by the master node need to use the processing result, the master node sends the identification information to the slave node.
S210, the slave node needing to use the processing result sends a processing result acquisition request to the coordinator.
S211, the coordinator obtains the processing result from the call record corresponding to the identification information according to the processing result obtaining request.
Optionally, after the coordinator obtains the processing result obtaining request, the coordinator may obtain, in the processing result obtaining request, the identification information used for searching for the call record, search for the call record according to the identification information, and obtain the processing result in the searched call record.
S212, the coordinator sends the processing result to the slave node that needs to use the processing result.
It should be noted that S206-S208 and S209-S210 may be executed in parallel.
It should be noted that, in the process of processing the service requested by the client by the master node, the master node may also need to use the processing result sent from the slave node to the coordinator in S207. When the main node needs to use the processing result, the main node sends a processing result acquisition request to the coordinator, and the processing result acquisition request carries identification information used for searching for the call record. And the coordinator acquires the processing result from the calling record corresponding to the identification information according to the processing result acquisition request and sends the processing result to the main node. It should be noted that, the process of the coordinator obtaining the processing result may refer to S211, and is not described herein again.
The method shown in the embodiment of fig. 2 is described in detail below by way of specific examples.
Illustratively, assume that the distributed system includes 5 nodes, denoted as node 1-node 5, respectively.
When a client needs to acquire a service 1 in a distributed system, the client determines that a main node for providing the service 1 is the node 1 in 5 nodes of the distributed system, and then the client requests the node 1 to process the service 1.
In the process that the node 1 processes the service 1 requested by the client, the node 1 determines a slave node which needs to be called. Suppose node 1 needs to call node 2 and node 3 during the process of handling service 1. When the node 1 needs to call the node 2, the node 1 sends an asynchronous call request to the coordinator, and the asynchronous call request carries the identifier of the node 2.
The coordinator creates a call record of the call according to the asynchronous call request sent by the node 1, the call identifier corresponding to the call record is '001', and the call node 2 processes the asynchronous call request. After the coordinator creates the call record 1, the coordinator constructs identification information for looking up the call record, for example, the coordinator may directly determine "001" as the identification information of the call record, and the coordinator transmits the identification information to the node 1.
And the node 2 processes the asynchronous call request to obtain a processing result, sends the processing result to the coordinator, and records the processing result in the call record by the coordinator.
During the processing of the service 1 by the node 1, the node 1 also needs to call the node 3 through the coordinator, because the processing result in the call record 1 needs to be used during the processing of the asynchronous call request by the node 3. In the application, the node 1 does not need to call the node 3 after the node 2 determines to obtain the processing result, when the node 1 needs to call the node 3, the node 1 calls the node 3 and sends the identification information "001" to the node 3, so that when the node 3 needs to use the processing result of the node 2, the node sends a processing result acquisition request to the coordinator, the processing result acquisition request carries the identification information ("001") used for searching the call record 1, the coordinator searches the call record according to the identification information in the processing result acquisition request, acquires the processing result in the call record, and sends the processing result to the node 3.
In the above process, after the node 1 calls the node 2, when the node 1 needs to call the node 3 and the call to the node 3 depends on the processing result of the node 2, the node 1 does not need to wait for the processing result of the node 2, so that the node 1 can call the node 2 and the node 3 in parallel, and further the processing efficiency of the distributed system is improved.
In the asynchronous call processing method provided by the embodiment of the invention, the coordinator is arranged in the distributed system, so that each service node can be called mutually through the coordinator. The coordinator can also cache the processing result of each service node in one service to the asynchronous call request. In this way, when the calling of the master node to the second slave node depends on the calling result of the master node to the first slave node, the master node does not need to wait for the calling result of the first slave node when calling the second slave node. When the master node calls the second slave node, the master node sends the identification information corresponding to the processing result of the first slave node to the second slave node, so that the second slave node can obtain the processing result in the coordinator according to the identification information corresponding to the processing result, the master node can call a plurality of interdependent slave nodes in parallel, and the processing efficiency of the distributed system is improved.
On the basis of the embodiment shown in fig. 2, optionally, the identification information for searching the call record may be carried in the processing result acquisition request sent by the service node that needs to use the processing result to the coordinator. Accordingly, the coordinator may obtain the processing result in the call record corresponding to the identification information according to the following feasible implementation manner (S211 in the embodiment shown in fig. 2). For a specific implementation of the acquiring process, please refer to the embodiment shown in fig. 3.
Fig. 3 is a flowchart illustrating a method for acquiring a processing result by a coordinator according to the present invention, referring to fig. 3, the method may include:
s301, the coordinator searches for the call record according to the identification information.
After the coordinator receives a processing result obtaining request sent by a service node which needs to use a processing result, the coordinator may obtain the identification information in the processing result obtaining request, and search for the obtaining call record according to the identification information.
S302, the coordinator judges whether a processing result exists in the call record.
If yes, go to S303.
If not, S304-S306 are executed.
S303, the coordinator obtains the processing result in the call record.
S304, the coordinator adds the identification of the node needing to use the processing result into a waiting list.
If the processing result does not exist in the call record, which indicates that the corresponding slave node has not been processed to obtain the processing result corresponding to the call record, the coordinator adds the node that needs to use the processing result into the waiting list, and at this time, the node that needs to use the processing result may execute other events independent of the processing result first.
S305, when the processing result exists in the call record, the coordinator acquires the processing result.
S306, the coordinator moves the identification of the node needing to use the processing result out of the waiting list.
In the above process, when the service node that needs to use the processing result needs to obtain the processing result and the call record does not have the processing result, the coordinator adds the identifier of the service node that needs to use the processing result to the waiting list. In this way, when the processing result exists in the call record, the coordinator can send the processing result to the service node which needs to use the processing result in the first time, so that the coordinator can quickly feed back the processing result to the service node which needs to use the processing result, and the processing efficiency of the distributed system is high.
On the basis of any one of the above embodiments, the following describes the above asynchronous call processing method in further detail through the embodiment shown in fig. 4.
Fig. 4 is a schematic flowchart of a second asynchronous call processing method provided by the present invention, please refer to fig. 4, where the method may include:
s401, the main node sends a service creation request to the coordinator according to the service requested by the client.
Optionally, the service creation request may include an identification of the service. In the actual application process, the content included in the service creation request may be determined according to actual needs.
S402, the coordinator creates a service record of the service according to the service creation request, wherein the service record comprises a service identifier used for searching the service record.
Optionally, when the coordinator creates the service record, the service record may be created in a tree structure, and the service record is a root node of the tree structure. While the coordinator creates the service record, the coordinator also generates a service identifier for looking up the service identifier, which may be represented by a character string, for example, the service identifier may be "001", "abc 1", etc.
S403, the coordinator sends the service identification to the master node.
S404, the main node determines that the first slave node needs to be called according to the service requested by the client.
S405, the main node sends an asynchronous call request to the coordinator, and the asynchronous call request comprises the node identification and the service identification of the first slave node.
S406, the coordinator creates a call record in the service record corresponding to the service identifier according to the asynchronous call request, wherein the call record comprises a call identifier for identifying the call.
Wherein the call record may create a service record of the service in which the call is located. In particular, the invocation record may be created under a root node representing the service as a child of the root node.
Alternatively, the formats of the service record created in S402 and the call record created in S406 may be as shown in fig. 5. Fig. 5 is a schematic diagram of a tree structure provided by the present invention, please refer to fig. 5, where a root node of the tree structure is a service record, a child node of the tree structure is a call record, and the call record is hung on the root node of the service record. The call record may include a processing result and a wait list for storing an identifier of a node waiting for the processing result, and optionally, a nested call record. Of course, other contents may be included in the tree structure, and the present invention is not particularly limited thereto.
The call records in one service are stored in the form of the tree structure, so that the distributed system can monitor and manage all the call records in the service conveniently, for example, the distributed system can monitor whether all the call records are normally completed (whether a processing result is obtained) according to the tree structure, and further the management efficiency of the service is improved.
It should be noted that the execution processes of S404-S406 may refer to S201-S203 in the embodiment shown in fig. 2, and are not described herein again.
S407, the coordinator constructs identification information for searching the call record according to the service identification and the call identification.
Optionally, the coordinator may construct the identification information of the search call record through two possible implementation manners:
one possible implementation is: the coordinator combines the service identifier and the call identifier as identification information for searching the call record. Optionally, the coordinator may combine the service identifier and the invocation identifier according to a preset combination sequence to obtain the identifier information. For example, assuming that the service identifier is "001" and the call identifier is "abc", the obtained identification information determined from the service identifier and the call identifier may be "001-abc".
Another possible implementation: the coordinator constructs a handle object based on the service identifier and the call identifier as identification information for finding the call record. Optionally, the handle object and the corresponding relationship between the service identifier and the call identifier may be set, so that one service identifier and one call identifier can be uniquely determined according to the handle object. For example, if the handle object "a" is set to correspond to the service identifier "001" and the call identifier "abc", the service identifier "001" and the call identifier "abc" can be determined from the handle object "a".
S408, the coordinator sends the identification information to the main node.
S409, the coordinator calls the first slave node to process the asynchronous call request.
S410, the first slave node sends the processing result to the coordinator.
S411, the coordinator records the processing result in the call record.
It should be noted that the execution process of S409-S411 may refer to S206-S208 in the embodiment shown in fig. 2, and is not described herein again.
It should be noted that S407-S408 and S409-S411 may be executed sequentially or simultaneously, and the execution order of S407-S408 and S409-S411 is not specifically limited in the embodiment of the present invention.
S412, the master node identifies a second slave node which needs to use the first slave node to process the asynchronous call request according to the dependency relationship between the slave nodes which need to be called.
The dependency between the slave nodes is used to indicate which slave nodes the processing result of a slave node needs to use, or which slave nodes the processing result of a slave node needs to be used by, for example, the dependency may be the processing result of the service node C relying on (needing to use) the call of the node B to the node a.
And S413, when the master node calls the second slave node, sending identification information to the second slave node to indicate the second slave node to obtain the processing result of the first slave node on the asynchronous call request according to the identification information.
And S414, the second slave node sends a processing result acquisition request comprising the identification information to the coordinator.
S415, the coordinator searches the call records according to the identification information and judges whether a processing result exists in the call records or not;
if yes, executing S416-S417;
if not, S418-S420 are performed.
S416, the coordinator obtains the processing result in the call record.
S417, the coordinator sends the processing result to the second slave node.
S418, the coordinator adds the identifier of the second slave node into a waiting list, and when the processing result exists in the calling record, the coordinator obtains the processing result;
s419, the coordinator sends the processing result to the second slave node.
S420, the coordinator moves the identity of the second slave node out of the waiting list.
It should be noted that, the execution process of S415 to S420 may refer to the embodiment shown in fig. 3, and is not described herein again.
The method shown in the embodiment of fig. 4 will be described in detail below by specific examples.
For example, assume that the distributed system includes 5 nodes, which are respectively denoted as node 1 to node 5, and further assume that the identifier of node 1 is "a", the identifier of node 2 is "b", and the identifier of node 3 is "c".
When a client needs to acquire a service 1 in a distributed system, the client determines that a main node for providing the service 1 is the node 1 in 5 nodes of the distributed system, and then the client requests the node 1 to process the service 1.
The node 1 sends a service creation request to the coordinator according to the service requested by the client, coordinates to create a service record of the service according to the service creation request, the service record includes a service identifier for searching the service record, and the coordinator also sends the service identifier to the node 1, assuming that the service record of the service is service record 1 and the service identifier is "001". Optionally, when the coordinator creates the service record 1, a tree structure may be created, and the service record 1 is a root node of the tree structure.
In the process of processing the service 1 requested by the client by the node 1, the node 1 determines that the node 2 (first slave node) needs to be called, and sends an asynchronous call request to the coordinator, wherein the asynchronous call request comprises 'b' (node identification of the node 2) and '001' (identification of the service 1).
The coordinator creates a call record 1 under the service record 1 according to the asynchronous call request, where the call record 1 includes a call identifier "ab", and optionally, the call record 1 may be hung in a node of a tree structure with the service record 1 as a root node.
The coordinator calls the node 2 to process the asynchronous call request, and after the node 2 determines that the processing result is obtained, the node 2 sends the processing result to the coordinator, so that the coordinator records the processing result in the call record 1. Meanwhile, the coordinator also determines "001-ab" as the identification information for searching the invocation record 1, and sends the identification information to the node 1.
In the process that the node 1 processes the service 1 requested by the client, the node 1 determines that the slave nodes needing to be called include the node 2 and the node 3, and when the node 1 calls the node 3, the node 1 needs to transmit the processing result of the node 2 as a parameter to the node 3 (the node 3 needs to use the processing result of the node 2), and then the coordinator determines the node 3 as a second slave node according to the dependency relationship.
When the node 1 needs to call the node 3, the node 1 does not need to wait for the processing result of the node 2, and the node 1 sends the identification information "001-ab" to the node 3, so that the node 3 can obtain the processing result from the coordinator according to the identification information "001-ab".
When the node 3 needs to use the processing result of the node 2, the node 3 sends a processing result acquisition request to the coordinator, the processing result acquisition request carries identification information '001-ab', the coordinator searches the calling record 1 corresponding to the calling identification 'ab' in the service record 1 corresponding to the service identification '001' according to the identification information, and judges whether the processing result exists in the calling record 1.
If the processing result exists, the coordinator directly obtains the processing result in the calling record 1 and sends the processing result to the node 3.
If the processing result does not exist, the coordinator adds the identifier 'c' of the node 3 into the waiting list, and when the processing result exists in the calling record 1, the coordinator obtains the processing result and sends the processing result to the node 3, and meanwhile, the coordinator also moves the identifier 'c' of the node 3 out of the waiting list.
In the above process, after the node 1 calls the node 2, when the node 1 needs to call the node 3, the node 1 does not need to wait for the processing result of the node 2, so that the node 1 can call the node 2 and the node 3 in parallel, and the asynchronous processing efficiency is further improved.
Fig. 6 is a schematic structural diagram of a coordinator provided in the present invention, where the coordinator is located in a distributed system, and the distributed system further includes at least two service nodes. The service node which is requested by the client to provide the service is a master node, and the service node which is called by the master node to complete the service is a slave node. Referring to fig. 6, the coordinator includes a receiving module 11, a processing module 12, and a transmitting module 13, wherein,
the receiving module 11 is configured to receive an asynchronous call request initiated by the master node based on a service requested by a client, where the asynchronous call request includes a node identifier of a slave node to be called.
The processing module 12 is configured to create a call record of the call according to the asynchronous call request, and call a slave node corresponding to the node identifier to process the asynchronous call request.
The receiving module 11 is further configured to receive the processing result sent by the slave node.
The processing module 12 is further configured to record the processing result in the call record.
The receiving module 11 is further configured to receive a processing result obtaining request sent by a service node that needs to use the processing result in the service requested by the client, where the service node that needs to use the processing result is another slave node called by the master node in the service.
The processing module 12 is further configured to obtain the processing result from the call record.
The sending module 13 is configured to send the processing result to the service node that needs to use the processing result.
The coordinator provided in the embodiment of the present invention may execute the technical solution shown in the embodiment of fig. 2, and the implementation principle and the beneficial effects thereof may specifically refer to the embodiment shown in fig. 2, which is not described herein again.
In a possible implementation manner, the processing module 12 may further construct identification information for searching for the call record according to S204 in the embodiment shown in fig. 2, and the implementation principle and the beneficial effect are similar, which are not described herein again. Correspondingly, the sending module 13 may send the identification information to the master node, and send the identification information to a slave node that needs to use the processing result and is called by the master node in the service through the master node.
Optionally, the call record further includes a call identifier for identifying the call, and correspondingly, the processing module 12 may construct, according to the method shown in S204 in the embodiment shown in fig. 2, the identifier information for searching the call record, which has similar implementation principles and beneficial effects, and is not described herein again.
In another possible implementation manner, the processing result obtaining request carries the identification information; correspondingly, the processing module 12 may obtain the processing result from the call record according to the embodiment shown in fig. 3, and the implementation principle and the beneficial effect thereof are similar, and are not described herein again.
In another possible implementation manner, the processing module 12 may also create a service record including a service identifier for searching the service record according to S402 in the embodiment shown in fig. 4, and the implementation principle and the beneficial effect are similar, and details are not described here again. Correspondingly, the sending module 13 may send the service identifier to the master node; so that the asynchronous call request initiated by the host node carries the service identifier, and thus, when creating the call record, the processing module 12 may create the call record in the service record according to the service identifier.
In another possible implementation manner, the receiving module 11 is further configured to receive a service creation request sent by the host node based on the service requested by the client, so that the processing module 12 may create the service record of the service in the method shown in S402 in the embodiment of fig. 4, and the implementation principle and the beneficial effect of the method are similar, and details are not repeated here.
In another possible implementation manner, the processing module 12 may construct the identification information for searching for the call record according to the method shown in S410 in the embodiment shown in fig. 4, and the implementation principle and the beneficial effect thereof are similar, and details are not repeated here.
In another possible embodiment, the service record and the call record are tree structures; the tree structure takes the service record as a root node, and the call record is a child node hung under the root node. The format of the service record and the call record in this embodiment can be seen in fig. 5, and will not be described herein.
Fig. 7 is a first schematic structural diagram of a service node provided in the present invention, where the service node is a master node in a distributed system, and the distributed system includes a coordinator and at least two service nodes. The service node which is requested by the client to provide the service is the master node, and the service node which is called by the master node to complete the service is the slave node. Referring to fig. 7, the master node includes a processing module 21 and a transmitting module 22, wherein,
the processing module 21 is configured to determine a slave node that needs to be invoked according to a service requested by a client.
The sending module 22 is configured to send an asynchronous call request for calling a first slave node to the coordinator, call the first slave node through the coordinator to process the asynchronous call request, and record a processing result of the first slave node on the asynchronous call request; the first slave node is one of the slave nodes which are determined to need to be called.
The processing module 21 is further configured to identify, according to a dependency relationship between the slave nodes that need to be called, a second slave node that needs to use the processing result of the first slave node for the asynchronous call request, from among the slave nodes that need to be called.
The processing module 21 is further configured to invoke the second slave node, and instruct the second slave node to obtain a processing result of the first slave node on the asynchronous invocation request from the coordinator in the process of invoking the second slave node.
The service node provided in the embodiment of the present invention may execute the technical solution shown in the embodiment of fig. 2, and reference may be made to the embodiment shown in fig. 2 for implementation principles and beneficial effects thereof, which are not described herein again.
Fig. 8 is a structural schematic diagram of a service node according to a second embodiment of the present invention, and referring to fig. 8, on the basis of the embodiment shown in fig. 7, the master node further includes a receiving module 23, wherein,
the sending module 22 is further configured to send a service creation request to the coordinator according to S401 in the embodiment of fig. 4 before the processing module 21 determines the node to be called according to the service initiated by the client, so that the coordinator creates a service record of the service according to the service creation request. Correspondingly, the receiving module 23 is configured to receive the identifier of the service sent by the coordinator. Correspondingly, the asynchronous call request includes the service identifier and the identifier of the first slave node.
Optionally, after the sending module 22 sends an asynchronous call request for calling the first slave node to the coordinator, the receiving module 23 is further configured to receive identification information, which is sent by the coordinator and used for searching for a call record corresponding to the asynchronous call request. Correspondingly, the sending module 22 is further configured to send the identification information to the second slave node, so that the second slave node obtains, in the coordinator, a processing result of the asynchronous call request by the first slave node according to the identification information.
Fig. 9 is a schematic hardware structure of a coordinator provided in the present invention, where the coordinator is located in a distributed system, and the distributed system further includes at least two service nodes. The service node which is requested by the client to provide the service is a master node, and the service node which is called by the master node to complete the service is a slave node. The coordinator comprises a receiver 31, a processor 32, a transmitter 33, a memory 34 for storing an application program, and a communication bus 35, wherein the processor 32 is used for executing corresponding operations according to the application program in the memory 34, the communication bus 35 is used for realizing communication connection between elements, wherein,
the receiver 31 is configured to receive an asynchronous call request initiated by the master node based on a service requested by a client, where the asynchronous call request includes a node identification of a slave node to be called.
The processor 32 is configured to create a call record of the call according to the asynchronous call request, and call a slave node corresponding to the node identifier to process the asynchronous call request.
The receiver 31 is further configured to receive the processing result sent by the slave node.
The processor 32 is further configured to record the processing result in the call record.
The receiver 31 is further configured to receive a processing result obtaining request sent by a service node that needs to use the processing result in the service requested by the client, where the service node that needs to use the processing result is another slave node called by the master node in the service.
The processor 32 is further configured to obtain the processing result from the call record.
The transmitter 33 is configured to transmit the processing result to the service node that needs to use the processing result.
Optionally, the processor 32 is further configured to construct identification information for searching the call record. The transmitter 33 is further configured to transmit the identification information to the master node, and transmit the identification information to a slave node that needs to use the processing result and is called by the master node in the service through the master node.
Optionally, the call record created by the processor 32 further includes a call identifier for identifying the call of this time, and the constructing, by the processor 32, the identifier information for searching the call record specifically includes: and directly taking the calling identifier as identifier information for searching the calling record, or constructing a handle object based on the calling identifier as identifier information for searching the calling record.
The coordinator provided in the embodiment of the present invention may execute the technical solution shown in the embodiment of fig. 2, and the implementation principle and the beneficial effects thereof may specifically refer to the embodiment shown in fig. 2, which is not described herein again.
In a possible implementation manner, the processing result obtaining request carries the identification information.
Correspondingly, the obtaining, by the processor 32, the processing result from the call record specifically includes:
and searching the calling record according to the identification information, and judging whether the processing result exists in the calling record.
If yes, the processor 32 is configured to obtain the processing result.
If not, the processor 32 adds the identifier of the node that needs to use the processing result into a waiting list, and when the processing result exists in the call record, obtains the processing result, and moves the identifier of the node that needs to use the processing result out of the waiting list.
In this possible implementation manner, the implementation principle and the beneficial effect of the coordinator may specifically refer to the embodiment shown in fig. 3, and are not described herein again.
In another possible implementation manner, the processor 32 is further configured to create a service record of the service based on the service requested by the client, where the service record includes a service identifier used for searching the service record.
The transmitter 33 is further configured to transmit the service identification to the master node.
The asynchronous call request initiated by the master node carries the service identifier, and the processor 32 creates the call record in the service record according to the service identifier when creating the call record.
Optionally, the receiver 31 is further configured to receive a service creation request sent by the master node based on the service requested by the client.
The creating, by the processor 32, the service record of the service according to the service creation request specifically includes: and creating a service record of the service according to the service creation request.
In this possible implementation manner, specific reference may be made to S401-S402 in the embodiment shown in fig. 4 for implementation principles and beneficial effects of the coordinator, which are not described herein again.
In another possible implementation manner, the constructing, by the processor 32, the identification information for searching the call record specifically includes:
and combining the service identifier and the calling identifier to be used as identifier information for searching the calling record, or constructing a handle object based on the service identifier and the calling identifier to be used as identifier information for searching the calling record.
In this possible implementation manner, the implementation principle and the beneficial effect of the coordinator may specifically refer to S410 in the embodiment shown in fig. 4, and are not described herein again.
In another possible embodiment, the service record and the call record are tree structures; the tree structure takes the service record as a root node, and the call record is a child node hung under the root node.
In this possible implementation manner, specific reference may be made to S402-S406 in the embodiment shown in fig. 4 for implementation principles and beneficial effects of the coordinator, which are not described herein again.
Fig. 10 is a first schematic diagram of a hardware structure of a service node provided in the present invention, where the service node is a master node in a distributed system, and the distributed system includes a coordinator and at least two service nodes, where a service node requested by a client to provide a service is the master node, and a service node called by the master node to complete the service is a slave node. Referring to fig. 10, the master node includes a processor 41, a transmitter 42, a memory 43 for storing an application program, and a communication bus 44, the processor 41 is configured to perform corresponding operations according to the application program in the memory 43, the communication bus 44 is configured to implement communication connections between elements, wherein,
the processor 41 is configured to determine a slave node to be invoked according to a service requested by a client.
The sender 42 is configured to send an asynchronous call request for calling a first slave node to the coordinator, call the first slave node through the coordinator to process the asynchronous call request, and record a processing result of the asynchronous call request by the first slave node; the first slave node is one of the slave nodes which are determined to need to be called.
The processor 41 is further configured to identify, according to a dependency relationship between slave nodes that need to be called, a second slave node that needs a processing result of the asynchronous call request by using the first slave node, from among the slave nodes that need to be called.
The processor 41 is further configured to invoke the second slave node, and instruct the second slave node to obtain a processing result of the first slave node on the asynchronous call request from the coordinator in the process of invoking the second slave node.
The service node provided in the embodiment of the present invention may execute the technical solution shown in the embodiment of fig. 2, and reference may be made to the embodiment shown in fig. 2 for implementation principles and beneficial effects thereof, which are not described herein again.
Fig. 11 is a schematic diagram of a hardware structure of a service node according to a second embodiment of the present invention, and referring to fig. 11, based on the embodiment shown in fig. 10, the master node further includes a receiver 45, wherein,
the sender 42 is further configured to, before the processor 41 determines a node that needs to be called according to a service initiated by a client, send a service creation request to the coordinator based on the service requested by the client, so that the coordinator creates a service record of the service according to the service creation request, where the service record includes a service identifier used for searching the service record.
The receiver 45 is configured to receive the identification of the service sent by the coordinator.
Correspondingly, the asynchronous call request includes the service identifier and the identifier of the first slave node.
In this possible implementation manner, the implementation principle and the beneficial effects of the service node may specifically refer to S401 to S402 in the embodiment shown in fig. 4, which are not described herein again.
Optionally, after the sender 42 sends an asynchronous call request for calling the first slave node to the coordinator, the receiver 45 is further configured to receive identification information sent by the coordinator and used for searching for a call record corresponding to the asynchronous call request.
Correspondingly, the transmitter 42 is further configured to transmit the identification information to the second slave node, so that the second slave node obtains, in the coordinator, a processing result of the asynchronous call request by the first slave node according to the identification information.
In this possible implementation manner, the implementation principle and the beneficial effect of the service node may specifically refer to S411 and S413 in the embodiment shown in fig. 4, and details are not described here.
An embodiment of the present invention further provides a distributed system, which includes the coordinator shown in the embodiment of fig. 9, the service node shown in fig. 10 or fig. 11, and at least one slave service node called by the service node to complete a service, wherein,
the coordinator is configured to store a processing result corresponding to each asynchronous call in the service, so that the service node and each slave service node obtain the processing result from the coordinator when the processing result needs to be used by the service node and each slave service node.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (23)
1. An asynchronous call processing method applied to a distributed system including a coordinator and at least two service nodes, wherein a service node requested to provide a service by a client is a master node, and a service node called by the master node to complete the service is a slave node, the method comprising:
the coordinator receives an asynchronous calling request initiated by the master node based on the service requested by the client, wherein the asynchronous calling request comprises a node identification of a slave node to be called;
the coordinator establishes a call record of the call according to the asynchronous call request, and calls a slave node corresponding to the node identification to process the asynchronous call request;
the coordinator receives the processing result sent by the slave node and records the processing result in the call record;
the coordinator receives a processing result acquisition request sent by a service node which needs to use the processing result in the service requested by the client, wherein the service node which needs to use the processing result is other slave nodes called by the master node in the service;
the coordinator obtains the processing result from the calling record and sends the processing result to the service node needing to use the processing result;
wherein a first process of the coordinator is executed in parallel with a second process, the first process including: creating a call record of the call according to the asynchronous call request, calling a slave node corresponding to the node identifier to process the asynchronous call request, receiving a processing result sent by the slave node, and recording the processing result in the call record; the second processing procedure comprises: and receiving a processing result acquisition request sent by a service node which needs to use the processing result in the service requested by the client.
2. The method of claim 1, further comprising:
the coordinator is used for searching the identification information of the calling record, sending the identification information to a main node, and sending the identification information to a slave node which is called by the main node in the service and needs to use the processing result through the main node.
3. The method according to claim 2, wherein the processing result acquisition request carries the identification information;
the coordinator obtains the processing result from the call record, and the processing result comprises:
the coordinator searches the calling record according to the identification information;
the coordinator judges whether the processing result exists in the calling record or not;
if so, the coordinator obtains the processing result;
if not, the coordinator adds the identifier of the node needing to use the processing result into a waiting list, acquires the processing result when the processing result exists in the call record, and moves the identifier of the node needing to use the processing result out of the waiting list.
4. The method according to claim 2 or 3, wherein the call record created by the coordinator further includes a call identifier for identifying the call, and the constructing the identifier information for searching the call record specifically includes:
and the coordinator directly takes the calling identifier as identifier information for searching the calling record, or constructs a handle object based on the calling identifier as identifier information for searching the calling record.
5. A method according to claim 2 or 3, characterized in that the method further comprises:
the coordinator establishes a service record of the service based on the service requested by the client, wherein the service record comprises a service identifier used for searching the service record, and the service identifier is sent to the master node;
the asynchronous call request initiated by the main node carries the service identifier, and the coordinator creates the call record in the service record according to the service identifier when creating the call record.
6. The method according to claim 5, wherein the creating a service record of the service based on the service requested by the client specifically includes:
the coordinator receives a service creation request sent by the master node based on the service requested by the client;
and the coordinator establishes the service record of the service according to the service establishing request.
7. The method according to claim 6, wherein the constructing identification information for searching the call record specifically comprises:
and the coordinator combines the service identifier and the calling identifier to be used as identifier information for searching the calling record, or constructs a handle object based on the service identifier and the calling identifier to be used as the identifier information for searching the calling record.
8. The method of claim 5, wherein the service record and the call record are tree-structured; the tree structure takes the service record as a root node, and the calling record is a child node hung under the root node.
9. An asynchronous call processing method applied to a distributed system including a coordinator and at least two service nodes, wherein a service node requested to provide a service by a client is a master node, and a service node called by the master node to complete the service is a slave node, the method comprising:
the master node determines a slave node to be called according to the service requested by the client;
the master node sends an asynchronous call request for calling a first slave node to the coordinator, the first slave node is called through the coordinator to process the asynchronous call request, and the processing result of the first slave node on the asynchronous call request is recorded; the first slave node is one of the determined slave nodes needing to be called;
the master node identifies a second slave node which needs to use the first slave node to process the asynchronous call request in the slave nodes needing to be called according to the dependency relationship among the slave nodes needing to be called;
the master node calls the second slave node and indicates the second slave node to obtain a processing result of the asynchronous call request from the coordinator in the process of calling the second slave node, wherein when the master node calls the second slave node, the master node does not need to wait for the call result of the first slave node.
10. The method of claim 9, before determining the nodes that need to be invoked according to the service initiated by the client, further comprising:
the main node sends a service creation request to the coordinator based on the service requested by the client, so that the coordinator creates a service record of the service according to the service creation request, wherein the service record comprises a service identifier used for searching the service record;
the main node receives the service identification sent by the coordinator;
correspondingly, the asynchronous call request includes the service identifier and the identifier of the first slave node.
11. The method of claim 9 or 10, wherein after the master node sends an asynchronous call request to the coordinator to call the first slave node, the method further comprises:
the master node receives identification information which is sent by the coordinator and used for searching for a call record corresponding to the asynchronous call request;
correspondingly, instructing the second slave node to obtain the processing result of the first slave node on the asynchronous call request from the coordinator in the process of calling the second slave node comprises:
and sending the identification information to the second slave node so that the second slave node acquires the processing result of the first slave node on the asynchronous call request in the coordinator according to the identification information.
12. A coordinator is located in a distributed system, the distributed system further comprises at least two service nodes, wherein the service node requested by a client to provide a service is a master node, the service node called by the master node to complete the service is a slave node, the coordinator comprises a receiving module, a processing module and a sending module, wherein,
the receiving module is used for receiving an asynchronous call request initiated by the master node based on the service requested by the client, wherein the asynchronous call request comprises a node identifier of a slave node to be called;
the processing module is used for creating a call record of the call according to the asynchronous call request and calling the slave node corresponding to the node identifier to process the asynchronous call request;
the receiving module is further configured to receive a processing result sent by the slave node;
the processing module is further used for recording the processing result in the call record;
the receiving module is further configured to receive a processing result obtaining request sent by a service node that needs to use the processing result in the service requested by the client, where the service node that needs to use the processing result is another slave node called by the master node in the service;
the processing module is further used for acquiring the processing result from the calling record;
the sending module is used for sending the processing result to the service node which needs to use the processing result;
wherein a first process of the coordinator is executed in parallel with a second process, the first process including: creating a call record of the call according to the asynchronous call request, calling a slave node corresponding to the node identifier to process the asynchronous call request, receiving a processing result sent by the slave node, and recording the processing result in the call record; the second processing procedure comprises: and receiving a processing result acquisition request sent by a service node which needs to use the processing result in the service requested by the client.
13. Coordinator according to claim 12,
the processing module is further configured to construct identification information for searching the call record;
the sending module is further configured to send the identification information to the master node, and send the identification information to a slave node that needs to use the processing result and is called by the master node in the service through the master node.
14. The coordinator according to claim 13, wherein the processing result acquisition request carries the identification information;
correspondingly, the acquiring, by the processing module, the processing result from the call record specifically includes:
searching the calling record according to the identification information, and judging whether the processing result exists in the calling record;
if yes, the processing module is used for obtaining the processing result;
if not, the processing module adds the identifier of the node needing to use the processing result into a waiting list, acquires the processing result when the processing result exists in the call record, and moves the identifier of the node needing to use the processing result out of the waiting list.
15. The coordinator according to claim 13 or 14, wherein the call record created by the processing module further includes a call identifier for identifying the call, and the constructing, by the processing module, the identifier information for searching the call record specifically includes:
and directly taking the calling identifier as identifier information for searching the calling record, or constructing a handle object based on the calling identifier as identifier information for searching the calling record.
16. Coordinator according to claim 13 or 14,
the processing module is further configured to create a service record of the service based on the service requested by the client, where the service record includes a service identifier for searching the service record;
the sending module is further configured to send the service identifier to the master node;
the asynchronous call request initiated by the main node carries the service identifier, and the processing module creates the call record in the service record according to the service identifier when creating the call record.
17. The coordinator according to claim 16,
the receiving module is further configured to receive a service creation request sent by the master node based on the service requested by the client;
the step of the processing module creating the service record of the service according to the service creation request specifically includes: and creating a service record of the service according to the service creation request.
18. The coordinator according to claim 17, wherein the processing module constructing identification information for searching the call record specifically includes:
and combining the service identifier and the calling identifier to be used as identifier information for searching the calling record, or constructing a handle object based on the service identifier and the calling identifier to be used as identifier information for searching the calling record.
19. The coordinator of claim 16, wherein the service record and the call record are tree-structured; the tree structure takes the service record as a root node, and the calling record is a child node hung under the root node.
20. A service node, wherein the service node is a master node in a distributed system, the distributed system comprises a coordinator and at least two service nodes, wherein the service node requested by a client to provide a service is the master node, the service node called by the master node to complete the service is a slave node, the master node comprises a processing module and a sending module, wherein,
the processing module is used for determining a slave node to be called according to the service requested by the client;
the sending module is used for sending an asynchronous call request for calling a first slave node to the coordinator, calling the first slave node through the coordinator to process the asynchronous call request and recording a processing result of the first slave node on the asynchronous call request; the first slave node is one of the determined slave nodes needing to be called;
the processing module is further used for identifying a second slave node which needs to use the first slave node to process the asynchronous call request in the slave nodes needing to be called according to the dependency relationship among the slave nodes needing to be called;
the processing module is further configured to invoke the second slave node, and instruct the second slave node to obtain, from the coordinator, a processing result of the asynchronous call request by the first slave node in a process of invoking the second slave node, where the master node does not need to wait for a call result of the first slave node when the master node invokes the second slave node.
21. The serving node of claim 20, further comprising a receiving module, wherein,
the sending module is further configured to send a service creation request to the coordinator based on the service requested by the client before the processing module determines a node to be called according to the service initiated by the client, so that the coordinator creates a service record of the service according to the service creation request, where the service record includes a service identifier used for searching the service record;
the receiving module is configured to receive the identifier of the service sent by the coordinator;
correspondingly, the asynchronous call request comprises the identification of the service and the identification of the first slave node.
22. The service node according to claim 21, wherein after the sending module sends an asynchronous call request for calling the first slave node to the coordinator, the receiving module is further configured to receive identification information sent by the coordinator and used for searching a call record corresponding to the asynchronous call request;
correspondingly, the sending module is further configured to send the identification information to the second slave node, so that the second slave node obtains, in the coordinator, a processing result of the asynchronous call request by the first slave node according to the identification information.
23. A distributed system comprising a coordinator according to any one of claims 12 to 19 and a service node according to any one of claims 20 to 22.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610944766.4A CN106453592B (en) | 2016-11-02 | 2016-11-02 | Asynchronous call processing method, device and distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610944766.4A CN106453592B (en) | 2016-11-02 | 2016-11-02 | Asynchronous call processing method, device and distributed system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106453592A CN106453592A (en) | 2017-02-22 |
CN106453592B true CN106453592B (en) | 2020-05-08 |
Family
ID=58177691
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610944766.4A Active CN106453592B (en) | 2016-11-02 | 2016-11-02 | Asynchronous call processing method, device and distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106453592B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108919756B (en) * | 2018-06-25 | 2020-07-28 | 首都师范大学 | Method for loading and calling CPS node function processing method |
CN115145997A (en) * | 2021-03-30 | 2022-10-04 | 华为云计算技术有限公司 | Distributed transaction implementation method and distributed system |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101056429A (en) * | 2007-05-29 | 2007-10-17 | 华为技术有限公司 | Universal service system and its implementation method |
CN101447981A (en) * | 2008-04-03 | 2009-06-03 | 中兴通讯股份有限公司 | Client-server interaction method based on LDAP protocol and system thereof |
US7770188B2 (en) * | 2006-04-20 | 2010-08-03 | Microsoft Corporation | Winsock APIs |
CN105099989A (en) * | 2014-04-24 | 2015-11-25 | 阿里巴巴集团控股有限公司 | Service request processing and service processing result acquiring method, device and system |
CN105159786A (en) * | 2015-07-03 | 2015-12-16 | 北京奇虎科技有限公司 | Method and device for inter-process communication |
CN105516086A (en) * | 2015-11-25 | 2016-04-20 | 广州华多网络科技有限公司 | Service processing method and apparatus |
CN105700937A (en) * | 2016-01-04 | 2016-06-22 | 北京百度网讯科技有限公司 | Multi-thread task processing method and device |
CN105872578A (en) * | 2016-03-30 | 2016-08-17 | 青岛海信电器股份有限公司 | Invoking method and server |
-
2016
- 2016-11-02 CN CN201610944766.4A patent/CN106453592B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7770188B2 (en) * | 2006-04-20 | 2010-08-03 | Microsoft Corporation | Winsock APIs |
CN101056429A (en) * | 2007-05-29 | 2007-10-17 | 华为技术有限公司 | Universal service system and its implementation method |
CN101447981A (en) * | 2008-04-03 | 2009-06-03 | 中兴通讯股份有限公司 | Client-server interaction method based on LDAP protocol and system thereof |
CN105099989A (en) * | 2014-04-24 | 2015-11-25 | 阿里巴巴集团控股有限公司 | Service request processing and service processing result acquiring method, device and system |
CN105159786A (en) * | 2015-07-03 | 2015-12-16 | 北京奇虎科技有限公司 | Method and device for inter-process communication |
CN105516086A (en) * | 2015-11-25 | 2016-04-20 | 广州华多网络科技有限公司 | Service processing method and apparatus |
CN105700937A (en) * | 2016-01-04 | 2016-06-22 | 北京百度网讯科技有限公司 | Multi-thread task processing method and device |
CN105872578A (en) * | 2016-03-30 | 2016-08-17 | 青岛海信电器股份有限公司 | Invoking method and server |
Also Published As
Publication number | Publication date |
---|---|
CN106453592A (en) | 2017-02-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107508795B (en) | Cross-container cluster access processing device and method | |
US10305823B2 (en) | Network interface card configuration method and resource management center | |
US20180239726A1 (en) | Data transmission method, device, and system | |
EP3800589A1 (en) | Task processing method and apparatus | |
CN107431651A (en) | The life cycle management method and equipment of a kind of network service | |
CN111897638A (en) | Distributed task scheduling method and system | |
CN111491037B (en) | Communication method with object storage server through SFTP data stream | |
CN109343983B (en) | Information interaction method, device, equipment and storage medium between function modules | |
CN111858083A (en) | Remote service calling method and device, electronic equipment and storage medium | |
CN106453592B (en) | Asynchronous call processing method, device and distributed system | |
CN103701653B (en) | The processing method of a kind of interface hot plug configuration data and network configuration server | |
US9350606B2 (en) | System and method for assigning server to terminal and efficiently delivering messages to the terminal | |
CN110674205B (en) | Single table query method, device, terminal and readable storage medium | |
US11706156B2 (en) | Method and system for changing resource state, terminal, and storage medium | |
CN106453213B (en) | Call method and device between a kind of system | |
CN108667750B (en) | Virtual resource management method and device | |
CN113923259A (en) | Data processing method and system | |
CN106202456B (en) | Send the method and device of picture | |
CN113761016A (en) | Data query method, device, equipment and storage medium | |
US20220350748A1 (en) | Consistent hashing for communication devices | |
CN107305581B (en) | Table connection method in distributed database system and distributed database system | |
CN110389966B (en) | Information processing method and device | |
JP2019536382A (en) | Packet forwarding | |
CN109309583B (en) | Information acquisition method and device based on distributed system, electronic equipment and medium | |
CN108933755B (en) | Application server message sending, receiving and interacting method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20211118 Address after: 215010 room 704, building 5, No. 556, Changjiang Road, high tech Zone, Suzhou, Jiangsu Patentee after: SUZHOU YUDESHUI ELECTRICAL TECHNOLOGY Co.,Ltd. Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd. |
|
TR01 | Transfer of patent right |