CN115599845B - Service execution method, device, storage medium and electronic equipment - Google Patents

Service execution method, device, storage medium and electronic equipment Download PDF

Info

Publication number
CN115599845B
CN115599845B CN202211557544.9A CN202211557544A CN115599845B CN 115599845 B CN115599845 B CN 115599845B CN 202211557544 A CN202211557544 A CN 202211557544A CN 115599845 B CN115599845 B CN 115599845B
Authority
CN
China
Prior art keywords
linked list
processing node
node
executed
annular
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211557544.9A
Other languages
Chinese (zh)
Other versions
CN115599845A (en
Inventor
黄金恺
孔维龙
魏雍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Xinzhi Cosmos Technology Co ltd
Original Assignee
Hangzhou Xinzhi Cosmos Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Xinzhi Cosmos Technology Co ltd filed Critical Hangzhou Xinzhi Cosmos Technology Co ltd
Priority to CN202211557544.9A priority Critical patent/CN115599845B/en
Publication of CN115599845A publication Critical patent/CN115599845A/en
Application granted granted Critical
Publication of CN115599845B publication Critical patent/CN115599845B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The specification discloses a method, equipment, a device and a storage medium for service execution. The distributed system determines the processing node and the position of the adjacent node of the processing node corresponding to the first annular linked list according to the identifier of the processing node, the processing node determines the query range on the second annular linked list according to the position of the processing node and the position of the adjacent node of the processing node corresponding to the first annular linked list, the distributed system determines the session task to be executed which falls in the query range in the second annular linked list according to the query range, the determined query result is sent to the processing node, and the processing node receives the query result and executes the session task to be executed in the query result. According to the method, other tasks related to the session task are executed in one processing node through the mode that the processing node searches for the task to be executed, the step of calling the session across the processing nodes is eliminated, and the efficiency of executing the session by the processing nodes is improved.

Description

Service execution method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer applications, and in particular, to a method, an apparatus, a storage medium, and an electronic device for executing a service.
Background
With the development of the times, computer technology has developed more mature and is widely applied in various fields. Among them, how to allocate resources in a distributed system is a technical problem to be solved.
In the prior art, a resource allocation method for a distributed system is to construct an annular linked list in advance, determine hash values corresponding to processing nodes in the distributed system, and determine positions of the processing nodes corresponding to the environment linked list according to the hash values of the processing nodes. And respectively determining the hash value corresponding to the service data aiming at each service data needing to be processed by the distributed system, thereby determining the position of the service data on the circular linked list. And finally, according to the preset traversal direction of the annular linked list, searching a position corresponding to the processing node closest to the position of the service data on the annular linked list, taking the found processing node closest to the position of the service data as the processing node for processing the service data, and sending the service data to the processing node to execute the service.
However, in a service scenario mainly involving a long-chain session, it is difficult to control service operations of the same session to be processed by the same processing node, which results in a large number of calls between processing nodes and reduces the processing efficiency of the distributed system. Accordingly, the present specification provides a method of service execution.
Disclosure of Invention
The present specification provides a method, an apparatus, a storage medium, and an electronic device for service execution, so as to at least partially solve the above problems in the prior art.
The technical scheme adopted by the specification is as follows:
the present specification provides a method for service execution, where the method is applied to any processing node in a distributed system, where in the distributed system, a first circular linked list corresponding to the processing node and a second circular linked list of a session task to be executed are preconfigured, and the method includes:
sending a first query request aiming at the first annular linked list to the distributed system according to the identification of the processing node;
receiving a first query result returned by the distributed system, wherein the first query result comprises: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node on the first annular linked list corresponds to the position in the first annular linked list;
determining the query range on the second annular linked list according to the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list;
determining a second query request according to the query range, and sending the second query request to the distributed system, so that the distributed system queries a to-be-executed session task falling in the query range in the second annular linked list, wherein the to-be-executed session task is determined by the distributed system according to the received request of the to-be-executed session task, and the position of the to-be-executed session task in the second annular linked list is determined by the distributed system according to the received identifier of the request of the to-be-executed session task;
receiving a second query result which is returned by the distributed system and carries the session task to be executed;
and executing the session task to be executed contained in the second query result.
Optionally, determining a query range on the second circular linked list according to a corresponding position of the processing node itself in the first circular linked list and a corresponding position of the neighboring node in the first circular linked list, specifically including:
sending an acquisition request to the distributed system, and receiving a mapping relation between the first annular linked list and the second annular linked list returned by the distributed system;
respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list;
and determining the range from the position of the processing node mapped to the second circular linked list to the corresponding position of the adjacent node in the second circular linked list as the query range on the second circular linked list according to a preset traversal direction.
Optionally, the lengths of the first circular linked list and the second circular linked list are the same, and the positions in the first circular linked list correspond to the positions in the second circular linked list one to one.
Optionally, executing the to-be-executed session task included in the second query result specifically includes:
determining a session identifier of each thread execution session in the local thread list according to the local thread list of the processing node;
judging whether a thread matched with the session identifier of each session task to be executed exists or not for each session task to be executed;
if so, distributing the session task to be executed to a thread matched with the session identifier of the session task to be executed, and enabling the thread to execute the session task to be executed;
if not, the session task to be executed is allocated to an idle thread, and the idle thread executes the session task to be executed.
Optionally, when the thread in the local thread list is not allocated with the session task to be executed, it is determined that the session executed by the thread is ended, and the thread is ended.
Optionally, the processing node corresponds to at least one virtual node, and the first circular linked list is configured with the processing node and a virtual node corresponding to the processing node;
determining a query range on the second annular linked list according to the corresponding position of the processing node in the first annular linked list and the corresponding positions of other processing nodes adjacent to the processing node in the first annular linked list, which specifically includes:
determining adjacent nodes of the processing nodes and adjacent nodes of the virtual nodes corresponding to the processing nodes;
acquiring a mapping relation between the first annular linked list and the second annular linked list;
determining the query range of the processing node on the second circular linked list according to the mapping relation, the corresponding position of the processing node in the first circular linked list and the corresponding position of the adjacent node of the processing node in the first circular linked list;
and determining the query range of each virtual node corresponding to the processing node on the second annular linked list according to the mapping relation, the corresponding position of the virtual node in the first annular linked list and the corresponding position of the adjacent node of the virtual node in the first annular linked list.
The present specification provides a method for service execution, where the method applies a distributed system, and in the distributed system, a first circular linked list corresponding to a processing node and a second circular linked list of a session task to be executed are preconfigured, and the method includes:
when a request of a session task to be executed is received, determining the position of the session task to be executed in a second annular linked list according to the identifier of the request of the session task to be executed;
responding to a first query request of a processing node, determining the corresponding position of the processing node in a first annular linked list, traversing the first annular linked list according to a preset direction, and determining the corresponding position of an adjacent node of the processing node in the first annular linked list;
returning the determined corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node of the processing node in the first annular linked list to the processing node as a first query result;
receiving a second query request of a query range carried on the second circular linked list, and determining the session task to be executed falling into the query range in the second circular linked list according to the query range;
and returning the determined session tasks to be executed as a second query result to the processing node, so that the processing node executes the received session tasks to be executed.
Optionally, for each processing node, monitoring the running state of the processing node;
when the processing node is determined to be offline, deleting the processing node in the first annular linked list;
and when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
The present specification provides a device for service execution, where the device is applied to any processing node in a distributed system, and in the distributed system, a first circular linked list corresponding to the processing node and a second circular linked list of a session task to be executed are preconfigured, including:
a first query request sending module, configured to send a first query request for the first circular linked list to the distributed system according to the identifier of the processing node;
a first query result receiving module, configured to receive a first query result returned by the distributed system, where the first query result includes: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node on the first annular linked list corresponds to the position in the first annular linked list;
a query range determining module, configured to determine a query range on the second circular linked list according to a corresponding position of the processing node in the first circular linked list and a corresponding position of the neighboring node in the first circular linked list;
a second query request sending module, configured to determine a second query request according to the query range, and send the second query request to the distributed system, so that the distributed system queries a to-be-executed session task that falls within the query range in the second circular linked list, where the to-be-executed session task is determined by the distributed system according to a received request for the to-be-executed session task, and a position of the to-be-executed session task in the second circular linked list is determined by the distributed system according to an identifier of the received request for the to-be-executed session task;
the second query result receiving module is used for receiving a second query result which is returned by the distributed system and carries the session task to be executed;
and the task execution module is used for executing the session task to be executed contained in the second query result.
Optionally, the first query request sending module is specifically configured to send an acquisition request to the distributed system, and receive a mapping relationship between the first circular linked list and the second circular linked list returned by the distributed system; respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; and determining the range from the position of the processing node mapped to the second circular linked list to the corresponding position of the adjacent node in the second circular linked list as the query range on the second circular linked list according to a preset traversal direction.
Optionally, the lengths of the first annular linked list and the second annular linked list are the same, and the positions in the first annular linked list correspond to the positions in the second annular linked list one to one.
Optionally, the task execution module is specifically configured to determine, according to a local thread list of the processing node, a session identifier of each thread execution session in the local thread list; judging whether a thread matched with the session identifier of each session task to be executed exists or not according to each session task to be executed; if so, distributing the session task to be executed to a thread matched with the session identifier of the session task to be executed, and enabling the thread to execute the session task to be executed; if not, the to-be-executed conversation task is distributed to an idle thread, and the to-be-executed conversation task is executed by the idle thread.
Optionally, the apparatus further comprises: and the thread ending module is used for determining that the session executed by the thread is ended and ending the thread when the thread in the local thread list is not allocated with the session task to be executed.
Optionally, the processing node corresponds to at least one virtual node, and the first circular linked list is configured with the processing node and a virtual node corresponding to the processing node;
the query range determining module is specifically configured to determine an adjacent node of the processing node and an adjacent node of the virtual node corresponding to the processing node; acquiring a mapping relation between the first annular linked list and the second annular linked list; determining the query range of the processing node on the second circular linked list according to the mapping relation, the corresponding position of the processing node in the first circular linked list and the corresponding position of the adjacent node of the processing node in the first circular linked list; and determining the query range of each virtual node corresponding to the processing node on the second annular linked list according to the mapping relation, the corresponding position of the virtual node in the first annular linked list and the corresponding position of the adjacent node of the virtual node in the first annular linked list.
The present specification provides a device for service execution, where the device is applied to a distributed system, and in the distributed system, a first circular linked list corresponding to a processing node and a second circular linked list of a session task to be executed are preconfigured, including:
the session task determining module is used for determining the position of the session task to be executed in the second annular linked list according to the identifier of the request of the session task to be executed when receiving the request of the session task to be executed;
a node determining module, configured to determine, in response to a first query request for a processing node, a corresponding position of the processing node in a first circular linked list, traverse the first circular linked list in a preset direction, and determine a corresponding position of an adjacent node of the processing node in the first circular linked list;
a first query result returning module, configured to return the determined corresponding position of the processing node in the first circular linked list and the corresponding position of the neighboring node of the processing node in the first circular linked list as a first query result to the processing node;
the session task query module is used for receiving a second query request of a query range carried on the second circular linked list and determining the session task to be executed falling into the query range in the second circular linked list according to the query range;
and the second query result returning module is used for returning the determined session tasks to be executed to the processing node as second query results, so that the processing node executes the received session tasks to be executed.
Optionally, the apparatus further comprises: the node state monitoring module is used for monitoring the running state of each processing node; when the processing node is determined to be offline, deleting the processing node in the first annular linked list; and when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
The present specification provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the method of service execution described above.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of service execution when executing the program.
The technical scheme adopted by the specification can achieve the following beneficial effects:
in a method for service execution provided in this specification, a first query request for the first circular linked list is sent to the distributed system according to an identifier of the processing node; receiving a first query result returned by the distributed system, wherein the first query result comprises: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node on the first annular linked list corresponds to the position in the first annular linked list; determining the query range on the second annular linked list according to the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a second query request according to the query range, and sending the second query request to the distributed system, so that the distributed system queries a to-be-executed session task falling in the query range in the second annular linked list, wherein the to-be-executed session task is determined by the distributed system according to the received request of the to-be-executed session task, and the position of the to-be-executed session task in the second annular linked list is determined by the distributed system according to the received identifier of the request of the to-be-executed session task; receiving a second query result which is returned by the distributed system and carries the session task to be executed; and executing the session task to be executed contained in the second query result.
It can be seen from the above method that the method enables other tasks related to the session task to be executed in one processing node by means of the processing node searching for the task to be executed, eliminates the step of calling the session across the processing nodes, and improves the efficiency of the processing nodes in executing the session.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
fig. 1 is a schematic flow chart of a method for executing a service provided in the present specification;
FIG. 2 is a diagram illustrating a mapping of processing nodes in a first circular linked list to a second circular linked list;
FIG. 3 is a schematic diagram of a determined session task to be executed that a processing node needs to process;
FIG. 4 is a schematic diagram of a query range determined on a second circular linked list when a virtual node exists;
FIG. 5 is a flow chart illustrating a method of service execution provided herein;
FIG. 6 is a diagram illustrating a change of a session task to be executed by each processing node after the processing node comes online;
fig. 7 is a schematic diagram of a service execution apparatus provided in the present specification;
fig. 8 is a schematic diagram of a service execution apparatus provided in the present specification;
fig. 9 is a schematic structural diagram of an electronic device corresponding to fig. 1 provided in this specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without making any creative effort fall within the protection scope of the specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a method for executing a service provided in this specification, which specifically includes the following steps:
s100: and sending a first query request aiming at the first annular linked list to the distributed system according to the identification of the processing node.
At present, computer technology has been widely used in various fields. In the distributed system, compared with the method of searching a processing node for executing the session task according to the request of the session task to be executed, the method of executing the session task according to the processing node. The method for searching the session task to be executed according to the processing node provided by the specification enables other tasks related to the session task to be executed in one processing node, eliminates a step of calling the session across the processing nodes, and improves the efficiency of the processing nodes in executing the session.
In one or more embodiments of the present specification, an online processing node is used as an execution subject, and before processing a to-be-executed session task, the processing node needs to determine a list of the to-be-executed session task through a series of operations, so as to execute the session task.
In this series of operations, the corresponding locations of the processing node and the processing node's neighbors in the first circular linked list are determined. And the distributed system determines the corresponding position of the processing node in the first circular linked list according to the identifier corresponding to the processing node. Thus, a first query request for the first circular linked list is sent to the distributed system based on the identity of the processing node. The first query request includes an identifier of the processing node, where the identifier may be a serial number, an Internet Protocol (IP) Address, or a Media Access Control (MAC) Address of the processing node. The IP address may be fixed or dynamic, and the specification does not limit this, and the identifier of the processing node may be selected according to the requirement.
When the distributed system determines the position of the processing node corresponding to the first circular linked list, aiming at each processing node, the distributed system transforms the identifier of the processing node according to a preset strategy, and determines the position of the processing node in the first circular linked list according to the transformed identifier of the processing node. The preset policy may be a consistent hash algorithm or other operation methods, which is not limited in this specification.
For example, the distributed system processes the identifier of the processing node by using a consistent hash algorithm to obtain a hash value of the processing node, and places each processing node in the first circular linked list according to the hash value of each processing node.
S102: receiving a first query result returned by the distributed system, wherein the first query result comprises: the processing node itself corresponds to a position in the first circular linked list, and a position in the first circular linked list corresponding to a position in the first circular linked list of a node adjacent to the processing node.
In one or more embodiments of the present specification, since the distributed system may transform the identifier of the processing node according to a preset policy, each processing node is placed in the first circular linked list according to the identifier of the processing node after transformation. Therefore, the distributed system performs the same transformation according to the identifier of the processing node included in the received first query request, and obtains the transformed identifier of the processing node. And traversing the first annular linked list according to a certain direction, inquiring a processing node consistent with the processed identifier, and recording the position of the processing node. And the distributed system continuously queries the first annular linked list, the next processing node which is inconsistent with the processed identifier is an adjacent node of the processing node, and the position of the adjacent processing node is recorded. The direction of traversing the first circular linked list can be anticlockwise or clockwise.
And the distributed system returns the position of the processing node and the adjacent processing node in the first annular linked list to the processing node as a first query result. The processing node receives a first query result returned by the distributed system, and determines the corresponding position of the processing node in the first annular chain table and the corresponding position of the adjacent node of the processing node in the first annular chain table on the first annular chain table according to the first query result.
S104: and determining the query range on the second annular linked list according to the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list.
Because the session task to be executed is in the second circular linked list, if the list of the session task to be executed of the processing node is determined, the position of the processing node in the second circular linked list needs to be determined.
In one or more embodiments of the present disclosure, the processing node sends an acquisition request to a distributed system, and the distributed system receives the acquisition request, determines a mapping relationship between a first circular linked list and a second circular linked list, and sends the mapping relationship to the processing node.
The processing node receives a mapping relationship of a first circular linked list and a second circular linked list of the distributed system.
Specifically, the first annular linked list and the second annular linked list have the same length, and the positions in the first annular linked list correspond to the positions in the second annular linked list one to one.
FIG. 2 is a diagram illustrating a mapping of processing nodes in a first circular linked list to a second circular linked list.
The left graph refers to the first circular linked list and the right graph refers to the second circular linked list. In fig. 2 and subsequent circular linked lists, squares are processing nodes, diamonds are session tasks to be executed, the traversal direction is clockwise traversal, and processing nodes from dotted arrows to the first circular linked list are mapped into the second circular linked list.
When the lengths of the first circular linked list and the second circular linked list are the same, three processing nodes, namely processing nodes A, B and C, exist in the first circular linked list of the left graph. In the second circular linked list, the conversation tasks W, X, Y, Z are to be executed. The positions of the processing nodes a, B, and C in the first circular linked list are 1, 2, and 3, respectively, and the positions of the processing nodes a, B, and C in the second circular linked list may be 1, 2, 3, 1,3, 2, 1, etc., as long as the positions of the processing nodes a, B, and C in the second circular linked list are in one-to-one correspondence.
When the length of the first circular linked list is 4, and the length of the second circular linked list is 9, four processing nodes exist in the first circular linked list, namely processing node a, processing node B, processing node C and processing node D, the positions of the processing nodes a, B, C and D in the first circular linked list are 1, 2, 3 and 4 respectively, and then through mapping, the positions of the processing nodes a, B, C and D in the second circular linked list can be 1, 2, 3, 4,2, 4, 6 and 8, and the like.
In addition, after a processing node on a first circular linked list is mapped, the processing node may have multiple corresponding locations in a second circular linked list, but the locations must be contiguous. After mapping, the sequence between processing nodes is unchanged. This is because a processing node determines that it is to perform a conversational task based on its neighbors. And if the sequence among the processing nodes is changed, determining that the session tasks to be executed by the processing nodes comprise the session tasks to be executed by other processing nodes according to the adjacent nodes of the processing nodes.
For example, processing node A, as described above, is mapped to locations 1 and 2 in the second circular linked list. Similarly, the positions of the processing node B in the second circular linked list are 3 and 4, which are sequentially extended. The sequence among the processing nodes is A, B, C and D, and the sequence among the processing nodes after mapping is still unchanged. If the mapped processing nodes have an order of a, C, B, and D, when a session task to be executed by the processing node a is to be determined according to the processing node a and the processing node B, the determined session task to be executed by the processing node a actually includes the session task to be executed by the processing node B.
After the processing node acquires the mapping relation, respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent processing node mapped to the second annular linked list according to the mapping relation, the position of the processing node in the first annular linked list and the position of the adjacent processing node in the first annular linked list.
And the processing node determines the range from the position of the processing node mapped to the second circular linked list to the corresponding position of the adjacent processing node in the second circular linked list according to the preset traversal direction, and the range is used as the query range on the second circular linked list. The traversing direction is consistent with the traversing direction in step S100, in which the distributed system queries the position of the processing node in the first linked list and the position of the neighboring node of the processing node, so that the neighboring node of the processing node is unchanged.
In addition, the query range may also be a location where the processing node maps to the second circular linked list to a corresponding location of the neighboring processing node in the second circular linked list.
For example, the position of the processing node mapped to the second circular linked list is 10, the corresponding position of the adjacent processing node in the second circular linked list is 90, the processing node may use 10 to 90, the traversal direction is clockwise traversal as the determined query range, or 10, 11, 12 \8230, 8230, 90 as the query range, which is not limited in this specification.
S106: and determining a second query request according to the query range, and sending the second query request to the distributed system, so that the distributed system queries the session task to be executed falling into the query range in the second annular linked list, wherein the session task to be executed is determined by the distributed system according to the received request of the session task to be executed, and the position of the session task to be executed in the second annular linked list is determined by the distributed system according to the received identifier of the request of the session task to be executed.
In one or more embodiments of the present specification, since the mapping relationship obtained by the processing node may only determine the location where the processing node is mapped to the second circular linked list and the location where the neighboring node is mapped to the second circular linked list, and may not determine the session task to be executed by the processing node on the second circular linked list. Therefore, the processing node determines a second query request according to the query scope, and sends the second query request to the distributed system.
The distributed system receives a second query request of a query range carried on a second annular linked list, receives a request of a session task to be executed before querying the session task to be executed falling into the query range in the second annular linked list according to the query range, and determines the position of the session task to be executed in the second annular linked list according to the identifier of the request of the session task to be executed.
Specifically, the distributed system may process an identifier of a request for a session task to be executed, and then match the position of the second circular linked list according to the processed identifier. And in the second annular linked list, the position identifier consistent with the processed identifier is the position of the session task to be executed in the second annular linked list.
In one or more embodiments of the present description, there are multiple tasks in a session, and the identity of these tasks is consistent with the identity of the session. Therefore, for a plurality of tasks, the identification of the task is matched with the identification of the session, the identification of the task is consistent with the identification of the session, the task is indicated as the task in the session, and therefore the tasks related to the session can be all executed by the nodes executing the session.
After determining the position of each session task to be executed, the distributed system traverses the second circular linked list according to the query range and a certain direction, queries the session tasks to be executed falling into the query range in the second circular linked list, and obtains a second query result. And the distributed system sends the second query result to the processing node, so that the processing node executes each acquired session task to be executed.
Fig. 3 is a schematic diagram of a session task to be executed, which is determined to be processed by a processing node.
In the second circular linked list, there are positions of processing nodes after mapping processing a, B, C in fig. 3, and there are session tasks W, X, Y, Z to be executed. Taking the determination of the session task to be executed of the processing node B as an example, the distributed system determines that the session task to be executed of the processing node B is W and X according to the query range and the clockwise traversal direction.
S108: and receiving a second query result which is returned by the distributed system and carries the session task to be executed.
S110: and executing the session task to be executed contained in the second query result.
Since the processing node cannot determine the local thread list of the processing node, whether the thread of the session task to be executed included in the second query result already exists. And, for a long chain session, the thread of the processing node will be held for a period of time waiting for the subsequent task of processing the session. If an idle thread is reallocated to each received session task to be executed, the original thread executing the session task will wait all the time, resulting in resource waste. Therefore, it is determined whether a thread for processing the to-be-executed session task included in the second query result exists in the local thread list, and then the to-be-executed session task included in the second query result is executed.
In one or more embodiments of the present description, the processing node determines, according to a local thread list of the processing node, a session identifier of each thread executing a session in the local thread list. And judging whether a thread matched with the session identifier of each session task to be executed exists or not.
Specifically, for each session task to be executed, according to the identifier of the session task to be executed, a session identifier consistent with the identifier of the session task to be executed is queried in the local thread list of the processing node. If the query result shows that the local thread list has a session identifier consistent with the identifier of the session task to be executed, the local thread list includes a thread for executing the session task to be executed included in the second query result, and the session task to be executed is allocated to a thread matched with the session identifier of the session task to be executed, so that the thread executes the session task to be executed, and the session task to be executed is deleted from the second query result, thereby avoiding repeated judgment.
And if the query result shows that the session identifier consistent with the identifier of the session task to be executed does not exist in the local thread list, indicating that the thread of the session task to be executed contained in the second query result is not executed in the local thread list. And allocating the session task to be executed to an idle thread, executing the session task to be executed by the idle thread, and recording the identifier of the session task to be executed in the idle thread so as to be convenient for next query.
And after the to-be-executed conversation task contained in the second query result is subjected to thread judgment, if the to-be-executed conversation task is not distributed in the threads in the local thread list, determining that the conversation executed by the thread is ended, and ending the thread.
In addition, when there are fewer processing nodes, the distribution of the processing nodes in the first circular linked list may not be uniform, resulting in uneven distribution of the processing nodes mapped into the second circular linked list. When a session task is executed, data access requests are concentrated on the processing nodes, so that each processing node has a large amount of cached data, and the processing nodes are crashed and stop working. Thus, for each processing node, the processing node corresponds to at least one virtual node, the first circular linked list is configured with the processing node, and the virtual node corresponding to the processing node. If the session task to be executed is allocated to a certain virtual node, when the session task to be executed is processed, the virtual node allocates the session task to be executed to a processing node corresponding to the virtual node through mapping.
And when the virtual node exists, the distributed system configures the virtual node to the first circular linked list. Similar to the process of configuring the common processing node to the first circular linked list, the difference is that the identifier of the virtual node is obtained after processing according to the identifier of the processing node corresponding to the virtual node.
For example, if the identifier of a processing node is 1, the identifiers of the corresponding virtual nodes are 1-1, 1-2, 1-3, etc., respectively, and the identifier of a virtual node can embody the processing node corresponding to the virtual node.
Due to the existence of the virtual nodes, the query ranges on the second annular linked list are determined to be different according to the corresponding positions of the processing nodes in the first annular linked list and the corresponding positions of other processing nodes adjacent to the processing nodes in the first annular linked list.
In one or more embodiments of the present specification, a neighboring node of a processing node and a neighboring node of a virtual node corresponding to the processing node are determined first, and a mapping relationship between a first circular linked list and a second circular linked list is obtained. And determining the query range of the processing node on the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node of the processing node in the first annular linked list. And determining the query range of the virtual node on the second circular linked list according to the mapping relation, the corresponding position of the virtual node in the first circular linked list and the corresponding position of the adjacent node of the virtual node in the first circular linked list aiming at each virtual node corresponding to the processing node.
FIG. 4 is a diagram illustrating query ranges determined on a second circular linked list in the presence of virtual nodes.
The left graph is a first circular linked list and the right graph is a second circular linked list. When the virtual nodes exist and the length of the first circular linked list is the same as that of the second circular linked list, processing nodes A, B and C and virtual nodes A1, A2 and A3 corresponding to the processing nodes A exist in the first circular linked list, and tasks W, X, Y and Z are to be executed in the second circular linked list. After the processing nodes a, B, and C and the virtual nodes A1, A2, and A3 corresponding to the processing node a are mapped into the second circular linked list, taking the processing node a as an example, the query range determined by the processing node a on the second circular linked list is the distance from the virtual node a to the processing node B in the clockwise direction, and the distance from the processing node C in the clockwise direction by the virtual node A2.
Based on the service execution method shown in fig. 1, sending a first query request for the first circular linked list to the distributed system according to the identifier of the processing node; receiving a first query result returned by the distributed system, wherein the first query result comprises: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node on the first annular linked list corresponds to the position in the first annular linked list; determining the query range on the second annular linked list according to the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a second query request according to the query range, and sending the second query request to the distributed system, so that the distributed system queries a to-be-executed session task falling in the query range in the second annular linked list, wherein the to-be-executed session task is determined by the distributed system according to the received request of the to-be-executed session task, and the position of the to-be-executed session task in the second annular linked list is determined by the distributed system according to the received identifier of the request of the to-be-executed session task; receiving a second query result which is returned by the distributed system and carries the session task to be executed; and executing the session task to be executed contained in the second query result.
It can be seen from the above method that the method enables other tasks related to the session task to be executed in one processing node by means of the processing node searching for the task to be executed, eliminates the step of calling the session across the processing nodes, and improves the efficiency of the processing nodes in executing the session.
For step S100, when determining the position of the processing node in the first circular linked list, if the identifier of the processing node is the hash value, and the hash value has a corresponding position in the first circular linked list, the processing node may be directly placed at the corresponding position in the first circular linked list without processing the identifier of the processing node. The present specification does not limit the position of each processing node in the first circular linked list as long as the position can be determined.
In addition, when determining the position of the processing node in the first circular linked list, specifically, the length of the first circular linked list is determined, and assuming that the length of the first circular linked list is 100 bits in total, the identifier value of the processing node is limited to be an integer value, and the range is 0 to 99. Then in a distributed system the identification of each processing node is in the range of 0-99 and globally unique. When the processing node is on line, matching the identifier of the processing node with the first annular linked list, and placing the processing node at a position in the first annular linked list, which is consistent with the identifier of the processing node.
In step S102, if the distributed system does not process the identifier of the processing node in step S100, the distributed system directly performs the traversal query operation according to the identifier of the processing node included in the received first query request.
With respect to step S104, in one or more embodiments of the present specification, the length of the first circular linked list and the length of the second circular linked list are not limited to be the same. But the length of the first circular linked list is not greater than the length of the second circular linked list. That is to say, when the length of the first annular linked list is the same as that of the second annular linked list, the positions of the first annular linked list and the second annular linked list are in one-to-one correspondence, and when the length of the first annular linked list is smaller than that of the second annular linked list, each position of the first annular linked list corresponds to a plurality of positions of the second annular linked list.
If the length of the first circular linked list is less than that of the second circular linked list, the position in the first circular linked list may correspond to the positions in the plurality of second circular linked lists, but one position in the second circular linked list only corresponds to one position in the first circular linked list.
Fig. 1 is a schematic flow diagram of a method for executing a service provided in this specification, and an embodiment of this specification further provides a flow executed by a distributed system, as shown in fig. 5, which specifically includes the following steps:
fig. 5 is a flowchart illustrating a method for executing a service according to the present disclosure.
S200: and when a request of the session task to be executed is received, determining the position of the session task to be executed in the second annular linked list according to the identifier of the request of the session task to be executed.
In one or more embodiments of the present description, a distributed system may pre-configure processing nodes onto a first circular linked list.
Specifically, the distributed system determines the corresponding position of the processing node in the first circular linked list according to the identifier corresponding to the processing node. When the distributed system determines that the processing node is at the position corresponding to the first annular linked list, aiming at each processing node, the distributed system transforms the identifier of the processing node according to a preset strategy, matches the transformed identifier of the processing node with the identifier of each position in the first annular linked list, and if the identifier of the position consistent with the transformed identifier of the processing node exists in the first annular linked list, the position is the position of the processing node in the first annular linked list. The preset policy may be a consistent hash algorithm or other operation methods, which is not limited in this specification.
For example, the distributed system processes the identifier of the processing node by using a consistent hash algorithm to obtain a hash value of the processing node, determines a position in the first circular linked list where the hash value of the position is the same as the hash value of the processing node according to the hash value of each processing node, and places each processing node at a corresponding position in the first circular linked list.
Of course, each processing node may be directly placed in the first circular linked list without processing the identifier of the processing node. The present specification does not limit the position of each processing node in the first circular linked list as long as the position can be determined.
In one or more embodiments of the present specification, the distributed system may determine, before receiving the second query request, a position of the session task to be executed in the second circular linked list according to the identifier of the request of the session task to be executed.
Specifically, when receiving a request for a session task to be executed, the distributed system may process an identifier of the request for the session task to be executed, and then match the position of the second circular linked list according to the processed identifier. And in the second circular linked list, the position identifier consistent with the processed identifier is the position of the session task to be executed in the second circular linked list.
S202: responding to a first query request of a processing node, determining the corresponding position of the processing node in a first annular linked list, traversing the first annular linked list according to a preset direction, and determining the corresponding position of the adjacent node of the processing node in the first annular linked list.
In one or more embodiments of the present specification, since the distributed system transforms the identifier of the processing node according to a preset policy, each processing node is placed in the first circular linked list according to the transformed identifier of the processing node. Therefore, the distributed system performs the same transformation according to the identifier of the processing node included in the received first query request, and obtains the transformed identifier of the processing node. And traversing the first annular linked list according to a certain direction, inquiring a processing node consistent with the processed identifier, and recording the position of the processing node. And the distributed system continuously queries the first annular linked list, the next processing node which is inconsistent with the processed identifier is an adjacent node of the processing node, and the position of the adjacent processing node is recorded. The direction of traversing the first circular linked list can be anticlockwise or clockwise.
And the distributed system returns the positions of the processing node and the adjacent processing node in the first annular chain table as a first query result to the processing node, so that the processing node determines the corresponding position of the processing node in the first annular chain table and the corresponding position of the adjacent node of the processing node in the first annular chain table according to the first query result.
If the distributed system does not process the identifier of the processing node, the distributed system directly performs the traversal query operation according to the identifier of the processing node included in the received first query request.
S204: and returning the determined corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node of the processing node in the first annular linked list to the processing node as a first query result.
S206: and receiving a second query request of a query range carried on the second circular linked list, and determining the session task to be executed falling into the query range in the second circular linked list according to the query range.
In one or more embodiments of the present specification, the distributed system receives a second query request of a query range carried on a second circular linked list, receives a request of a session task to be executed before querying the session task to be executed falling within the query range in the second circular linked list according to the query range, and determines a position of the session task to be executed in the second circular linked list according to an identifier of the request of the session task to be executed.
Specifically, the distributed system may process an identifier of a request for a session task to be executed, and then match the position of the second circular linked list according to the processed identifier. And in the second circular linked list, the position identifier consistent with the processed identifier is the position of the session task to be executed in the second circular linked list.
After determining the position of each session task to be executed, the distributed system traverses the second circular linked list according to the query range and a certain direction, queries the session tasks to be executed falling into the query range in the second circular linked list, and obtains a second query result. And the distributed system sends the second query result to the processing node, so that the processing node executes each acquired session task to be executed.
S208: and returning the determined session tasks to be executed as a second query result to the processing node, so that the processing node executes the received session tasks to be executed.
In addition, for each processing node, the running state of the processing node is monitored, wherein each processing node comprises an on-line and an off-line.
When the processing node is determined to be offline, the processing node is deleted from the first circular linked list. And when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
Specifically, for each processing node, a fault condition or the like may occur in the processing node, so that the processing node cannot continue to operate. In order to avoid that the processing node continuously occupies the resources, whether the processing node is in operation is determined by monitoring the processing node, and if the processing node is not in operation, the processing node is cleared from the first ring linked list. There are many methods for monitoring processing nodes, which can be set as needed, and this specification does not limit this.
When the current processing nodes are fewer and insufficient to process the session task to be executed, a new processing node needs to be added, so that the processing node is subscribed to determine whether the processing node is started. If the processing node is started, the processing node is added to the corresponding position in the first annular linked list according to the identifier of the processing node, so that the corresponding position of the processing node in the first annular linked list can be determined subsequently according to the identifier of the processing node.
Fig. 6 is a schematic diagram illustrating a change of a to-be-executed session task of each processing node after the processing node is online.
The left graph is a second ring linked list before the processing node D is on line, the right graph is a second ring linked list after the processing node D is on line, a dotted line box represents that the processing node D is not on line, and the dotted line box indicates that the implementation box in the right graph represents that the processing node D is on line. The second annular linked list has the mapping positions of processing nodes A, B and C in the first annular linked list, conversation tasks W, X, Y and Z to be processed are processed, and the traversing direction is clockwise traversing.
Before the processing node D is online, the session tasks to be executed of the processing node B are W and X, after the processing node D is online, the session tasks to be executed of the processing node B are W, and the session tasks to be executed X are handed to the processing node D for execution.
Based on the same idea, the present specification further provides a device for performing a service, as shown in fig. 7.
Fig. 7 is a schematic diagram of a service execution apparatus provided in this specification, where the apparatus is applied to any processing node in a distributed system, and in the distributed system, a first ring linked list corresponding to the processing node and a second ring linked list of a session task to be executed are preconfigured, where the apparatus includes:
a first query request sending module 300, configured to send a first query request for the first circular linked list to the distributed system according to the identifier of the processing node;
a first query result receiving module 302, configured to receive a first query result returned by the distributed system, where the first query result includes: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node on the first annular linked list corresponds to the position in the first annular linked list;
a query range determining module 304, configured to determine a query range on the second circular linked list according to a corresponding position of the processing node in the first circular linked list and a corresponding position of the neighboring node in the first circular linked list;
a second query request sending module 306, configured to determine a second query request according to the query range, and send the second query request to the distributed system, so that the distributed system queries a to-be-executed session task that falls within the query range in the second annular linked list, where the to-be-executed session task is determined by the distributed system according to a received request of the to-be-executed session task, and a position of the to-be-executed session task in the second annular linked list is determined by the distributed system according to a received identifier of the to-be-executed session task;
a second query result receiving module 308, configured to receive a second query result carrying the session task to be executed and returned by the distributed system;
the task execution module 310 is configured to execute the session task to be executed included in the second query result.
Optionally, the first query request sending module 300 is specifically configured to send an acquisition request to the distributed system, and receive a mapping relationship between the first circular linked list and the second circular linked list returned by the distributed system; respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; and determining the range from the position of the processing node mapped to the second circular linked list to the corresponding position of the adjacent node in the second circular linked list as the query range on the second circular linked list according to a preset traversal direction.
Optionally, the lengths of the first circular linked list and the second circular linked list are the same, and the positions in the first circular linked list correspond to the positions in the second circular linked list one to one.
Optionally, the task execution module 310 is specifically configured to determine, according to a local thread list of the processing node, a session identifier of each thread execution session in the local thread list; judging whether a thread matched with the session identifier of each session task to be executed exists or not for each session task to be executed; if so, distributing the session task to be executed to a thread matched with the session identifier of the session task to be executed, and enabling the thread to execute the session task to be executed; if not, the to-be-executed conversation task is distributed to an idle thread, and the to-be-executed conversation task is executed by the idle thread.
Optionally, the apparatus further comprises: a thread ending module 312, configured to determine that a session executed by a thread is ended and end the thread when the thread in the local thread list does not allocate the to-be-executed session task.
Optionally, the processing node corresponds to at least one virtual node, and the first circular linked list is configured with the processing node and a virtual node corresponding to the processing node;
the query range determining module 304 is specifically configured to determine the neighboring node of the processing node and the neighboring node of the virtual node corresponding to the processing node; acquiring a mapping relation between the first annular linked list and the second annular linked list; determining the query range of the processing node on the second circular linked list according to the mapping relation, the corresponding position of the processing node in the first circular linked list and the corresponding position of the adjacent node of the processing node in the first circular linked list; and determining the query range of each virtual node corresponding to the processing node on the second annular linked list according to the mapping relation, the corresponding position of the virtual node in the first annular linked list and the corresponding position of the adjacent node of the virtual node in the first annular linked list.
Fig. 8 is a schematic diagram of a service execution apparatus provided in this specification, where the apparatus is applied to a distributed system, and in the distributed system, a first circular linked list corresponding to a processing node and a second circular linked list of a session task to be executed are preconfigured, where the apparatus includes:
a session task determining module 400, configured to determine, when receiving a request for a session task to be executed, a position of the session task to be executed in the second circular linked list according to an identifier of the request for the session task to be executed;
a node determining module 402, configured to determine, in response to a first query request of a processing node, a corresponding position of the processing node in a first circular linked list, traverse the first circular linked list in a preset direction, and determine a corresponding position of an adjacent node of the processing node in the first circular linked list;
a first query result returning module 404, configured to return the determined corresponding position of the processing node in the first circular linked list and the corresponding positions of the neighboring nodes of the processing node in the first circular linked list as a first query result to the processing node;
a session task query module 406, configured to receive a second query request of a query range carried on the second circular linked list, and determine, according to the query range, the session task to be executed that falls within the query range in the second circular linked list;
and a second query result returning module 408, configured to return the determined session task to be executed to the processing node as a second query result, so that the processing node executes each received session task to be executed.
Optionally, the apparatus further comprises: a node status monitoring module 410, configured to monitor, for each processing node, an operating status of the processing node; when the processing node is determined to be offline, deleting the processing node in the first annular linked list; and when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
The present specification also provides a computer-readable storage medium storing a computer program, which is operable to execute the method of service execution provided in fig. 1 above.
The present specification also provides a schematic structural diagram of the electronic device shown in fig. 9. As shown in fig. 9, the drone includes, at the hardware level, a processor, an internal bus, a network interface, a memory, and a non-volatile storage, although it may include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs the computer program to implement the method for executing the service described in fig. 1. Of course, besides the software implementation, the present specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or logic devices.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is an integrated circuit whose Logic functions are determined by a user programming the Device. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as ABEL (Advanced Boolean Expression Language), AHDL (alternate Hardware Description Language), traffic, CUPL (core universal Programming Language), HDCal, jhddl (Java Hardware Description Language), lava, lola, HDL, PALASM, rhyd (Hardware Description Language), and vhigh-Language (Hardware Description Language), which is currently used in most popular applications. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be regarded as a hardware component and the means for performing the various functions included therein may also be regarded as structures within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, respectively. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of other like elements in a process, method, article, or apparatus comprising the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present application.

Claims (16)

1. A method for executing service is applied to any processing node in a distributed system, wherein a first ring linked list corresponding to the processing node and a second ring linked list of a session task to be executed are configured in advance in the distributed system, the length of the first ring linked list is not greater than that of the second ring linked list, and one position in the second ring linked list only corresponds to one position of the first ring linked list, and the method comprises the following steps:
sending a first query request aiming at the first annular linked list to the distributed system according to the identification of the processing node;
receiving a first query result returned by the distributed system, wherein the first query result comprises: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node in the preset traversal direction on the first annular linked list corresponds to the position in the first annular linked list;
determining the mapping relation between the first annular linked list and the second annular linked list, and respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a range from the position mapped to the second annular linked list by the processing node to the corresponding position of the adjacent node in the second annular linked list as an inquiry range on the second annular linked list according to a preset traversal direction;
determining a second query request according to the query range, and sending the second query request to the distributed system, so that the distributed system queries a to-be-executed session task falling in the query range in the second annular linked list, wherein the to-be-executed session task is determined by the distributed system according to the received request of the to-be-executed session task, and the position of the to-be-executed session task in the second annular linked list is determined by the distributed system according to the received identifier of the request of the to-be-executed session task;
receiving a second query result which is returned by the distributed system and carries the session task to be executed;
and executing the session task to be executed contained in the second query result.
2. The method of claim 1, wherein determining the mapping relationship between the first circular linked list and the second circular linked list comprises:
sending an acquisition request to the distributed system, and receiving the mapping relation between the first annular linked list and the second annular linked list returned by the distributed system.
3. The method according to claim 1, wherein executing the session task to be executed included in the second query result specifically includes:
determining a session identifier of each thread execution session in the local thread list according to the local thread list of the processing node;
judging whether a thread matched with the session identifier of each session task to be executed exists or not according to each session task to be executed;
if so, distributing the session task to be executed to a thread matched with the session identifier of the session task to be executed, and enabling the thread to execute the session task to be executed;
if not, the to-be-executed conversation task is distributed to an idle thread, and the to-be-executed conversation task is executed by the idle thread.
4. The method of claim 3, further comprising:
and when the thread in the local thread list is not allocated with the session task to be executed, determining that the session executed by the thread is ended, and ending the thread.
5. The method of claim 1, wherein the processing node corresponds to at least one virtual node, and wherein the first circular linked list is configured with the processing node and the virtual node corresponding to the processing node;
respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a range from the position mapped to the second circular linked list by the processing node to the corresponding position of the adjacent node in the second circular linked list according to a preset traversal direction, wherein the range is used as a query range on the second circular linked list, and the method specifically comprises the following steps:
determining adjacent nodes of the processing nodes and adjacent nodes of the virtual nodes corresponding to the processing nodes;
respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a range from the position mapped to the second circular linked list by the processing node to the corresponding position of the adjacent node in the second circular linked list according to a preset traversal direction, and taking the range as an inquiry range on the second circular linked list;
for each virtual node corresponding to the processing node, respectively determining the position of the virtual node mapped to the second annular linked list and the position of the adjacent node of the virtual node mapped to the second annular linked list according to the mapping relation, the corresponding position of the virtual node in the first annular linked list and the corresponding position of the adjacent node of the virtual node in the first annular linked list; and determining the range from the position mapped to the second circular linked list by the virtual node to the corresponding position of the adjacent node of the virtual node in the second circular linked list according to a preset traversal direction, and taking the range as the query range of the virtual node on the second circular linked list.
6. A method for executing service is applied to a distributed system, wherein a first circular linked list corresponding to a processing node and a second circular linked list of a session task to be executed are configured in advance in the distributed system, the length of the first circular linked list is not greater than that of the second circular linked list, and one position in the second circular linked list only corresponds to one position of the first circular linked list, and the method comprises the following steps:
when a request of a session task to be executed is received, determining the position of the session task to be executed in a second annular linked list according to the identifier of the request of the session task to be executed;
responding to a first query request of a processing node, determining the corresponding position of the processing node in a first annular linked list, traversing the first annular linked list according to a preset traversing direction, and determining the corresponding position of an adjacent node of the processing node in the first annular linked list;
returning the determined corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node of the processing node in the first annular linked list to the processing node as a first query result;
receiving a second query request of a query range carried on the second circular linked list, and determining the session task to be executed falling into the query range in the second circular linked list according to the query range, wherein the query range is determined by the processing node by adopting the following method: determining the mapping relation between the first annular linked list and the second annular linked list, and respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a query range on a second annular linked list according to the traversing direction according to the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list;
and returning the determined session tasks to be executed as a second query result to the processing node, so that the processing node executes the received session tasks to be executed.
7. The method of claim 6, further comprising:
monitoring the running state of each processing node;
when the processing node is determined to be offline, deleting the processing node in the first annular linked list;
and when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
8. A device for service execution is applied to any processing node in a distributed system, in the distributed system, a first annular linked list corresponding to the processing node and a second annular linked list for a session task to be executed are configured in advance, the length of the first annular linked list is not more than that of the second annular linked list, one position in the second annular linked list only corresponds to one position of the first annular linked list, and the device comprises:
a first query request sending module, configured to send a first query request for the first circular linked list to the distributed system according to the identifier of the processing node;
a first query result receiving module, configured to receive a first query result returned by the distributed system, where the first query result includes: the processing node self corresponds to the position in the first annular linked list, and the adjacent node of the processing node in the preset traversal direction on the first annular linked list corresponds to the position in the first annular linked list;
a query range determining module, configured to determine a mapping relationship between the first circular linked list and the second circular linked list, and determine, according to the mapping relationship, a corresponding position of the processing node in the first circular linked list and a corresponding position of the adjacent node in the first circular linked list, a position where the processing node is mapped to the second circular linked list and a position where the adjacent node is mapped to the second circular linked list, respectively; determining a range from the position mapped to the second circular linked list by the processing node to the corresponding position of the adjacent node in the second circular linked list according to a preset traversal direction, and taking the range as an inquiry range on the second circular linked list;
a second query request sending module, configured to determine a second query request according to the query range, and send the second query request to the distributed system, so that the distributed system queries a to-be-executed session task that falls within the query range in the second circular linked list, where the to-be-executed session task is determined by the distributed system according to a received request for the to-be-executed session task, and a position of the to-be-executed session task in the second circular linked list is determined by the distributed system according to an identifier of the received request for the to-be-executed session task;
the second query result receiving module is used for receiving a second query result which is returned by the distributed system and carries the session task to be executed;
and the task execution module is used for executing the session task to be executed contained in the second query result.
9. The apparatus of claim 8, wherein the query range determining module is specifically configured to send an acquisition request to the distributed system, and receive a mapping relationship between the first circular linked list and the second circular linked list returned by the distributed system.
10. The apparatus according to claim 8, wherein the task execution module is specifically configured to determine, according to a local thread list of the processing node, a session identifier of each thread execution session in the local thread list; judging whether a thread matched with the session identifier of each session task to be executed exists or not for each session task to be executed; if so, distributing the session task to be executed to a thread matched with the session identifier of the session task to be executed, and enabling the thread to execute the session task to be executed; if not, the to-be-executed conversation task is distributed to an idle thread, and the to-be-executed conversation task is executed by the idle thread.
11. The apparatus of claim 10, further comprising:
and the thread ending module is used for determining that the session executed by the thread is ended and ending the thread when the thread in the local thread list is not allocated with the session task to be executed.
12. The apparatus of claim 8, wherein the processing node corresponds to at least one virtual node, and the first circular linked list is configured with the processing node and a virtual node corresponding to the processing node;
the query range determining module is specifically configured to determine an adjacent node of the processing node and an adjacent node of the virtual node corresponding to the processing node; respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a range from the position mapped to the second circular linked list by the processing node to the corresponding position of the adjacent node in the second circular linked list according to a preset traversal direction, and taking the range as an inquiry range on the second circular linked list; for each virtual node corresponding to the processing node, respectively determining the position of the virtual node mapped to the second annular linked list and the position of the adjacent node of the virtual node mapped to the second annular linked list according to the mapping relation, the corresponding position of the virtual node in the first annular linked list and the corresponding position of the adjacent node of the virtual node in the first annular linked list; and determining the range from the position mapped to the second circular linked list by the virtual node to the corresponding position of the adjacent node of the virtual node in the second circular linked list according to a preset traversal direction, and taking the range as the query range of the virtual node on the second circular linked list.
13. A device for executing service is applied to a distributed system, wherein a first circular linked list corresponding to a processing node and a second circular linked list of a session task to be executed are configured in advance in the distributed system, the length of the first circular linked list is not greater than that of the second circular linked list, and one position in the second circular linked list only corresponds to one position of the first circular linked list, and the device comprises:
the session task determining module is used for determining the position of the session task to be executed in the second annular linked list according to the identifier of the request of the session task to be executed when receiving the request of the session task to be executed;
a node determining module, configured to determine, in response to a first query request for a processing node, a corresponding position of the processing node in a first circular linked list, traverse the first circular linked list in a preset traversal direction, and determine a corresponding position of an adjacent node of the processing node in the first circular linked list;
a first query result returning module, configured to return the determined corresponding position of the processing node in the first circular linked list and the corresponding position of the neighboring node of the processing node in the first circular linked list as a first query result to the processing node;
a session task query module, configured to receive a second query request of a query range carried on the second circular linked list, and determine, according to the query range, the session task to be executed that falls within the query range in the second circular linked list, where the query range is determined by the processing node using the following method: determining the mapping relation between the first annular linked list and the second annular linked list, and respectively determining the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list according to the mapping relation, the corresponding position of the processing node in the first annular linked list and the corresponding position of the adjacent node in the first annular linked list; determining a query range on a second annular linked list according to the traversing direction according to the position of the processing node mapped to the second annular linked list and the position of the adjacent node mapped to the second annular linked list;
and the second query result returning module is used for returning the determined to-be-executed session tasks to the processing node as second query results so that the processing node executes the received to-be-executed session tasks.
14. The apparatus of claim 13, the apparatus further comprising:
the node state monitoring module is used for monitoring the running state of each processing node; when the processing node is determined to be offline, deleting the processing node in the first annular linked list; and when the processing node is determined to be on-line, determining the position of the processing node in the first annular linked list according to the identifier of the processing node, and adding the processing node at the position determined by the first annular linked list.
15. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
16. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1 to 7 when executing the program.
CN202211557544.9A 2022-12-06 2022-12-06 Service execution method, device, storage medium and electronic equipment Active CN115599845B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211557544.9A CN115599845B (en) 2022-12-06 2022-12-06 Service execution method, device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211557544.9A CN115599845B (en) 2022-12-06 2022-12-06 Service execution method, device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN115599845A CN115599845A (en) 2023-01-13
CN115599845B true CN115599845B (en) 2023-04-07

Family

ID=84853300

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211557544.9A Active CN115599845B (en) 2022-12-06 2022-12-06 Service execution method, device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115599845B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656158A (en) * 2021-08-12 2021-11-16 深圳市商汤科技有限公司 Task allocation method, device, equipment and storage medium

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8239879B2 (en) * 2008-02-01 2012-08-07 International Business Machines Corporation Notification by task of completion of GSM operations at target node
US20130263151A1 (en) * 2012-04-03 2013-10-03 Microsoft Corporation Consistent Hashing Table for Workload Distribution
CN103414756B (en) * 2013-07-18 2016-08-24 华为技术有限公司 A kind of task distribution method, distribution node and system
CN108132830B (en) * 2016-12-01 2020-12-25 北京金山云网络技术有限公司 Task scheduling method, device and system
CN107567100B (en) * 2017-08-22 2021-10-15 国网福建晋江市供电有限公司 Method and device for scheduling resources of wireless communication system
US10657061B1 (en) * 2017-09-29 2020-05-19 Amazon Technologies, Inc. Resource distribution using attributes of versioned hash rings
CN111338806B (en) * 2020-05-20 2020-09-04 腾讯科技(深圳)有限公司 Service control method and device
CN112527479A (en) * 2020-12-03 2021-03-19 武汉联影医疗科技有限公司 Task execution method and device, computer equipment and storage medium
CN114650320B (en) * 2022-03-10 2024-03-15 腾讯科技(深圳)有限公司 Task scheduling method and device, storage medium and electronic equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656158A (en) * 2021-08-12 2021-11-16 深圳市商汤科技有限公司 Task allocation method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN115599845A (en) 2023-01-13

Similar Documents

Publication Publication Date Title
US11431794B2 (en) Service deployment method and function management platform under serverless architecture
CN107622091B (en) Database query method and device
CN107181787B (en) Request processing method and device
CN108845876B (en) Service distribution method and device
US20150081914A1 (en) Allocation of Resources Between Web Services in a Composite Service
WO2016175768A1 (en) Map tables for hardware tables
CN110046187B (en) Data processing system, method and device
TW202008763A (en) Data processing method and apparatus, and client
CN109391512A (en) A kind of service issuing method, device and electronic equipment
US10599436B2 (en) Data processing method and apparatus, and system
CN114500467A (en) Address conflict detection method, address conflict detection device and electronic equipment
CN112003922A (en) Data transmission method and device
CN111355672A (en) Message forwarding method and device
CN115599845B (en) Service execution method, device, storage medium and electronic equipment
CN112559565A (en) Abnormity detection method, system and device
CN116737345A (en) Distributed task processing system, distributed task processing method, distributed task processing device, storage medium and storage device
CN108124021B (en) Method, device and system for obtaining Internet Protocol (IP) address and accessing website
CN116304212A (en) Data processing system, method, equipment and storage medium
CN115374117A (en) Data processing method and device, readable storage medium and electronic equipment
CN115714775A (en) Load balancing method and device
CN114513492A (en) Method and device for configuring IP address
CN111163171A (en) Remote control method and device for terminal equipment
CN115129709A (en) Data processing method, server and system
CN108255820B (en) Method and device for data storage in distributed system and electronic equipment
CN117041980B (en) Network element management method and device, storage medium and electronic equipment

Legal Events

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