Task cleaning optimization method and system
By providing the timing task SDK toolkit, automatically monitoring and closing invalid tasks, the problem of invalid tasks occupies resources in the timing task system is solved and the system efficiency is improved.
Patent Information
- Application Number
- CN202510511465.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, there is a problem of a large number of invalid tasks occupying resources in the timing task system, and manual processing efficiency is low and cannot be completely solved.
Provides a general timed task SDK toolkit, which monitors the SQL operations of tasks through the face layer, counts the number of writes, automatically recognizes and closes invalid tasks, records logs and recycles.
Automatically identify and close invalid tasks through programs to reduce resource usage and improve the efficiency of the timing task system.
Smart Images

Figure CN120448107A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer communication technology, and in particular to an optimization method and system for task clearing. Background Art
[0002] Modern internet systems are increasingly populated with scheduled tasks. To manage the scheduled tasks of multiple business entities, a dedicated scheduled task management module is typically deployed to manage this massive volume of scheduled tasks. However, as the number of business entities and business volume increases, the number of scheduled tasks also increases dramatically. However, some of these added scheduled tasks may have expired and become useless, some may continue to run but produce no output, and some may fail or remain in a "ready" state. These tasks provide no benefit to the system while consuming significant resources. Currently, the most common approach is manual processing, which involves manually analyzing and verifying each task. When certain tasks are deemed invalid, they are simply closed. However, manual processing is time-consuming and labor-intensive, and does not fully resolve this type of issue. Summary of the Invention
[0003] To overcome the above problems, the purpose of the present invention is to provide a method for automatically determining which tasks are invalid tasks through a program, effectively reducing the situation where invalid tasks occupy resources, and improving the efficiency of the scheduled task system.
[0004] The present invention is implemented by the following scheme: a task cleaning optimization method, the method comprising the following steps:
[0005] Step S1: Provide a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit;
[0006] Step S2: When the task is started, the relevant business operations of the task are performed normally. When operating the database or data source, the SDK toolkit's aspect layer is automatically entered and the relevant code of the aspect layer is executed;
[0007] Step S3: The relevant code of the aspect layer counts the SQL of the data source, closes the tasks that are identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated.
[0008] Step S4: Reclaim the tasks that are identified as invalid tasks.
[0009] Furthermore, the relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
[0010] Furthermore, the cache data includes the ID of the scheduled task and the number of write times.
[0011] Furthermore, all scheduled tasks include all new scheduled tasks and all existing scheduled tasks.
[0012] Furthermore, tasks that are deemed invalid are closed as follows: the number of external writes for each task in each machine is counted once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.
[0013] A task cleaning optimization system, comprising an SDK toolkit module, an execution module, and an invalid task closing module:
[0014] The SDK toolkit module provides a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit;
[0015] The execution module: when the task is started, it normally performs the relevant business operations of its own task. When operating the database or data source, it automatically enters the aspect layer of the SDK toolkit and executes the relevant code of the aspect layer;
[0016] The invalid task closing module: the relevant code of the aspect layer counts the SQL of the data source, closes the tasks identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated;
[0017] The invalid task recycling module is used to recycle tasks that are identified as invalid tasks.
[0018] Furthermore, the relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
[0019] Furthermore, the cache data includes the ID of the scheduled task and the number of write times.
[0020] Furthermore, all scheduled tasks include all new scheduled tasks and all existing scheduled tasks.
[0021] Furthermore, tasks that are deemed invalid are closed as follows: the number of external writes for each task in each machine is counted once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.
[0022] The beneficial effects of the present invention are as follows: by providing a universal SDK toolkit, all scheduled tasks need to integrate this SDK. The SDK internally uses a faceted approach, without intruding on the internal business, and uniformly collects the external writing scenarios of scheduled tasks. When it is clear that a task does not have any function of writing data to the outside world, the task is judged as invalid, directly closed, and a task closure log is recorded. In this way, the program automatically determines which tasks are invalid and automatically performs task closure operations, effectively reducing the situation where invalid tasks occupy resources and improving the efficiency of the scheduled task system. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic flow chart of the method of the present invention.
[0024] Figure 2 It is a system principle block diagram of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described below with reference to the accompanying drawings.
[0026] See also Figure 1 As shown, a task cleaning optimization method of the present invention includes the following steps:
[0027] Step S1: Provide a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit;
[0028] Step S2: When the task is started, the relevant business operations of the task are performed normally. When operating the database or data source, the SDK toolkit's aspect layer is automatically entered and the relevant code of the aspect layer is executed;
[0029] Step S3: The relevant code of the aspect layer counts the SQL of the data source, closes the tasks that are identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated.
[0030] Step S4: Reclaim the tasks that are identified as invalid tasks.
[0031] The present invention will be further described below with reference to a specific embodiment:
[0032] A method for optimizing task cleaning, comprising the following steps:
[0033] 1. Provide a general scheduled task SDK toolkit, all scheduled tasks are connected to this toolkit;
[0034] All scheduled tasks include all new scheduled tasks and all historical and existing scheduled tasks.
[0035] 2. When a task starts, it performs its own business operations normally. When operating a database or data source, it automatically enters the SDK toolkit's aspect layer and executes the relevant code in that aspect layer. This article uses Java as an example, and various scheduled tasks are implemented using Java code. Java's AOP feature, known as aspect-oriented programming, allows for unified, additional functional processing without intruding on the business system. The SDK package provides such a scheduled task aspect function.
[0036] 3. The relevant code of the aspect layer counts the SQL of the data source, closes the tasks that are identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated;
[0037] The relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
[0038] The cached data includes the ID of the scheduled task and the number of times it is written. When each task is started, a unique task ID is automatically generated and the unique task ID and the machine and instance information where the task is located are added to the central cluster cache.
[0039] Closing tasks that are deemed invalid is further done by counting the number of external writes for each task in each machine once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.
[0040] For example, all scheduled tasks integrate with the universal task SDK. During task launch, the task SDK automatically monitors all SQL operations within the task. Imagine there are 100 tasks, and 10 of them are abandoned because they only read SQL statements and have no write operations. These are simply idle tasks.
[0041] 4. Recycle tasks that are deemed invalid. Based on the invalid task ID, obtain the central cluster information about which machine and instance the invalid task is on, and finally execute the invalid task recycling process.
[0042] For example, after the task SDK has been executed for a period of time, the SQL execution status of each task will be recorded in the memory. If only read operations exist for the 10 tasks above, they are idle tasks, which will be recycled later.
[0043] A task cleaning optimization system includes an SDK toolkit module, an execution module, an invalid task closing module, and an invalid task recycling module:
[0044] The SDK toolkit module provides a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit;
[0045] All scheduled tasks include all new scheduled tasks and all historical and existing scheduled tasks.
[0046] The execution module: when the task is started, it normally executes the relevant business operations of its own task. When operating the database or data source, it automatically enters the aspect layer of the SDK toolkit and executes the relevant code of the aspect layer. The AOP function in the Java language is aspect-oriented programming, which can uniformly perform additional functional processing without intruding into the business system. The SDK package provides such a timed task aspect function.
[0047] The invalid task closing module: the relevant code of the aspect layer counts the SQL of the data source, closes the tasks identified as invalid tasks, and records the closed task log. When the scheduled task is executed, the statistical function of this aspect is automatically ended.
[0048] The relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
[0049] The cached data includes the ID of the scheduled task and the number of times it is written. When each task is started, a unique task ID is automatically generated and the unique task ID and the machine and instance information where the task is located are added to the central cluster cache.
[0050] Closing tasks that are deemed invalid is further done by counting the number of external writes for each task in each machine once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.
[0051] For example, all scheduled tasks integrate with the universal task SDK. During task launch, the task SDK automatically monitors all SQL operations within the task. Imagine there are 100 tasks, and 10 of them are abandoned because they only read SQL statements and have no write operations. These are simply idle tasks.
[0052] The invalid task recycling module is used to recycle tasks that are identified as invalid tasks.
[0053] After the task SDK has been running for a period of time, it will record the SQL execution status of each task in memory. For example, if only read operations exist for the 10 tasks above, they are idle tasks. Based on the invalid task ID, the central cluster is retrieved to determine which machine and instance the invalid task is on, and the invalid task is finally recycled.
[0054] In summary, the present invention provides a universal SDK toolkit that all scheduled tasks need to integrate. The SDK uses a faceted approach internally, without intruding into the business, to uniformly collect the external writing scenarios of scheduled tasks. When it is clear that a task does not have any function of writing data externally, the task is judged as an invalid task, directly closed, and a task closing log is recorded. In this way, the program automatically determines which tasks are invalid and automatically performs task closing operations, effectively reducing the situation where invalid tasks occupy resources and improving the efficiency of the scheduled task system.
[0055] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A task cleaning optimization method, characterized in that: The method comprises the following steps: Step S1: Provide a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit; Step S2: When the task is started, the relevant business operations of the task are performed normally. When operating the database or data source, the SDK toolkit's aspect layer is automatically entered and the relevant code of the aspect layer is executed; Step S3: The relevant code of the aspect layer counts the SQL of the data source, closes the tasks that are identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated. Step S4: Reclaim the tasks that are identified as invalid tasks.
2. The task clearing optimization method according to claim 1, characterized in that: The relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
3. The task clearing optimization method according to claim 2, characterized in that: The cache data includes the ID of the scheduled task and the number of write times.
4. The method for optimizing task clearing according to claim 1, characterized in that: All scheduled tasks include all new scheduled tasks and all historical and existing scheduled tasks.
5. The method for optimizing task clearing according to claim 1, characterized in that: Closing tasks that are deemed invalid is further done by counting the number of external writes for each task in each machine once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.
6. A task cleaning optimization system, characterized in that: The system includes an SDK toolkit module, an execution module, an invalid task closing module and an invalid task recycling module; The SDK toolkit module provides a general scheduled task SDK toolkit, and all scheduled tasks are connected to this toolkit; The execution module: when the task is started, it normally performs the relevant business operations of its own task. When operating the database or data source, it automatically enters the aspect layer of the SDK toolkit and executes the relevant code of the aspect layer; The invalid task closing module: the relevant code of the aspect layer counts the SQL of the data source, closes the tasks identified as invalid tasks, and records the closed task log. When the scheduled task is completed, the statistical function of this aspect is automatically terminated; The invalid task recycling module is used to recycle tasks that are identified as invalid tasks.
7. The task clearing optimization system according to claim 6, characterized in that: The relevant code of the aspect layer further performs statistics on the SQL of the data source: when SQL of the write operation type such as insert, update, and delete appears, cache data will be newly added in the local memory.
8. The task clearing optimization system according to claim 7, characterized in that: The cache data includes the ID of the scheduled task and the number of write times.
9. The task clearing optimization system according to claim 6, characterized in that: All scheduled tasks include all new scheduled tasks and all historical and existing scheduled tasks.
10. The task clearing optimization system according to claim 6, characterized in that: Closing tasks that are deemed invalid is further done by counting the number of external writes for each task in each machine once a day. When a task has been executed and the number of external writes is 0, it indicates that the task is invalid and is closed directly.