A method, device, equipment and medium for reporting batch execution results
By recording the unsuccessfully reported batch execution results in the error log and adding them to the blocking queue, and re-reporting the results, the problem of resource waste caused by batch execution results when network jitter or downtime is solved, and efficient result reporting and business are achieved. stability.
Patent Information
- Application Number
- CN202011355408.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-11-27
AI Technical Summary
In the existing technology, batch execution results report errors when the network jitters or crashes and restarts, causing re-execution results to consume a large amount of CPU resources and time, affecting normal business operations.
Record the execution results that are not successfully reported in the error log, add them to the blocking queue, and re-report the results according to the blocking queue, thereby avoiding the waste of resources and time in repeated executions, separating batch execution result reporting and the main thread, and easing the main thread pressure.
It improves the efficiency of reporting batch execution results, ensures the normal operation of the business, reduces the waste of CPU resources, and improves the high availability and fault tolerance of the system.
Smart Images

Figure CN112416717B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an access control method, apparatus, device, and computer-readable storage medium. Background Art
[0002] Whether it is an Internet application or an enterprise application, there are a large number of batch processing tasks. Batch processing tasks refer to tasks that are processed in batches, such as batch collection and payment services, personal loan repayments, automatic credit card repayments, regular automatic transfers, fund fixed investment, and interest settlement processing.
[0003] These scattered and unreliable batch processing tasks usually need to be included in a unified platform, such as a batch scheduling platform, for processing. Specifically, the proxy service in the batch scheduling platform will actively report the batch execution results after calling the batch processing task. The batch execution results mainly include information such as the plan serial number, node execution status, and node execution results. If the receiving service cannot receive the batch execution results, it will usually affect the normal operation of the business.
[0004] When network jitter or downtime restart causes batch execution result reporting errors, if the batch is re-executed and the execution results are obtained again, it will take a lot of time and occupy a lot of central processing unit (CPU) resources. The industry urgently needs to provide an efficient and low-cost batch execution result reporting method. Summary of the invention
[0005] The present application provides a batch execution result reporting method. When the batch execution results include an unsuccessful execution result reporting, the method records the unsuccessful execution result in the reporting error log, then adds the execution result recorded in the reporting error log to a blocking queue, and re-reports the execution result according to the blocking queue, thereby avoiding the problem that the execution result cannot be saved in the database and the re-execution consumes a lot of resources and time, thereby ensuring the normal operation of the business.
[0006] In a first aspect, the present application provides a method for reporting batch execution results. The method comprises:
[0007] When the batch execution results include at least one execution result that is unsuccessfully reported, the at least one execution result is recorded in a reporting error log;
[0008] Add at least one execution result recorded in the reported error log to the blocking queue;
[0009] Re-report at least one execution result according to the blocking queue.
[0010] In some possible implementations, the at least one execution result includes multiple execution results, and the multiple execution results are recorded in different reported error logs;
[0011] Add at least one execution result recorded in the reported error log to the blocking queue, including:
[0012] The execution results recorded in the reporting error log whose reporting times are less than the preset times are added to the blocking queue.
[0013] In some possible implementations, re-reporting at least one execution result according to the blocking queue includes:
[0014] When the service startup time reaches the preset time, at least one execution result is re-reported according to the blocking queue.
[0015] In some possible implementations, the method further includes:
[0016] When the execution result in the blocking queue is reported successfully, the corresponding reporting error log is deleted.
[0017] In some possible implementations, the method further includes:
[0018] When the execution result in the blocking queue is not reported successfully, the reporting count is increased by one, and the reporting error log corresponding to the execution result is updated.
[0019] In some possible implementations, re-reporting at least one execution result according to the blocking queue includes:
[0020] When the number of execution result reports in the blocking queue is less than a preset number, at least one execution result is re-reported.
[0021] In some possible implementations, after adding at least one execution result recorded in the reporting error log to the blocking queue, the method further includes:
[0022] End the batch execution result reporting thread.
[0023] In a second aspect, the present application provides a batch execution result reporting device, the device comprising:
[0024] A recording module, used for recording at least one execution result in a reporting error log when the batch execution results include at least one execution result that is unsuccessfully reported;
[0025] An adding module, used for adding at least one execution result recorded in the reported error log to a blocking queue;
[0026] The reporting module is used to re-report at least one execution result according to the blocking queue.
[0027] In some possible implementations, the at least one execution result includes multiple execution results, and the multiple execution results are recorded in different reported error logs;
[0028] The additional module is specifically used for:
[0029] The execution results recorded in the reporting error log whose reporting times are less than the preset times are added to the blocking queue.
[0030] In some possible implementations, the reporting module is specifically used to:
[0031] When the service startup time reaches the preset time, at least one execution result is re-reported according to the blocking queue.
[0032] In some possible implementations, the device further includes:
[0033] The deletion module is used to delete the corresponding reporting error log when the execution result in the blocking queue is reported successfully.
[0034] In some possible implementations, the device further includes:
[0035] The update module is used to increase the reporting times by one and update the reporting error log corresponding to the execution result when the execution result in the blocking queue is not reported successfully.
[0036] In some possible implementations, the reporting module is specifically used to:
[0037] When the number of execution result reports in the blocking queue is less than a preset number, at least one execution result is re-reported.
[0038] In some possible implementations, after adding at least one execution result recorded in the reporting error log to the blocking queue, the apparatus further includes:
[0039] The end module is used to end the batch execution result reporting thread.
[0040] In a third aspect, the present application provides a device, comprising a processor and a memory. The processor and the memory communicate with each other. The processor is used to execute instructions stored in the memory, so that the device executes the batch execution result reporting method in the first aspect or any implementation of the first aspect.
[0041] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, wherein the instructions instruct a device to execute the batch execution result reporting method described in the above-mentioned first aspect or any one of the implementations of the first aspect.
[0042] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a device, enables the device to execute the batch execution result reporting method described in the first aspect or any one of the implementations of the first aspect.
[0043] Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations.
[0044] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0045] An embodiment of the present application provides a batch execution result reporting method. When the batch execution results include an unsuccessful execution result report, the method records the unsuccessful execution result in a reporting error log, then adds the execution result recorded in the reporting error log to a blocking queue, and re-reports the execution result according to the blocking queue, thereby avoiding the problem that the execution result cannot be saved in the database and the re-execution consumes a lot of resources and time, thereby ensuring the normal operation of the business.
[0046] Furthermore, a blocking queue is used to completely separate the batch execution result reporting and the batch scheduling main thread, which relieves the pressure on the main thread. The application of scheduled tasks ensures the thread safety of each round of execution result reporting. The number of reports for each batch execution result is limited to reduce meaningless repeated reports. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical methods of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 A flowchart of a batch execution result reporting method provided in an embodiment of the present application;
[0049] Figure 2 A flowchart of another batch execution result reporting method provided in an embodiment of the present application;
[0050] Figure 3 A schematic diagram of the structure of a batch execution result reporting device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The scheme in the embodiments provided in this application will be described below in conjunction with the drawings in this application.
[0052] The terms "first" and "second" in the embodiments of the present application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0053] First, some technical terms involved in the embodiments of the present application are introduced.
[0054] Batch tasks, also known as batch processing tasks, refer to the execution of a series of programs on a computer without human intervention.
[0055] Batch business processing refers to the batch processing of specific business logic through an executable unit, such as a program or script. Batch business processing includes batch collection and payment services, personal loan due repayments, automatic credit card repayments, regular automatic transfers, fund fixed investment and interest settlement processing, etc.
[0056] Typically, batch processing tasks are processed on a batch scheduling platform, which manages and schedules batch processing tasks in a unified manner, thereby achieving centralized job management. Specifically, the proxy service in the batch scheduling platform will proactively report the batch execution results after invoking the batch processing tasks, for example, by requesting the batch execution results through a representational state transfer (REST). If the receiving service fails to receive the batch execution results, it will usually affect the normal operation of the business.
[0057] In the prior art, when a REST request fails to send batch execution results due to network jitter or shutdown and restart, the batch execution results cannot be saved in the database, but executing the entire batch again will consume a lot of CPU resources and time.
[0058] In view of this, the present application provides an efficient batch execution result reporting method. The method can be executed by a processing device. The processing device refers to a device with data processing capabilities, such as a server, or a terminal device such as a desktop, laptop or smart phone.
[0059] Specifically, the processing device records the unsuccessful execution results in the batch execution results in the reporting error log, and then adds it to the blocking queue for re-reporting. Through the blocking queue, only the unsuccessful results are re-reported, avoiding the waste of a lot of CPU resources and time by re-reporting all execution results, improving the efficiency of batch execution result reporting, and ensuring the high availability and fault tolerance of the batch scheduling platform.
[0060] Among them, the processing device can also end the batch execution result reporting thread after adding the batch execution results to the blocking queue, thereby releasing resources and ensuring the maximum utilization of system resources such as the CPU. In addition, the processing device uses a blocking queue such as a one-way linked list blocking queue LinkedBlockingQueue to cache data, ensuring the priority of the result reporting error retry and the complete parallelism of production and consumption, and completely separates the batch execution result reporting error retry from the batch scheduling main thread, alleviating the pressure on the main thread.
[0061] In order to make the technical solution of the present application clearer and easier to understand, the technical solution of the present application will be described in detail from the perspective of the processing equipment.
[0062] See also Figure 1 A flow chart of a method for reporting batch execution results provided in an embodiment of the present application, the method comprising the following steps:
[0063] S102: When the batch execution results include at least one execution result that is unsuccessfully reported, the processing device records the at least one execution result in a reporting error log.
[0064] Typically, a batch execution result may include multiple execution result reports that failed, so the processing device records the multiple execution results in different reporting error logs.
[0065] In some possible implementations, the same execution result may fail to execute multiple times, and the execution result is stored in the same reporting error log each time. In order to solve the meaningless repeated reporting, the number of reports of the same execution result can be limited. When the report is still not successful after reaching the limited number of times, it means that there may be a problem with the execution result. Therefore, the corresponding log is transferred to the backup directory to facilitate relevant personnel to query the problem.
[0066] S104: The processing device adds at least one execution result recorded in the reporting error log to a blocking queue.
[0067] Specifically, the processing device reads the error reporting log file list one by one in order, maps the acquired execution results to be reported, and then adds them to the blocking queue.
[0068] Blocking queues, such as LinkedBlockingQueue, are thread-safe blocking queues that implement the BlockingQueue interface and introduce two locks, takeLock and putLock, for take and put operations. That is, LinkedBlockingQueue uses different locks for entry and exit, so entry and exit operations can be performed at the same time. At the same time, two conditional variables, notEmpty and notFull, are introduced. notEmpty indicates that the program now has elements in the queue and can perform the take operation; notFull indicates that the program queue is not full and can still be put into it. With reference to the producer and consumer model, when the queue is not full, the producer can produce, and when the queue is not empty, the consumer can consume.
[0069] In some possible implementations, such as proxy services, there are many batch scheduling requests, and batch scheduling is performed asynchronously, so at a certain moment there will be a large number of batch results to be sent to the receiving service, so when the execution result fails to be sent, it is necessary to ensure that the execution result is saved smoothly and to ensure the priority of the retry when the result is reported as an error. LinkedBlockingQueue is a blocking version of the queue based on the linked list. It realizes the separation of entry and exit, has high efficiency, and supports capacity restrictions. Therefore, using LinkedBlockingQueue to save data can meet the requirements of batch processing in proxy services.
[0070] Typically, a plurality of execution results are recorded in the error reporting log, and the processing device adds the execution results recorded in the error reporting log to the blocking queue in the order in which they are added.
[0071] In this application, a blocking queue LinkedBlockingQueue is used to cache data, which ensures the priority of error reporting and retrying of results and the complete parallelism of production and consumption; and the error reporting and retrying of batch execution results are completely separated from the batch scheduling main thread, which relieves the pressure on the main thread.
[0072] According to some possible implementations of S102, the reporting times can be limited, and the processing device adds the execution results recorded in the reporting error log whose reporting times are less than the preset times to the blocking queue.
[0073] In some possible implementations, after the processing device adds the execution results recorded in the reporting error log to the blocking queue, it ends the batch execution result reporting thread to save thread resources.
[0074] S106: The processing device re-reports at least one execution result according to the blocking queue.
[0075] Specifically, the processing device takes out the reported error execution results one by one from the blocking queue, and sends a Rest request with the execution result to the receiving service, so as to realize the re-reporting of the execution result.
[0076] In some possible implementations, a timed task can be applied, that is, a preset time is set before S102 starts, and timing is performed at the start of S102. When the service startup time reaches the preset time, at least one execution result is re-reported according to the blocking queue. A timed task refers to certain business logic that is usually completed using a timer in order to reduce the pressure on the server and database. In this application, a Spring Boot timed delay task can be set, that is, the first retry is started after a predefined time after the service is restarted. The use of a timed task can not only reduce the pressure on the server and database, but also ensure the thread safety of each round of result reporting error retry.
[0077] When the execution result in the blocking queue is reported successfully, the corresponding reporting error log is deleted to prevent log accumulation, which can release memory in time and improve efficiency.
[0078] When the execution result in the blocking queue is not successfully reported, the reporting number is increased by one, and the reporting error log corresponding to the execution result is updated, that is, there is at least one execution result in the batch execution result that is not successfully reported, and S102 is performed to prepare for the next round of re-reporting.
[0079] In some possible implementations, the above S102, S104, and S106 form a loop, and the number of retries for reporting errors can be limited as needed, so that the memory can be released in time and the efficiency of log scanning can be improved.
[0080] When the execution result reporting fails and the preset number of retries has been reached, the reporting error log corresponding to the execution result is migrated to the backup directory to facilitate relevant technical personnel to check the problem.
[0081] When executing the above loop, since batch scheduling is performed asynchronously, in S102, the processing device can record the first unsuccessful execution result report in the reporting error log, and can also record multiple unsuccessful execution result reports in the reporting error log that does not reach the length limit.
[0082] In another embodiment, when the project is initialized, the current thread of the system is used to search for historical error-free reporting results, which can ensure that after the system crashes and restarts, historical error-reporting tasks can be automatically scanned and obtained without the need to develop a special monitoring program, thereby saving thread resources.
[0083] See also Figure 2A complete flow chart of another batch execution result reporting method provided in an embodiment of the present application, the method comprising the following steps:
[0084] S202: Determine whether the processing device is restarting after a service shutdown. If so, proceed to S204 to scan the historical unsuccessful reporting logs; otherwise, proceed to S206, indicating that it is the first startup.
[0085] Downtime refers to the phenomenon that the computer cannot recover from a serious system error, or there is a problem with the hardware system, so that the system is unresponsive for a long time and has to be restarted. When a large number of execution results are not reported successfully, it may cause service downtime.
[0086] This application uses the current thread of the system to search for historical error-free reporting results when the project is initialized, ensuring that after a shutdown and restart, historical result reporting errors and tasks to be retried are automatically scanned and obtained, without the need to develop a dedicated listening program, saving thread resources.
[0087] S204: The processing device obtains a file list stored in the error reporting directory and proceeds to S208.
[0088] S206: The processing device waits for starting the scheduled task.
[0089] S208: The processing device obtains whether the reported error log file list is empty. If it is empty, the process goes to S204; otherwise, the process goes to S210.
[0090] S210: The processing device determines whether all files have been scanned. If yes, it proceeds to S204; otherwise, it proceeds to S212.
[0091] S212: The processing device reads the reported error log files one by one in sequence.
[0092] S214: The processing device maps the acquired execution result to be reported, and adds the execution result to be reported to a blocking queue.
[0093] S216: The processing device determines whether the blocking queue is empty, that is, whether the execution results in the queue have completed this round of retry. If the queue is empty, it means that the execution results in the queue have completed this round of retry, and the retry is over. The waiting timer wakes up again after the scheduled delay time after the completion of this task. Otherwise, it means that there are still objects in the queue that have not completed this round of retry, and enters S218.
[0094] S218: The processing device takes out the reported error execution result from the blocking queue.
[0095] S220: The processing device performs a report retry. Specifically, the processing device sends a Rest request with an execution result to the receiving service.
[0096] S222: The processing device determines whether the retry is successful. If the retry is successful, the process proceeds to S224; otherwise, the process proceeds to S226.
[0097] S224: The processing device deletes the corresponding log and enters S216.
[0098] S226: The processing device determines whether the number of retries has reached the upper limit, and if so, proceeds to S228, otherwise proceeds to S230.
[0099] S228: The processing device migrates the corresponding log to the backup directory, and then enters S216.
[0100] S230: The processing device increases the reporting times of the reporting execution result by 1.
[0101] S232: The processing device updates the log corresponding to the reported execution result.
[0102] S234: The processing device adds the reported execution result to the queue again and proceeds to S216.
[0103] Corresponding to the above method embodiment, the present application also provides a batch execution result reporting device, see Figure 3 The device 300 includes: a recording module 302, an adding module 304 and a reporting module 306.
[0104] The recording module 302 is used to record the at least one execution result in a reporting error log when the batch execution results include at least one execution result that is unsuccessful to report;
[0105] An adding module 304 is used to add at least one execution result recorded in the reporting error log to a blocking queue;
[0106] The reporting module 306 is used to re-report at least one execution result according to the blocking queue.
[0107] In some possible implementations, the at least one execution result includes multiple execution results, and the multiple execution results are recorded in different reported error logs;
[0108] The adding module 304 is specifically used for:
[0109] The execution results recorded in the reporting error log whose reporting times are less than the preset times are added to the blocking queue.
[0110] In some possible implementations, the reporting module 306 is specifically configured to:
[0111] When the service startup time reaches the preset time, at least one execution result is re-reported according to the blocking queue.
[0112] In some possible implementations, the device further includes:
[0113] The deletion module is used to delete the corresponding reporting error log when the execution result in the blocking queue is reported successfully.
[0114] In some possible implementations, the device further includes:
[0115] The update module is used to increase the reporting times by one and update the reporting error log corresponding to the execution result when the execution result in the blocking queue is not reported successfully.
[0116] In some possible implementations, the reporting module 306 is specifically configured to:
[0117] When the number of execution result reports in the blocking queue is less than a preset number, at least one execution result is re-reported.
[0118] In some possible implementations, after adding at least one execution result recorded in the reporting error log to the blocking queue, the apparatus further includes:
[0119] The end module is used to end the batch execution result reporting thread.
[0120] The present application provides a device for implementing a batch execution result reporting method. The device includes a processor and a memory. The processor and the memory communicate with each other. The processor is used to execute instructions stored in the memory so that the device executes the batch execution result reporting method.
[0121] The present application provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a device, the device executes the above-mentioned batch execution result reporting method.
[0122] The present application provides a computer program product including instructions, which, when executed on a device, enables the device to execute the above-mentioned batch execution result reporting method.
[0123] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0124] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0125] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0126] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for reporting batch execution results. It is characterized in that The method comprises: When the batch execution results include at least one execution result that is unsuccessfully reported, recording the at least one execution result in a reporting error log; Adding the at least one execution result recorded in the reported error log to a blocking queue; the blocking queue is a blocking queue LinkedBlockingQueue of a one-way linked list; The at least one execution result includes multiple execution results, and the multiple execution results are recorded in different reporting error logs; the adding the at least one execution result recorded in the reporting error log to the blocking queue includes: adding the execution result recorded in the reporting error log whose reporting number is less than a preset number to the blocking queue; End the batch execution result reporting thread; re-reporting the at least one execution result according to the blocking queue; When the execution result in the blocking queue is reported successfully, the corresponding reporting error log is deleted.
2. The method according to claim 1, It is characterized in that The re-reporting of the at least one execution result according to the blocking queue includes: When the service startup time reaches the preset time, the at least one execution result is re-reported according to the blocking queue.
3. The method according to any one of claims 1 to 2, It is characterized in that The method further comprises: When the execution result in the blocking queue is not successfully reported, the reporting number is increased by one, and the reporting error log corresponding to the execution result is updated.
4. The method according to claim 3, It is characterized in that The re-reporting of the at least one execution result according to the blocking queue includes: When the number of reports of the execution results in the blocking queue is less than the preset number, the at least one execution result is re-reported.
5. A batch execution result reporting device, It is characterized in that The device comprises: A recording module, configured to record at least one execution result in a reporting error log when the batch execution results include at least one execution result that is unsuccessful to report; An adding module, used for adding the at least one execution result recorded in the reported error log to a blocking queue; the blocking queue is a blocking queue LinkedBlockingQueue of a one-way linked list; Wherein, the at least one execution result includes multiple execution results, and the multiple execution results are recorded in different reporting error logs, and the adding module is specifically used to: add the execution results recorded in the reporting error log whose reporting times are less than the preset times to the blocking queue; End module, used to end the batch execution result reporting thread; A reporting module, configured to re-report the at least one execution result according to the blocking queue; The deletion module is used to delete the corresponding reporting error log when the execution result in the blocking queue is reported successfully.
6. A device, It is characterized in that The device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the device performs the method according to any one of claims 1 to 4.
7. A computer-readable storage medium, It is characterized in that The method comprises instructions for instructing a device to execute the method according to any one of claims 1 to 4.
