CN113190371B - Task compensation method and device, electronic equipment and readable storage medium - Google Patents

Task compensation method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN113190371B
CN113190371B CN202110539748.9A CN202110539748A CN113190371B CN 113190371 B CN113190371 B CN 113190371B CN 202110539748 A CN202110539748 A CN 202110539748A CN 113190371 B CN113190371 B CN 113190371B
Authority
CN
China
Prior art keywords
target
task
backup machine
information
backup
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110539748.9A
Other languages
Chinese (zh)
Other versions
CN113190371A (en
Inventor
韩晓飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202110539748.9A priority Critical patent/CN113190371B/en
Publication of CN113190371A publication Critical patent/CN113190371A/en
Application granted granted Critical
Publication of CN113190371B publication Critical patent/CN113190371B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1456Hardware arrangements for backup

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Hardware Redundancy (AREA)

Abstract

The application discloses a task compensation method, a device, electronic equipment and a readable storage medium, wherein the method comprises the following steps: if the abnormal task is detected, carrying out instantiation processing on the abnormal task to obtain a target instance object; placing the target instance object into a task queue; acquiring target backup machine information from the backup machine list, and determining a target backup machine by utilizing the target backup machine information; the method comprises the steps that abnormal task information is sent to a target backup machine, so that the target backup machine obtains a target instance object from a task queue according to the abnormal task information, re-executes an abnormal task by utilizing the target instance object and feeds back an execution result; according to the method, the target backup machine is selected from a plurality of backup machines corresponding to the backup machine list to perform task compensation according to the current situation, the decentralization effect is achieved, the servers serving as the backup machines and the local machine are mutually backed up, so that the abnormal situation of a single server does not cause the failure of all abnormal task compensation, and the robustness of a service system is improved.

Description

Task compensation method and device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of business systems, and in particular, to a task compensation method, a task compensation device, an electronic device, and a computer readable storage medium.
Background
In the running process of the service system, the situation that part of task logic cannot normally run or cannot normally end may exist, and in this case, in order to ensure that the service system normally works, the abnormal tasks need to be re-executed, namely, task compensation is performed. The related art is generally provided with a scheduling center, and each server transmits an abnormal task to the scheduling center, and the scheduling center performs trigger execution on the abnormal task by using a trigger. However, the task compensation method by using the dispatching center excessively depends on the dispatching center, and if the dispatching center fails, a large number of abnormal services cannot be compensated and executed, so that the robustness of the service system is poor.
Disclosure of Invention
In view of this, an object of the present application is to provide a task compensation method, a task compensation device, an electronic device, and a readable storage medium, which utilize each server as a backup machine and a local server to perform backup, so that an abnormality of a single server does not cause compensation failure of all abnormal tasks, and robustness of a service system is improved.
In order to solve the above technical problems, in a first aspect, the present application provides a task compensation method, which specifically includes:
if an abnormal task is detected, carrying out instantiation processing on the abnormal task to obtain a target instance object;
placing the target instance object into a task queue;
acquiring target backup machine information from a backup machine list, and determining a target backup machine by utilizing the target backup machine information;
and sending abnormal task information to the target backup machine, so that the target backup machine obtains the target instance object from the task queue according to the abnormal task information, re-executes the abnormal task by using the target instance object and feeds back an execution result.
In a possible embodiment, the method further includes:
if target task information sent by a target server is received, acquiring a target object from the task queue by utilizing the target task information;
acquiring class name information and parameter information corresponding to the target task from a task compensation database table by utilizing the target task information;
re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result;
And feeding back the target execution result to the target server.
In a possible implementation manner, the re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result includes:
re-executing the target task by using the class name information, the parameter information and the target object to obtain an initial execution result;
judging whether the initial execution result is a legal result or not;
if the result is the legal result, determining the initial execution result as the target execution result;
and if the target task is not the legal result, determining the target task as an abnormal task.
In a possible embodiment, the method further includes:
modifying a target data item corresponding to the target task in the task compensation database table according to the execution condition of the target task; the target data item comprises task state, execution times and original server information.
In a possible implementation manner, the process for generating the backup machine list includes:
acquiring an initial backup machine list, and testing network connectivity among candidate backup machines in the initial backup machine list;
Forming the backup machine list by using target candidate backup machines communicated with all other candidate backup machines;
and if the fact that the target network connection between the two target candidate backup machines is disconnected is detected in the backup machine list, deleting the target candidate backup machine corresponding to the target network connection from the backup machine list.
In a possible embodiment, the method further includes:
if the disconnection of the target network connection is detected, a daemon thread is established;
judging whether the target network connection is restored or not;
if the target network connection is restored, adding the target candidate backup machine corresponding to the target network connection into the backup machine list;
and if the target network connection is not recovered, recovering the target network connection by using the daemon thread according to a preset recovery frequency.
In a possible implementation manner, the sending abnormal task information to the target backup machine includes:
determining the target backup machine as a client, and placing the client into a global single-instance object set;
establishing a remote method call service between the target backup machine and the service system according to a service port of the service system;
And sending the abnormal task information to the target backup machine through the remote method calling service.
In a second aspect, the present application provides a task compensation device, including:
the instantiation module is used for carrying out instantiation processing on the abnormal task if the abnormal task is detected, so as to obtain a target instance object;
the queue filling module is used for placing the target instance object into a task queue;
the target backup machine determining module is used for acquiring target backup machine information from the backup machine list and determining a target backup machine by utilizing the target backup machine information;
and the task compensation module is used for sending abnormal task information to the target backup machine so that the target backup machine can acquire the target instance object from the task queue according to the abnormal task information, re-execute the abnormal task by utilizing the target instance object and feed back an execution result.
In a third aspect, the present application provides an electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the task compensation method described above.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program, where the computer program when executed by a processor implements the task compensation method described above.
According to the task compensation method, if an abnormal task is detected, the abnormal task is subjected to instantiation processing to obtain a target instance object; placing the target instance object into a task queue; acquiring target backup machine information from the backup machine list, and determining a target backup machine by utilizing the target backup machine information; and sending the abnormal task information to the target backup machine so that the target backup machine obtains a target instance object from the task queue according to the abnormal task information, re-executing the abnormal task by using the target instance object and feeding back an execution result.
Therefore, the method does not utilize a unified dispatching center to compensate abnormal tasks, but builds a backup machine list, wherein backup machine information corresponding to at least two backup machines is recorded. After detecting that an abnormal task occurs, instantiating the abnormal task to obtain a target instance object, and putting the target instance object into a task queue so that a subsequent backup machine can re-execute the abnormal task by using the target instance object. Meanwhile, the target backup machine information, which is the information corresponding to the backup machine for executing the task compensation, can be obtained from the backup machine list, and the target backup machine can be determined by using the target backup machine information. By sending the abnormal task information, the target instance object can be acquired by the target backup machine by using the abnormal task information, and the abnormal task is executed, in this case, the abnormal task becomes a method on the target backup machine, and the local machine can obtain the execution result fed back by the target backup machine. Because the task compensation is not executed by the dispatching center, but the target backup machine is selected from a plurality of backup machines corresponding to the backup machine list according to the current situation, the decentralization effect is realized, and the servers serving as the backup machines and the local machine are mutually backed up, so that the abnormal of a single server does not cause the failure of the compensation of all abnormal tasks, the robustness of a service system is improved, and the problem of poor robustness of the service system in the related technology is solved. In addition, by the method, the original codes of the service system do not need to be configured or the codes do not need to be invaded to realize task compensation, so that the access standard and the invasiveness to the service codes are reduced.
In addition, the application also provides a task compensation device, electronic equipment and a computer readable storage medium, and the task compensation device and the electronic equipment have the beneficial effects.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings may be obtained according to the provided drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flowchart of a task compensation method according to an embodiment of the present application;
FIG. 2 is a flowchart of another task compensation method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a task compensation device according to an embodiment of the present application;
fig. 4 is a schematic diagram of a hardware composition framework to which a task compensation method according to an embodiment of the present application is applicable.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The related art adopts a distributed timing task mode when re-executing an abnormal task, namely, when performing task compensation. The whole process comprises the following steps:
1. and when the abnormal task is detected, defining a compensation task processor corresponding to the abnormal task.
2. Registering the defined compensation task processor in the dispatching center, wherein the registration process comprises configuration of compensation frequency.
3. The dispatch center establishes a trigger for the compensation task processor.
4. A timer is started and the trigger is triggered according to the compensation frequency defined in step 2.
5. And after the trigger is triggered, the task processor is called, and the task processor calls a specific implementation class of the task to execute the task.
6. When the task is normally completed, the state of the task is modified so as not to be repeatedly triggered, otherwise, the steps 4-6 are repeated.
It follows that the overall task compensation process is heavily dependent on the dispatch center, which is responsible for re-executing all abnormal tasks. When the dispatching center is abnormal such as faults, compensation of all abnormal tasks fails completely, so that the robustness of the service system is poor. Meanwhile, in order to realize the steps, configuration and code intrusion are required to be carried out in a normal service system, so that the code intrusion to the service system is high. Furthermore, dispatch centers are typically physically remote from devices such as servers of the business system, e.g., typically deployed across a machine room, which makes the process of task compensation susceptible to network conditions.
In order to solve the above problems, the present application provides a task compensation method. Referring to fig. 1, fig. 1 is a flowchart of a task compensation method according to an embodiment of the present application. The method comprises the following steps:
s101: if the abnormal task is detected, carrying out instantiation processing on the abnormal task to obtain a target instance object.
The abnormal task is a task (or becomes logic) which does not normally end, or a task whose execution result is not a normal result, and the specific type, number, and the like thereof are not limited. The abnormal task may be a task that is originally executed on the current server, or may be a task that cannot be executed normally on other servers but cannot be executed normally when the current server performs task compensation. The current server refers to a server that executes all or part of the steps in the present application, and in this embodiment, its identity is a local server, and the local server refers to a server that invokes other servers as backup machines.
The embodiment is not limited to a specific detection mode of an abnormal task, in one implementation, a task execution result and a preset legal result can be compared, and when the task execution result and the preset legal result are inconsistent, the task is determined to be the abnormal task; in another embodiment, tasks that are executed for longer than a preset length of time may be determined to be abnormal tasks.
After the abnormal task is detected, the abnormal task can be subjected to instantiation processing to obtain a corresponding object, namely a target instance object. Instantiation refers to the process of creating objects using classes during object-oriented programming, while target instance objects are objects created using classes of abnormal tasks. In a specific embodiment, a blank object may be preset, and when the instantiation process is performed, certain information (for example, identity information) corresponding to the abnormal task is written into the blank object, so that a corresponding target instance object may be obtained. According to the different instantiation processing modes, the instantiation processing process may also be different, and the specific modes and processes may refer to related technologies, and this embodiment will not be described again.
S102: and placing the target instance object into a task queue.
The task queue refers to a queue for storing objects corresponding to tasks, and in one embodiment, objects corresponding to tasks waiting normally to be executed and objects corresponding to tasks to be compensated (i.e., abnormal tasks) may be placed therein. After the target instance object is obtained, the target instance object can be obtained from the task queue by filling the target instance object into the task queue, and then the backup machine is allowed to be used for restarting the abnormal task.
S103: and acquiring target backup machine information from the backup machine list, and determining the target backup machine by utilizing the target backup machine information.
The backup machine list is a list for recording backup machine information corresponding to each backup machine, and the number of the backup machine information recorded is not limited. The backup machine list may be a global list, that is, when all servers in the service system need to perform task compensation, the backup machine list may be used to determine the needed backup machine. In another embodiment, the backup machine list may correspond to each server, that is, each server constructs its own corresponding backup machine list, and when task compensation is required, determines the target backup machine by using its own backup machine list.
Backup machine information refers to information that characterizes the identity of the backup machine, which may be in the form of an IP address (i.e., internet Protocol Address, internet protocol address), or may be in other forms, such as a server number, server hardware address (i.e., MAC address, media Access Control Address), etc. The target backup machine information refers to backup machine information specified in the backup machine list, and is not limited in particular, and for example, the first backup machine information in the list, the last backup machine information, or the backup machine information corresponding to a certain fixed sequence number in the middle may be used. It should be noted that, in order to enable the task compensation work to be distributed as much as possible over the most servers, it is necessary to update the backup machine list after each selection of the target backup machine information, so that task compensation is performed with another server when an abnormal task occurs again. According to different modes of acquiring the target backup machine information, the update modes of the backup machine list can also be different, for example, when the target backup machine information is the first backup machine information in the list, the update mode can be that the target backup machine information is placed at the last position of the backup machine list, and the serial numbers of other backup machine information are sequentially updated forward by one bit.
Because the backup machine information corresponds to the backup machines one by one, after the target backup machine information is obtained, the corresponding target backup machine can be determined by using the target backup machine information.
S104: and sending the abnormal task information to the target backup machine so that the target backup machine obtains a target instance object from the task queue according to the abnormal task information, re-executing the abnormal task by using the target instance object and feeding back an execution result.
The abnormal task information refers to information corresponding to an abnormal task, and can represent the identity of the abnormal task. The abnormal task information may be serial number information such as a task ID (identification) or information such as a task name. After the target backup machine is determined, abnormal task information can be sent to the target backup machine through network connection between the local machine and the target backup machine. The embodiment is not limited to a specific manner of sending the abnormal task information, and in one embodiment, a remote method may be used to send a call request, where the call request includes the abnormal task information, and control the target backup machine to execute task compensation. The remote method call service is Remote Method Invocation, and is an RMI service which supports communication among program-level objects stored in different address spaces, so that seamless remote call among remote objects is realized. It should be noted that before the RMI service is used to call the target backup machine to perform task compensation, the RMI service between the local machine and the target backup machine needs to be initialized, and the specific initialization process may refer to the related technology, which is not described again.
After the abnormal task information is sent to the target backup machine, the target backup machine can acquire the target instance object from the task queue so as to re-execute the abnormal task by using the target instance object, and after the execution is finished, the task result is fed back to the target backup machine. It should be noted that, in this embodiment, it is not limited whether other data is required for re-executing the abnormal task, for example, in an embodiment, data such as class name information of the abnormal task, method entry, etc. is also required to be acquired.
For the specific execution process of the target backup machine on the abnormal task, in one implementation mode, when the RMI service is utilized to perform task compensation, the target backup machine acquires the corresponding execution class and execution method in a reflection mode after receiving the call request sent by the target backup machine, and calls (i.e. invoke) the corresponding method to obtain an execution result. After the execution result is obtained, the target backup machine can directly feed back the execution result to the local machine, or can firstly judge whether the execution result is normal or not, and feed back the execution result to the local machine when the normal execution result is obtained.
By applying the task compensation method provided by the embodiment of the application, the abnormal task is not compensated by using a unified dispatching center, but a backup machine list is constructed, wherein backup machine information corresponding to at least two backup machines is recorded. After detecting that an abnormal task occurs, instantiating the abnormal task to obtain a target instance object, and putting the target instance object into a task queue so that a subsequent backup machine can re-execute the abnormal task by using the target instance object. Meanwhile, the target backup machine information, which is the information corresponding to the backup machine for executing the task compensation, can be obtained from the backup machine list, and the target backup machine can be determined by using the target backup machine information. By sending the abnormal task information, the target instance object can be acquired by the target backup machine by using the abnormal task information, and the abnormal task is executed, in this case, the abnormal task becomes a method on the target backup machine, and the local machine can obtain the execution result fed back by the target backup machine. Because the task compensation is not executed by the dispatching center, but the target backup machine is selected from a plurality of backup machines corresponding to the backup machine list according to the current situation, the decentralization effect is realized, and the servers serving as the backup machines and the local machine are mutually backed up, so that the abnormal of a single server does not cause the failure of the compensation of all abnormal tasks, the robustness of a service system is improved, and the problem of poor robustness of the service system in the related technology is solved. In addition, by the method, the original codes of the service system do not need to be configured or the codes do not need to be invaded to realize task compensation, so that the access standard and the invasiveness to the service codes are reduced.
Based on the above embodiments, the present embodiment will specifically explain several steps in the above embodiments. In order to ensure the reliability of the task execution result, the problems of inconsistent and unreliable execution result caused by concurrent execution of abnormal tasks are prevented. The process of sending abnormal task information to the target backup machine may specifically include the following steps:
step 11: and determining the target backup machine as the client, and placing the client into the global single-instance object set.
After the target backup machine is determined, the target backup machine is determined to be a client, and is added to the global single-instance object set. The global single-instance object set is a set for storing single-instance objects, and the client is used as the single-instance object, so that each abnormal task and the corresponding backup machine can be singly and one-to-one corresponding to each other, and the occurrence of the concurrency condition is prevented. The embodiment is not limited to a specific manner of placing the client into the global single-instance object set, and specific reference may be made to related technology, which is not described herein.
Step 12: and establishing a remote method call service between the service system service port and the target backup machine according to the service system service port.
Step 13: and sending abnormal task information to the target backup machine through a remote method calling service.
The remote method utility service is an RMI service, the process of establishing a remote method call service is a process of initializing the RMI service between the local machine and the target backup machine, and the specific initialization process is not limited. For example, a service port corresponding to the service system may be obtained, and the RMI service initialization operation may be performed using the service port.
Further, based on the above embodiment, it may be understood that before determining the target backup machine by using the backup machine list, an accurate backup machine list needs to be generated first, and the use of the global backup machine list can enable the task compensation to be more evenly distributed on each backup machine, so the backup machine list generating process may include the following steps:
step 21: and acquiring an initial backup machine list, and testing network connectivity among candidate backup machines in the initial backup machine list.
The backup machine information corresponding to the plurality of candidate backup machines is recorded in the initial backup machine list, and the candidate backup machines refer to servers which can be used as backup machines, and can be specifically all servers in the service system or part of servers in the service system. The server serving as the backup machine can also serve as the local machine, and the abnormal tasks of the server running abnormally are compensated by calling other servers, so that the network communication between any two of all the backup machines is required to be ensured. Therefore, after the initial backup machine list is obtained, network connectivity among candidate backup machines is tested, and the backup machines are selected according to the test result. The embodiment is not limited to a specific test mode of network connectivity, for example, a network report detection tool may be used to test the network connectivity status between any two candidate backup machines.
Step 22: and forming a backup machine list by using the target candidate backup machines communicated with all other candidate backup machines.
After the test results are obtained, determining the target candidate backup machines which are communicated with the network among all other candidate backup machines as backup machines, forming a backup machine list by using the target candidate backup machines, specifically numbering the backup machine information of each target candidate backup machine, and sequencing the backup machine information according to the numbers to obtain a corresponding backup machine list.
Step 23: and if the fact that the target network connection between the two target candidate backup machines is disconnected in the backup machine list is detected, deleting the target candidate backup machine corresponding to the target network connection from the backup machine list.
It should be noted that, when the backup machine list is a global list, each recorded server is also a local server when the service system operates, and each server may be a backup machine. After the backup machine list is constructed, network connection among all the target candidate backup machines can be continuously detected, whether the target candidate backup machines are disconnected or not is judged, and when the disconnection of the target network connection among any two target candidate backup machines is detected, the target candidate backup machines related to the target network connection are deleted from the backup machine list, namely, the corresponding backup machine information is deleted from the backup machine list. By deleting the target candidate backup machine related to the target network connection (namely, disconnected network connection), any one backup machine corresponding to the backup machine list can be ensured to be used as a local machine, and any other target candidate backup machine recorded in the backup machine list can be called as a backup machine.
The present embodiment is not limited to a specific number of target network connections, and when the number of target network connections is plural, they respectively correspond to different target candidate backup machines.
Further, in order to ensure the number of servers corresponding to the backup machine list, after the situation that the target network connection is disconnected, the backup machine list can be tried to be restored, and when the disconnected network connection is restored, the related target candidate backup machine is added into the backup machine list again. Specifically, the method can further comprise the following steps:
step 31: if the disconnection of the target network is detected, a daemon thread is established.
The daemon thread can run in the background and can daemon all non-daemon threads, and the daemon threads all work as long as any one non-daemon thread is not finished. A daemon thread is established with which an attempt can be made to restore the target network connection.
Step 32: and judging whether the target network connection is restored.
Step 33: and if the target network connection is restored, adding the target candidate backup machine corresponding to the target network connection into the backup machine list.
If the target network connection is restored, it indicates that data can be transferred between the target candidate backup machines designed by the target network connection, and the target candidate backup machines can be the relationship between the host machine and the backup machine, so that the target candidate backup machines can be added into the backup machine list again.
Step 34: if the target network connection is not restored, restoring the target network connection by using the daemon thread according to the preset restoration frequency.
The preset recovery frequency refers to a frequency of attempting to recover the target network connection by the daemon thread, and the specific size of the frequency is not limited, and when it is determined that the target network connection is not recovered, the target network connection can be attempted to be recovered by the daemon thread at a time point when the preset recovery frequency is satisfied.
Based on the above embodiment, in practical application, the local machine performing steps S101 to S104 may be called as a backup machine of another server. Referring specifically to fig. 2, fig. 2 is a flowchart of another task compensation method provided in an embodiment of the present application, including:
s201: and if the target task information sent by the target server is received, acquiring a target object from the task queue by utilizing the target task information.
The target server refers to another server that invokes the current server, which in this embodiment is the backup machine that accepts the invocation, and the target server is the local machine. It can be appreciated that if the RMI service is used to obtain the target task information sent by the target server, before the target task information is obtained, the RMI service needs to be established with the target server.
After the target task information is obtained, the corresponding object, namely the target object, can be obtained from the task queue by utilizing the target task information. The target object is an object obtained after the target server carries out instantiation processing on the target task.
S202: and obtaining class name information and parameter information corresponding to the target task from the task compensation database table by utilizing the target task information.
The task compensation database table refers to a database table for recording information and execution conditions of each task in the service system, and specifically is a global table for covering each server of the whole service system. In this embodiment, the task compensation database table includes at least target task information, class name information (i.e., classname) and parameter information (i.e., method parameter) corresponding to the target task information, and may include other data items. In one possible implementation, the task compensation database table may be of the form:
wherein, job_id refers to a serial number for uniquely identifying the current task, namely the target task information; job_params refers to the method parameter of the current task, namely parameter information, and is stored in a jsonStr format; job_excitor refers to the className of the target method, namely class name information; status refers to a task state, wherein 1 indicates that a task is newly built, 2 indicates that the task is being executed, 3 indicates that the execution is successful, and 4 indicates that the execution is failed; limit refers to the upper threshold of the compensation times of the current task; target_domain refers to a server ip (i.e., original server information) to which the current task initially belongs; times refers to the number of Times the current task has been retried (i.e., has been compensatively performed); the create_date refers to the creation time of the current task;
modification_date refers to the modification time of the current task.
After the target task information is obtained, the task compensation database table can be screened by using the target task information, so that the corresponding class name information and parameter information are obtained. The class name information and the parameter information are data necessary for executing the target task, and the specific content and the number thereof are not limited. In this example, it is obtained by a task compensation database table, in other embodiments it may be obtained by other means.
S203: and re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result.
S204: and feeding back the target execution result to the target server.
After class name information, parameter information and target objects are obtained, the target tasks are re-executed by using the class name information, the parameter information and the target objects, the specific execution mode of the target tasks is not limited, and the specific execution process of the target tasks can be different according to different target tasks. After the target execution result is obtained, the target execution result can be fed back to the target server.
In one embodiment, the target execution result may be fed back to the target server directly after the target execution result is obtained, and in another embodiment, legal detection may be performed on the target execution result. Specifically, re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result, including:
Step 41: and re-executing the target task by using the class name information, the parameter information and the target object to obtain an initial execution result.
Step 42: and judging whether the initial execution result is a legal result or not.
In this embodiment, after re-executing the target task by using the class name information, the parameter information and the target object, the directly obtained result is the initial execution result. After the initial execution result is obtained, judging whether the initial execution result is legal or not, namely whether the initial execution result is legal or not. For a specific judging method, in a possible implementation manner, whether the initial execution result is matched with the preset result or not can be judged, and if so, the legal result is determined.
Step 43: if the result is legal, the initial execution result is determined to be the target execution result.
Step 44: if the target task is not the legal result, the target task is determined to be an abnormal task.
If the initial execution result is a legal result, the initial execution result is determined to be a target execution result and is directly fed back to the target server. If the initial execution result is not legal, in other embodiments, the initial execution result may be fed back to the target server, and the target server determines the target backup machine again and performs task compensation. In this embodiment, in order to increase the task compensation speed and reduce the waste of computing resources, the task compensation speed may be determined as an abnormal task, and the current server may be directly used to call the backup machine to perform task compensation on the target task. And after the current server acquires the corresponding target execution result, forwarding the target execution result to the target server.
Further, in one embodiment, data items such as task status are recorded in the task compensation database table. Because the task compensation database table is a global table, any server can carry out operations such as modification and the like on the task compensation database table, in order to update the task compensation database table in time, the target data item corresponding to the target task can be directly updated according to the execution condition of the target task, and the target server is not required to modify the target data item. Specifically, the method can further comprise the following steps.
Step 51: and according to the execution condition of the target task, modifying the target data item corresponding to the target task in the task compensation database table.
In this embodiment, the target data item includes task status, execution times, and original server information, and may include other information, and specifically, reference may be made to the description of the task compensation database table. The execution condition of the target task can be executing, executing successfully or executing failure, and according to the execution condition, the current server can directly modify the corresponding target data item without modifying the target server, so that the updating efficiency and speed of the information in the database table are improved.
The task compensation device provided in the embodiments of the present application is described below, and the task compensation device described below and the task compensation method described above may be referred to correspondingly.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a task compensation device according to an embodiment of the present application, including:
the instantiation module 110 is configured to, if an abnormal task is detected, perform instantiation processing on the abnormal task to obtain a target instance object;
a queue filling module 120, configured to put the target instance object into a task queue;
the target backup machine determining module 130 is configured to obtain target backup machine information from the backup machine list, and determine a target backup machine by using the target backup machine information;
the task compensation module 140 is configured to send abnormal task information to the target backup machine, so that the target backup machine obtains a target instance object from the task queue according to the abnormal task information, re-executes the abnormal task by using the target instance object, and feeds back an execution result.
Optionally, the method further comprises:
the information acquisition module is used for acquiring a target object from the task queue by utilizing the target task information if the target task information sent by the target server is received;
The table reading module is used for acquiring class name information and parameter information corresponding to the target task from the task compensation database table by utilizing the target task information;
the execution module is used for re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result;
and the feedback module is used for feeding back the target execution result to the target server.
Optionally, the execution module includes:
the initial execution unit is used for re-executing the target task by using the class name information, the parameter information and the target object to obtain an initial execution result;
the legal judging unit is used for judging whether the initial execution result is a legal result or not;
the first determining unit is used for determining the initial execution result as a target execution result if the initial execution result is a legal result;
and the second determining unit is used for determining the target task as an abnormal task if the target task is not a legal result.
Optionally, the method further comprises:
the table modification module is used for modifying a target data item corresponding to the target task in the task compensation database table according to the execution condition of the target task; the target data item comprises task state, execution times and original server information.
Optionally, the method comprises:
The network testing module is used for acquiring an initial backup machine list and testing network connectivity among candidate backup machines in the initial backup machine list;
the list construction module is used for constructing a backup machine list by utilizing a target candidate backup machine communicated with all other candidate backup machines;
and the deleting module is used for deleting the target candidate backup machine corresponding to the target network connection from the backup machine list if the target network connection disconnection between the two target candidate backup machines exists in the backup machine list.
Optionally, the method further comprises:
the thread establishing module is used for establishing a daemon thread if the disconnection of the target network connection is detected;
the restoration judging module is used for judging whether the target network connection is restored or not;
the adding module is used for adding the target candidate backup machine corresponding to the target network connection into the backup machine list if the target network connection is restored;
and the attempt recovery module is used for recovering the target network connection by using the daemon thread according to the preset recovery frequency if the target network connection is not recovered.
Optionally, the task compensation module 140 includes:
the single-instance processing unit is used for determining the target backup machine as a client and placing the client into the global single-instance object set;
The service establishing unit is used for establishing a remote method call service between the service establishing unit and the target backup machine according to the service port of the business system;
and the information sending unit is used for sending the abnormal task information to the target backup machine through the remote method calling service.
The electronic device provided in the embodiments of the present application is described below, and the electronic device described below and the task compensation method described above may be referred to correspondingly.
Referring to fig. 4, fig. 4 is a schematic diagram of a hardware composition framework to which a task compensation method according to an embodiment of the present application is applicable. Wherein the electronic device 100 may include a processor 101 and a memory 102, and may further include one or more of a multimedia component 103, an information input/information output (I/O) interface 104, and a communication component 105.
Wherein the processor 101 is configured to control the overall operation of the electronic device 100 to perform all or part of the steps in the task compensation method described above; the memory 102 is used to store various types of data to support operation at the electronic device 100, which may include, for example, instructions for any application or method operating on the electronic device 100, as well as application-related data. The Memory 102 may be implemented by any type or combination of volatile or non-volatile Memory devices, such as one or more of static random access Memory (Static Random Access Memory, SRAM), electrically erasable programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM), programmable Read-Only Memory (Programmable Read-Only Memory, PROM), read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. In the present embodiment, at least programs and/or data for realizing the following functions are stored in the memory 102:
If an abnormal task is detected, carrying out instantiation processing on the abnormal task to obtain a target instance object;
placing the target instance object into a task queue;
acquiring target backup machine information from a backup machine list, and determining a target backup machine by utilizing the target backup machine information;
and sending abnormal task information to the target backup machine, so that the target backup machine obtains the target instance object from the task queue according to the abnormal task information, re-executes the abnormal task by using the target instance object and feeds back an execution result.
The multimedia component 103 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen, the audio component being for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in the memory 102 or transmitted through the communication component 105. The audio assembly further comprises at least one speaker for outputting audio signals. The I/O interface 104 provides an interface between the processor 101 and other interface modules, which may be a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 105 is used for wired or wireless communication between the electronic device 100 and other devices. Wireless communication, such as Wi-Fi, bluetooth, near field communication (Near Field Communication, NFC for short), 2G, 3G or 4G, or a combination of one or more thereof, the respective communication component 105 may thus comprise: wi-Fi part, bluetooth part, NFC part.
The electronic device 100 may be implemented by one or more application specific integrated circuits (Application Specific Integrated Circuit, abbreviated as ASIC), digital signal processors (Digital Signal Processor, abbreviated as DSP), digital signal processing devices (Digital Signal Processing Device, abbreviated as DSPD), programmable logic devices (Programmable Logic Device, abbreviated as PLD), field programmable gate arrays (Field Programmable Gate Array, abbreviated as FPGA), controllers, microcontrollers, microprocessors, or other electronic components for performing the task compensation methods given by the above embodiments.
Of course, the structure of the electronic device 100 shown in fig. 4 is not limited to the electronic device in the embodiment of the present application, and the electronic device 100 may include more or fewer components than those shown in fig. 4 or may combine some components in practical applications.
The following describes a readable storage medium provided in an embodiment of the present application, and the readable storage medium described below and the task compensation method described above may be referred to correspondingly.
The present application also provides a readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the task compensation method described above.
The readable storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application, but such implementation should not be considered to be beyond the scope of this application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms include, comprise, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The principles and embodiments of the present application are described herein with specific examples, the above examples being provided only to assist in understanding the methods of the present application and their core ideas; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A task compensation method, characterized in that it is applied to a current server, the method comprising:
if an abnormal task is detected, carrying out instantiation processing on the abnormal task to obtain a target instance object;
placing the target instance object into a task queue;
acquiring target backup machine information from a backup machine list, and determining a target backup machine by utilizing the target backup machine information; the backup machine list is a global list, and all servers can determine backup machines by utilizing the backup machine list when performing task compensation; or the backup machine list corresponds to each server respectively, each server respectively constructs a backup machine list corresponding to the server, and when task compensation is carried out, the target backup machine is determined by utilizing the backup machine list of the server;
and sending abnormal task information to the target backup machine, so that the target backup machine obtains the target instance object from the task queue according to the abnormal task information, re-executes the abnormal task by using the target instance object and feeds back an execution result.
2. The task compensation method of claim 1, further comprising:
if target task information sent by a target server is received, acquiring a target object from the task queue by utilizing the target task information;
Acquiring class name information and parameter information corresponding to the target task from a task compensation database table by utilizing the target task information;
re-executing the target task by using the class name information, the parameter information and the target object to obtain a target execution result;
and feeding back the target execution result to the target server.
3. The task compensation method according to claim 2, wherein re-executing the target task using the class name information, the parameter information, and the target object to obtain a target execution result, comprises:
re-executing the target task by using the class name information, the parameter information and the target object to obtain an initial execution result;
judging whether the initial execution result is a legal result or not;
if the result is the legal result, determining the initial execution result as the target execution result;
and if the target task is not the legal result, determining the target task as an abnormal task.
4. The task compensation method of claim 2, further comprising:
modifying a target data item corresponding to the target task in the task compensation database table according to the execution condition of the target task; the target data item comprises task state, execution times and original server information.
5. The task compensation method according to any one of claims 1 to 4, wherein the backup machine list generation process includes:
acquiring an initial backup machine list, and testing network connectivity among candidate backup machines in the initial backup machine list;
forming the backup machine list by using target candidate backup machines communicated with all other candidate backup machines;
and if the fact that the target network connection between the two target candidate backup machines is disconnected is detected in the backup machine list, deleting the target candidate backup machine corresponding to the target network connection from the backup machine list.
6. The task compensation method of claim 5, further comprising:
if the disconnection of the target network connection is detected, a daemon thread is established;
judging whether the target network connection is restored or not;
if the target network connection is restored, adding the target candidate backup machine corresponding to the target network connection into the backup machine list;
and if the target network connection is not recovered, recovering the target network connection by using the daemon thread according to a preset recovery frequency.
7. The task compensation method of claim 1, wherein the sending abnormal task information to the target backup machine comprises:
Determining the target backup machine as a client, and placing the client into a global single-instance object set;
establishing a remote method call service between the target backup machine and the service system according to a service port of the service system;
and sending the abnormal task information to the target backup machine through the remote method calling service.
8. A task compensation device, characterized in that it is applied to a current server, the device comprising:
the instantiation module is used for carrying out instantiation processing on the abnormal task if the abnormal task is detected, so as to obtain a target instance object;
the queue filling module is used for placing the target instance object into a task queue;
the target backup machine determining module is used for acquiring target backup machine information from the backup machine list and determining a target backup machine by utilizing the target backup machine information; the backup machine list is a global list, and all servers can determine backup machines by utilizing the backup machine list when performing task compensation; or the backup machine list corresponds to each server respectively, each server respectively constructs a backup machine list corresponding to the server, and when task compensation is carried out, the target backup machine is determined by utilizing the backup machine list of the server;
And the task compensation module is used for sending abnormal task information to the target backup machine so that the target backup machine can acquire the target instance object from the task queue according to the abnormal task information, re-execute the abnormal task by utilizing the target instance object and feed back an execution result.
9. An electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor being configured to execute the computer program to implement the task compensation method of any one of claims 1 to 7.
10. A computer readable storage medium for storing a computer program, wherein the computer program when executed by a processor implements the task compensation method of any one of claims 1 to 7.
CN202110539748.9A 2021-05-18 2021-05-18 Task compensation method and device, electronic equipment and readable storage medium Active CN113190371B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110539748.9A CN113190371B (en) 2021-05-18 2021-05-18 Task compensation method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110539748.9A CN113190371B (en) 2021-05-18 2021-05-18 Task compensation method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN113190371A CN113190371A (en) 2021-07-30
CN113190371B true CN113190371B (en) 2024-04-05

Family

ID=76982609

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110539748.9A Active CN113190371B (en) 2021-05-18 2021-05-18 Task compensation method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN113190371B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116560896B (en) * 2023-07-11 2023-10-10 智慧眼科技股份有限公司 Abnormality compensation method, device, equipment and storage medium
CN116909760B (en) * 2023-09-13 2023-11-28 中移(苏州)软件技术有限公司 Data processing method, device, readable storage medium and electronic equipment
CN117557427B (en) * 2023-12-15 2024-05-14 广州启德教育科技有限公司 Big data based school information consultation system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528327A (en) * 2016-09-30 2017-03-22 华为技术有限公司 Data processing method and backup server
CN106878473A (en) * 2017-04-20 2017-06-20 腾讯科技(深圳)有限公司 A kind of message treatment method, server cluster and system
CN108040108A (en) * 2017-12-11 2018-05-15 杭州电魂网络科技股份有限公司 Communication handover method, device, coordination service device and readable storage medium storing program for executing
CN110928716A (en) * 2019-10-24 2020-03-27 江苏苏宁物流有限公司 Scheduling task exception handling method and device
CN111782431A (en) * 2020-06-22 2020-10-16 深圳乐信软件技术有限公司 Exception processing method, exception processing device, terminal and storage medium
CN111930529A (en) * 2020-10-09 2020-11-13 上海富友支付服务股份有限公司 Data synchronization method, module and system based on message queue and micro-service
CN112637335A (en) * 2020-12-22 2021-04-09 新华三大数据技术有限公司 Main/standby mode service deployment method, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8041985B2 (en) * 2006-08-11 2011-10-18 Chicago Mercantile Exchange, Inc. Match server for a financial exchange having fault tolerant operation
US11275764B2 (en) * 2018-10-11 2022-03-15 EMC IP Holding Company LLC Highly resilient synchronous replication with automatic recovery

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106528327A (en) * 2016-09-30 2017-03-22 华为技术有限公司 Data processing method and backup server
CN106878473A (en) * 2017-04-20 2017-06-20 腾讯科技(深圳)有限公司 A kind of message treatment method, server cluster and system
CN108040108A (en) * 2017-12-11 2018-05-15 杭州电魂网络科技股份有限公司 Communication handover method, device, coordination service device and readable storage medium storing program for executing
CN110928716A (en) * 2019-10-24 2020-03-27 江苏苏宁物流有限公司 Scheduling task exception handling method and device
CN111782431A (en) * 2020-06-22 2020-10-16 深圳乐信软件技术有限公司 Exception processing method, exception processing device, terminal and storage medium
CN111930529A (en) * 2020-10-09 2020-11-13 上海富友支付服务股份有限公司 Data synchronization method, module and system based on message queue and micro-service
CN112637335A (en) * 2020-12-22 2021-04-09 新华三大数据技术有限公司 Main/standby mode service deployment method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN113190371A (en) 2021-07-30

Similar Documents

Publication Publication Date Title
CN113190371B (en) Task compensation method and device, electronic equipment and readable storage medium
US6026499A (en) Scheme for restarting processes at distributed checkpoints in client-server computer system
CN109308227B (en) Fault detection control method and related equipment
CN107171825B (en) Repeated log filtering method for terminal
US8140908B2 (en) System and method of client side analysis for identifying failing RAM after a user mode or kernel mode exception
CN112463144B (en) Distributed storage command line service method, system, terminal and storage medium
US20160132420A1 (en) Backup method, pre-testing method for environment updating and system thereof
CN111770169A (en) Method, device, equipment and storage medium for upgrading equipment firmware
GB2518458A (en) Method for pre-testing software compatibility and system thereof.
CN111752696B (en) Distributed timing task scheduling method based on RPC and thread lock
CN109325016B (en) Data migration method, device, medium and electronic equipment
JP2785998B2 (en) Computer system
US8612799B2 (en) Method and apparatus of backing up subversion repository
CN112395050B (en) Virtual machine backup method and device, electronic equipment and readable storage medium
CN109462507B (en) Configuration updating method, device and system and electronic equipment
US6185702B1 (en) Method and system for process state management using checkpoints
JP3117958B2 (en) Server setting device
CN108241543B (en) Method, service server and system for executing service operation breakpoint
CN108804239B (en) Platform integration method and device, computer equipment and storage medium
CN109257235B (en) Network anomaly recovery method, device, equipment and computer readable storage medium
US20210382764A1 (en) Comparisons of application programming interface interactions to determine compatibilities
CN114385504A (en) Development and debugging method and device for microservice application
US10540175B2 (en) Up-level applications to a new OS
CN114356643B (en) Automatic task discovery failure and recovery method in remote sensing satellite processing system
US10282188B2 (en) Apparatus and method for creating modification application information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Information Technology Co.,Ltd.

Address before: 601, 6th floor, building 2, yard 18, Kechuang 11th Street, Beijing Economic and Technological Development Zone, Daxing District, Beijing

Applicant before: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant