Main task processing method, device, server and storage medium
By determining the sequential properties of the main task and adopting appropriate distribution strategies, the problem of the existing technology that cannot meet the serial processing requirements of the main task in special scenarios is solved, and the orderliness and scope of application of the main task processing is achieved.
Patent Information
- Application Number
- CN202011307444.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-19
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-11-19
AI Technical Summary
The existing technology cannot meet the serial processing requirements of main tasks in special scenarios, resulting in multiple main tasks entering the processing stage at the same time, and cannot meet the processing requirements of strict order dependence.
By determining the sequential attributes of the target main task, using real-time or delayed strategies to distribute the main task, ensuring the orderliness of the main task from preprocessing to final execution, and using the status and number of out-of-order main tasks to determine the distribution strategy, satisfying the Strictly sequentially dependent processing requirements.
The processing of main tasks with strict order dependence is realized, the orderliness of the entire process from preprocessing to final execution is ensured, the usage needs in special scenarios are met, and the scope of application of the main task processing mechanism is broadened.
Smart Images

Figure CN112416552B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing technology, and in particular to a main task processing method, device, server and storage medium. Background Art
[0002] Batch processing tasks, also called main tasks, refer to a group of tasks suitable for batch processing that are obtained by combining a series of subtasks according to certain rules. Since batch processing does not require human intervention, it has the advantages of high resource utilization and high throughput. It is highly favored in business scenarios involving the processing of massive data, such as large banks.
[0003] In the prior art, a main task preprocessing inspector uses a structured query language (SQL) statement to screen a database main task table to obtain multiple main tasks that meet the conditions, and batch modify the stage status of these main tasks to enter the preprocessing stage, thereby realizing the distribution of the main tasks.
[0004] However, the existing method will cause multiple main tasks to enter the processing stage at the same time, which cannot meet the serial processing requirements of the main tasks in special scenarios. Summary of the invention
[0005] The embodiments of the present application provide a main task processing method, device, server and storage medium, which realize serial processing of the main task and meet the usage requirements in special scenarios.
[0006] In a first aspect, an embodiment of the present application provides a main task processing method, including:
[0007] If the target main task belongs to a sequential execution type main task, determining the sequential attribute of the target main task; wherein the sequential attribute is an interruptible execution attribute or a non-interruptible execution attribute;
[0008] The target main task is processed according to the sequence attribute of the target main task.
[0009] Optionally, the processing the target main task according to the sequence attribute of the target main task includes:
[0010] If the sequence attribute of the target main task is the interruptible execution attribute, the preceding main task closest to the target main task in the main task parameter table is used as the first preceding main task;
[0011] The target main task is processed according to the task status of the first preceding main task.
[0012] Optionally, the processing the target main task according to the sequence attribute of the target main task includes:
[0013] If the sequence attribute of the target main task is a non-interruptible execution attribute, the preceding main task closest to the target main task in the task execution sequence rule is used as the second preceding main task;
[0014] Determining whether the main task parameter table includes the second preceding main task;
[0015] According to the determination result, the target main task is processed.
[0016] Optionally, the task status of the first predecessor main task includes a completed state and an uncompleted state; and processing the target main task according to the task status of the first predecessor main task includes:
[0017] If the task status of the first preceding main task is a completed status, distributing the target main task using an immediate strategy;
[0018] If the task status of the first preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
[0019] Optionally, the adopting a delay strategy to distribute the target main task includes:
[0020] After a preset delay, determining whether the task status of the first preceding main task is a completed state;
[0021] If the task status of the first preceding main task is a completed status, the target main task is distributed using an immediate strategy.
[0022] Optionally, the adopting an immediate strategy to distribute the target main task includes:
[0023] Constructing a main task message including the target main task;
[0024] The main task message is sent to the message middleware or the target main task execution node.
[0025] Optionally, processing the target main task according to the determination result includes:
[0026] If it is determined that the main task parameter table does not include the second preceding main task, updating the out-of-sequence number of the target main task;
[0027] Determining whether the out-of-sequence number reaches an alarm threshold;
[0028] If the number of out-of-sequence times reaches the alarm threshold, an alarm is issued.
[0029] Optionally, processing the target main task according to the determination result includes:
[0030] If it is determined that the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
[0031] Optionally, the task status of the second predecessor main task includes a completed state and an uncompleted state, and the distributing the target main task according to the task status of the second predecessor main task includes:
[0032] If the task status of the second preceding main task is a completed status, the target main task is distributed using an immediate strategy;
[0033] If the task status of the second preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
[0034] Optionally, the method further comprises:
[0035] If the out-of-sequence number does not reach the alarm threshold, after a delay of a preset time, determining whether the main task parameter table includes the second preceding main task;
[0036] If the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
[0037] In a second aspect, an embodiment of the present application provides a main task processing device, including:
[0038] A first processing module is used to determine a sequence attribute of the target main task if the target main task belongs to a sequence execution type main task; wherein the sequence attribute is an interruptible execution attribute or a non-interruptible execution attribute;
[0039] The second processing module is used to process the target main task according to the sequence attribute of the target main task.
[0040] In a third aspect, an embodiment of the present application provides a server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the main task processing method as described in the first aspect above is implemented.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the main task processing method as described in the first aspect above.
[0042] The main task processing method, device, server and storage medium provided in the embodiments of the present application determine the sequential attribute of the target main task if the target main task belongs to the sequential execution type main task; wherein the sequential attribute is an interruptible execution attribute or a non-interruptible execution attribute; according to the sequential attribute of the target main task, the target main task is processed to realize the processing of the main tasks with strict sequential dependencies, thereby ensuring the orderliness of the entire process from pre-processing distribution to final execution of the main task, being able to meet the usage requirements in special scenarios, and broadening the scope of application of the main task processing mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of an application scenario of an embodiment of the present application;
[0044] Figure 2 A flowchart of the main task processing method provided in Example 1 of the present application;
[0045] Figure 3 This is a flowchart of a specific implementation method of S102 in Example 1 of the present application;
[0046] Figure 4 A schematic diagram of an execution logic of the main task processing method provided in the first embodiment of the present application;
[0047] Figure 5 A schematic diagram of the structure of the main task processing device provided in Embodiment 3 of the present application;
[0048] Figure 6 A schematic diagram of the structure of a server provided in Example 4 of the present application. DETAILED DESCRIPTION
[0049] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.
[0050] The present application provides a technical solution for sequentially processing main tasks, which is mainly used in cluster systems. For example, Figure 1 Schematic diagram of application scenarios of the embodiments of the present application, such as Figure 1 As shown, a cluster system includes three nodes: node A, node B and node C as an example, wherein any node can be used as the execution subject of the method embodiment of the present application, the cache server D is used to store distributed locks, the shared database is used to store the main tasks and main task parameter tables to be processed, and the message middleware is used to realize the decoupling of the distribution, claim and execution process of the main tasks.
[0051] Embodiment 1
[0052] Figure 2 This is a flow chart of the main task processing method provided in the first embodiment of the present application. The method of this embodiment can be executed by the main task processing device provided in the embodiment of the present application. The device can be implemented by software and / or hardware and can be integrated in the server. Figure 2 As shown, the main task processing method of this embodiment includes:
[0053] S101: If the target main task belongs to a sequential execution type main task, determine the sequential attribute of the target main task.
[0054] In this step, in order to meet the processing needs of main tasks with different sequence characteristics, after determining that the target main task is a sequence execution type main task, the sequence attribute of the target main task will be further determined.
[0055] Exemplarily, before executing S101, a main task parameter table can be obtained from a shared database via a network. The main task parameter table can be a task list of main tasks received within a period of time (such as within one day) in the shared database. The main task parameter table can also include the main task identification (number, name, etc.) and its configuration information. The configuration information may include the task type, task status, sequence attributes, sequence rules, etc. of the main task.
[0056] Among them, the task type is used to describe the processing method of the corresponding main task, whether fast parallel processing is required or order-preserving processing is required. Optionally, in this embodiment, the task type is divided into two types: sequential execution type and parallel execution type.
[0057] The task status is used to describe the current status of the corresponding main task. Unlike the parallel execution type main task, the sequential execution type main task usually only needs to pay attention to whether it is in the completed state. Optionally, in this embodiment, the task status of the main task is divided into two states: completed state and uncompleted state.
[0058] The sequence attribute is used to describe the sequence characteristics of the corresponding main task, that is, whether it is necessary to strictly abide by the front-end dependency relationship specified in the sequence rule. Optionally, in this embodiment, the sequence attribute is divided into two types: interruptible execution attribute and non-interruptible execution attribute.
[0059] The order rule is used to describe the execution order of multiple main tasks with a front-to-back dependency relationship, such as main task a must be executed before main task b, etc. It is usually reflected by the sequence number. The smaller the sequence number of the main task, the earlier its execution order.
[0060] Accordingly, in this step, the main task parameter table can be queried according to the identification of the target main task, so as to determine whether the type of the target main task is a sequential execution type according to the main task type recorded in the main task parameter table. If it is a sequential execution type, the sequence attribute of the target main task is further determined. The specific implementation method of determining the sequence attribute of the target main task is similar to the method of determining the task type of the target main task, that is, according to the identification of the target main task, it is determined by querying the main task parameter table.
[0061] It can be understood that when a new main task is received or the configuration information such as the task status of the main task changes, the shared database will update the main task parameter table accordingly and send the latest main task parameter table to each node in the cluster system. Accordingly, each node can obtain the latest main task parameter table by refreshing the main task parameter table, thereby ensuring the effectiveness and availability of the information in the main task parameter table.
[0062] S102: Process the target main task according to the sequence attribute of the target main task.
[0063] In this step, after S101, by processing the target main task in different ways according to the different sequence attributes of the target main task, adaptive processing of main tasks with different sequence characteristics is achieved, meeting the usage requirements in different scenarios and improving the distribution efficiency of the main tasks.
[0064] In one possible implementation, Figure 3 This is a flowchart of a specific implementation method of S102 in the first embodiment of the present application, such as Figure 3 As shown, in this implementation, S102 includes:
[0065] S1021. If the sequence attribute of the target main task is an interruptible execution attribute, a preceding main task closest to the target main task in the main task parameter table is used as the first preceding main task.
[0066] S1022: Process the target main task according to the task status of the first preceding main task.
[0067] In this embodiment, for the main tasks of the sequential execution type, multiple main tasks with specific front-to-back dependencies will be numbered to obtain corresponding sequence numbers. It can be understood that the smaller the sequence number of the main task, the earlier its execution order, and the front-to-back dependencies are recorded in the main task parameter table by means of sequence rules, such as main task a must be executed before main task b, etc. It should be noted that the main task with a sequence number smaller than the sequence number of the target main task is the predecessor main task of the target main task. If the sequence number of the target main task is xxxx_4, the main tasks with sequence numbers xxxx_1, xxxx_2, and xxxx_3 are all predecessor main tasks of the target main task, while the main tasks with sequence numbers xxxx_5, xxxx_6, etc. cannot be called predecessor main tasks of the target main task.
[0068] It is understandable that in this implementation, after determining the sequence number of the target main task, by querying the main task number recorded in the main task parameter table, it is possible to determine which main tasks precede the target main task included in the main task parameter table.
[0069] In S1021, the preceding main task included in the main task parameter table and closest to the target main task is taken as the first preceding main task, that is, the first preceding main task is the preceding main task whose sequence number included in the main task parameter table is closest to the sequence number of the target main task. For example, if the target main task is numbered xxxx_4, and the main task parameter table also includes two preceding main tasks with sequence numbers xxxx_1 and xxxx_2 (the main task with sequence number xxxx_3 may not be saved successfully due to the large file size), then the main task with sequence number 2 is the first preceding main task.
[0070] Similarly, in this step, the task status of the first preceding main task can also be determined according to the identifier of the first preceding main task by querying the main task parameter table.
[0071] Optionally, the task status of the first predecessor main task includes a completed state and an uncompleted state. Accordingly, in this step, after determining the task status of the first predecessor main task, if the task status of the first predecessor main task is a completed state, the target main task is distributed using an immediate strategy, and if the task status of the first predecessor main task is an uncompleted state, the target main task is distributed using a delayed strategy.
[0072] The real-time strategy specifically includes: constructing a main task message including the target main task, sending the main task message to the message middleware or to the execution node of the target main task, and completing the distribution of the target main task. When constructing the main task message, specifically, the target main task can be obtained from the shared database, and a distributed lock can be added to the target main task, and then the main task message can be constructed according to the message protocol used.
[0073] The delay strategy specifically includes: (1) after delaying for a preset time (delay_time), determining whether the task status of the first predecessor main task is in a completed state; (2) if the task status of the first predecessor main task is in a completed state, using the aforementioned immediate strategy to distribute the target main task; if the task status of the first predecessor main task is in an uncompleted state, repeating (1) until the state of the first predecessor main task becomes a completed state (i.e., until the first predecessor main task is executed). Among them, the preset time (delay_time) can be configured according to actual conditions to meet the usage requirements in different scenarios.
[0074] It should be noted that before determining whether the task status of the first preceding main task is completed each time, the main task parameter table is refreshed to ensure the timeliness of the main task parameter table, thereby ensuring the accuracy of the operation.
[0075] In this step, for the target main task with the attribute of intermittent execution, the target main task is distributed according to the task status of the first predecessor main task in the main task parameter table (i.e. the status of the currently executable predecessor main task), thereby ensuring the distribution efficiency of the target main task.
[0076] S1023. If the sequence attribute of the target main task is a non-interruptible execution attribute, a preceding main task closest to the target main task in the task execution sequence rule is used as the second preceding main task.
[0077] S1024: Determine whether the main task parameter table includes the second preceding main task.
[0078] S1025. Process the target main task according to the determination result.
[0079] In S1023, the predecessor main task closest to the target main task determined in the task execution sequence rule is used as the second predecessor main task. The determination of the second predecessor main task is independent of the main task parameter table, that is, the second predecessor main task is the predecessor main task immediately adjacent to the target main task as defined in the sequence rule. Exemplarily, if the target main task is numbered xxxx_4, then xxxx_3 is the second predecessor main task. In order to ensure the smooth execution of the target main task and the accuracy of the execution result, in this step, a determination result is obtained based on whether there is a second predecessor main task in the main task parameter table, and the target main task is processed based on the determination result. Among them, the determination result includes two types: the second predecessor main task is included in the main task parameter table and the second predecessor main task is not included in the main task parameter table. Accordingly:
[0080] If the main task parameter table does not include the second predecessor main task (such as sequence number xxxx_3) of the target main task (such as sequence number xxxx_4), the out-of-sequence count of the target main task is updated, and it is determined whether the out-of-sequence count reaches the alarm threshold. If the out-of-sequence count reaches the alarm threshold, an alarm is issued; if the main task parameter table includes the second predecessor main task of the target main task, the target main task is distributed according to the task status of the second predecessor main task.
[0081] It can be understood that in this step, the number of out-of-sequence times of the target main task can be counted by setting a counter. The initial value of the counter is 0. Each time it is determined that the second predecessor main task is not included in the main task parameter table, the number of out-of-sequence times is increased by 1, and it is judged whether the number of out-of-sequence times reaches the alarm threshold, that is, the maximum value of the allowed number of out-of-sequence times. If it is reached (the number of out-of-sequence times is greater than or equal to the alarm threshold), an alarm is issued to notify relevant staff to investigate and solve the problem.
[0082] If the alarm threshold is not reached (the number of out-of-sequence times is less than the alarm threshold), the previous steps are repeated after a preset delay, that is, it is determined again whether there is a second predecessor main task of the target main task in the main task parameter table, until the second predecessor main task appears in the main task parameter table or the number of out-of-sequence times reaches the alarm threshold.
[0083] The alarm threshold may also be set according to actual usage scenario requirements, and there is no restriction on the specific value of the alarm threshold.
[0084] Optionally, the task status of the second predecessor main task may also include a completed state and an uncompleted state. Similarly, the target main task is distributed according to the task status of the second predecessor main task, specifically including: if the task status of the second predecessor main task is a completed state, the target main task is distributed using an immediate strategy; if the task status of the second predecessor main task is an uncompleted state, the target main task is distributed using a delayed strategy. The specific implementation method is similar to the specific implementation method of distributing the target main task according to the task status of the first predecessor main task, and will not be repeated here.
[0085] It should be noted that each time before determining whether there is a second predecessor main task of the target main task in the main task parameter table, the main task parameter table will be refreshed to ensure the timeliness of the main task parameter table, thereby ensuring the accuracy of the operation.
[0086] For example, Figure 4 This is a schematic diagram of an execution logic of the main task processing method provided in the first embodiment of the present application. In practical applications, Figure 4 The execution logic shown implements the processing of main tasks of sequential execution type. Specifically, before distributing the main task, it is necessary to first determine the type of the main task based on the main task parameter table. If it is determined that the type of the main task is a parallel execution type, the main task is distributed according to the parallel task distribution process (that is, a main task message is constructed together with other main tasks that meet the requirements, and the main task message is sent to the message middleware or the main task execution node). If the type of the main task is determined to be a sequential execution type, further distribution judgment is required. Specifically, based on the sequential attributes recorded in the main task parameter table, it is determined whether the main task has an interruptible execution attribute or a non-interruptible execution attribute.
[0087] If it is an interruptible execution attribute, further determine whether the task status of the first predecessor main task (the predecessor main task whose sequence number is closest to the sequence number of the target main task included in the main task parameter table) is completed or uncompleted. If it is completed, add a distributed lock to the main task, and after the lock is successful, distribute the main task (build the main task message, and send the main task message to the message middleware or the main task processing node). If it is an uncompleted state, delay the first preset time and judge again whether the task status of the first predecessor main task is completed. If it is completed, add a distributed lock to the main task, and after the lock is successful, distribute the main task. If it is an uncompleted state, continue to delay the preset time, that is, each time the task status of the first predecessor main task is determined to be uncompleted, it is delayed by a first preset time until the task status of the first predecessor main task is determined to be completed, and the distribution of the main task is completed.
[0088] If the attribute is non-interruptible execution, it is necessary to first determine whether there is a second preceding main task in the main task parameter table (the preceding main task with a sequential number adjacent to the target main task as defined in the sequence rule). If there is a second preceding main task, it is necessary to further determine the task status of the second preceding main task. According to whether the task status of the second preceding main task is completed or uncompleted, different strategies are used to implement the distribution of the main task (similar to the specific implementation method of distributing the main task according to the task status of the first preceding main task in the attribute of interruptible execution); if there is no second preceding main task in the main task parameter table, the number of out-of-sequence times is accumulated, and it is determined whether the number of out-of-sequence times exceeds the alarm threshold. If it exceeds, an alarm is issued. If it does not exceed, it is delayed for a second preset time (which may be the same as or different from the first preset time), and then it is determined again whether there is a second preceding main task in the main task parameter table. Each time it is determined that there is no second preceding main task in the main task parameter table, the number of out-of-sequence times is increased by one until it is determined that there is a second preceding main task in the main task parameter table or the out-of-sequence times reaches the alarm threshold.
[0089] like Figure 4 As shown, when locking is unsuccessful, it is necessary to delay the third preset time and then lock the main task again until locking is successful and the distribution of the main task is completed. The third preset time may be the same as the first preset time or the second preset time, or it may be different from both the first preset time and the second preset time. It should be noted that the distributed lock here is added for a specific main task, so the corresponding distributed lock will only be released when the main task is executed.
[0090] It can be understood that the main task distribution in this embodiment refers to the main task distribution in the preprocessing stage. By strictly controlling the distribution order of the main tasks in the preprocessing stage, it is ensured that the preprocessing distribution of the subsequent main tasks will not be carried out if the previous main tasks are not completed, thereby effectively ensuring the orderliness of the entire process from distribution to execution of the main tasks.
[0091] In this embodiment, if the target main task belongs to a sequential execution type main task, the sequential attribute of the target main task is determined; wherein the sequential attribute is an interruptible execution attribute or a non-interruptible execution attribute; according to the sequential attribute of the target main task, the target main task is processed to realize the processing of the main task with strict sequential dependence, thereby ensuring the orderliness of the entire process from pre-processing distribution to final execution of the main task, being able to meet the usage requirements in special scenarios, and broadening the scope of application of the main task processing mechanism.
[0092] Embodiment 2
[0093] Figure 5 This is a schematic diagram of the structure of the main task processing device provided in Example 3 of the present application, such as Figure 5As shown, the main task processing device 10 in this embodiment includes:
[0094] A first processing module 11 and a second processing module 12 .
[0095] The first processing module 11 is used to determine the sequence attribute of the target main task if the target main task belongs to the sequence execution type main task; wherein the sequence attribute is an interruptible execution attribute or a non-interruptible execution attribute;
[0096] The second processing module 12 is used to process the target main task according to the sequence attribute of the target main task.
[0097] Optionally, the second processing module 12 is specifically used for:
[0098] If the sequence attribute of the target main task is the interruptible execution attribute, the preceding main task closest to the target main task in the main task parameter table is used as the first preceding main task;
[0099] The target main task is processed according to the task status of the first preceding main task.
[0100] Optionally, the second processing module 12 is specifically used for:
[0101] If the sequence attribute of the target main task is a non-interruptible execution attribute, the preceding main task closest to the target main task in the task execution sequence rule is used as the second preceding main task;
[0102] Determining whether the main task parameter table includes the second preceding main task;
[0103] According to the determination result, the target main task is processed.
[0104] Optionally, the task status of the first preceding main task includes a completed state and an uncompleted state; the second processing module 12 is specifically configured to:
[0105] If the task status of the first preceding main task is a completed status, distributing the target main task using an immediate strategy;
[0106] If the task status of the first preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
[0107] Optionally, the second processing module 12 is specifically used for:
[0108] After a preset delay, determining whether the task status of the first preceding main task is a completed state;
[0109] If the task status of the first preceding main task is a completed status, the target main task is distributed using an immediate strategy.
[0110] Optionally, the second processing module 12 is specifically used for:
[0111] Constructing a main task message including the target main task;
[0112] The main task message is sent to the message middleware or the target main task execution node.
[0113] Optionally, the second processing module 12 is specifically used for:
[0114] If it is determined that the main task parameter table does not include the second preceding main task, updating the out-of-sequence number of the target main task;
[0115] Determining whether the out-of-sequence number reaches an alarm threshold;
[0116] If the number of out-of-sequence times reaches the alarm threshold, an alarm is issued.
[0117] Optionally, the second processing module 12 is specifically used for:
[0118] If it is determined that the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
[0119] Optionally, the task status of the second preceding main task includes a completed state and an uncompleted state, and the second processing module 12 is specifically configured to:
[0120] If the task status of the second preceding main task is a completed status, the target main task is distributed using an immediate strategy;
[0121] If the task status of the second preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
[0122] Optionally, the second processing module 12 is further used for:
[0123] If the out-of-sequence number does not reach the alarm threshold, after a delay of a preset time, determining whether the main task parameter table includes the second preceding main task;
[0124] If the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
[0125] The main task processing device provided in this embodiment can execute the main task processing method provided in the above method embodiment, and has the corresponding functional modules and beneficial effects of the execution method. The implementation principle and technical effects of this embodiment are similar to those of the above method embodiment, and will not be repeated here.
[0126] Embodiment 3
[0127] Figure 6 A schematic diagram of the structure of a server provided in Embodiment 4 of the present application, such as Figure 6 As shown, the server 20 includes a memory 21, a processor 22, and a computer program stored in the memory and executable on the processor; the number of the processors 22 in the server 20 may be one or more. Figure 6 A processor 22 is taken as an example; the processor 22 and the memory 21 in the server 20 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0128] The memory 21, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the first processing module 11 and the second processing module 12 in the embodiment of the present application. The processor 22 executes various functional applications and data processing of the server by running the software programs, instructions and modules stored in the memory 21, that is, realizes the above-mentioned main task processing method.
[0129] The memory 21 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 21 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 21 may further include a memory remotely arranged relative to the processor 22, and these remote memories may be connected to the server via a grid. Examples of the above-mentioned grid include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0130] Embodiment 4
[0131] Embodiment 5 of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a computer processor, the computer program is used to execute a main task processing method, the method comprising:
[0132] If the target main task belongs to a sequential execution type main task, determining the sequential attribute of the target main task; wherein the sequential attribute is an interruptible execution attribute or a non-interruptible execution attribute;
[0133] The target main task is processed according to the sequence attribute of the target main task.
[0134] Of course, the computer-readable storage medium provided in the embodiment of the present application, whose computer program is not limited to the method operations described above, can also execute the relevant operations in the main task processing method provided in any embodiment of the present application.
[0135] Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present application can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or grid device, etc.) to execute the methods described in each embodiment of the present application.
[0136] It is worth noting that in the above-mentioned embodiment of the main task processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0137] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A main task processing method, characterized in that: include: If the target main task belongs to a sequential execution type main task, determining the sequential attribute of the target main task; wherein the sequential attribute is an interruptible execution attribute or a non-interruptible execution attribute, and the sequential attribute is used to describe the sequential characteristics of the target main task; Processing the target main task according to the sequence attribute of the target main task; Wherein, if the target main task belongs to a sequential execution type main task, before determining the sequential attribute of the target main task, it includes: Obtaining a main task parameter table from a shared database, wherein the main task parameter table is a task list of main tasks received within a preset time in the shared database, the main task parameter table includes the identification and configuration information of the main task, the configuration information includes the task type, task status, sequence attribute and sequence rule of the main task, the task type is used to describe the processing method of the corresponding main task, and the task type is divided into a sequential execution type and a parallel execution type; According to the identifier of the target main task, query the main task parameter table, and determine whether the type of the target main task is a sequential execution type according to the main task type recorded in the main task parameter table; The processing of the target main task according to the sequence attribute of the target main task includes: If the sequence attribute of the target main task is the interruptible execution attribute, the preceding main task closest to the target main task in the main task parameter table is used as the first preceding main task; Processing the target main task according to the task status of the first preceding main task; If the sequence attribute of the target main task is the non-interruptible execution attribute, a previous main task whose identifier is adjacent to the identifier of the target main task is used as the second previous main task; Determining whether the main task parameter table includes the second preceding main task; According to the determination result, the target main task is processed.
2. The method according to claim 1, characterized in that The task status of the first predecessor main task includes a completed state and an uncompleted state; and the processing of the target main task according to the task status of the first predecessor main task includes: If the task status of the first preceding main task is a completed status, distributing the target main task using an immediate strategy; If the task status of the first preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
3. The method according to claim 2, characterized in that The adopting a delay strategy to distribute the target main task includes: After a preset delay, determining whether the task status of the first preceding main task is a completed state; If the task status of the first preceding main task is a completed status, the target main task is distributed using an immediate strategy.
4. The method according to claim 2 or 3, characterized in that: The adopting of an immediate strategy to distribute the target main task includes: Constructing a main task message including the target main task; The main task message is sent to the message middleware or the target main task execution node.
5. The method according to claim 1, characterized in that The step of processing the target main task according to the determination result includes: If it is determined that the main task parameter table does not include the second preceding main task, updating the out-of-sequence number of the target main task; Determining whether the out-of-sequence number reaches an alarm threshold; If the number of out-of-sequence times reaches the alarm threshold, an alarm is issued.
6. The method according to claim 1, characterized in that The step of processing the target main task according to the determination result includes: If it is determined that the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
7. The method according to claim 6, characterized in that The task status of the second predecessor main task includes a completed state and an uncompleted state, and the distributing the target main task according to the task status of the second predecessor main task includes: If the task status of the second preceding main task is a completed status, the target main task is distributed using an immediate strategy; If the task status of the second preceding main task is an unfinished state, a delay strategy is adopted to distribute the target main task.
8. The method according to claim 5, characterized in that The method further comprises: If the out-of-sequence number does not reach the alarm threshold, after a delay of a preset time, determining whether the main task parameter table includes the second preceding main task; If the main task parameter table includes the second preceding main task, the target main task is distributed according to the task status of the second preceding main task.
9. A main task processing device, characterized in that: include: A first processing module is used to determine a sequence attribute of the target main task if the target main task belongs to a sequence execution type main task; wherein the sequence attribute is an interruptible execution attribute or a non-interruptible execution attribute, and the sequence attribute is used to describe the sequence characteristics of the target main task; A second processing module, used for processing the target main task according to the sequence attribute of the target main task; Wherein, the first processing module is further configured to: If the target main task belongs to a main task of sequential execution type, before determining the sequential attribute of the target main task, a main task parameter table is obtained from a shared database, wherein the main task parameter table is a task list of main tasks received within a preset time in the shared database, and the main task parameter table includes the identification and configuration information of the main task, and the configuration information includes the task type, task status, sequential attribute and sequential rule of the main task, and the task type is used to describe the processing method of the corresponding main task, and the task type is divided into a sequential execution type and a parallel execution type; According to the identifier of the target main task, query the main task parameter table, and determine whether the type of the target main task is a sequential execution type according to the main task type recorded in the main task parameter table; The second processing module is specifically configured to: If the sequence attribute of the target main task is the interruptible execution attribute, the preceding main task closest to the target main task in the main task parameter table is used as the first preceding main task; Processing the target main task according to the task status of the first preceding main task; If the sequence attribute of the target main task is the non-interruptible execution attribute, a previous main task whose identifier is adjacent to the identifier of the target main task is used as the second previous main task; Determining whether the main task parameter table includes the second preceding main task; According to the determination result, the target main task is processed.
10. A server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the main task processing method as described in any one of claims 1-8 is implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the main task processing method as described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Task scheduling method and device and computer readable storage medium
CN110472876A