Task execution method and device, electronic equipment and computer readable medium

By using the lock mechanism to manage task execution in a clustered environment, the problem of task failure caused by the application not considering concurrent execution is solved, and the efficiency and success rate of task execution are improved.

CN118747113APending Publication Date: 2024-10-08CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411077275.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

In a clustered deployment environment, some applications do not consider concurrent execution, resulting in unequal business logic and failure to execute business-related tasks.

Method used

By responding to the task execution request, obtain the local server ID and method name, generate a lock ID, execute the task locking process based on the lock ID, obtain the current system time and task timeout, calculate the timeout, and execute the setting function based on the lock ID and timeout. The calling process determines the target execution logic based on the call result data, executes the target execution logic, and releases the lock when necessary to end the task.

Benefits of technology

It improves the execution efficiency and success rate of business-related tasks, avoids business logic confusion caused by concurrent execution, and achieves stable task execution in a clustered environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747113A_ABST
    Figure CN118747113A_ABST
Patent Text Reader

Abstract

The invention discloses a task execution method and device, electronic equipment and a computer readable medium, and relates to the technical field of computers.The specific implementation mode comprises the steps that in response to a task execution request, a corresponding local server identifier and a method name are obtained; generating a lock identifier based on the local server identifier and the method name, and executing a task locking process based on the lock identifier; the current time of the system and the task timeout time are obtained, and then the timeout time is obtained through calculation; based on the lock identifier and the timeout time, executing a calling process of the setting function, and obtaining calling result data; and determining target execution logic according to the calling result data, and executing the target execution logic. And the execution efficiency and success rate of business-related tasks are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a task execution method, device, electronic device and computer-readable medium. Background Art

[0002] Currently, it is a common practice to use Java to implement scheduled tasks. However, in a clustered deployment environment, it is easy for scheduled task instances to be executed concurrently. Because some applications do not consider concurrent execution when implementing them, the business logic is not idempotent, which leads to confusion in business logic execution and ultimately causes the failure of business-related task execution. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a task execution method, device, electronic device and computer-readable medium, which can solve the existing problem in a clustered deployment environment that some applications do not consider concurrent execution when implementing them, the business logic is not idempotent, resulting in confusion in business logic execution and ultimately leading to failure in the execution of business-related tasks.

[0004] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present application, a task execution method is provided, including: in response to a task execution request, obtaining the corresponding local server identifier and method name; based on the local server identifier and method name, generating a lock identifier, and executing the task locking process based on the lock identifier; obtaining the system current time and the task timeout time, and then calculating the timeout time; based on the lock identifier and the timeout time, executing the calling process of the setting function, and obtaining the calling result data; according to the calling result data, determining the target execution logic, and executing the target execution logic.

[0005] Optionally, determining the target execution logic and executing the target execution logic include: in response to the call result data corresponding to the call failure, determining the target execution logic to exit the execution of the current task; executing the target execution logic, calling the delete key function to release the lock corresponding to the lock identifier, thereby ending the execution of the current task.

[0006] Optionally, calling the delete key function to release the lock corresponding to the lock identifier includes: calling the delete key function to delete the key corresponding to the lock identifier from the configuration data of the task that failed to call the setting function, so as to release the lock corresponding to the lock identifier.

[0007] Optionally, generating the lock identifier includes: calculating the lock identifier using the local server identifier and the method name based on an information digest algorithm.

[0008] Optionally, calculating the timeout time includes: adding the system current time and the task timeout time to determine the timeout time.

[0009] Optionally, executing the calling process of the setting function includes: passing a lock identifier to a key parameter of the setting function, passing a timeout period to a value parameter corresponding to the key parameter, so as to execute the calling process of the setting function based on the key parameter and the value parameter.

[0010] In addition, the present application also provides a task execution device, including: an acquisition unit, configured to obtain the corresponding local server identifier and method name in response to a task execution request; a task locking unit, configured to generate a lock identifier based on the local server identifier and method name, and execute the task locking process based on the lock identifier; a calculation unit, configured to obtain the current system time and the task timeout time, and then calculate the timeout time; a calling unit, configured to execute a calling process for a set function based on the lock identifier and the timeout time, and obtain the calling result data; an execution unit, configured to determine the target execution logic according to the calling result data, and execute the target execution logic.

[0011] Optionally, the execution unit is further configured to: in response to the call result data corresponding to a call failure, determine the target execution logic to exit the execution of the current task; execute the target execution logic, call the delete key function to release the lock corresponding to the lock identifier, and then end the execution of the current task.

[0012] Optionally, the execution unit is further configured to: call a delete key function to delete the key corresponding to the lock identifier from the configuration data of the task that failed to call the setting function, so as to release the lock corresponding to the lock identifier.

[0013] Optionally, the task locking unit is further configured to: calculate the lock identifier by using the local server identifier and the method name based on a message digest algorithm.

[0014] Optionally, the calculation unit is further configured to: determine the timeout time by adding the system current time and the task timeout time.

[0015] Optionally, the calling unit is further configured to: pass a lock identifier to a key parameter of the setting function, and pass a timeout period to a value parameter corresponding to the key parameter, so as to execute a calling process of the setting function based on the key parameter and the value parameter.

[0016] In addition, the present application also provides a task execution electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the task execution method as described above.

[0017] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the task execution method as described above is implemented.

[0018] To achieve the above objective, according to another aspect of the embodiments of the present application, a computer program product is provided.

[0019] A computer program product according to an embodiment of the present application includes a computer program, and when the program is executed by a processor, the task execution method provided by the embodiment of the present application is implemented.

[0020] An embodiment of the above invention has the following advantages or beneficial effects: the application obtains the corresponding local server identifier and method name in response to the task execution request; generates a lock identifier based on the local server identifier and method name, and executes the task locking process based on the lock identifier; obtains the system current time and the task timeout time, and then calculates the timeout time; executes the call process of the setting function based on the lock identifier and the timeout time, and obtains the call result data; determines the target execution logic according to the call result data, and executes the target execution logic. Improve the execution efficiency and success rate of business-related tasks.

[0021] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.

[0023] Figure 1 is a schematic diagram of the main process of a task execution method according to an embodiment of the present application;

[0024] Figure 2 is a schematic diagram of the main process of a task execution method according to an embodiment of the present application;

[0025] Figure 3 It is a main flow chart of a task execution method according to an embodiment of the present application;

[0026] Figure 4 is a schematic diagram of the main units of the task execution device according to an embodiment of the present application;

[0027] Figure 5 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;

[0028] Figure 6 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following is a description of the exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, and they should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of known functions and structures is omitted in the following description. It should be noted that the acquisition, transmission, storage, use, and processing of data in the technical solution of the present application are in compliance with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of the present application, certain software, components, models, and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or must have used the solution. In the technical solution of the present application, the collection, analysis, use, transmission, storage, and other aspects of the user's personal information involved are in compliance with the provisions of relevant laws and regulations, and are used for legal and reasonable purposes, and are not shared, leaked, or sold outside of these legal uses, and are subject to supervision and management by regulatory authorities. Take necessary measures to prevent illegal access to such personal information, ensure that persons with access to personal information comply with relevant laws and regulations, and ensure the security of personal information. Once such personal information is no longer needed, risks should be minimized by limiting or even prohibiting data collection and / or deleting data.

[0030] When used, including in certain related applications, user privacy is protected by de-identifying data, such as by removing specific identifiers when used, controlling the amount or specificity of data stored, controlling how data is stored, and / or other methods of de-identification.

[0031] Figure 1 is a schematic diagram of the main process of a task execution method according to an embodiment of the present application, such as Figure 1 As shown, the task execution method mainly includes the following steps S101 to S105.

[0032] Step S101, in response to a task execution request, obtaining a corresponding local server identifier and method name.

[0033] In this embodiment, the execution subject of the task execution method (for example, a server) can receive the task execution request through a wired connection or a wireless connection. After receiving the task execution request, the execution subject can obtain the local server identifier and method name carried in the request. The method name can be the name of the task execution method.

[0034] Step S102: Generate a lock identifier based on the local server identifier and the method name, and execute a task locking process based on the lock identifier.

[0035] Specifically, generating the lock identifier includes: calculating the local server identifier and the method name based on an information digest algorithm to obtain the lock identifier.

[0036] For example, the information digest algorithm is the md5 algorithm. The execution subject reads the local server identifier and method name, and uses the md5 algorithm to generate a unique lock identifier, namely the lock ID, also known as lockId. The lock identifier is used to lock the currently executed task to ensure that the task execution is not interfered with and improve the efficiency and accuracy of task execution.

[0037] Step S103, obtaining the system current time and the task timeout time, and then calculating the timeout time.

[0038] Specifically, calculating the timeout time includes: adding the system current time and the task timeout time to determine the timeout time.

[0039] Step S104: Based on the lock identifier and the timeout period, a calling process for the setting function is executed, and calling result data is obtained.

[0040] The lock identifier and timeout period are used as input parameters of the setting function to call the setting function, and the calling result data of the setting function is obtained in real time.

[0041] Step S105, determining the target execution logic according to the call result data, and executing the target execution logic.

[0042] The execution subject can determine the target execution logic according to the call success or call failure corresponding to the call result data. The target execution logic can include continuing to execute the task or exiting the task.

[0043] This embodiment obtains the corresponding local server identifier and method name in response to the task execution request; generates a lock identifier based on the local server identifier and method name, and executes the task locking process based on the lock identifier; obtains the system current time and the task timeout time, and then calculates the timeout time; executes the call process of the setting function based on the lock identifier and the timeout time, and obtains the call result data; determines the target execution logic according to the call result data, and executes the target execution logic. Improve the execution efficiency and success rate of business-related tasks.

[0044] Figure 2 is a schematic diagram of the main flow of a task execution method according to an embodiment of the present application, such as Figure 2 As shown, the task execution method mainly includes the following steps S201 to S206.

[0045] Step S201, in response to a task execution request, obtain a corresponding local server identifier and method name.

[0046] The task execution request may be a request for executing a scheduled task, and the embodiment of the present application does not specifically limit the type of the task to be executed. When the execution subject receives the task execution request, it may obtain the local server identifier and method name carried in the request.

[0047] Step S202: Generate a lock identifier based on the local server identifier and the method name, and execute a task locking process based on the lock identifier.

[0048] The lock identifier generation template is called to fill the local server identifier and method name into the corresponding placeholder to quickly and accurately obtain the corresponding lock identifier.

[0049] Step S203, obtaining the system current time and the task timeout time, and then calculating the timeout time.

[0050] The timeout time is determined as the sum of the current system time and the task timeout time.

[0051] Step S204: Based on the lock identifier and the timeout period, execute the calling process of the setting function and obtain the calling result data.

[0052] The lock identifier and the timeout period are respectively used as parameters of the setting function to call the setting function and obtain corresponding calling result data.

[0053] Step S205 , in response to the call result data corresponding to the call failure, determining the target execution logic to exit the execution of the current task.

[0054] If there is a call failure identifier in the call result data, such as N or 0, it is determined that the call result data corresponds to a call failure, and the execution subject can determine that the target execution logic is to exit the execution of the current task.

[0055] Step S206, executing the target execution logic, calling the delete key function to release the lock corresponding to the lock identifier, and then ending the execution of the current task.

[0056] Specifically, calling the delete key function to release the lock corresponding to the lock identifier includes: calling the delete key function to delete the key corresponding to the lock identifier from the configuration data of the task that failed to call the setting function, so as to release the lock corresponding to the lock identifier.

[0057] The delete key function, for example, can be the stopJob() function. When executing the target execution logic, the delete key function is called to release the corresponding lock according to the lock identifier, end the execution of the current task, calculate the execution time of the task, return to the application, and return the lock identifier and the execution time of the task. Improve the execution efficiency and success rate of business-related tasks.

[0058] Figure 3is a schematic diagram of the main flow of a task execution method according to an embodiment of the present application, such as Figure 3 As shown, the task execution method mainly includes the following steps S301 to S305.

[0059] Step S301, in response to a task execution request, obtain a corresponding local server identifier and method name.

[0060] After receiving the task execution request, the execution subject can obtain the local server identifier and method name carried in the request, wherein the method name can be the name of the task execution method.

[0061] Step S302: Generate a lock identifier based on the local server identifier and the method name, and execute a task locking process based on the lock identifier.

[0062] The execution subject can encrypt the local server identifier and the method name based on the symmetric encryption algorithm to generate a lock identifier, thereby increasing the speed of encryption and subsequent decryption.

[0063] Step S303, obtaining the system current time and the task timeout time, and then calculating the timeout time.

[0064] The execution entity can obtain the task timeout from the yml configuration file, and add the current system time to the obtained task timeout to obtain the timeout.

[0065] Step S304: a lock identifier is passed into the key parameter of the setting function, and a timeout period is passed into the value parameter corresponding to the key parameter, so as to execute the calling process of the setting function based on the key parameter and the value parameter, and obtain the calling result data.

[0066] For example, call the set() function of redis, pass lockId to the key parameter of the set() function, and pass the timeout to the value parameter. If the call to the set() function is successful, the call result data is returned.

[0067] The call result data contains a return value, which contains two parameters: lockId (lock ID) and call result.

[0068] Step S305, determining the target execution logic according to the call result data, and executing the target execution logic.

[0069] According to the call result in the return value in the call result data, determine whether to continue execution, that is, determine the target execution logic and execute the target execution logic. Execute the target execution logic, including: if the value of the call result in the return value in the call result data is true, continue to execute the current task; if the value of the call result is false, exit the current task. Improve the execution efficiency and success rate of business-related tasks.

[0070] In this application, it is a common practice to use Java to implement scheduled tasks. However, in a clustered deployment environment, it is easy for scheduled task instances to be executed concurrently. The task execution method of the embodiment of this application can avoid concurrent execution of scheduled tasks; it is simple to implement, has little reliance on external resources, and is friendly to application developers. A set of task start and stop interfaces is provided, which implements a set of concurrent execution solutions for cluster systems based on redis; it can avoid concurrent execution and reduce confusion in business logic execution.

[0071] In the task execution method of the embodiment of the present application, initialization: Step 1: In the yml configuration file of the application, configure the IP, port, user name, and password of the redis server.

[0072] Start the scheduled task: In the business logic timing program, introduce a component RedisJob, call the RedisJob.startJob() function to start the scheduled task, and the parameter is the business logic scheduled task name.

[0073] Inside the startJob() function, implement the following logic:

[0074] Step 1: Read the redis configuration of the application from the yml configuration file to obtain the IP, port, username, and password of the redis server;

[0075] Step 2: Read the local server's IP address and method name, and use the md5 algorithm to generate a unique lock ID (i.e. lock identifier, also known as lockId);

[0076] Step 3: Get the current system time, then get the task timeout from the yml configuration file, and calculate the timeout. Timeout = current system time + task timeout.

[0077] Step 4: Call the redis set() function, where the key parameter is passed in as lockId, and the value parameter is passed in as the timeout. If the call to set succeeds, it returns; the return value contains two parameters: lockId and the call result;

[0078] Step 5: Determine whether to continue execution based on the return value of the startJob() function; if the value of the call result is true, continue execution; if the value of the call result is false, exit execution.

[0079] After executing the business logic, call the stopJob() function to end the execution of the task.

[0080] In the stopJob() function, implement the following logic:

[0081] Step 1: Call the redis.del() function to release the lock. The parameter is the lock ID (i.e. lock identifier, also known as lockId).

[0082] Step 2: Calculate the task execution time and return it to the application; the return value includes the lock ID and task execution time.

[0083] The task execution method scheme of the embodiment of the present application is simple and does not require the deployment of an independent task scheduling framework. The intrusion to the application is small. The application only needs to introduce a Java component dependency. The interface is simple, and the application only needs to call the start task function (startJob) and the end task function (stopJob). The above logic is implemented as a three-party Maven component, which is convenient for Java applications to be introduced through Maven dependencies.

[0084] Figure 4 Schematic diagram of the main units of the task execution device according to an embodiment of the present application. Figure 4 As shown, the task execution device 400 includes an acquisition unit 401 , a task locking unit 402 , a calculation unit 403 , a calling unit 404 and an execution unit 405 .

[0085] The acquisition unit 401 is configured to acquire the corresponding local server identifier and method name in response to the task execution request.

[0086] The task locking unit 402 is configured to generate a lock identifier based on the local server identifier and the method name, and execute the task locking process based on the lock identifier.

[0087] The calculation unit 403 is configured to obtain the current system time and the task timeout time, and then calculate the timeout time.

[0088] The calling unit 404 is configured to execute a calling process of the setting function based on the lock identifier and the timeout period, and obtain calling result data.

[0089] The execution unit 405 is configured to determine the target execution logic according to the call result data and execute the target execution logic.

[0090] In some embodiments, the execution unit 405 is further configured to: in response to the call result data corresponding to the call failure, determine the target execution logic to exit the execution of the current task; execute the target execution logic, call the delete key function to release the lock corresponding to the lock identifier, and then end the execution of the current task.

[0091] In some embodiments, the execution unit 405 is further configured to: call a delete key function to delete the key corresponding to the lock identifier from the configuration data of the task that failed to call the set function, so as to release the lock corresponding to the lock identifier.

[0092] In some embodiments, the task locking unit 402 is further configured to: calculate the lock identifier by using the local server identifier and the method name based on a message digest algorithm.

[0093] In some embodiments, the calculation unit 403 is further configured to: determine the timeout time by adding the system current time and the task timeout time.

[0094] In some embodiments, the calling unit 404 is further configured to: pass a lock identifier to a key parameter of the setting function, and pass a timeout period to a value parameter corresponding to the key parameter, so as to execute a calling process of the setting function based on the key parameter and the value parameter.

[0095] It should be noted that the task execution method and task execution device of the present application have a corresponding relationship in terms of specific implementation content, so the repeated content will not be explained again.

[0096] Figure 5 An exemplary system architecture 500 is shown to which the task execution method or task execution apparatus according to the embodiments of the present application can be applied.

[0097] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0098] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0099] The terminal devices 501 , 502 , and 503 may be various electronic devices having a task execution processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0100] Server 505 can be a server that provides various services, such as a background management server that supports task execution requests submitted by users using terminal devices 501, 502, and 503 (only as an example). The background management server can respond to the task execution request, obtain the corresponding local server identifier and method name; generate a lock identifier based on the local server identifier and method name, and execute the task locking process based on the lock identifier; obtain the system current time and task timeout time, and then calculate the timeout time; based on the lock identifier and timeout time, execute the call process of the setting function and obtain the call result data; determine the target execution logic based on the call result data, and execute the target execution logic. Improve the execution efficiency and success rate of business-related tasks.

[0101] It should be noted that the task execution method provided in the embodiment of the present application is generally executed by the server 505 , and accordingly, the task execution device is generally set in the server 505 .

[0102] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0103] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present application. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0104] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0105] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0106] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present application are executed.

[0107] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0108] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0109] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit, a task locking unit, a calculation unit, a call unit, and an execution unit. The names of these units do not constitute limitations on the units themselves in some cases.

[0110] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device responds to the task execution request, obtains the corresponding local server identifier and method name; generates a lock identifier based on the local server identifier and method name, and executes the task locking process based on the lock identifier; obtains the system current time and the task timeout time, and then calculates the timeout time; based on the lock identifier and the timeout time, executes the call process of the setting function and obtains the call result data; determines the target execution logic according to the call result data, and executes the target execution logic.

[0111] The computer program product of the present application includes a computer program, and when the computer program is executed by a processor, the task execution method in the embodiment of the present application is implemented.

[0112] According to the technical solution of the embodiment of the present application, the execution efficiency and success rate of business-related tasks can be improved.

[0113] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A task execution method, It is characterized in that include: In response to the task execution request, obtain the corresponding local server identifier and method name; Generate a lock identifier based on the local server identifier and the method name, and execute a task locking process based on the lock identifier; Get the system current time and task timeout time, and then calculate the timeout time; Based on the lock identifier and the timeout period, executing a calling process for a setting function, and obtaining calling result data; According to the call result data, a target execution logic is determined, and the target execution logic is executed.

2. The method according to claim 1, It is characterized in that The determining the target execution logic and executing the target execution logic include: In response to the call result data corresponding to a call failure, determining the target execution logic to exit execution of the current task; The target execution logic is executed, and the delete key function is called to release the lock corresponding to the lock identifier, thereby terminating the execution of the current task.

3. The method according to claim 2, It is characterized in that The calling of the delete key function to release the lock corresponding to the lock identifier includes: A delete key function is called to delete the key corresponding to the lock identifier from the configuration data of the task that fails to call the setting function, so as to release the lock corresponding to the lock identifier.

4. The method according to claim 1, It is characterized in that The generating of the lock identifier comprises: The local server identifier and the method name are calculated based on an information digest algorithm to obtain a lock identifier.

5. The method according to claim 1, It is characterized in that The timeout period is calculated, including: The timeout time is determined by adding the current system time and the task timeout time.

6. The method according to claim 1, It is characterized in that The execution of the calling process of the setting function includes: The lock identifier is passed into the key parameter of the setting function, and the timeout period is passed into the value parameter corresponding to the key parameter, so as to execute the calling process of the setting function based on the key parameter and the value parameter.

7. A task execution device, It is characterized in that include: an acquisition unit, configured to acquire a corresponding local server identifier and a method name in response to a task execution request; A task locking unit, configured to generate a lock identifier based on the local server identifier and the method name, and execute a task locking process based on the lock identifier; A calculation unit is configured to obtain the current system time and the task timeout time, and then calculate the timeout time; A calling unit, configured to execute a calling process of a setting function based on the lock identifier and the timeout period, and obtain calling result data; The execution unit is configured to determine the target execution logic according to the call result data and execute the target execution logic.

8. The device according to claim 7, It is characterized in that The execution unit is further configured to: In response to the call result data corresponding to a call failure, determining the target execution logic to exit execution of the current task; The target execution logic is executed, and the delete key function is called to release the lock corresponding to the lock identifier, thereby terminating the execution of the current task.

9. The device according to claim 8, It is characterized in that The execution unit is further configured to: A delete key function is called to delete the key corresponding to the lock identifier from the configuration data of the task that fails to call the setting function, so as to release the lock corresponding to the lock identifier.

10. The device according to claim 7, It is characterized in that The task locking unit is further configured to: The local server identifier and the method name are calculated based on an information digest algorithm to obtain a lock identifier.

11. The device according to claim 7, It is characterized in that The computing unit is further configured to: The timeout time is determined by adding the current system time and the task timeout time.

12. The device according to claim 7, It is characterized in that The calling unit is further configured to: The lock identifier is passed into the key parameter of the setting function, and the timeout period is passed into the value parameter corresponding to the key parameter, so as to execute the calling process of the setting function based on the key parameter and the value parameter.

13. A task execution electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

14. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

15. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.