Method for judging whether program operation starting meets conditions or not based on cache
By using Hash objects in Redis to store the task execution status and judge specific characters in the string, the problem of difficulty in accurately determining the program job startup conditions in the prior art is solved, and efficient and accurate judgment is achieved and the problem of preventing repeated tasks from being started.
Patent Information
- Application Number
- CN202311343052.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2025-04-18
AI Technical Summary
It is difficult for the prior art to accurately determine whether a program job meets the startup conditions, which may lead to data logic abnormality, loss or miswrite.
By creating a Hash object in Redis as a job cache, using a specific string to store the execution status of each task in the task group, and by determining whether the string contains a specific character with the "unexecuted" state, it is determined whether the job meets the startup conditions.
It realizes a simple, efficient and accurate judgment of whether the program job start meets the conditions, prevents the task from being restarted without execution, and improves the stability of the system and data integrity.
Smart Images

Figure FT_1
Abstract
Description
Technical Field
[0001] The present invention relates to the field of program job scheduling processing, and in particular to a method for judging whether a cache-based program job startup meets conditions. Background Art
[0002] A software system may contain multiple subsystems, which are heterogeneous and run on different operating systems. There is a program job that contains several task group programs, each of which contains several tasks, and the tasks are distributed in different subsystems. The execution time of each task program varies greatly. Each job needs to be started after all tasks of the previous job are completed. If the execution status of each task cannot be accurately obtained, the rash start of the job may lead to serious consequences (data logic anomalies, loss, wrong writing, etc.). How to simply, efficiently and accurately determine whether the program job startup meets the conditions has become a problem that must be solved.
[0003] Redis is a NOSQL, non-relational database, and also a cache database, which means that data is stored in the cache. The cache has a fast reading speed and can greatly improve operating efficiency. Summary of the invention
[0004] In response to the actual needs of existing application scenarios, the present invention provides a method for determining whether a program job startup meets the conditions based on cache. By determining whether a specific character string contains specific characters, a simple, efficient and accurate method for determining whether a program job startup meets the conditions is implemented.
[0005] To achieve the above object, the present invention provides a method for determining whether a cache-based program job startup meets a condition, comprising:
[0006] S1. Create a task group cache under the program job;
[0007] S2. Receive program job start information;
[0008] S3. Determine whether the program operation meets the start conditions;
[0009] S4. Send program job start information;
[0010] S5. Receive program task execution status information.
[0011] Furthermore, S1 creates a task group cache under the program job, specifically including: a program job (referred to as job) contains multiple program task groups (referred to as task groups), each task group contains multiple program tasks (referred to as tasks). Create a Hash object in Redis as a job cache, each field of which stores a task group information, and the value of the field is a specific string used to store the execution status of each task in the task group.
[0012] Furthermore, the value of the field is a specific string used to store the execution status of each task in the task group, including:
[0013] S1-1. The length of the string is equal to the number of tasks in the task group;
[0014] S1-2. Each task corresponds to the character in the string with the same index position according to its predefined index position in the task group;
[0015] S1-3. Each character in the string is filled with a specific character representing the state ("executed" state, "not executed" state);
[0016] S1-4. Initialize the status of all tasks to a specific character indicating the "executed" status.
[0017] Furthermore, the S2. receiving program job start information specifically includes: establishing a software program for queuing to receive request program job start information, and after receiving the request program job start information, sending this information to a program for determining whether the program job meets the start conditions for processing.
[0018] Furthermore, the S3. determines whether the program job meets the start conditions, specifically including: establishing a software program for determining whether the program job meets the start conditions, and when receiving a request to determine whether the program job meets the start conditions, reading the program job cache carrier in Redis, traversing the value of all fields, if the value string in any field contains a specific character indicating the "not executed" state, it means that the program job start conditions are not met, otherwise it means that the program job start conditions are met; after meeting the start conditions, traverse all fields and adjust each character in the value string to a specific character in the "executed" state, and send the notification job start information to the start job notification program for processing.
[0019] Furthermore, the S4. sending program job start information specifically includes: establishing a software program for distributing job start notifications, distributing the job start information after receiving the job start information, and starting the task program after receiving the job start information.
[0020] Furthermore, the S5. receiving program task execution status information specifically includes: establishing a software program for receiving task execution status information, and upon receiving the task "executed" status information, updating the character corresponding to the task in the program job cache carrier in Redis to a specific character of the "executed" status.
[0021] Compared with the prior art, the present invention has the following technical effects:
[0022] 1. Using Redis cache technology, it has fast reading and writing speed, simple storage structure and small space occupation;
[0023] 2. It can effectively prevent tasks from being restarted before they are completed;
[0024] 3. The method of judging whether the start-up conditions are met is simple and quick;
[0025] 4. The program that executes the task has little intrusion and is easy to modify. It only needs to add a monitoring startup program segment to trigger the program task startup and add a task status sending program segment to send the task status after the task is completed;
[0026] 5. The programs that perform tasks can be heterogeneous (different development platforms, different programming languages, different software architectures, etc.) and can run on different operating systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of a method for judging whether a cache-based program job startup meets conditions provided by the present invention. DETAILED DESCRIPTION
[0028] The specific implementation modes of the present invention will be further described in detail below in conjunction with the accompanying drawings.
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] Embodiment 1: The present invention provides a method for determining whether a cache-based program job startup meets the conditions, such as Figure 1 As shown, including:
[0031] S1. Create a task group cache under the program job;
[0032] S2. Receive program job start information;
[0033] S3. Determine whether the program operation meets the start conditions;
[0034] S4. Send program job start information;
[0035] S5. Receive program task execution status information.
[0036] S1 specifically includes:
[0037] A program job (referred to as job) contains multiple program task groups (referred to as task groups), and each task group contains multiple program tasks (referred to as tasks).
[0038] Create a Hash object in Redis as a job cache. Each field stores information about a task group. The value of the field is a specific string used to store the execution status of each task in the task group, including:
[0039] S1-1. The length of the string is equal to the number of tasks in the task group. For example, if a task group contains 5 tasks, the length of the string is 5.
[0040] S1-2. Each task corresponds to the character in the string with the same index position according to its predefined index position in the task group. For example, a task group contains 5 tasks, and the predefined index position of the task is 3. Then the third character from left to right in the string corresponds to this task.
[0041] S1-3. Each character in the string is filled with a specific character representing the status ("executed" status, "not executed" status). For example, "1" or "0" is used to represent the execution status of the task, "1" represents the "executed" status of the task, and "0" represents the "not executed" status of the task.
[0042] S1-4. Initialize the status of all tasks to a specific character to represent the "executed" status. For example, "1" represents the task "executed", and a task group contains 5 tasks, so this string is initialized to "11111".
[0043] S2 specifically includes:
[0044] A software program is established for queuing and receiving information on the start of a requesting program job. After receiving the information on the start of a requesting program job, the information is sent to a program for determining whether the program job meets the start conditions for processing.
[0045] S3 specifically includes:
[0046] A software program is established to determine whether a program job meets the start conditions. When a request to determine whether a program job meets the start conditions is received, the program job cache carrier in Redis is read, and the values of all fields are traversed. If the value string in any field contains a specific character indicating the "unexecuted" state, it means that the program job start conditions are not met, otherwise it means that the program job start conditions are met; after the start conditions are met, all fields are traversed to adjust each character in the value string to a specific character in the "executed" state, and the job start notification information is sent to the start job notification program for processing.
[0047] S4 specifically includes:
[0048] Establish a software program for distributing job start notifications. When the job start information is received, the job start information is distributed. For example, Kafka is used to distribute messages. After the task program receives the job start information, the task program starts the job.
[0049] S5 specifically includes:
[0050] Establish a software program to receive task execution status information. When receiving the task "executed" status information, update the character corresponding to the task in the program job cache carrier in Redis to the specific character of the "executed" status. For example: a task group contains 5 tasks, and the current value corresponding to its field is "10001". When receiving the task status of the predefined index bit 3 is "executed", the value in value needs to be updated to "10101".
[0051] It should be clear to those skilled in the art that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0052] The above-mentioned embodiments only express the implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the patent of the present application. It should be pointed out that, for ordinary technicians in the field, the technical solutions recorded in the above-mentioned embodiments can be modified, or some or all of the technical features therein can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present application shall be based on the attached claims.
Claims
1. A method for determining whether a cache-based program job startup meets a condition, the characteristics of which include: S1. Create a task group cache under the program job; S2. Receive program job start information; S3. Determine whether the program operation meets the start conditions; S4. Send program job start information; S5. Receive program task execution status information.
2. A method for determining whether a cache-based program job startup meets a condition as claimed in claim 1, characterized in that: The S1 creates a task group cache under the program job, including: a program job (referred to as job) contains multiple program task groups (referred to as task groups), each task group contains multiple program tasks (referred to as tasks); a Hash object is created in Redis as a job cache, each field of which stores a task group information, and the value of the field is a specific string used to store the execution status of each task in the task group.
3. The task group cache under the S1 creation program job as claimed in claim 2, characterized in that: The value of the field is a specific string used to store the execution status of each task in the task group, including: S1-1 The string length is equal to the number of tasks in the task group; S1-2 Each task corresponds to the character in the string with the same index position according to its predefined index position in the task group; Each character in the S1-3 string is filled with a specific character representing the status ("executed", "not executed"); S1-4 Initialize the status of all tasks to a specific character indicating the "executed" status.
4. A method for determining whether a cache-based program job startup meets a condition as claimed in claim 1, characterized in that: The S2. receiving program job start information includes: establishing a software program for queuing to receive request program job start information, and after receiving the request program job start information, sending the information to a program for determining whether the program job meets the start conditions for processing.
5. A method for determining whether a cache-based program job startup meets a condition as claimed in claim 1, characterized in that: The S3. determines whether the program job meets the start conditions, including: establishing a software program for determining whether the program job meets the start conditions, and when receiving a request to determine whether the program job meets the start conditions, reading the program job cache carrier in Redis, and traversing the value of all fields; if the value string in any field contains a specific character indicating the "not executed" state, it means that the program job start conditions are not met, otherwise it means that the program job start conditions are met; after the start conditions are met, traverse all fields and adjust each character in the value string to a specific character in the "executed" state, and send the notification job start information to the start job notification program for processing.
6. A method for determining whether a cache-based program job startup meets a condition as claimed in claim 1, characterized in that: The S4. sending program job start information includes: establishing a software program for distributing job start notifications, distributing the job start information after receiving the job start information, and starting the task program after receiving the job start information.
7. A method for determining whether a cache-based program job startup meets a condition as claimed in claim 1, characterized in that: The S5. receiving program task execution status information includes: establishing a software program for receiving task execution status information, and upon receiving the task "executed" status information, updating the character corresponding to the task in the program job cache carrier in Redis to a specific character of the "executed" status.