Edge task execution method and device
By using the ring cache queue and the Disruptor framework to execute edge tasks asynchronously, the inefficiency problem caused by the merger of main task and edge tasks is solved, and an efficient edge task execution and fault tolerance mechanism is achieved, ensuring the successful execution of edge tasks.
Patent Information
- Application Number
- CN202010462510.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-27
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2040-05-27
AI Technical Summary
In the prior art, putting the main task and the edge task in the same process will result in a longer process execution time and low execution efficiency, and an error will be caused by an abnormal edge task.
By using the task framework's ring cache queue to store edge tasks and perform edge tasks asynchronously through the execution thread, the Disruptor framework implements queue concurrent operations without locks, and adds retry mechanisms and alarm mechanisms to ensure successful execution of edge tasks.
Without affecting the execution of the main task, the execution efficiency is greatly improved, the development difficulty is reduced, and the successful execution of edge tasks is ensured through a complete fault tolerance mechanism.
Smart Images

Figure CN113742035B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for executing edge tasks. Background Art
[0002] Edge tasks are auxiliary processes or tasks in addition to the main process (i.e., main task) in the business process, and whether the edge tasks are successfully executed has no impact on the main task. For example, in a business scenario, it is necessary to modify user data in the database and synchronize the modification status to a third-party system (such as Figure 1 In this business scenario, modifying user data in the database is the primary task, and synchronizing the modified state to other systems is the edge task. As long as the user data modification in the primary task is successful, there is no need to roll back the user data modification operation even if the modification state synchronization fails.
[0003] In the prior art, for the business scenarios that require the execution of main tasks and edge tasks, the main tasks and edge tasks are usually placed in the same process, and the process is not completed until the edge tasks are completed (e.g. Figure 2 ).
[0004] In the process of implementing the present invention, the inventors discovered that the prior art has at least the following problems:
[0005] Placing the main task and edge task in the same process will result in longer process execution time and lower execution efficiency. If an exception is thrown when executing the edge task, the entire process will report an error. Summary of the Invention
[0006] In view of this, an embodiment of the present invention provides an edge task execution method and device, which uses the circular cache queue of the task framework to store edge tasks and executes edge tasks asynchronously through execution threads, thereby greatly improving execution efficiency without affecting the execution of the main task.
[0007] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for executing an edge task is provided.
[0008] An edge task execution method according to an embodiment of the present invention includes: when a task framework receives an edge task separated from a business process, obtaining a pointer to a target storage location from a circular cache queue of the task framework; writing the edge task to the target storage location pointed to by the pointer in the circular cache queue, and notifying an execution thread to process the edge task; when the execution thread asynchronously obtains the edge task from the circular cache queue, using the task parameters of the edge task to execute the business logic of the edge task.
[0009] Optionally, the edge task is obtained by extracting the auxiliary process from the business process and encapsulating the auxiliary process, and the edge task includes the task parameters required to execute the auxiliary process and the business logic corresponding to the auxiliary process; using the task parameters of the edge task to execute the business logic of the edge task includes: passing the task parameters of the edge task to the business logic of the edge task to execute the business logic.
[0010] Optionally, the method further includes: determining whether the edge task is executed successfully, and if so, ending the process; if the edge task fails to execute, re-executing the business logic of the edge task using the task parameters according to the configured number of retries.
[0011] Optionally, the method also includes: determining whether the edge task retry is successful, and if the edge task retry is successful, ending the process; if the edge task retry fails, generating task metadata based on the task parameters and the reason for the execution failure, and saving the task metadata; and generating the storage identifier for the edge task, associating the storage identifier with the task metadata of the same edge task, and outputting an alarm message; wherein the alarm message includes the storage identifier.
[0012] Optionally, the method further includes: receiving a resubmitted edge task through the task framework; wherein, the resubmitted edge task is to obtain corresponding task metadata based on the storage identifier of the alarm information, and analyze and resolve the error based on the task metadata to retry the failed edge task.
[0013] Optionally, the task framework is a Disruptor framework.
[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, an edge task execution device is provided.
[0015] An edge task execution device according to an embodiment of the present invention includes: an acquisition module, which is used to obtain a pointer to a target storage location from the circular cache queue of the task framework after the task framework receives an edge task separated from a business process; a writing module, which is used to write the edge task to the target storage location pointed to by the pointer in the circular cache queue, and notify the execution thread to process the edge task; and an execution module, which is used to execute the business logic of the edge task using the task parameters of the edge task after the execution thread asynchronously obtains the edge task from the circular cache queue.
[0016] Optionally, the edge task is obtained by extracting the auxiliary process from the business process and encapsulating the auxiliary process, and the edge task includes the task parameters required to execute the auxiliary process and the business logic corresponding to the auxiliary process; the execution module is also used to: pass the task parameters of the edge task to the business logic of the edge task to execute the business logic.
[0017] Optionally, the device also includes: a judgment retry module, used to judge whether the edge task is executed successfully, and if the edge task is executed successfully, end the processing; and if the edge task fails to execute, use the task parameters to re-execute the business logic of the edge task according to the configured number of retries.
[0018] Optionally, the device also includes: an alarm judgment module, used to judge whether the edge task retry is successful, and if the edge task retry is successful, end the processing; if the edge task retry fails, generate task metadata based on the task parameters and the reason for the execution failure, and save the task metadata; and generate the storage identifier for the edge task, associate the storage identifier with the task metadata of the same edge task, and output an alarm message; wherein, the alarm information includes the storage identifier.
[0019] Optionally, the device also includes: a task receiving module, used to receive a resubmitted edge task through the task framework; wherein, the resubmitted edge task is to obtain the corresponding task metadata based on the storage identifier of the alarm information, and analyze the failed edge task after retrying and resolving the error based on the task metadata.
[0020] Optionally, the task framework is a Disruptor framework.
[0021] To achieve the above objective, according to another aspect of the embodiments of the present invention, an electronic device is provided.
[0022] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement an edge task execution method according to an embodiment of the present invention.
[0023] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer-readable medium is provided.
[0024] A computer-readable medium according to an embodiment of the present invention stores a computer program, which, when executed by a processor, implements an edge task execution method according to an embodiment of the present invention.
[0025] An embodiment of the above invention has the following advantages or beneficial effects: by using the circular cache queue of the task framework to store edge tasks, and executing edge tasks asynchronously through the execution thread, the execution efficiency is greatly improved without affecting the execution of the main task, and at the same time, the asynchronous execution scheme is encapsulated internally, which reduces the difficulty of development and use; extracting auxiliary processes from the business process and encapsulating the auxiliary processes as edge tasks can separate the edge tasks from the main tasks, and then the task parameters can be directly passed to the business logic for asynchronous execution, thereby improving the execution performance of the edge tasks; adding a retry mechanism during the execution of the edge tasks improves the existing execution process and ensures the successful execution of the edge tasks; ensuring that the system maintenance personnel can know the failure of the edge task retry through the alarm mechanism; further ensuring the successful execution of the edge tasks through a perfect fault-tolerant mechanism, making development and use simpler; realizing the asynchronous execution of edge tasks through the Disruptor framework, and realizing the concurrent operation of the queue without locks, thereby improving the asynchronous execution capability of the edge tasks.
[0026] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.
[0028] Figure 1 This is a schematic diagram of the division of main tasks and marginal tasks in a business scenario in the prior art;
[0029] Figure 2 This is a schematic diagram of the execution process of the main task and the edge task in a business scenario in the prior art;
[0030] Figure 3 is a schematic diagram of the main steps of the edge task execution method according to one embodiment of the present invention;
[0031] Figure 4 is a schematic diagram of the main flow of an edge task execution method according to another embodiment of the present invention;
[0032] Figure 5 1 is a schematic diagram of the main flow of an edge task execution method according to another embodiment of the present invention;
[0033] Figure 6 1 is a schematic diagram of the main process of resubmitting an edge task in the edge task execution method according to an embodiment of the present invention;
[0034] Figure 7 is a schematic diagram of main modules of an edge task execution device according to an embodiment of the present invention;
[0035] Figure 8 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
[0036] Figure 9 It is a schematic structural diagram of a computer device suitable for implementing an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0038] Figure 3 FIG. 1 is a schematic diagram of the main steps of the edge task execution method according to an embodiment of the present invention. Figure 3 As shown, the edge task execution method of the embodiment of the present invention mainly includes the following steps:
[0039] Step S301: After receiving an edge task separated from a business process, the task framework retrieves a pointer to the target storage location from the task framework's circular cache queue. Auxiliary processes are pre-extracted from the business process, encapsulated as edge tasks, and then submitted to the task framework. Auxiliary processes are processes in the business process other than the main process. The edge task includes the task parameters required to execute the auxiliary process and the business logic corresponding to the auxiliary process.
[0040] After receiving an edge task, the task framework retrieves a pointer from its RingBuffer queue to the next available element (i.e., the target storage location). The RingBuffer is a circular queue, and each element in the queue can be considered a slot. During initialization, the total size of the queue is specified, which is the maximum number of slots it can accommodate. As data is added to the queue, the pointer (i.e., the sequence number) continues to increase. The element pointed to by the Sequence in the RingBuffer is obtained by taking the modulus of the Sequence and the total size of the queue.
[0041] Step S302: Write the edge task to the target storage location pointed to by the pointer in the ring buffer queue, and notify the execution thread to process the edge task. Fill the edge task into the target storage location corresponding to the Sequence in the RingBuffer, then update the Sequence in the RingBuffer and publish it to the public, and notify the execution thread to process the edge task.
[0042] Step S303: After the execution thread asynchronously retrieves the edge task from the ring buffer queue, it uses the edge task's task parameters to execute the edge task's business logic. The execution thread asynchronously retrieves the edge task from the RingBuffer and executes it. If the edge task executes successfully, the result flow is complete. If the edge task fails, the edge task can be re-executed. Executing the edge task involves passing the edge task's task parameters to the edge task's business logic for execution.
[0043] Figure 4 FIG. 1 is a schematic diagram of the main flow of the edge task execution method according to another embodiment of the present invention. Figure 4 As shown, the edge task execution method of an embodiment of the present invention is implemented by a blocking queue (BlockingQueue). Specifically: first, the main task and the edge task are extracted from the business process, and the main task is executed; then, after the main task is executed, the edge task is written to the BlockingQueue; finally, the execution thread asynchronously pulls the edge task from the BlockingQueue and executes the edge task.
[0044] Although the above embodiment executes the edge task and the main task separately, and uses BlockingQueue to implement the asynchronous execution of the edge task, so that the edge task no longer affects the execution and response time of the main task, and to a certain extent improves the execution efficiency of the edge task. However, since BlockingQueue is implemented based on locks, and the efficiency of locks is generally low, its execution performance is poor. Moreover, this solution has no fault-tolerant mechanism and requires users to develop asynchronous execution solutions themselves, which is relatively complex to develop. Therefore, the embodiment of the present invention provides another new technical solution to execute edge tasks to solve the above problems. For details, see about Figure 5 、 Figure 6 Description.
[0045] Figure 5 FIG. 1 is a schematic diagram of the main flow of the edge task execution method according to another embodiment of the present invention. Figure 5 As shown, the edge task execution method of the embodiment of the present invention mainly includes the following steps:
[0046] Step S501: Extract auxiliary processes from the business process, encapsulate them into edge tasks, and submit them to the Disruptor framework. During business development, extract auxiliary processes from the business process and encapsulate them into edge tasks. After the main task completes, proactively submit the edge tasks to the Disruptor framework. The Disruptor is a high-performance asynchronous processing framework that enables concurrent queue operations without locks, providing 7-8 times higher concurrency than a standard BlockingQueue.
[0047] In the embodiment, it is possible to manually determine which of the business processes are auxiliary processes and which are main processes and extract them. It is also possible to extract and encapsulate auxiliary processes through computer programs based on the characteristics of the business processes.
[0048] Taking the modification of user data in the database as an example, the synchronization modification status is extracted from the third-party system and then encapsulated. The encapsulation here includes passing in the necessary task parameters and the business logic corresponding to the auxiliary process. In the embodiment, the task parameters are the user ID and the latest modification status, and the business logic is the code logic that synchronizes the modification status to the third-party system. After encapsulation, when executing the edge task, the task parameters can be directly passed to the business logic for execution.
[0049] Step S502: After receiving the edge task, the Disruptor framework retrieves a pointer to the target storage location from the Ring Buffer queue. Before receiving the edge task, the Disruptor framework initializes the RingBuffer, constructing an empty RingBuffer of a certain size. Typically, the size of the RingBuffer is a power of 2.
[0050] After receiving the edge task, the Disruptor obtains a pointer from its RingBuffer, which points to the next available element in the RingBuffer. For example, if the pointer maintained by the RingBuffer is 4, then the sequence number of the next available element in the RingBuffer is 4.
[0051] Step S503: The Disruptor framework writes the edge task to the target storage location pointed to by the pointer in the RingBuffer queue and notifies the execution thread to process the edge task. The Disruptor framework writes the edge task to the next available element in the RingBuffer. The RingBuffer then updates the pointer and publishes it to the public, notifying the execution thread to process the edge task. For example, the Disruptor framework writes the edge task to the RingBuffer at position 4, updates the pointer to 5, and publishes it to the public.
[0052] Step S504: The execution thread asynchronously retrieves edge tasks from the ring buffer queue and executes them. When the Disruptor framework starts, the execution thread is also started. The number of execution threads can be set by the user when initializing the execution method, for example, to one or more. When a new edge task is available, the execution thread retrieves it and uses the task parameters of the edge task to execute the corresponding business logic, thus achieving asynchronous execution.
[0053] Step S505: Determine whether the edge task is executed successfully. If it is executed successfully, the process ends; if it fails, step S506 is executed. During the edge task execution, if no exception is thrown, the execution is considered successful; if an exception is thrown, the execution fails.
[0054] Step S506: Re-execute the edge task according to the configured number of retries. Before using this execution method, the user usually needs to initialize it, and during initialization, the number of retries N can be configured. If the edge task fails in step S504, the execution thread can retry N times.
[0055] Step S507: Determine whether the edge task retry is successful. If successful, end this process; if unsuccessful, execute step S508.
[0056] Step S508: Generate task metadata based on the task parameters and the reason for the execution failure, save the task metadata, and generate a storage identifier. If the retry fails, generate and save the task metadata, and generate a storage identifier when saving. The task metadata may include the task parameters and the reason for the execution failure; the execution failure reason may be, for example, "failed to call an external interface." The storage identifier is a globally unique storage ID.
[0057] In an embodiment, task metadata can be saved through a task storage TaskStore (such as various databases), and a globally unique storage identifier is generated in TaskStore for edge tasks that fail to be retried, and the storage identifier and task metadata belonging to the same edge task are associated.
[0058] Step S509: Output alarm information. The alarm information is output through the alarm device Alarmer to alert the system maintenance personnel. The alarm information includes a storage identifier and may also include basic error information such as the reason for the execution failure.
[0059] This embodiment uses the Disruptor framework as the task executor and stores edge tasks through RingBuffer. When a new edge task arrives, it only modifies the properties of existing objects in the RingBuffer, and does not create or delete new objects. This solves the problem of expensive lock overhead in ordinary BlockingQueue, making the execution of edge tasks more efficient, and through a complete fault tolerance mechanism (i.e., retry + storage + alarm), it ensures that edge tasks can be successfully executed.
[0060] After receiving the alarm information, the system maintenance personnel can manually intervene in the execution of the edge task to further ensure the successful execution of the edge task.
[0061] Figure 6 FIG. 1 is a schematic diagram of the main process of resubmitting edge tasks in the edge task execution method according to an embodiment of the present invention. Figure 6 As shown, after step S509, the edge task execution method of this embodiment may further include: the Disruptor framework receives the resubmitted edge task and executes step S502.
[0062] After receiving the alarm information, the system maintenance personnel can obtain the task metadata corresponding to the storage identifier from the TaskStore based on the storage identifier of the alarm information; then, based on the reason for the execution failure of the task metadata, analyze the cause of the error and solve the error; after solving the error, resubmit the edge task to the Disruptor framework.
[0063] The failure reason in task metadata is usually simple and serves as a brief reminder. For example, if the failure reason is "failure to call an external interface," system maintenance personnel can further investigate the failure in the external system, such as whether there is a lack of user data or a business logic issue.
[0064] It can be seen from the edge task execution method of the embodiment of the present invention that by using the circular cache queue of the task framework to store edge tasks and asynchronously executing edge tasks through the execution thread, the execution efficiency is greatly improved without affecting the execution of the main task. At the same time, the asynchronous execution scheme is encapsulated internally, which reduces the difficulty of development and use.
[0065] Figure 7 Schematic diagram of the main modules of the edge task execution device according to an embodiment of the present invention. As shown in the figure, the edge task execution device 700 according to the embodiment of the present invention mainly includes:
[0066] Acquisition module 701 is used to obtain a pointer to the target storage location from the circular cache queue of the task framework after the task framework receives the edge task separated from the business process. The auxiliary process is extracted from the business process in advance, the auxiliary process is encapsulated as an edge task, and then the edge task is submitted to the task framework. Auxiliary processes are some processes in the business process other than the main process. The edge task includes the task parameters required to execute the auxiliary process and the business logic corresponding to the auxiliary process.
[0067] After receiving an edge task, the task framework retrieves a pointer from its RingBuffer queue to the next available element (i.e., the target storage location). The RingBuffer is a circular queue, and each element in the queue can be considered a slot. During initialization, the total size of the queue is specified, which is the maximum number of slots it can accommodate. As data is added to the queue, the pointer (i.e., the sequence number) continues to increase. The element pointed to by the Sequence in the RingBuffer is obtained by taking the modulus of the Sequence and the total size of the queue.
[0068] The writing module 702 is configured to write the edge task to the target storage location pointed to by the pointer in the ring buffer queue and notify the execution thread to process the edge task. The edge task is filled into the target storage location corresponding to the Sequence in the RingBuffer. The RingBuffer then updates the Sequence and publishes it to the public, notifying the execution thread to process the edge task.
[0069] Execution module 703 is configured to execute the business logic of the edge task using the task parameters of the edge task after the execution thread asynchronously obtains the edge task from the ring buffer queue. The execution thread asynchronously obtains the edge task from the RingBuffer and executes the edge task. If the edge task is executed successfully, the result flow is processed; if the edge task fails, the edge task can be re-executed. Executing the edge task means passing the task parameters of the edge task to the business logic of the edge task to execute the business logic.
[0070] In addition, the edge task execution device 700 of the embodiment of the present invention may further include: a judgment retry module, a judgment alarm module and a task receiving module ( Figure 7 (not shown). The judgment retry module is configured to determine whether the edge task is successfully executed, and if so, terminate the processing; and if the edge task fails, re-execute the business logic of the edge task using the task parameters according to the configured number of retries.
[0071] An alarm judgment module is used to judge whether the edge task retry is successful. If the edge task retry is successful, the processing is terminated; if the edge task retry fails, task metadata is generated according to the task parameters and the reason for the execution failure, and the task metadata is saved; and the storage identifier is generated for the edge task, the storage identifier is associated with the task metadata of the same edge task, and an alarm message is output; wherein the alarm message includes the storage identifier.
[0072] A task receiving module is used to receive resubmitted edge tasks through the task framework; wherein, the resubmitted edge tasks are to obtain corresponding task metadata based on the storage identifier of the alarm information, and to analyze and resolve the error based on the task metadata to retry the failed edge tasks.
[0073] From the above description, it can be seen that by using the task framework's circular cache queue to store edge tasks and executing edge tasks asynchronously through execution threads, the execution efficiency is greatly improved without affecting the execution of the main task. At the same time, the asynchronous execution solution is encapsulated internally, which reduces the difficulty of development and use.
[0074] Figure 8 An exemplary system architecture 800 is shown to which the edge task execution method or edge task execution apparatus according to an embodiment of the present invention may be applied.
[0075] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0076] Users can use terminal devices 801, 802, and 803 to interact with server 805 via network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0077] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0078] Server 805 can be a server that provides various services, such as a background management server that an administrator uses to process edge tasks sent by terminal devices 801, 802, and 803. The background management server can write edge tasks to a target storage location, have them executed asynchronously by an execution thread, and feed back the processing results (e.g., execution result information) to the terminal device.
[0079] It should be noted that the edge task execution method provided in the embodiment of the present application is generally executed by the server 805 , and accordingly, the edge task execution device is generally set in the server 805 .
[0080] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0081] According to an embodiment of the present invention, the present invention further provides an electronic device and a computer-readable medium.
[0082] The electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement an edge task execution method of an embodiment of the present invention.
[0083] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, an edge task execution method according to an embodiment of the present invention is implemented.
[0084] Reference below Figure 9 , which shows a structural diagram of a computer system 900 suitable for implementing an electronic device according to an embodiment of the present invention. Figure 9 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0085] like Figure 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage unit 908 into a random access memory (RAM) 903. Various programs and data required for the operation of the computer system 900 are also stored in the RAM 903. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0086] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, and the like; an output section 907 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card or a modem. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 910 as needed, so that computer programs read therefrom can be installed into the storage section 908 as needed.
[0087] In particular, according to an embodiment disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from a removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are performed.
[0088] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0089] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0090] The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The modules described may also be provided in a processor. For example, they may be described as follows: a processor includes an acquisition module, a write module, and an execution module. The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, the acquisition module may also be described as "a module that obtains a pointer to a target storage location from the circular cache queue of the task framework when the task framework receives an edge task separated from a business process."
[0091] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: when the task framework receives an edge task separated from a business process, obtaining a pointer to a target storage location from the circular cache queue of the task framework; writing the edge task to the target storage location pointed to by the pointer in the circular cache queue, notifying the execution thread to process the edge task; when the execution thread asynchronously obtains the edge task from the circular cache queue, using the task parameters of the edge task to execute the business logic of the edge task.
[0092] According to the technical solution of an embodiment of the present invention, by using the circular cache queue of the task framework to store edge tasks and asynchronously executing edge tasks through the execution thread, the execution efficiency is greatly improved without affecting the execution of the main task. At the same time, the asynchronous execution solution is encapsulated internally, which reduces the difficulty of development and use.
[0093] The above-mentioned product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0094] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for executing edge tasks, characterized in that: include: When the task framework receives the edge task separated from the business process, it obtains a pointer to the target storage location from the circular buffer queue of the task framework; Writing the edge task into the target storage location pointed to by the pointer in the ring buffer queue, and notifying the execution thread to process the edge task; When the execution thread asynchronously obtains the edge task from the ring buffer queue, it uses the task parameters of the edge task to execute the business logic of the edge task; Determining whether the edge task is successfully executed, and if the edge task fails, re-executing the edge task; Determine whether the edge task retry is successful; if the edge task retry fails, generate task metadata based on the task parameters and the execution failure reason, and save the task metadata; as well as A storage identifier is generated for the edge task, the storage identifier is associated with task metadata of the same edge task, and an alarm message is output; wherein the alarm message includes the storage identifier.
2. The method according to claim 1, characterized in that The edge task is obtained by extracting an auxiliary process from the business process and encapsulating the auxiliary process, and the edge task includes task parameters required to execute the auxiliary process and business logic corresponding to the auxiliary process; Executing the business logic of the edge task using the task parameters of the edge task includes: The task parameters of the edge task are passed to the business logic of the edge task to execute the business logic.
3. The method according to claim 1, characterized in that After determining whether the edge task is successfully executed, the method further includes: if the edge task is successfully executed, ending the process; If the edge task fails to execute, then re-execute the edge task, including: if the edge task fails to execute, then re-execute the business logic of the edge task using the task parameters according to the configured number of retries.
4. The method according to claim 1, wherein After determining whether the edge task retry is successful, the method further includes: If the edge task is successfully retried, the process ends.
5. The method according to claim 1, wherein The method further comprises: The resubmitted edge task is received through the task framework; wherein, the resubmitted edge task is to obtain the corresponding task metadata according to the storage identifier of the alarm information, and to analyze and resolve the error according to the task metadata to retry the failed edge task.
6. The method according to any one of claims 1 to 5, characterized in that The task framework is a Disruptor framework.
7. An edge task execution device, characterized in that: include: an acquisition module, configured to acquire a pointer to a target storage location from a circular buffer queue of the task framework after the task framework receives the edge task separated from the business process; a writing module, configured to write the edge task into a target storage location pointed to by the pointer in the ring buffer queue, and notify an execution thread to process the edge task; an execution module, configured to execute the business logic of the edge task using the task parameters of the edge task after the execution thread asynchronously obtains the edge task from the ring cache queue; A judgment and retry module, configured to judge whether the edge task is successfully executed, and to re-execute the edge task if the edge task fails to execute; a judgment alarm module, configured to judge whether the edge task retry is successful; if the edge task retry fails, generate task metadata based on the task parameters and the execution failure reason, and save the task metadata; as well as A storage identifier is generated for the edge task, the storage identifier is associated with task metadata of the same edge task, and an alarm message is output; wherein the alarm message includes the storage identifier.
8. The device according to claim 7, characterized in that The judgment and retry module is further used to: If the edge task is successfully executed, then the process ends; and If the edge task fails to execute, the business logic of the edge task is re-executed using the task parameters according to the configured number of retries.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Request scheduling method and request scheduling device
CN106775990A
Data sending and receiving method based on Disruptor
CN106802824A