Nothing Special   »   [go: up one dir, main page]

CN113190371A - 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
CN113190371A
CN113190371A CN202110539748.9A CN202110539748A CN113190371A CN 113190371 A CN113190371 A CN 113190371A CN 202110539748 A CN202110539748 A CN 202110539748A CN 113190371 A CN113190371 A CN 113190371A
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.)
Granted
Application number
CN202110539748.9A
Other languages
Chinese (zh)
Other versions
CN113190371B (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 Shuke Haiyi Information Technology Co Ltd
Original Assignee
Jingdong Shuke Haiyi 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 Shuke Haiyi Information Technology Co Ltd filed Critical Jingdong Shuke Haiyi 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

Images

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 task compensation device, an electronic device and a readable storage medium, wherein the method comprises the following steps: if the abnormal task is detected, the abnormal task is instantiated to obtain a target instance object; putting 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 using the target backup machine information; sending abnormal task information to the target backup machine so that the target backup machine can acquire a target instance object from the task queue according to the abnormal task information, and re-execute the abnormal task by using the target instance object and feed back an execution result; according to the method, the target backup machine is selected from the plurality of backup machines corresponding to the backup machine list according to the current situation for task compensation, the decentralized effect is achieved, servers serving as the backup machines and the local machine are mutually backed up, so that all abnormal tasks cannot be failed in compensation due to the abnormality of a single server, 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 application relates to the field of business system technologies, and in particular, to a task compensation method, a task compensation apparatus, an electronic device, and a computer-readable storage medium.
Background
In the operation process of the service system, a situation that part of task logic cannot normally operate or cannot normally end may occur, and in this situation, in order to ensure that the service system normally operates, these abnormal tasks need to be re-executed, that is, task compensation is performed. The related art is generally provided with a scheduling center, each server sends an abnormal task to the scheduling center, and the scheduling center triggers and executes the abnormal task by using a trigger. However, the task compensation mode using the scheduling center excessively depends on the scheduling center, and a failure of the scheduling center may cause a problem that a large amount of abnormal services cannot be compensated and executed, so that the robustness of the service system is poor.
Disclosure of Invention
In view of the above, an object of the present application is to provide a task compensation method, a task compensation apparatus, an electronic device, and a readable storage medium, which utilize each server as a backup machine and a local server to backup each other, so that an exception of a single server does not cause all abnormal task compensation failures, thereby improving the robustness of a service system.
In order to solve the above technical problem, in a first aspect, the present application provides a task compensation method, which specifically includes:
if the abnormal task is detected, performing instantiation processing on the abnormal task to obtain a target instance object;
putting 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 using the target backup machine information;
and 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, and re-execute the abnormal task by using the target instance object and feed back an execution result.
In a possible embodiment, the method further comprises:
if target task information sent by a target server is received, acquiring a target object from the task queue by using the target task information;
acquiring class name information and parameter information corresponding to the target task from a task compensation database table by using 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;
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 comprises:
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 generation process of the backup machine list includes:
acquiring an initial backup machine list, and testing the network connectivity among candidate backup machines in the initial backup machine list;
forming the backup machine list by using a target candidate backup mechanism communicated with all other candidate backup machines;
and if the situation 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.
In a possible embodiment, the method further comprises:
if the target network connection is detected to be disconnected, establishing a daemon thread;
judging whether the target network connection is recovered;
if the target network connection is recovered, 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 the abnormal task information to the target backup machine includes:
determining the target backup machine as a client, and putting the client into a global singleton object set;
establishing a remote method calling service between the target backup machine and a service port of a service system;
and sending the abnormal task information to the target backup machine through the remote method call service.
In a second aspect, the present application provides a task compensation apparatus, comprising:
the instantiation module is used for instantiating the abnormal task to obtain a target instance object if the abnormal task is detected;
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 a backup machine list and determining a target backup machine by using 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, and re-execute the abnormal task by using 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.
In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the task compensation method described above.
According to the task compensation method, if the abnormal task is detected, the abnormal task is instantiated, and a target instance object is obtained; putting 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 using the target backup machine information; and 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, and re-execute the abnormal task by using the target instance object and feed back an execution result.
Therefore, the method does not utilize a uniform dispatching center to compensate the abnormal tasks, but constructs a backup machine list, wherein backup machine information corresponding to at least two backup machines is recorded. After the abnormal task is detected, the abnormal task is instantiated to obtain a target instance object, and the target instance object is placed in a task queue, so that a subsequent backup machine can execute the abnormal task again by using the target instance object. Meanwhile, target backup machine information can be obtained from the backup machine list, the target backup machine information refers to information corresponding to a backup machine used for executing the task compensation, and the target backup machine can be determined by using the target backup machine information. By sending the abnormal task information, the target backup machine can acquire the target instance object by using the abnormal task information and execute the abnormal task, 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. The task compensation is not executed by the scheduling 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, so that the decentralized effect is realized, servers serving as the backup machines and the local machine are mutually backed up, the exception of a single server does not cause the failure of all the abnormal task compensation, the robustness of the 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 code of the business system does not need to be configured or code intrusion is not needed to be executed so as to realize task compensation, and the access standard and the intrusiveness to the business code are reduced.
In addition, the application also provides a task compensation device, an electronic device and a computer readable storage medium, which also 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 needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
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 provided in an embodiment of the present application;
fig. 3 is a schematic structural diagram of a task compensation apparatus according to an embodiment of the present disclosure;
fig. 4 is a hardware composition framework diagram applicable to a task compensation method according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in 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 obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
When the related technology re-executes the abnormal task, namely, when task compensation is performed, a distributed timing task mode is adopted for performing. The whole process comprises the following steps:
1. when the abnormal task is detected, a compensation task processor corresponding to the abnormal task is defined.
2. And registering the defined compensation task processor to a dispatching center, wherein the registration process comprises the configuration of the compensation frequency.
3. The dispatching center establishes a trigger aiming at 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 the trigger calls the task processor after being triggered, and the task processor calls the specific implementation class of the task to execute the task.
6. When the task is completed normally, modifying the task state to avoid repeated triggering, otherwise, repeating the steps 4-6.
Therefore, the whole task compensation process depends heavily on the scheduling center, and the scheduling center is responsible for re-executing all abnormal tasks. When the scheduling center has faults and other abnormalities, the compensation of all the abnormal tasks fails, so that the robustness of the service system is poor. Meanwhile, in order to implement the above steps, configuration and code intrusion are also required in a normal business system, so that the code intrusion on the business system is high. In addition, the dispatch center is usually physically far away from the devices such as the servers of the service system, for example, it is usually deployed across a computer room, which makes the task compensation process susceptible to the network state.
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 disclosure. The method comprises the following steps:
s101: and if the abnormal task is detected, performing instantiation processing on the abnormal task to obtain a target instance object.
The abnormal task is a task that does not end normally (or becomes logic), or a task whose execution result is not a normal result, and the specific type, number, and the like of the abnormal task 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 normally executed on other servers and cannot be normally executed when the current server performs task compensation. The current server refers to a server that performs all or part of the steps in the present application, and in this embodiment, the identity of the current server is the local server, and the local server refers to a server that calls other servers as backup machines.
In an embodiment, the task execution result may be compared with a preset legal result, and when the task execution result is inconsistent with the preset legal result, the task is determined to be an abnormal task; in another embodiment, a task having an execution time greater than a preset time may be determined as an abnormal task.
After the abnormal task is detected, the abnormal task can be instantiated to obtain a corresponding object, namely a target instance object. Instantiation refers to the process of creating an object by using a class in the process of object-oriented programming, and a target instance object is the object created by using the class of an abnormal task. In a specific implementation manner, a blank object may be preset, and when the instantiation process is performed, some information (for example, identity information) corresponding to the abnormal task is written into the blank object, so that the corresponding target instance object can be obtained. According to different instantiation processing modes, the instantiation processing process may also be different, and the specific mode and process may refer to related technologies, which is not described again in this embodiment.
S102: and putting 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 to be executed normally and objects corresponding to tasks needing to be compensated (i.e., abnormal tasks) may be placed therein. After the target instance object is obtained, the target instance object is filled into the task queue, so that the backup machine is allowed to obtain the target instance object from the task queue subsequently, and further, the abnormal task is recovered by using the target instance object.
S103: and acquiring the information of the target backup machine from the backup machine list, and determining the target backup machine by using the information of the target backup machine.
The backup machine list is a list for recording backup machine information corresponding to each backup machine, wherein the number of the recorded backup machine information is not limited. The backup machine list may be a global list, that is, all servers in the service system may determine a required backup machine by using the backup machine list when task compensation is required. In another embodiment, the backup machine lists may respectively correspond to the servers, that is, each server respectively constructs a backup machine list corresponding to itself, and when task compensation is required, determines the target backup machine by using the backup machine list of itself.
The backup machine information refers to information capable of representing the identity of the backup machine, and may be in the form of an IP Address (i.e., Internet Protocol Address), or may be in other forms, such as a server number, a server hardware Address (i.e., MAC Address, Media Access Control Address), and the like. The target backup machine information refers to one piece of backup machine information specified in the backup machine list, and is not limited specifically, for example, the first backup machine information in the list may be, or the last backup machine information may be, or the backup machine information corresponding to a certain fixed sequence number in the middle may be. It should be noted that, in order to distribute the task compensation work to the largest number of servers as possible, after selecting the target backup machine information each time, the backup machine list needs to be updated so as to perform task compensation by using another server when an abnormal task occurs again. For example, when the target backup machine information is the first backup machine information in the list, the update mode may be to place the target backup machine information in the last position of the backup machine list, and sequentially update the serial numbers of other backup machine information 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 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, and re-execute the abnormal task by using the target instance object and feed back an execution result.
The abnormal task information refers to information corresponding to the 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 information), or may be 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 backup machine and the target backup machine. The embodiment does not limit the specific way of sending the abnormal task information, and in an implementation, the call request may be sent by using a remote method call service, where the call request includes the abnormal task information, and controls the target backup machine to perform task compensation. Among them, Remote Method Invocation service, namely Remote Method Invocation, RMI service supports mutual communication between program-level objects stored in different address spaces, and realizes seamless Remote Invocation between Remote objects. It should be noted that before invoking the target backup machine by using the RMI service to perform task compensation, the RMI service between the local machine and the target backup machine needs to be initialized, and a specific initialization process may refer to related technologies and 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 local machine. It should be noted that, this embodiment does not limit whether other data is needed to re-execute the exception task, for example, in an embodiment, data such as class name information and method entry parameters of the exception task needs to be obtained.
In one embodiment, when task compensation is performed by using RMI service, the target backup machine receives a call request sent by the local machine, acquires a corresponding execution class and an execution method in a reflection manner, and calls (i.e., invoke) the corresponding method to obtain an execution result. After obtaining the execution result, the target backup machine may directly feed back the execution result to the local machine, or may first determine whether the execution result is normal, 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 uniform scheduling center, but a backup machine list is constructed, wherein backup machine information corresponding to at least two backup machines is recorded. After the abnormal task is detected, the abnormal task is instantiated to obtain a target instance object, and the target instance object is placed in a task queue, so that a subsequent backup machine can execute the abnormal task again by using the target instance object. Meanwhile, target backup machine information can be obtained from the backup machine list, the target backup machine information refers to information corresponding to a backup machine used for executing the task compensation, and the target backup machine can be determined by using the target backup machine information. By sending the abnormal task information, the target backup machine can acquire the target instance object by using the abnormal task information and execute the abnormal task, 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. The task compensation is not executed by the scheduling 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, so that the decentralized effect is realized, servers serving as the backup machines and the local machine are mutually backed up, the exception of a single server does not cause the failure of all the abnormal task compensation, the robustness of the 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 code of the business system does not need to be configured or code intrusion is not needed to be executed so as to realize task compensation, and the access standard and the intrusiveness to the business code are reduced.
Based on the above embodiments, the present embodiment will specifically describe several steps in the above embodiments. In order to ensure the reliability of the task execution result, the problems of inconsistent execution results and unreliability caused by the concurrent execution of abnormal tasks are prevented. The process of sending the abnormal task information to the target backup machine may specifically include the following steps:
step 11: and determining the target backup machine as a client, and putting the client into the global singleton object set.
And after the target backup machine is determined, determining the target backup machine as a client, and adding the target backup machine into the global singleton object set. The global singleton object set is a set used for storing singleton objects, and the client is used as the singleton object, so that each abnormal task can be individually in one-to-one correspondence with the corresponding backup machine, and the concurrence condition is prevented. The embodiment does not limit the specific manner of putting the client into the global single instance object set, and reference may be made to related technologies, which are not described herein again.
Step 12: and establishing a remote method call service between the target backup machine and the service system service port.
Step 13: and sending abnormal task information to the target backup machine through the remote method calling service.
The remote method utility service is an RMI service, the process of establishing the 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 by using the service port.
Further, based on the above embodiments, it can be understood that before the backup machine list is used to determine the target backup machine, an accurate backup machine list needs to be generated, and the global backup machine list can make the task compensation more evenly distributed on each backup machine, so the generation process of the backup machine list may include the following steps:
step 21: and acquiring an initial backup machine list, and testing the network connectivity among the candidate backup machines in the initial backup machine list.
The initial backup machine list records backup machine information corresponding to a plurality of candidate backup machines, where a candidate backup machine refers to a server capable of serving as a backup machine, and may specifically be all servers in a service system or may be a part of servers therein. Because the server serving as the backup machine can also serve as the local machine, and the abnormal tasks with abnormal operation of the server can be compensated by calling other servers, the communication of any two networks of all the backup machines needs to be ensured. Therefore, after the initial backup machine list is obtained, the network connectivity among the candidate backup machines is tested, and the backup machine is selected according to the test result. The embodiment does not limit the specific test mode of network connectivity, and 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 mechanism communicated with all other candidate backup machines.
After the test result is obtained through the test, the target candidate backup machines which are communicated with the networks among all other candidate backup machines are determined as the backup machines, and a backup machine list is formed by using the target candidate backup machines.
Step 23: and if the target network connection disconnection between the two target candidate backup machines is detected in the backup machine list, 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 server recorded therein is also a local server when the service system operates, and each server may be a backup machine. After the backup machine list is established, the network connection between the target candidate backup machines can be continuously detected, whether the target candidate backup machines are disconnected or not is judged, and when the target network connection between any two target candidate backup machines is detected to be disconnected, 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 machines related to the target network connection (namely, the disconnected network connection), it can be ensured that any backup machine corresponding to the backup machine list can call any other target candidate backup machine recorded in the backup machine list as the backup machine when the backup machine is used as the local machine.
The present embodiment does not limit the specific number of target network connections, and when the number of target network connections is multiple, the target network connections 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 target network connection is disconnected, an attempt may be made to restore the target network connection, and when the disconnected network connection is restored, the related target candidate backup machines are added back to the backup machine list. Specifically, the method can further comprise the following steps:
step 31: and if the disconnection of the target network is detected, establishing a daemon thread.
The daemon threads can run in the background and can daemon all the non-daemon threads, and as long as any non-daemon thread is not finished, all the daemon threads work. A daemon thread is established with which attempts can be made to restore the target network connection.
Step 32: and judging whether the target network connection is recovered.
Step 33: and if the target network connection is recovered, adding the target candidate backup machine corresponding to the target network connection into a backup machine list.
If the target network connection is restored, it indicates that data can be transmitted between the target candidate backup machines designed by the target network connection, and the two backup machines can be the relationship between the host machine and the backup machine, so that the data can be added into the backup machine list again.
Step 34: and if the target network connection is not recovered, recovering the target network connection by using the daemon thread according to the preset recovery frequency.
The preset restoration frequency is the frequency at which the daemon thread tries to restore the target network connection, the specific size of the preset restoration frequency is not limited, and when the target network connection is determined not to be restored, the daemon thread can be used for trying to restore the target network connection at a time point meeting the preset restoration frequency.
Based on the above embodiment, in practical applications, the local computer executing steps S101 to S104 may also be called as a backup computer of another server. Referring to fig. 2 in detail, fig. 2 is a flowchart of another task compensation method provided in the embodiment of the present application, including:
s201: and if the target task information sent by the target server is received, acquiring the target object from the task queue by using the target task information.
The target server refers to another server that calls the current server, and in this embodiment, the current server is a backup machine that accepts calls, and the target server is a local machine. It can be understood that, if the RMI service is used to acquire target task information sent by the target server, the RMI service needs to be established with the target server before acquiring the target task information.
After the target task information is obtained, the target task information can be used to obtain a corresponding object, namely a target object, from the task queue. The target object is obtained after the target server performs instantiation processing on the target task.
S202: and acquiring class name information and parameter information corresponding to the target task from the task compensation database table by using 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 is specifically a global table covering each server of the whole service system. In this embodiment, the task compensation database table at least includes target task information, and class name information (i.e., classname) and parameter information (i.e., method parameter) corresponding to the target task information, and may further include other data items in addition to the target task information. In one possible implementation, the task compensation database table may be of the form:
Figure BDA0003071201010000121
wherein, Job _ id refers to a serial number used for uniquely identifying the current task, namely the target task information; job _ params refers to method entry parameter of the current task, namely parameter information, and is stored in a format of jsonStr; job _ executor refers to className of the target method, i.e., class name information; status refers to a task state, wherein 1 represents that a task is newly built, 2 represents that the task is being executed, 3 represents that the execution is successful, and 4 represents that the execution fails; the Limit refers to an upper Limit threshold of the compensation times of the current task; target _ domain refers to the server ip (i.e. original server information) to which the current task originally belongs; times refers to the number of Times the current task has been retried (i.e., has been compensated for execution); create _ date refers to the creation time of the current task;
modify _ 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 to obtain corresponding class name information and parameter information. The class name information and the parameter information are data necessary for executing the target task, and the specific content and number thereof are not limited. In this embodiment 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 the class name information, the parameter information and the target object are obtained, the target task is re-executed by using the class name information, the parameter information and the target object, the specific execution mode of the target task is not limited, and the specific execution process can be different according to different target tasks. After the target execution result is obtained, the target execution result may be fed back to the target server.
In one embodiment, the target execution result can be directly fed back to the target server after being obtained, and in another embodiment, the target execution result can be legally detected. Specifically, 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:
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.
In this embodiment, after the target task is re-executed by using the class name information, the parameter information, and the target object, a result directly obtained is an initial execution result. After the initial execution result is obtained, whether the initial execution result is legal or not is judged, namely whether the initial execution result is a legal result or not is judged. For the specific determination method, in a feasible implementation manner, it may be determined whether the initial execution result matches the preset result, and if so, the result is determined to be a legal result.
Step 43: and if the result is a legal result, determining the initial execution result as a target execution result.
Step 44: and if the target task is not a legal result, determining the target task as an abnormal task.
And if the initial execution result is a legal result, determining the initial execution result as a target execution result, and directly feeding back the target execution result to the target server. If the initial execution result is not a legal result, in other embodiments, the initial execution result may also 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 speed of task compensation and reduce the waste of computing resources, it may be determined as an abnormal task, and the current server is 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, the task compensation database table records data items such as task status. Because the task compensation database table is a global table, any server can modify the task compensation database table and the like, 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 may further include the following steps.
Step 51: and modifying the target data item corresponding to the target task in the task compensation database table according to the execution condition of the target task.
In this embodiment, the target data item includes task status, execution times, and information of the origin server, and in addition, may include other information, which may specifically refer to the description of the task compensation database table. The execution condition of the target task can be executing, successful executing or failed executing, and according to the execution condition, the current server can directly modify the corresponding target data item without modifying by the target server, so that the updating efficiency and speed of the information in the database table are improved.
In the following, the task compensation device provided by the embodiment of the present application is introduced, 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 apparatus 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;
and the task compensation module 140 is configured to send the 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, and 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 using 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 using the target task information;
the execution module is used for re-executing the target task by utilizing 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 utilizing the class name information, the parameter information and the target object to obtain an initial execution result;
a legal judging unit for judging whether the initial execution result is a legal result;
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 the abnormal task if the target task is not the 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, comprising:
the network testing module is used for acquiring an initial backup machine list and testing the network connectivity among candidate backup machines in the initial backup machine list;
the list construction module is used for forming a backup machine list by using a target candidate backup mechanism which is 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 is detected 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 is detected;
the recovery judging module is used for judging whether the target network connection is recovered;
the joining module is used for joining the target candidate backup machine corresponding to the target network connection into the backup machine list if the target network connection is recovered;
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 singleton processing unit is used for determining the target backup machine as a client and putting the client into a global singleton object set;
the service establishing unit is used for establishing a remote method calling service with the target backup machine according to the service port of the service 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.
In the following, the electronic device provided by the embodiment of the present application is introduced, 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 hardware composition framework diagram for a task compensation method according to an embodiment of the present disclosure. 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.
The processor 101 is configured to control the overall operation of the electronic device 100 to complete all or part of the steps in the task compensation method; the memory 102 is used to store various types of data to support operation at the electronic device 100, such data 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 and non-volatile Memory devices, such as one or more of Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk. In the present embodiment, the memory 102 stores therein at least programs and/or data for realizing the following functions:
if the abnormal task is detected, performing instantiation processing on the abnormal task to obtain a target instance object;
putting 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 using the target backup machine information;
and 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, and re-execute the abnormal task by using the target instance object and feed 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 and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 102 or transmitted through the communication component 105. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 104 provides an interface between the processor 101 and other interface modules, such as 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 (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 105 may include: Wi-Fi part, Bluetooth part, NFC part.
The electronic Device 100 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components, and is configured to perform the task compensation method according to the above embodiments.
Of course, the structure of the electronic device 100 shown in fig. 4 does not constitute a limitation of the electronic device in the embodiment of the present application, and in practical applications, the electronic device 100 may include more or less components than those shown in fig. 4, or some components may be combined.
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 further provides a readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the task compensation method described above.
The readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components 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 components and steps have been described above generally in terms of their functionality in order to clearly illustrate this 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 implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present 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. A software module may reside 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 should also be noted that, herein, relationships such as first and second, etc., are intended only 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. Also, the terms include, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes 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 principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A task compensation method, comprising:
if the abnormal task is detected, performing instantiation processing on the abnormal task to obtain a target instance object;
putting 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 using the target backup machine information;
and 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, and re-execute the abnormal task by using the target instance object and feed 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 using the target task information;
acquiring class name information and parameter information corresponding to the target task from a task compensation database table by using 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 of claim 2, wherein the 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;
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. A task compensation method according to any one of claims 1 to 4, wherein the generation process of the backup machine list comprises:
acquiring an initial backup machine list, and testing the network connectivity among candidate backup machines in the initial backup machine list;
forming the backup machine list by using a target candidate backup mechanism communicated with all other candidate backup machines;
and if the situation 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.
6. The task compensation method of claim 5, further comprising:
if the target network connection is detected to be disconnected, establishing a daemon thread;
judging whether the target network connection is recovered;
if the target network connection is recovered, 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 of the abnormal task information to the target backup machine comprises:
determining the target backup machine as a client, and putting the client into a global singleton object set;
establishing a remote method calling service between the target backup machine and a service port of a service system;
and sending the abnormal task information to the target backup machine through the remote method call service.
8. A task compensation apparatus, comprising:
the instantiation module is used for instantiating the abnormal task to obtain a target instance object if the abnormal task is detected;
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 a backup machine list and determining a target backup machine by using 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, and re-execute the abnormal task by using 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 for executing 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 true CN113190371A (en) 2021-07-30
CN113190371B 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)

Cited By (3)

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

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017647A1 (en) * 2006-08-11 2010-01-21 Chicago Mercantile Exchange, Inc. Match server for a financial exchange having fault tolerant operation
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
US20200117750A1 (en) * 2018-10-11 2020-04-16 EMC IP Holding Company LLC Highly Resilient Synchronous Replication With Automatic Recovery
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

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017647A1 (en) * 2006-08-11 2010-01-21 Chicago Mercantile Exchange, Inc. Match server for a financial exchange having fault tolerant operation
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
US20200117750A1 (en) * 2018-10-11 2020-04-16 EMC IP Holding Company LLC Highly Resilient Synchronous Replication With Automatic Recovery
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

Cited By (6)

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

Also Published As

Publication number Publication date
CN113190371B (en) 2024-04-05

Similar Documents

Publication Publication Date Title
CN108170740B (en) Data migration method, system and computer readable storage medium
CN113190371A (en) Task compensation method and device, electronic equipment and readable storage medium
CN109347675B (en) Server configuration method and device and electronic equipment
US20220147367A1 (en) Method and System for Automation Tool Set for Server Maintenance Actions
CN110324174B (en) Block chain environment detection method, equipment, device and storage medium
CN111770169A (en) Method, device, equipment and storage medium for upgrading equipment firmware
US10853227B2 (en) Systems and methods for modular test platform for applications
CN109308227B (en) Fault detection control method and related equipment
CN112637346A (en) Proxy method, device, proxy server and storage medium
CN112463144B (en) Distributed storage command line service method, system, terminal and storage medium
CN110569035A (en) Code compiling method, device, equipment and storage medium of software development project
CN112148315A (en) Software deployment method, device, server and storage medium
US8612799B2 (en) Method and apparatus of backing up subversion repository
CN110750415B (en) Interface service configuration method, device, medium and computer equipment
CN111770174A (en) Cloud platform deployment method, device, equipment and readable storage medium
CN110780918A (en) Middleware container processing method and device, electronic equipment and storage medium
CN112199178A (en) Cloud service dynamic scheduling method and system based on lightweight container
US20130086572A1 (en) Generation apparatus, generation method and computer readable information recording medium
CN108132832B (en) Application program starting method and device
CN116257438A (en) Updating method of interface test case and related equipment
CN111324419A (en) Deployment method, device, equipment and storage medium of combined container
CN113419818A (en) Basic component deployment method, device, server and storage medium
CN115221156A (en) Database cluster capacity expansion method and device, computer equipment and storage medium
CN112506590A (en) Interface calling method and device and electronic equipment
CA2997302C (en) Application migration

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

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.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant