WO2020232951A1 - Task execution method and device - Google Patents

Task execution method and device Download PDF

Info

Publication number
WO2020232951A1
WO2020232951A1 PCT/CN2019/110466 CN2019110466W WO2020232951A1 WO 2020232951 A1 WO2020232951 A1 WO 2020232951A1 CN 2019110466 W CN2019110466 W CN 2019110466W WO 2020232951 A1 WO2020232951 A1 WO 2020232951A1
Authority
WO
WIPO (PCT)
Prior art keywords
steps
execution
task
executed
directed graph
Prior art date
Application number
PCT/CN2019/110466
Other languages
French (fr)
Chinese (zh)
Inventor
夏勇
李凌
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2020232951A1 publication Critical patent/WO2020232951A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Definitions

  • the present invention relates to the field of task processing and financial technology (Fintech), in particular to a task execution method and device.
  • a task consists of one or more steps.
  • step execution mode since the task execution requires high stability and reliability in the process of financial transactions, it is necessary to execute step by step sequentially until all steps are completed. Obviously, in this step execution mode, each step can only be executed after the previous step is executed, and the waiting time is longer. Once the previous step fails to execute again, it will waste more time. In this way, the execution time of the entire task is longer and the execution efficiency is lower.
  • the embodiments of the present application provide a task execution method and device, which solve the problems of long execution time and low execution efficiency of tasks in the prior art.
  • An embodiment of the present application provides a task execution method, including: a first processing device acquires a predefined task; the predefined task includes N steps; N is an integer greater than 1, and the first processing device according to the N The dependency relationship between steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship, if If any two steps of the dependency relationship do not exist among the N steps, the directed graph indicates that any two steps are executed in parallel; the first processing device executes the steps indicated by the directed graph The execution sequence is to execute the predefined tasks.
  • the first step is any one of the N steps, and the first processing device executes the first step in the following manner: if the first step includes only one sub-step, then directly execute the Sub-step; if the first step includes M sub-steps, execute the M sub-steps in parallel, and M is an integer greater than 1.
  • the method further includes: if any step that has the dependency relationship with the first step is not defined in the predefined task, executing the predefined task first when the first processing device executes the predefined task The first step.
  • the method further includes: the first processing device determining whether the predefined task has sent heartbeat data within a preset time period, if not, and determining that the running state of the predefined task is running, Then, a notification message indicating to host the predefined task is sent to the second processing device.
  • the method further includes: if the first processing device determines that there are at least two failed execution steps among the N steps, re-executing the at least two failed execution steps in parallel.
  • the steps may be executed by defining the execution directed graph in a predefined task.
  • the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship. Figure, if any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel.
  • the execution directed graph also indicates the dependency relationship existing among the N steps, thereby ensuring that tasks are processed normally according to the preset execution sequence. Therefore, the execution time of each step in any two steps overlaps, and they are not affected by execution failure or not, thereby shortening the execution time of the entire task while ensuring the stable execution of the predefined task. Improve the efficiency of task execution.
  • the embodiment of the present application provides a task execution device, which includes: an acquisition module for acquiring a predefined task; the predefined task includes N steps; N is an integer greater than 1, and a processing module is used for The dependency relationship between steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship, if If any two steps of the dependency relationship do not exist among the N steps, the directed graph indicates that any two steps are executed in parallel; the execution of the steps is in the order indicated by the executed directed graph.
  • Pre-defined tasks Pre-defined tasks.
  • the first step is any one of the N steps, and the processing module is specifically configured to: execute the first step in the following manner: if the first step includes only one sub-step, directly Perform this sub-step; if the first step includes M sub-steps, execute the M sub-steps in parallel, and M is an integer greater than 1.
  • processing module is further configured to: if any step that has the dependency relationship with the first step is not defined in the predefined task, execute the first step first when executing the predefined task. step.
  • the processing module is further configured to: determine whether the predefined task has sent heartbeat data within a preset period of time, if not, and if it is determined that the running state of the predefined task is running, then send the pre-configuration The device sends a notification message indicating to host the predefined task.
  • the processing module is further configured to: if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
  • the embodiment of the present application provides a computer device, including a program or instruction.
  • a program or instruction When the program or instruction is executed, a task execution method and optional method provided in the embodiment of the present application are executed.
  • the embodiment of the present application provides a storage medium including a program or instruction.
  • a task execution method and optional method provided in the embodiment of the present application are executed.
  • FIG. 1 is a schematic diagram of a predefined task in an embodiment of this application
  • FIG. 2 is a schematic flowchart of a task execution method in an embodiment of this application.
  • FIG. 3 is a schematic structural diagram of a task execution device in an embodiment of the application.
  • a processing device In order to achieve a certain requirement or purpose, a processing device often needs to perform a series of steps.
  • the combination of this series of steps is called a task.
  • the task of modifying data table A in the database to data table B includes a series of steps of data insertion and data modification to the data table, and the whole task can be called a data processing task.
  • the current way of executing the task is to execute each step in the task serially, that is, step by step and proceed sequentially until all steps are completed.
  • task one has 5 steps: step one, step two, step three, step four, step five, regardless of whether there are necessary constraints between step one, step two, step three, step four, and step five.
  • steps 1 to 5 are executed in series.
  • the necessary sequential execution constraint relationship refers to the sequential execution sequence relationship that must be followed when the two steps are executed. For example, to modify a piece of data in a data table, you must first find and locate this data, and then modify it.
  • each step must be executed after the previous step is executed, and the waiting time is longer. If the previous step fails to execute and needs to be executed again, it will waste more time. In this way, the execution time of the entire task is longer, especially when there are many steps, the execution efficiency is lower.
  • an embodiment of the present application provides a task execution method.
  • the embodiment of the application provides a task processing model based on a directed graph.
  • Directed graph In mathematics, a graph is a method of representing the relationship between objects and objects, and is the basic research object of graph theory. A graph appears to be composed of small dots (called vertices or nodes) and straight lines or curves (called edges) connecting these dots. If a direction is specified for each edge of the graph, the resulting graph is called a directed graph.
  • the task Before the task is executed, the task needs to be defined first, which can be divided into three parts: task definition, step definition and step dependency definition.
  • a task model of directed graph can be generated.
  • the task definition is to name the task, such as data processing task 1, task Q, etc.
  • the name does not limit the character type;
  • the step definition includes the definition of each step in the task and the specific execution method of each step. Some steps are also available.
  • step dependency is: in the N steps, before each step is executed, the constraint relationship of the execution results of other steps needs to be obtained.
  • step A and step B if step A and step B meet any of the following conditions, it is said that there is a dependency between step A and step B: (1) Step A must be executed before step A is executed B, and the next step to be executed after step B is executed is step A, step A needs to be executed on the basis of the execution result of step B, also called step A depends on step B; (2) step B must be executed before step B is executed A, and the next step that needs to be executed after step A is executed is step B, and step B needs to be executed on the basis of the execution result of step A, which is called step B depends on step A.
  • step A there can be multiple steps that depend on step A or step B in the task. It should be noted that if a step in the task does not need to be executed before any other steps in the task are executed, then this step is called the apex step of the task, that is, the first step executed when the task is executed.
  • Step definition: Task X includes step X1, step X2, step X3, step X4, step X5, and step X6.
  • step X3 includes two sub-steps: step X3-1, step X3-2;
  • step X6 includes three sub-steps: step X6-1, step X6-2, and step X6-3.
  • Step dependency definition step X1 is the vertex step; step X2, step X3 needs to be executed before step X1; step X4 and step X5 need to be executed before step X2; step X6 needs to be executed before step X3, step X4 and step X5, Therefore, step X6 is the last step executed by task X.
  • the step dependency can be defined by storing the step dependency definition table in the database. If the step dependency needs to be adjusted between steps, you only need to modify the step dependency definition table, which improves the flexibility of task definition.
  • FIG. 1 it is a schematic diagram of a task definition in an embodiment of this application.
  • the task shown in FIG. 1 is named task Y and includes step Y1, step Y2, step Y3, step Y4, step Y5, and step Y6.
  • a corresponding directed graph as shown in Figure 1 can be generated.
  • step Y1 is the vertex step of task Y; step Y1 needs to be executed before step Y2, step Y3, and step Y5 are executed; and in task Y, after step Y2 and step Y3 are executed, the next step that needs to be executed
  • the step is step Y4, and the prerequisite for the execution of step Y4 is that both steps Y2 and Y3 are executed; after both steps Y4 and Y5 are executed, the next step to be executed is step Y6, and the premise of step Y6 is step Y4 , Step Y5 has been executed, and step Y6 is divided into step Y6-1 and step Y6-2.
  • FIG. 2 it is a schematic flowchart of a task execution method in an embodiment of this application.
  • the task execution method shown in FIG. 2 can be applied to Figure 1 shows task Y.
  • the execution status is defined, and the execution status is updated according to the current execution status of the step, which specifically includes: execution failed, completed, executed, scheduled, and not started.
  • the first processing device is any device that can execute instructions and is not limited.
  • the first processing device is a computer device; predefined tasks are tasks that have been defined in advance, such as task X and task Y.
  • the first processing device executes each step defined in the predefined task in the following manner:
  • the first processing device obtains a predefined task.
  • the predefined task includes N steps, and N is an integer greater than 1.
  • the first processing device generates an execution directed graph corresponding to the predefined task according to the dependency relationship existing between the N steps.
  • the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship. If any two steps of the dependency relationship do not exist in the N steps, then the The directed graph indicates that any two steps are executed in parallel.
  • FIG. 2 only uses the first processing device as an example to illustrate the execution process of the task.
  • each step or substep can be executed on different processing devices to facilitate concurrent processing.
  • the number of processing devices can be expanded horizontally to improve computing processing capabilities, and therefore, to maximize the concurrent processing capabilities between and within steps.
  • task definitions can be loaded into memory when the system starts.
  • S203 The first processing device executes the predefined task according to the execution order of the steps indicated by the execution directed graph.
  • the first step is any step defined in the predefined task; the precursor dependency indication: in the predefined task, and the N second steps are all successfully executed, it is allowed Perform the first step. It should be noted that since each step in the predefined task defines a state, after the first step is executed once, the execution may succeed or fail. When the execution of the first step fails, the execution will be retried. The first step Skip after successful execution.
  • step Y4 when the first step is step Y4 in task Y, then N is 2, and the two second steps are step Y2 and step Y3.
  • Step Y2 and step Y3 will be executed in parallel first. After step Y2 and step Y3 are all successfully executed, the next step to be executed is step Y4, and step Y2 and step Y3 are all executed successfully before step Y4 is allowed to be executed.
  • step Y5 may be a long time step. Step Y2, step Y3, and step Y4 can be executed in parallel with step Y5. After step Y4 is completed, it will check whether step Y5 is successfully executed, and then step Y6 can be executed. Improve the efficiency of task execution.
  • an execution log will be generated, which is divided into three parts: task execution log, step execution log, and sub-step execution log.
  • the sub-step log and the step log have a one-to-many relationship. If the step is not split, there is one sub-step log; if there is a split, then there are multiple sub-step logs.
  • the sub-step execution log includes: first, the data of the definition table is included, the task name, step name, implementation class, how to split the data, the execution thread size, the read data size, the commit transaction size, and the log level are included. And, the currently processed data pieces, the total number of pending items, the number of read items, the number of processed items, the number of ignored items, the processing Internet address (Internet protocol, IP), creation time, start time, completion time and other information.
  • an optional implementation manner is that, if any step that has the dependency relationship with the first step is not defined in the predefined task, the first processing device first executes the predefined task Perform the first step.
  • the first step when the first step is the apex step, the first step will be executed first when the predefined task is executed.
  • the first step is step Y1.
  • step Y1 When step Y is executed, step Y1 is executed first.
  • an optional implementation manner is that the first processing device executes the first step in the following manner:
  • the sub-step is directly executed.
  • the M sub-steps are executed in parallel, and M is an integer greater than 1.
  • step Y4 in task Y when the first step is step Y4 in task Y, and Y4 includes only one substep, then this substep is directly executed; when the first step is step Y6 in task Y, M is 2, and Y6 includes, 2. Sub-steps, then execute these two sub-steps in parallel.
  • an optional implementation manner is that, if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
  • step Y4 when the first step is step Y4 in task Y, the two second steps are step Y2 and step Y3. Therefore, if step Y2 and step Y3 fail to execute, step Y2 and step Y3 will be executed again in parallel .
  • an optional implementation manner is that the first processing device determines whether the predefined task has sent heartbeat data within a preset period of time, if not, and determines that the running status of the predefined task is During operation, a notification message indicating to host the predefined task is sent to the second processing device.
  • the running status of the task can be obtained in time, so that the task that is not running normally can be managed, saving computing resources.
  • the hosting is: a.
  • the machine executes the task, the task is being processed due to hardware failures and other conditions, but it is not actually processed.
  • the machine b judges whether machine a is unavailable according to the heartbeat time updated by each machine. If there is no heartbeat for more than the preset time, it is considered unavailable. Then machine b modifies the predefined task to machine b to execute, and executes this task again to achieve high availability the goal of. Simply put, that is, a normally operating machine can perform the tasks of a faulty machine.
  • the embodiments of this application have the following advantages: (1) Define task step dependencies based on the directed graph, and each step only cares about whether the dependent step is completed and then can start; (2) A single step can be split into multiple sub-steps according to the definition, all When the sub-step is completed, the current step is completed; (3) Realization and configuration are separated, and different configuration combinations form different functional combinations.
  • the steps may be executed by defining the execution directed graph in a predefined task.
  • the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship.
  • Figure if any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel.
  • the execution directed graph also indicates the dependency relationship existing among the N steps, thereby ensuring that tasks are processed normally according to the preset execution sequence. Therefore, the execution time of each step in any two steps overlaps, and they are not affected by execution failure or not, so that the execution time of the entire task is shortened while ensuring the stable execution of the predefined task. Improve the efficiency of task execution.
  • FIG. 3 it is a schematic structural diagram of a task execution device in an embodiment of this application.
  • An embodiment of the present application provides a task execution device, including: an acquisition module 301, configured to acquire a predefined task; the predefined task includes N steps; N is an integer greater than 1; a processing module 302, configured to The dependency relationship between the N steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship , If any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel; the execution order of the steps indicated by the executed directed graph is executed The predefined task.
  • the first step is any one of the N steps, and the processing module 302 is specifically configured to: execute the first step in the following manner: if the first step includes only one sub-step, then This sub-step is directly executed; if the first step includes M sub-steps, the M sub-steps are executed in parallel, and M is an integer greater than 1.
  • processing module 302 is further configured to: if any step that has the dependency relationship with the first step is not defined in the predefined task, execute the first step first when executing the predefined task One step.
  • the processing module 302 is further configured to: determine whether the predefined task has sent heartbeat data within a preset period of time; if not, and if it is determined that the running state of the predefined task is running, then send the pre-defined task to the pre-defined task.
  • the configuration device sends a notification message indicating to host the predefined task.
  • the processing module 302 is further configured to: if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
  • the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, optical storage, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention discloses a task execution method and device. Said method comprises: a first processing device acquiring a predefined task, the predefined task comprising N steps, N being an integer greater than 1; the first processing device generating, according to a dependency relationship existing between the N steps, an execution directed graph corresponding to the predefined task, the execution directed graph being a directed graph indicating an execution order of the N steps determined according to the dependency relationship, and in the case of any two steps among said N steps without said dependency relationship, the directed graph indicating that said any two steps are executed in parallel; and the first processing device executing the predefined task according to the step execution order indicated by the execution directed graph. When applied to the field of finance technology (Fintech), said method improves the efficiency of financial transactions.

Description

一种任务执行方法及装置Task execution method and device
相关申请的交叉引用Cross references to related applications
本申请要求在2019年05月17日提交中国专利局、申请号为201910413986.8、申请名称为“一种任务执行方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910413986.8, and the application name is "a task execution method and device" on May 17, 2019, the entire content of which is incorporated into this application by reference .
技术领域Technical field
本发明涉及任务处理和金融科技(Fintech)领域,尤其涉及一种任务执行方法及装置。The present invention relates to the field of task processing and financial technology (Fintech), in particular to a task execution method and device.
背景技术Background technique
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Finteh)转变。目前,金融科技领域中,为了实现某个需求或目的,处理设备需要执行的一系列指令组合,称为一个任务。举例来说,对数据库中一张数据表进行数据插入和数据修改的组合,称为一个数据处理任务。一个任务包括一个或多个步骤。With the development of computer technology, more and more technologies (Big Data, Distributed, Blockchain, Artificial Intelligence, etc.) are applied in the financial field, and the traditional financial industry is gradually changing to Finteh. At present, in the field of financial technology, in order to achieve a certain requirement or purpose, a series of instruction combinations that a processing device needs to execute is called a task. For example, the combination of data insertion and data modification on a data table in the database is called a data processing task. A task consists of one or more steps.
现有技术中,由于金融交易过程中,任务执行要求有较高的稳定性和可靠性,因此需要一个步骤接一个步骤依次往下执行,直至所有步骤执行完成。显然,这种步骤执行方式下,每个步骤都要在前一个步骤执行完毕后才能执行,等待时间较久,一旦前一个步骤执行失败重新执行,会浪费更长时间。这样以来,整个任务的执行时间较长,执行效率较低。In the prior art, since the task execution requires high stability and reliability in the process of financial transactions, it is necessary to execute step by step sequentially until all steps are completed. Obviously, in this step execution mode, each step can only be executed after the previous step is executed, and the waiting time is longer. Once the previous step fails to execute again, it will waste more time. In this way, the execution time of the entire task is longer and the execution efficiency is lower.
因此,现有技术中,任务的执行时间较长、执行效率较低是一个亟待解决的问题。Therefore, in the prior art, a long task execution time and low execution efficiency are a problem to be solved urgently.
发明内容Summary of the invention
本申请实施例提供一种任务执行方法及装置,解决了现有技术中任务的执行时间较长、执行效率较低的问题。The embodiments of the present application provide a task execution method and device, which solve the problems of long execution time and low execution efficiency of tasks in the prior art.
本申请实施例提供一种任务执行方法,包括:第一处理设备获取预定义任务;所述预定义任务包括N个步骤;N为大于1的整数;所述第一处理设备根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图;所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行;所述第一处理设备按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。An embodiment of the present application provides a task execution method, including: a first processing device acquires a predefined task; the predefined task includes N steps; N is an integer greater than 1, and the first processing device according to the N The dependency relationship between steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship, if If any two steps of the dependency relationship do not exist among the N steps, the directed graph indicates that any two steps are executed in parallel; the first processing device executes the steps indicated by the directed graph The execution sequence is to execute the predefined tasks.
可选的,第一步骤为所述N个步骤中任一步骤,所述第一处理设备按照以下方式执行所述第一步骤:若所述第一步骤仅包括一个子步骤,则直接执行该子步骤;若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。Optionally, the first step is any one of the N steps, and the first processing device executes the first step in the following manner: if the first step includes only one sub-step, then directly execute the Sub-step; if the first step includes M sub-steps, execute the M sub-steps in parallel, and M is an integer greater than 1.
可选的,所述方法还包括:若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则所述第一处理设备执行所述预定义任务时首先执行所述第一步骤。Optionally, the method further includes: if any step that has the dependency relationship with the first step is not defined in the predefined task, executing the predefined task first when the first processing device executes the predefined task The first step.
可选的,所述方法还包括:所述第一处理设备确定所述预定义任务在预设时长内是否发送了心跳数据,若否,且确定所述预定义任务的运行状态为运行中,则向第二处理设备发送指示托管所述预定义任务的通知消息。Optionally, the method further includes: the first processing device determining whether the predefined task has sent heartbeat data within a preset time period, if not, and determining that the running state of the predefined task is running, Then, a notification message indicating to host the predefined task is sent to the second processing device.
可选的,所述方法还包括:若所述第一处理设备确定所述N个步骤中存在执行失败的至少两个步骤,则重新并行执行所述执行失败的至少两个步骤。Optionally, the method further includes: if the first processing device determines that there are at least two failed execution steps among the N steps, re-executing the at least two failed execution steps in parallel.
本申请实施例中,可以通过在预定义任务中定义所述执行有向图来执行步骤,所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行。另外,所述执行有向图还指示所述N个步骤之间存在的依赖关系,从而保证了任务按照预设执行先后次序正常处理。因此,所述任意两个步骤中各个步骤的执行时间有重叠,且相互 之间不受执行失败与否的影响,从而在保证预定义任务稳定执行的前提下,缩短了整个任务的执行时间,提升了任务的执行效率。In the embodiment of the present application, the steps may be executed by defining the execution directed graph in a predefined task. The execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship. Figure, if any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel. In addition, the execution directed graph also indicates the dependency relationship existing among the N steps, thereby ensuring that tasks are processed normally according to the preset execution sequence. Therefore, the execution time of each step in any two steps overlaps, and they are not affected by execution failure or not, thereby shortening the execution time of the entire task while ensuring the stable execution of the predefined task. Improve the efficiency of task execution.
本申请实施例提供一种任务执行装置,包括:获取模块,用于获取预定义任务;所述预定义任务包括N个步骤;N为大于1的整数;处理模块,用于根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图;所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行;按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。The embodiment of the present application provides a task execution device, which includes: an acquisition module for acquiring a predefined task; the predefined task includes N steps; N is an integer greater than 1, and a processing module is used for The dependency relationship between steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship, if If any two steps of the dependency relationship do not exist among the N steps, the directed graph indicates that any two steps are executed in parallel; the execution of the steps is in the order indicated by the executed directed graph. Pre-defined tasks.
可选的,第一步骤为所述N个步骤中任一步骤,所述处理模块具体用于:按照以下方式执行所述第一步骤:若所述第一步骤仅包括一个子步骤,则直接执行该子步骤;若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。Optionally, the first step is any one of the N steps, and the processing module is specifically configured to: execute the first step in the following manner: if the first step includes only one sub-step, directly Perform this sub-step; if the first step includes M sub-steps, execute the M sub-steps in parallel, and M is an integer greater than 1.
可选的,所述处理模块还用于:若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则执行所述预定义任务时首先执行所述第一步骤。Optionally, the processing module is further configured to: if any step that has the dependency relationship with the first step is not defined in the predefined task, execute the first step first when executing the predefined task. step.
可选的,所述处理模块还用于:确定所述预定义任务在预设时长内是否发送了心跳数据,若否,且确定所述预定义任务的运行状态为运行中,则向预配置设备发送指示托管所述预定义任务的通知消息。Optionally, the processing module is further configured to: determine whether the predefined task has sent heartbeat data within a preset period of time, if not, and if it is determined that the running state of the predefined task is running, then send the pre-configuration The device sends a notification message indicating to host the predefined task.
可选的,所述处理模块还用于:若所述第一处理设备确定所述N个步骤中存在执行失败的至少两个步骤,则重新并行执行所述执行失败的至少两个步骤。Optionally, the processing module is further configured to: if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
本申请实施例提供一种计算机设备,包括程序或指令,当所述程序或指令被执行时,如本申请实施例提供的一种任务执行方法及可选方法被执行。The embodiment of the present application provides a computer device, including a program or instruction. When the program or instruction is executed, a task execution method and optional method provided in the embodiment of the present application are executed.
本申请实施例提供一种存储介质,包括程序或指令,当所述程序或指令被执行时,如本申请实施例提供的一种任务执行方法及可选方法被执行。The embodiment of the present application provides a storage medium including a program or instruction. When the program or instruction is executed, a task execution method and optional method provided in the embodiment of the present application are executed.
附图说明Description of the drawings
图1为本申请实施例中一种预定义任务的示意图;FIG. 1 is a schematic diagram of a predefined task in an embodiment of this application;
图2为本申请实施例中一种任务执行方法的流程示意图;2 is a schematic flowchart of a task execution method in an embodiment of this application;
图3为本申请实施例中一种任务执行装置的结构示意图。FIG. 3 is a schematic structural diagram of a task execution device in an embodiment of the application.
具体实施方式Detailed ways
为了更好的理解上述技术方案,下面将结合说明书附图及具体的实施方式对上述技术方案进行详细的说明,应当理解本申请实施例以及实施例中的具体特征是对本申请技术方案的详细的说明,而不是对本申请技术方案的限定,在不冲突的情况下,本申请实施例以及实施例中的技术特征可以相互结合。In order to better understand the above technical solutions, the above technical solutions will be described in detail below with reference to the drawings and specific implementations of the specification. It should be understood that the embodiments of the application and the specific features in the embodiments are detailed to the technical solutions of the application. Note, rather than limiting the technical solution of the present application, the embodiments of the present application and the technical features in the embodiments can be combined with each other if there is no conflict.
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Finteh)转变。目前,金融科技领域中,为了实现某个需求或目的,处理设备往往需要执行一系列步骤,这一系列步骤的组合,称为一个任务。举例来说,将数据库中的数据表A修改为数据表B的任务,包括对数据表进行数据插入和数据修改的一系列步骤,整个任务可以称为一个数据处理任务。再如,将一台计算机在一定时长范围内的运行日志收集起来,并对这些运行日志进行统计,以对这台计算机的运行状况进行分析,整个任务可以称为一个日志统计任务。With the development of computer technology, more and more technologies (Big Data, Distributed, Blockchain, Artificial Intelligence, etc.) are applied in the financial field, and the traditional financial industry is gradually changing to Finteh. At present, in the field of financial technology, in order to achieve a certain requirement or purpose, a processing device often needs to perform a series of steps. The combination of this series of steps is called a task. For example, the task of modifying data table A in the database to data table B includes a series of steps of data insertion and data modification to the data table, and the whole task can be called a data processing task. For another example, collect the running logs of a computer within a certain period of time and perform statistics on these running logs to analyze the running status of this computer. The whole task can be called a log statistics task.
目前执行任务的方式为,串行执行任务中的每个步骤,即一个步骤接一个步骤依次往下执行,直至所有步骤执行完成。举例来说,任务一有5个步骤:步骤一、步骤二、步骤三、步骤四、步骤五,不管步骤一、步骤二、步骤三、步骤四、步骤五之间有无必要的先后执行约束关系,都会串行执行步骤一至步骤五。其中,必要的先后执行约束关系指,两个步骤执行时必须遵循的先后执行的次序关系,如修改数据表中的某条数据,必须先查找定位到这条数据,然后再进行修改。显然,这种串行执行步骤的方式下,每个步骤 都要在前一个步骤执行完毕后才能执行,等待时间较久,一旦前一个步骤执行失败需要重新执行,就会浪费更长时间。这样以来,整个任务的执行时间较长,尤其步骤较多时,执行效率较低。The current way of executing the task is to execute each step in the task serially, that is, step by step and proceed sequentially until all steps are completed. For example, task one has 5 steps: step one, step two, step three, step four, step five, regardless of whether there are necessary constraints between step one, step two, step three, step four, and step five. Relationship, steps 1 to 5 are executed in series. Among them, the necessary sequential execution constraint relationship refers to the sequential execution sequence relationship that must be followed when the two steps are executed. For example, to modify a piece of data in a data table, you must first find and locate this data, and then modify it. Obviously, in this way of serially executing steps, each step must be executed after the previous step is executed, and the waiting time is longer. If the previous step fails to execute and needs to be executed again, it will waste more time. In this way, the execution time of the entire task is longer, especially when there are many steps, the execution efficiency is lower.
为此,为了解决现有技术中任务的执行时间较长、执行效率较低的问题,本申请实施例提供了一种任务执行方法。To this end, in order to solve the problems of long execution time and low execution efficiency of tasks in the prior art, an embodiment of the present application provides a task execution method.
本申请实施例提供了一种基于有向图的任务处理模型。有向图:在数学上,一个图(Graph)是表示物件与物件之间的关系的方法,是图论的基本研究对象。一个图看起来是由一些小圆点(称为顶点或结点)和连结这些圆点的直线或曲线(称为边)组成的。如果给图的每条边规定一个方向,那么得到的图称为有向图。The embodiment of the application provides a task processing model based on a directed graph. Directed graph: In mathematics, a graph is a method of representing the relationship between objects and objects, and is the basic research object of graph theory. A graph appears to be composed of small dots (called vertices or nodes) and straight lines or curves (called edges) connecting these dots. If a direction is specified for each edge of the graph, the resulting graph is called a directed graph.
在任务执行之前,需要先对任务进行定义,具体可分为三部分:任务定义、步骤定义和步骤依赖关系的定义,根据定义可以生成一个的有向图的任务模型。其中,任务定义即对任务进行命名,如数据处理任务一,任务Q等,名称不限定字符类型;步骤定义包括对任务中各个步骤的定义、以及每个步骤的具体执行方法,一些步骤还可以有包括几个子步骤,这部分也在步骤定义中给出,另外,步骤定义时,可定义步骤名,实现类,如何拆分数据,执行线程大小,读数据大小,提交事务大小,日志级别等;步骤依赖关系为:所述N个步骤中,每个执行步骤之前,需要获取其它步骤执行结果的约束关系。具体来说,对于任意两个步骤:步骤A和步骤B,若步骤A和步骤B满足以下任一条件,则称步骤A和步骤B存在依赖关系:(1)步骤A执行之前必须先执行步骤B,且步骤B执行之后下一个需要执行的步骤即为步骤A,步骤A需要在步骤B的执行结果基础上执行,也称步骤A依赖步骤B;(2)步骤B执行之前必须先执行步骤A,且步骤A执行之后下一个需要执行的步骤即为步骤B,步骤B需要在步骤A的执行结果基础上执行,称为步骤B依赖于步骤A。显然,任务中可以有多个依赖于步骤A或步骤B的步骤。需要说明的是,如果任务中一个步骤执行之前不需要执行任务中任何其他步骤,则称该步骤为任务的顶点步骤,也就是执行任务时第一个执行的步骤。Before the task is executed, the task needs to be defined first, which can be divided into three parts: task definition, step definition and step dependency definition. According to the definition, a task model of directed graph can be generated. Among them, the task definition is to name the task, such as data processing task 1, task Q, etc. The name does not limit the character type; the step definition includes the definition of each step in the task and the specific execution method of each step. Some steps are also available. There are several sub-steps, which are also given in the step definition. In addition, when the step is defined, you can define the step name, implementation class, how to split data, execute thread size, read data size, commit transaction size, log level, etc. ; The step dependency is: in the N steps, before each step is executed, the constraint relationship of the execution results of other steps needs to be obtained. Specifically, for any two steps: step A and step B, if step A and step B meet any of the following conditions, it is said that there is a dependency between step A and step B: (1) Step A must be executed before step A is executed B, and the next step to be executed after step B is executed is step A, step A needs to be executed on the basis of the execution result of step B, also called step A depends on step B; (2) step B must be executed before step B is executed A, and the next step that needs to be executed after step A is executed is step B, and step B needs to be executed on the basis of the execution result of step A, which is called step B depends on step A. Obviously, there can be multiple steps that depend on step A or step B in the task. It should be noted that if a step in the task does not need to be executed before any other steps in the task are executed, then this step is called the apex step of the task, that is, the first step executed when the task is executed.
以一个具体例子说明一个任务的定义:Take a specific example to illustrate the definition of a task:
任务定义:任务X。Task definition: task X.
步骤定义:任务X包括步骤X1、步骤X2、步骤X3、步骤X4、步骤X5、步骤X6。其中,步骤X3包括两个子步骤:步骤X3-1、步骤X3-2;步骤X6包括三个子步骤:步骤X6-1、步骤X6-2、步骤X6-3。Step definition: Task X includes step X1, step X2, step X3, step X4, step X5, and step X6. Wherein, step X3 includes two sub-steps: step X3-1, step X3-2; step X6 includes three sub-steps: step X6-1, step X6-2, and step X6-3.
步骤依赖关系定义:步骤X1为顶点步骤;步骤X2、步骤X3执行之前需要执行步骤X1;步骤X4和步骤X5执行之前需要执行步骤X2;步骤X6执行之前需要执行步骤X3、步骤X4和步骤X5,因此步骤X6为任务X执行的最后一个步骤。另外,可通过在数据库中存储步骤依赖定义表来定义步骤依赖关系,步骤间如有步骤依赖关系须调整,只需修改步骤依赖定义表即可,从而提升了任务定义的灵活性。Step dependency definition: step X1 is the vertex step; step X2, step X3 needs to be executed before step X1; step X4 and step X5 need to be executed before step X2; step X6 needs to be executed before step X3, step X4 and step X5, Therefore, step X6 is the last step executed by task X. In addition, the step dependency can be defined by storing the step dependency definition table in the database. If the step dependency needs to be adjusted between steps, you only need to modify the step dependency definition table, which improves the flexibility of task definition.
下面再以图1为例,详细说明本申请实施例中的任务定义。如图1所示,为本申请实施例中一种任务定义的示意图。图1示出的任务命名为任务Y,包括步骤Y1、步骤Y2、步骤Y3、步骤Y4、步骤Y5、步骤Y6。根据任务定义,可生成一个如图1所示的对应有向图。The following takes FIG. 1 as an example to describe in detail the task definition in the embodiment of the present application. As shown in Figure 1, it is a schematic diagram of a task definition in an embodiment of this application. The task shown in FIG. 1 is named task Y and includes step Y1, step Y2, step Y3, step Y4, step Y5, and step Y6. According to the task definition, a corresponding directed graph as shown in Figure 1 can be generated.
由图1可知,步骤Y1为任务Y的顶点步骤;步骤Y2、步骤Y3、步骤Y5执行之前,均需要执行步骤Y1;且任务Y中,步骤Y2、步骤Y3执行完后,下一个需要执行的步骤为步骤Y4,而步骤Y4执行的前提是步骤Y2、步骤Y3均执行完;步骤Y4和步骤Y5均执行完后,下一个需要执行的步骤为步骤Y6,而步骤Y6执行的前提是步骤Y4、步骤Y5均执行完,步骤Y6又分为步骤Y6-1和步骤Y6-2。It can be seen from Figure 1 that step Y1 is the vertex step of task Y; step Y1 needs to be executed before step Y2, step Y3, and step Y5 are executed; and in task Y, after step Y2 and step Y3 are executed, the next step that needs to be executed The step is step Y4, and the prerequisite for the execution of step Y4 is that both steps Y2 and Y3 are executed; after both steps Y4 and Y5 are executed, the next step to be executed is step Y6, and the premise of step Y6 is step Y4 , Step Y5 has been executed, and step Y6 is divided into step Y6-1 and step Y6-2.
下面结合图2,详细说明图1示出的任务Y的执行步骤,如图2所示,为本申请实施例中一种任务执行方法的流程示意图,图2示出的任务执行方法可应用于图1示出的任务Y。需要说明的是,任务中每个步骤在执行过程中,都定义了执行状态,并根据步骤当前执行的状态更新执行状态,具体包括:执行失败、已完成、执行中、调度中和未启动。以第一处理设备为例,说明预定义任务中的步骤执行过程。需要说明的是,第一处理设备为任何能 执行指令的设备,不做限定,举例来说,第一处理设备为计算机设备;预定义任务即事先已经定义的任务,如任务X和任务Y。The following describes in detail the execution steps of task Y shown in FIG. 1 with reference to FIG. 2. As shown in FIG. 2, it is a schematic flowchart of a task execution method in an embodiment of this application. The task execution method shown in FIG. 2 can be applied to Figure 1 shows task Y. It should be noted that during the execution of each step in the task, the execution status is defined, and the execution status is updated according to the current execution status of the step, which specifically includes: execution failed, completed, executed, scheduled, and not started. Take the first processing device as an example to illustrate the execution process of the steps in the predefined task. It should be noted that the first processing device is any device that can execute instructions and is not limited. For example, the first processing device is a computer device; predefined tasks are tasks that have been defined in advance, such as task X and task Y.
第一处理设备按照以下方式执行预定义任务中定义的每个步骤:The first processing device executes each step defined in the predefined task in the following manner:
S201:第一处理设备获取预定义任务。S201: The first processing device obtains a predefined task.
所述预定义任务包括N个步骤,N为大于1的整数。The predefined task includes N steps, and N is an integer greater than 1.
S202:所述第一处理设备根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图。S202: The first processing device generates an execution directed graph corresponding to the predefined task according to the dependency relationship existing between the N steps.
所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行。The execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship. If any two steps of the dependency relationship do not exist in the N steps, then the The directed graph indicates that any two steps are executed in parallel.
需要强调的是,图2仅以第一处理设备为例说明任务的执行过程。事实上,每个步骤或者子步骤都可以在不同处理设备上执行,以便于并发处理。从而,处理设备的数量可以横向扩展,以提高计算处理能力,因此,最大限度地提高了步骤间以及步骤内的并发处理能力。另外,为了提高性能,可将任务定义在系统启动时加载到内存中。It should be emphasized that FIG. 2 only uses the first processing device as an example to illustrate the execution process of the task. In fact, each step or substep can be executed on different processing devices to facilitate concurrent processing. As a result, the number of processing devices can be expanded horizontally to improve computing processing capabilities, and therefore, to maximize the concurrent processing capabilities between and within steps. In addition, in order to improve performance, task definitions can be loaded into memory when the system starts.
S203:所述第一处理设备按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。S203: The first processing device executes the predefined task according to the execution order of the steps indicated by the execution directed graph.
S201中,所述第一步骤为所述预定义任务中定义的任一步骤;所述前驱依赖关系指示:所述预定义任务中,且所述N个第二步骤全部成功执行后,才允许执行所述第一步骤。需要说明的是,由于预定义任务中每个步骤都定义了状态,第一步骤在执行一次之后,可能执行成功也可能执行失败,当第一步骤执行失败后,将重试执行,第一步骤执行成功后就跳过。In S201, the first step is any step defined in the predefined task; the precursor dependency indication: in the predefined task, and the N second steps are all successfully executed, it is allowed Perform the first step. It should be noted that since each step in the predefined task defines a state, after the first step is executed once, the execution may succeed or fail. When the execution of the first step fails, the execution will be retried. The first step Skip after successful execution.
举例来说,第一步骤为任务Y中步骤Y4时,则N为2,2个第二步骤即为步骤Y2和步骤Y3。会先并行执行步骤Y2和步骤Y3,待步骤Y2和步骤Y3全部成功执行后,下一个需要执行的步骤均为步骤Y4,而且,步骤Y2和步骤Y3全部成功执行后,才允许执行步骤Y4。另外,步骤Y5可能是个长时间步骤,步骤Y2、步骤Y3和步骤Y4,均可与步骤Y5一起并行执行,步 骤Y4完成后,会检验步骤Y5是否成功执行完成,之后才能开始执行步骤Y6,从而提高了任务执行的效率。For example, when the first step is step Y4 in task Y, then N is 2, and the two second steps are step Y2 and step Y3. Step Y2 and step Y3 will be executed in parallel first. After step Y2 and step Y3 are all successfully executed, the next step to be executed is step Y4, and step Y2 and step Y3 are all executed successfully before step Y4 is allowed to be executed. In addition, step Y5 may be a long time step. Step Y2, step Y3, and step Y4 can be executed in parallel with step Y5. After step Y4 is completed, it will check whether step Y5 is successfully executed, and then step Y6 can be executed. Improve the efficiency of task execution.
另外,预定义任务在执行过程中,会产生执行日志,分三部分:任务执行日志,步骤执行日志,子步骤执行日志。子步骤日志和步骤日志是一对多的关系,如果步骤无拆分,那就有一条子步骤日志,如果有拆分,那么子步骤日志有多条。子步骤执行日志里包括:首先包括定义表的数据,可定义任务名,步骤名,实现类,如何拆分数据,执行线程大小,读数据大小,提交事务大小,日志级别。以及,当前处理的数据片,总共待处理条数,已读条数,已处理条数,忽略条数,处理互联网地址(Internet protocol,IP),创建时间,开始时间,完成时间等信息。In addition, during the execution of a predefined task, an execution log will be generated, which is divided into three parts: task execution log, step execution log, and sub-step execution log. The sub-step log and the step log have a one-to-many relationship. If the step is not split, there is one sub-step log; if there is a split, then there are multiple sub-step logs. The sub-step execution log includes: first, the data of the definition table is included, the task name, step name, implementation class, how to split the data, the execution thread size, the read data size, the commit transaction size, and the log level are included. And, the currently processed data pieces, the total number of pending items, the number of read items, the number of processed items, the number of ignored items, the processing Internet address (Internet protocol, IP), creation time, start time, completion time and other information.
S202中,一种可选实施方式为,若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则所述第一处理设备执行所述预定义任务时首先执行所述第一步骤。In S202, an optional implementation manner is that, if any step that has the dependency relationship with the first step is not defined in the predefined task, the first processing device first executes the predefined task Perform the first step.
也就是说,当第一步骤为顶点步骤时,会在执行所述预定义任务时首先执行所述第一步骤。举例来说,第一步骤为步骤Y1,执行步骤Y时,首先执行步骤Y1。In other words, when the first step is the apex step, the first step will be executed first when the predefined task is executed. For example, the first step is step Y1. When step Y is executed, step Y1 is executed first.
S203中,一种可选实施方式为,所述第一处理设备按照以下方式执行所述第一步骤:In S203, an optional implementation manner is that the first processing device executes the first step in the following manner:
(1)若所述第一步骤仅包括一个子步骤,则直接执行该子步骤。(1) If the first step includes only one sub-step, the sub-step is directly executed.
(2)若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。(2) If the first step includes M sub-steps, the M sub-steps are executed in parallel, and M is an integer greater than 1.
举例来说,当第一步骤为任务Y中步骤Y4时,Y4仅包括一个子步骤,则直接执行这个子步骤;当第一步骤为任务Y中步骤Y6时,M为2,Y6包括,2个子步骤,则并行执行这2个子步骤。For example, when the first step is step Y4 in task Y, and Y4 includes only one substep, then this substep is directly executed; when the first step is step Y6 in task Y, M is 2, and Y6 includes, 2. Sub-steps, then execute these two sub-steps in parallel.
S203中,一种可选实施方式为,若所述第一处理设备确定所述N个步骤中存在执行失败的至少两个步骤,则重新并行执行所述执行失败的至少两个步骤。In S203, an optional implementation manner is that, if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
举例来说,当第一步骤为任务Y中步骤Y4时,2个第二步骤为步骤Y2和步骤Y3,因此,如果步骤Y2和步骤Y3执行均执行失败,会重新并行执行步骤Y2和步骤Y3。For example, when the first step is step Y4 in task Y, the two second steps are step Y2 and step Y3. Therefore, if step Y2 and step Y3 fail to execute, step Y2 and step Y3 will be executed again in parallel .
S201至S203中,一种可选实施方式为,所述第一处理设备确定所述预定义任务在预设时长内是否发送了心跳数据,若否,且确定所述预定义任务的运行状态为运行中,则向第二处理设备发送指示托管所述预定义任务的通知消息。通过上述方式,可及时获取任务的运行状态,从而将未正常运行的任务托管,节约了运算资源。In S201 to S203, an optional implementation manner is that the first processing device determines whether the predefined task has sent heartbeat data within a preset period of time, if not, and determines that the running status of the predefined task is During operation, a notification message indicating to host the predefined task is sent to the second processing device. Through the above method, the running status of the task can be obtained in time, so that the task that is not running normally can be managed, saving computing resources.
其中托管为:a机器执行任务时因硬件故障等情况导致任务是处理中,而实际没有处理。b机器根据每个机器更新的心跳时间判断a机器是否不可用,如果超过预设时长没有心跳,则认为不可用,那么b机器修改预定义任务为b机器执行,重新执行此任务,达到高可用的目的。简单的说,就是,正常运行的机器能将有故障机器的任务拿来执行。The hosting is: a. When the machine executes the task, the task is being processed due to hardware failures and other conditions, but it is not actually processed. The machine b judges whether machine a is unavailable according to the heartbeat time updated by each machine. If there is no heartbeat for more than the preset time, it is considered unavailable. Then machine b modifies the predefined task to machine b to execute, and executes this task again to achieve high availability the goal of. Simply put, that is, a normally operating machine can perform the tasks of a faulty machine.
S203中,当所述第一步骤存在有依赖关系的至少一个步骤中任何一个步骤执行成功后,都会检验下是否是所述至少一个步骤中最后一个执行成功的步骤,若是,则执行所述第一步骤。In S203, when any one of the at least one step that has a dependency relationship in the first step is executed successfully, it will be checked whether it is the last step in the at least one step that has successfully executed, and if so, the first step is executed. One step.
本申请实施例具有以下优点:(1)基于有向图定义任务步骤依赖,每个步骤只关心依赖步骤是否完成则可以开始;(2)单步骤内可以根据定义拆分成多个子步骤,所有子步骤完成则当前步骤完成;(3)实现与配置分离,不同的配置组合形成不同的功能组合。The embodiments of this application have the following advantages: (1) Define task step dependencies based on the directed graph, and each step only cares about whether the dependent step is completed and then can start; (2) A single step can be split into multiple sub-steps according to the definition, all When the sub-step is completed, the current step is completed; (3) Realization and configuration are separated, and different configuration combinations form different functional combinations.
本申请实施例中,可以通过在预定义任务中定义所述执行有向图来执行步骤,所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行。另外,所述执行有向图还指示所述N个步骤之间存在的依赖关系,从而保证了任务按照预设执行先后次序正常处理。因此,所述任意两个步骤中各个步骤的执行时间有重叠,且相互之间不受执行失败与否的影响,从而在保证预定义任务稳定执行的前提下, 缩短了整个任务的执行时间,提升了任务的执行效率。In the embodiment of the present application, the steps may be executed by defining the execution directed graph in a predefined task. The execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship. Figure, if any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel. In addition, the execution directed graph also indicates the dependency relationship existing among the N steps, thereby ensuring that tasks are processed normally according to the preset execution sequence. Therefore, the execution time of each step in any two steps overlaps, and they are not affected by execution failure or not, so that the execution time of the entire task is shortened while ensuring the stable execution of the predefined task. Improve the efficiency of task execution.
如图3所示,为本申请实施例中一种任务执行装置的结构示意图。As shown in FIG. 3, it is a schematic structural diagram of a task execution device in an embodiment of this application.
本申请实施例提供一种任务执行装置,包括:获取模块301,用于获取预定义任务;所述预定义任务包括N个步骤;N为大于1的整数;处理模块302,用于根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图;所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行;按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。An embodiment of the present application provides a task execution device, including: an acquisition module 301, configured to acquire a predefined task; the predefined task includes N steps; N is an integer greater than 1; a processing module 302, configured to The dependency relationship between the N steps is generated, and the execution directed graph corresponding to the predefined task is generated; the execution directed graph is a directed graph indicating the execution order of the N steps determined according to the dependency relationship , If any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that the any two steps are executed in parallel; the execution order of the steps indicated by the executed directed graph is executed The predefined task.
可选的,第一步骤为所述N个步骤中任一步骤,所述处理模块302具体用于:按照以下方式执行所述第一步骤:若所述第一步骤仅包括一个子步骤,则直接执行该子步骤;若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。Optionally, the first step is any one of the N steps, and the processing module 302 is specifically configured to: execute the first step in the following manner: if the first step includes only one sub-step, then This sub-step is directly executed; if the first step includes M sub-steps, the M sub-steps are executed in parallel, and M is an integer greater than 1.
可选的,所述处理模块302还用于:若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则执行所述预定义任务时首先执行所述第一步骤。Optionally, the processing module 302 is further configured to: if any step that has the dependency relationship with the first step is not defined in the predefined task, execute the first step first when executing the predefined task One step.
可选的,所述处理模块302还用于:确定所述预定义任务在预设时长内是否发送了心跳数据,若否,且确定所述预定义任务的运行状态为运行中,则向预配置设备发送指示托管所述预定义任务的通知消息。Optionally, the processing module 302 is further configured to: determine whether the predefined task has sent heartbeat data within a preset period of time; if not, and if it is determined that the running state of the predefined task is running, then send the pre-defined task to the pre-defined task. The configuration device sends a notification message indicating to host the predefined task.
可选的,所述处理模块302还用于:若所述第一处理设备确定所述N个步骤中存在执行失败的至少两个步骤,则重新并行执行所述执行失败的至少两个步骤。Optionally, the processing module 302 is further configured to: if the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
最后应说明的是:本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、光学存储器等)上实施的计算机程序产品的形 式。Finally, it should be noted that those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to flowcharts and/or block diagrams of methods, equipment (systems), and computer program products according to this application. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the application without departing from the scope of the application. In this way, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application also intends to include these modifications and variations.

Claims (10)

  1. 一种任务执行方法,其特征在于,包括:A task execution method, characterized in that it comprises:
    第一处理设备获取预定义任务;所述预定义任务包括N个步骤;N为大于1的整数;The first processing device acquires a predefined task; the predefined task includes N steps; N is an integer greater than 1;
    所述第一处理设备根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图;所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行;The first processing device generates an execution directed graph corresponding to the predefined task according to the dependency relationship existing between the N steps; the execution directed graph indicates that the N steps are based on the dependency A directed graph of an execution sequence determined by a relationship, if any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that any two steps are executed in parallel;
    所述第一处理设备按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。The first processing device executes the predefined task according to the execution sequence of the steps indicated by the execution directed graph.
  2. 如权利要求1所述的方法,其特征在于,第一步骤为所述N个步骤中任一步骤,所述第一处理设备按照以下方式执行所述第一步骤:The method according to claim 1, wherein the first step is any one of the N steps, and the first processing device executes the first step in the following manner:
    若所述第一步骤仅包括一个子步骤,则直接执行该子步骤;If the first step includes only one sub-step, then directly execute the sub-step;
    若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。If the first step includes M sub-steps, the M sub-steps are executed in parallel, and M is an integer greater than 1.
  3. 如权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, wherein the method further comprises:
    若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则所述第一处理设备执行所述预定义任务时首先执行所述第一步骤。If any step that has the dependency relationship with the first step is not defined in the predefined task, the first step is first executed when the first processing device executes the predefined task.
  4. 如权利要求1至3任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises:
    所述第一处理设备确定所述预定义任务在预设时长内是否发送了心跳数据,若否,且确定所述预定义任务的运行状态为运行中,则向第二处理设备发送指示托管所述预定义任务的通知消息。The first processing device determines whether the predefined task has sent heartbeat data within a preset period of time, and if not, and determines that the running state of the predefined task is running, it sends an instruction to the second processing device Describes notification messages for predefined tasks.
  5. 如权利要求1至3任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises:
    若所述第一处理设备确定所述N个步骤中存在执行失败的至少两个步骤,则重新并行执行所述执行失败的至少两个步骤。If the first processing device determines that there are at least two failed execution steps among the N steps, re-execute the at least two failed execution steps in parallel.
  6. 一种任务执行装置,其特征在于,包括:A task execution device is characterized by comprising:
    获取模块,用于获取预定义任务;所述预定义任务包括N个步骤;N为大于1的整数;The obtaining module is used to obtain a predefined task; the predefined task includes N steps; N is an integer greater than 1;
    处理模块,用于根据所述N个步骤之间存在的依赖关系,生成所述预定义任务对应的执行有向图;所述执行有向图为指示出所述N个步骤根据所述依赖关系确定的执行顺序的有向图,若所述N个步骤中不存在所述依赖关系的任意两个步骤,则所述有向图指示所述任意两个步骤并行执行;按照所述执行有向图指示的步骤执行顺序,执行所述预定义任务。The processing module is configured to generate an execution directed graph corresponding to the predefined task according to the dependency relationship existing between the N steps; the execution directed graph indicates that the N steps are based on the dependency relationship A directed graph with a determined execution order. If any two steps of the dependency relationship do not exist in the N steps, the directed graph indicates that any two steps are executed in parallel; The execution sequence of the steps indicated in the figure is to execute the predefined task.
  7. 如权利要求6所述的装置,其特征在于,第一步骤为所述N个步骤中任一步骤,所述处理模块具体用于:The device according to claim 6, wherein the first step is any one of the N steps, and the processing module is specifically configured to:
    按照以下方式执行所述第一步骤:Perform the first step as follows:
    若所述第一步骤仅包括一个子步骤,则直接执行该子步骤;If the first step includes only one sub-step, then directly execute the sub-step;
    若所述第一步骤包括M个子步骤,则并行执行所述M个子步骤,M为大于1的整数。If the first step includes M sub-steps, the M sub-steps are executed in parallel, and M is an integer greater than 1.
  8. 如权利要求7所述的装置,其特征在于,所述处理模块还用于:The device according to claim 7, wherein the processing module is further configured to:
    若所述预定义任务中未定义与所述第一步骤存在所述依赖关系的任何步骤,则执行所述预定义任务时首先执行所述第一步骤。If any step that has the dependency relationship with the first step is not defined in the predefined task, the first step is executed first when the predefined task is executed.
  9. 一种计算机设备,其特征在于,包括程序或指令,当所述程序或指令被执行时,如权利要求1至5中任意一项所述的方法被执行。A computer device characterized by comprising a program or an instruction, and when the program or an instruction is executed, the method according to any one of claims 1 to 5 is executed.
  10. 一种存储介质,其特征在于,包括程序或指令,当所述程序或指令被执行时,如权利要求1至5中任意一项所述的方法被执行。A storage medium, characterized by comprising a program or instruction, and when the program or instruction is executed, the method according to any one of claims 1 to 5 is executed.
PCT/CN2019/110466 2019-05-17 2019-10-10 Task execution method and device WO2020232951A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910413986.8A CN110147273A (en) 2019-05-17 2019-05-17 A kind of task executing method and device
CN201910413986.8 2019-05-17

Publications (1)

Publication Number Publication Date
WO2020232951A1 true WO2020232951A1 (en) 2020-11-26

Family

ID=67595550

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/110466 WO2020232951A1 (en) 2019-05-17 2019-10-10 Task execution method and device

Country Status (2)

Country Link
CN (1) CN110147273A (en)
WO (1) WO2020232951A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147273A (en) * 2019-05-17 2019-08-20 深圳前海微众银行股份有限公司 A kind of task executing method and device
CN110689344B (en) * 2019-08-30 2021-04-09 创新先进技术有限公司 Method and apparatus for concurrently executing transactions in a blockchain
CN110599166A (en) * 2019-09-09 2019-12-20 深圳前海微众银行股份有限公司 Method and device for acquiring transaction dependency relationship in block chain
CN111181793B (en) * 2019-12-31 2021-12-21 京信网络系统股份有限公司 Method, device, equipment and storage medium for controlling chain communication business process
CN113238533B (en) * 2021-05-12 2022-05-13 广东美房智高机器人有限公司 System and method for dynamically scheduling and issuing job tasks of mobile robot

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103077006A (en) * 2012-12-27 2013-05-01 浙江工业大学 Multithreading-based parallel executing method for long transaction
CN104679763A (en) * 2013-11-28 2015-06-03 富士通株式会社 Device and method for accelerating performing of workflow
CN106447173A (en) * 2016-09-05 2017-02-22 北京理工大学 Cloud workflow scheduling method supporting any flow structure
CN107633125A (en) * 2017-09-14 2018-01-26 北京仿真中心 A kind of analogue system Parallelism method based on Weighted Directed Graph
US20180032568A1 (en) * 2016-07-29 2018-02-01 Sysomos L.P. Computing System with Multi-Processor Platform for Accelerating Influence Maximization Computation and Related Methods
CN110147273A (en) * 2019-05-17 2019-08-20 深圳前海微众银行股份有限公司 A kind of task executing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103077006A (en) * 2012-12-27 2013-05-01 浙江工业大学 Multithreading-based parallel executing method for long transaction
CN104679763A (en) * 2013-11-28 2015-06-03 富士通株式会社 Device and method for accelerating performing of workflow
US20180032568A1 (en) * 2016-07-29 2018-02-01 Sysomos L.P. Computing System with Multi-Processor Platform for Accelerating Influence Maximization Computation and Related Methods
CN106447173A (en) * 2016-09-05 2017-02-22 北京理工大学 Cloud workflow scheduling method supporting any flow structure
CN107633125A (en) * 2017-09-14 2018-01-26 北京仿真中心 A kind of analogue system Parallelism method based on Weighted Directed Graph
CN110147273A (en) * 2019-05-17 2019-08-20 深圳前海微众银行股份有限公司 A kind of task executing method and device

Also Published As

Publication number Publication date
CN110147273A (en) 2019-08-20

Similar Documents

Publication Publication Date Title
WO2020232951A1 (en) Task execution method and device
US10453010B2 (en) Computer device, method, and apparatus for scheduling business flow
CN107391628B (en) Data synchronization method and device
US8381015B2 (en) Fault tolerance for map/reduce computing
US20130227194A1 (en) Active non-volatile memory post-processing
CN107016029B (en) Method, device and system for processing service data
US11176086B2 (en) Parallel copying database transaction processing
CN107016016B (en) Data processing method and device
WO2021238273A1 (en) Message fault tolerance method and system based on spark streaming computing framework
CN111897633A (en) Task processing method and device
CN110413428B (en) Account checking data processing method, electronic equipment and storage medium
US11392414B2 (en) Cooperation-based node management protocol
US9116843B2 (en) Avoiding restart on error in data integration
CN115220876A (en) Virtual resource creating method, device, program product, medium and electronic equipment
CN112231403B (en) Consistency verification method, device, equipment and storage medium for data synchronization
JP2023553220A (en) Process mining for multi-instance processes
US11748164B2 (en) FAAS distributed computing method and apparatus
CN111147541B (en) Node processing method, device and equipment based on parameter server and storage medium
CN109445800A (en) A kind of version automatic deployment method and system based on distributed system
WO2023185137A1 (en) Task management method and apparatus, and device and storage medium
CN110908644B (en) Configuration method and device of state node, computer equipment and storage medium
CN111913858A (en) Pressure testing system and method
US10944850B2 (en) Methods, devices and systems for non-disruptive upgrades to a distributed coordination engine in a distributed computing environment
CN115499493A (en) Asynchronous transaction processing method and device, storage medium and computer equipment
CN114791900A (en) Operator-based Redis operation and maintenance method, device, system and storage medium

Legal Events

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

Ref document number: 19929690

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 01/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19929690

Country of ref document: EP

Kind code of ref document: A1