CN117632408A - Task execution method and device, electronic equipment and storage medium - Google Patents

Task execution method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117632408A
CN117632408A CN202311451085.0A CN202311451085A CN117632408A CN 117632408 A CN117632408 A CN 117632408A CN 202311451085 A CN202311451085 A CN 202311451085A CN 117632408 A CN117632408 A CN 117632408A
Authority
CN
China
Prior art keywords
task
target
execution
unique key
record table
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.)
Pending
Application number
CN202311451085.0A
Other languages
Chinese (zh)
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.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp 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 China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202311451085.0A priority Critical patent/CN117632408A/en
Publication of CN117632408A publication Critical patent/CN117632408A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention provides a method, a device, electronic equipment and a storage medium for executing tasks, wherein the method comprises the following steps: receiving a task execution right request of a target task of any target server in the distributed cluster; generating a target unique key aiming at a target task according to the task execution request; judging whether a target unique key is stored in a task execution record table; when the target unique key is not stored in the task execution record table, the target unique key is newly added into the task execution record table, and the task execution right of the target task is issued for the target server so as to execute the target task through the target server. According to the embodiment of the invention, the servers of the distributed cluster can be managed, so that a plurality of servers can be prevented from executing the same task at the same time.

Description

Task execution method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of distributed technologies, and in particular, to a method and apparatus for executing a task, an electronic device, and a storage medium.
Background
In a distributed environment, multiple timed task services may query the same timed task at the same time and attempt to execute the task at the same time. At this time, a plurality of task services may simultaneously execute the same task, thereby causing repeated execution of the task and inconsistency of data.
Disclosure of Invention
In view of the foregoing, it is proposed to provide a method, apparatus, electronic device and storage medium for performing a task that overcomes or at least partially solves the foregoing problems, comprising:
a method for executing tasks, applied to a distributed cluster, where the distributed cluster includes a plurality of servers for executing tasks, and a task execution record table is set for the distributed cluster, the method includes:
receiving a task execution right request of a target task of any target server in the distributed cluster;
generating a target unique key aiming at the target task according to the task execution request;
judging whether the target unique key is stored in the task execution record table or not;
and when the target unique key is not stored in the task execution record table, newly adding the target unique key into the execution task record table, and issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
Optionally, the task execution request includes a task name stored in an annotation form, and the generating, according to the task execution request, a target unique key for the target task includes:
and generating a target unique key aiming at the target task according to the task name and the timestamp.
Optionally, the generating a target unique key for the target task according to the task name and the timestamp includes:
formatting the timestamp;
and generating the target unique key according to the formatted time stamp and the task name.
Optionally, the task execution request further includes an open instruction stored in a form of an annotation, and the method further includes:
judging the type of the opening instruction, wherein the type comprises opening and non-opening;
and when the type of the opening instruction is opening, executing the step of generating a target unique key aiming at the target task according to the task execution request.
Optionally, the adding the target unique key to the task execution record table and issuing the task execution right of the target task for the target server includes:
executing the operation of newly adding the target unique key into the execution task record table, and judging whether the target unique key is newly added into the execution task record table;
when the target unique key is newly added into the execution task record table, the operation of updating the version number of the target task is executed;
and when the version number updating aiming at the target task is completed, issuing the task execution right of the target task for the target server.
Optionally, the method further comprises:
after the operation of newly adding the target unique key into the execution task record table is executed, if the target unique key is not successfully added into the execution task record table, performing abnormal record on the target server;
after the operation of updating the version number of the target task is executed, if the version number of the target task is not updated successfully, the exception record is carried out for the target server.
Optionally, the method further comprises:
and when the abnormal records carried out on each server in the distributed cluster meet the preset conditions, carrying out alarm reminding on the distributed cluster.
The embodiment of the invention also provides a task execution device, which is applied to a distributed cluster, wherein the distributed cluster comprises a plurality of servers for executing tasks, and a task execution record table is arranged for the distributed cluster, and the device comprises:
the request module is used for receiving a task execution right request of a target task of any target server in the distributed cluster;
the unique key generation module is used for generating a target unique key aiming at the target task according to the task execution request;
the first judging module is used for judging whether the target unique key is stored in the task execution record table or not;
and the execution module is used for newly adding the target unique key into the execution task record table when the target unique key is not stored in the task execution record table, and issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
Optionally, the task execution request includes a task name stored in an annotation form, and the unique key generating module is configured to generate a target unique key for the target task according to the task name and the timestamp.
Optionally, the unique key generating module is configured to format the timestamp; and generating the target unique key according to the formatted time stamp and the task name.
Optionally, the task execution request further includes an open instruction stored in a form of an annotation, and the apparatus further includes:
the second judging module is used for judging the type of the opening instruction, wherein the type comprises opening and non-opening;
and the unique key generation module is used for generating a target unique key aiming at the target task according to the task execution request when the type of the opening instruction is opening.
Optionally, the execution module is configured to perform an operation of adding the target unique key to the execution task record table, and determine whether to add the target unique key to the execution task record table; when the target unique key is newly added into the execution task record table, the operation of updating the version number of the target task is executed; and when the version number updating aiming at the target task is completed, issuing the task execution right of the target task for the target server.
Optionally, the apparatus further comprises:
the abnormality detection module is used for performing abnormality recording on the target server if the target unique key is not successfully added into the execution task record table after performing the operation of adding the target unique key into the execution task record table; after the operation of updating the version number of the target task is executed, if the version number of the target task is not updated successfully, the exception record is carried out for the target server.
Optionally, the apparatus further comprises:
and the abnormality reminding module is used for carrying out alarm reminding on the distributed cluster when the abnormality records carried out on each server in the distributed cluster meet the preset conditions.
The embodiment of the invention also provides electronic equipment, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the execution method of the task when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the execution method of the task when being executed by a processor.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, a task execution right request of a target task of any target server in a distributed cluster is received; generating a target unique key aiming at a target task according to the task execution request; judging whether a target unique key is stored in a task execution record table; when the target unique key is not stored in the task execution record table, the target unique key is newly added into the task execution record table, and the task execution right of the target task is issued for the target server so as to execute the target task through the target server. According to the embodiment of the invention, the servers of the distributed cluster can be managed, so that a plurality of servers can be prevented from executing the same task at the same time.
Drawings
In order to more clearly illustrate the technical solutions of the present invention, the drawings that are needed in the description of the present invention will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flow chart of steps of a method of performing a task according to an embodiment of the present invention;
FIG. 2 is a flow chart of steps of another method of performing tasks according to an embodiment of the invention;
FIG. 3 is a flowchart of steps for performing tasks according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an application scenario according to an embodiment of the present invention;
FIG. 5 is a flow chart of the steps of the deployment of the method of an embodiment of the present invention;
FIG. 6 is a schematic diagram of a deployment method of an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a task execution device according to an embodiment of the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description. It will be apparent that the described embodiments are some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a step flow diagram of a task execution method according to an embodiment of the present invention is shown, where the method may be applied to a distributed cluster, where the distributed cluster may include a plurality of servers for executing tasks, and the plurality of servers may execute different tasks in a task set or one task in a distributed manner, so as to improve efficiency; for the distributed cluster, a task execution record table may be provided that records tasks executed by the respective servers;
the method may comprise the steps of:
step 101, receiving a task execution right request of a target task of any target server in the distributed cluster.
In some possible embodiments, when a server in the distributed cluster queries a target task and attempts to execute the target task, a target task execution right request may be generated to request that task execution rights to execute the target task be obtained.
By way of example, task execution rights may be issued by a distributed computing system of a distributed cluster; distributed computing systems may also be used to manage servers in a distributed cluster.
Step 102, generating a target unique key aiming at a target task according to the task execution request.
To avoid multiple servers executing the same target task at the same time, a unique key may be used for constraint; specifically, a target unique key for the target task may be generated according to the task execution request, and the target unique key may be used to determine that the execution of the target task is unique, and based on the unique target unique key, the execution of the target task may be managed.
Step 103, judging whether the target unique key is stored in the task execution record table.
Specifically, after the target unique key of the target task is generated, it may be first determined whether the target unique key is stored in the task execution record table, so as to know whether other servers have previously executed the target task.
If the task execution record table stores the target unique key, the task execution record table can indicate that other servers execute the target task in advance; at this time, the task execution right of the target task may not be issued to the target server, so as to avoid that the target server executes the target task and causes the target task to be repeatedly executed.
And 104, when the target unique key is not stored in the task execution record table, adding the target unique key to the task execution record table, and issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
If the task execution record table does not store the target unique key, the task execution record table can indicate that no other servers execute the target task before; at this time, the distributable computing system may issue a task execution right to execute the target task to the target server so that the target server may execute the target task.
In addition, in order to avoid that the executed task is repeatedly executed by other servers, after the fact that the target unique key is not stored in the task execution record table is determined, the target unique key can be added into the execution task record table, so that when the other servers request to issue the task execution right of the target task, the plurality of servers can be prevented from executing the same target task at the same time based on the stored target unique key.
In the embodiment of the invention, a task execution right request of a target task of any target server in a distributed cluster is received; generating a target unique key aiming at a target task according to the task execution request; judging whether a target unique key is stored in a task execution record table; when the target unique key is not stored in the task execution record table, the target unique key is newly added into the task execution record table, and the task execution right of the target task is issued for the target server so as to execute the target task through the target server. According to the embodiment of the invention, the servers of the distributed cluster can be managed, so that a plurality of servers can be prevented from executing the same task at the same time.
Referring to fig. 2, a flowchart illustrating steps of another method for performing tasks according to an embodiment of the present invention may include the following steps:
step 201, receiving a task execution right request of a target task of any target server in the distributed cluster.
In some possible embodiments, when a server in the distributed cluster queries a target task and attempts to execute the target task, a target task execution right request may be generated to request that task execution rights to execute the target task be obtained. In particular, task execution rights may be issued by the distributed computing systems of the distributed cluster.
Step 202, the task execution request comprises a task name stored in an annotation form, and a target unique key aiming at a target task is generated according to the task name and a timestamp.
In some possible embodiments, the task execution request may include a task name stored in the form of an annotation; when the target unique key is generated, the target unique key may be generated based on the system name corresponding to the target task (i.e., the system name of the access method), the task name of the target task, and the timestamp of the current execution of the target task.
By way of example, the unique key may be a system name + a timed task name + yyymmddhhmms; for example: the system name is cps_xxxx, the timing task name is xxxxTask, the timestamp is 202308220000, and the unique target key can be: cps_xxxx_xxxxtask_202308220000.
In one embodiment of the invention, the target unique key may be generated by the sub-steps of:
and a substep 11, formatting the time stamp.
In some possible embodiments, the time stamp may be formatted first to obtain a pre-formatted time stamp.
And a sub-step 12 of generating a target unique key according to the formatted time stamp and the task name.
After the timestamp is formatted, a target unique key can be generated based on the formatted timestamp and the task name; illustratively, if the time stamp is 2023, 8, 22, 00 minutes, 00 seconds, the time stamp may be converted into a preset format, thereby obtaining 202308220000. Based on the formatted time stamp, a target unique key may be generated with the task name and the system name.
In an embodiment of the present invention, before the step of generating the target unique key is performed, the method may further include the steps of:
the task execution request also comprises an opening instruction stored in an annotation form, and the type of the opening instruction is judged, wherein the type comprises opening and non-opening; when the type of the open instruction is open, a step of generating a target unique key for the target task according to the task execution request is performed.
In some possible embodiments, an attribute description may be added to the annotation, in particular, an open instruction may be added to the annotation, which may include an open type and a non-open type; whether to turn on the annotation may be indicated by an enable attribute, for example.
If the opening instruction is judged to be an opening instruction, the generated target unique key can be further executed; otherwise, the steps may be ended.
For example: the enable attribute may fill true/false, true is on, false is not on, and default to true-on if not filled.
Step 203, determining whether the task execution record table stores the target unique key.
After the target unique key of the target task is generated, it may be determined whether the target unique key is stored in the task execution record table, so as to know whether other servers have previously executed the target task.
If the task execution record table stores the target unique key, the task execution record table can indicate that other servers execute the target task in advance; at this time, the task execution right of the target task may not be issued to the target server, so as to avoid that the target server executes the target task and causes the target task to be repeatedly executed.
And 204, when the target unique key is not stored in the task execution record table, executing the operation of newly adding the target unique key to the execution task record table, and judging whether the target unique key is newly added to the execution task record table.
If the task execution record table does not store the target unique key, the task execution record table can indicate that no other servers execute the target task before; at this time, the distributable computing system may issue a task execution right to execute the target task to the target server so that the target server may execute the target task.
In addition, in order to avoid that the executed task is repeatedly executed by other servers, after the fact that the target unique key is not stored in the task execution record table is determined, the target unique key can be added into the execution task record table, so that when the other servers request to issue the task execution right of the target task, the plurality of servers can be prevented from executing the same target task at the same time based on the stored target unique key.
In some possible embodiments, to ensure that both the new addition and the update are performed by the same server, it may be determined whether the new addition of the target unique key to the execution task record table is successful or not after the new addition of the target unique key to the execution task record table is performed.
Step 205, when the target unique key is newly added to the execution task record table, the operation of updating the version number of the target task is executed.
If the fact that the target unique key is added to the execution task record table is detected to be successful, the operation of updating the version number of the target task can be further executed; the default version number may be 0, and the operation of updating the version number may be an operation of increasing or decreasing based on the default version number; the specific operation may be set according to the actual situation, for example: when the method is used for killing commodities in seconds, the number of the commodities can be used as a version number, and when the method is updated, a 'subtracting' operation can be performed; when the mobile phone number is used for registering a unique mobile phone number, the version number is 0 when the mobile phone number is not registered, and when the mobile phone number is registered, the version number is 1, and the embodiment of the invention is not limited to this.
In an embodiment of the present invention, after the operation of adding the target unique key to the execution task record table is executed, if the target unique key is not successfully added to the execution task record table, the exception record is performed for the target server.
In some possible embodiments, after the operation of adding the target unique key to the execution task record table is completed, whether the target unique key is successfully added to the execution task record table may be detected; if the target unique key is not successfully added to the execution task record table because of a network or the like, an abnormal recording may be performed for the target server so that a disk duplication or the like may be performed based on the recording later.
And 206, when the version number updating for the target task is completed, issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
In some possible embodiments, after updating the version number of the target task is completed, the target server may be issued with task execution rights for executing the target task, so as to execute the target task through the target server.
In an embodiment of the present invention, after the operation of updating the version number of the target task is performed, if the version number of the target task is not updated successfully, an exception record is performed for the target server.
In some possible embodiments, after the operation of updating the version number of the target task is performed, whether the version number of the target task is successfully updated may be detected; if the version number of the target task is not successfully updated because of a network or the like, an abnormal recording may be performed with respect to the target server so that a disk duplication or the like may be performed based on the recording later.
In some possible implementations, the execution task record table may be rolled back when the update version number fails or the new target unique key fails.
In an embodiment of the present invention, the method may further include the following steps:
and when the abnormal records carried out on each server in the distributed cluster meet the preset conditions, carrying out alarm reminding on the distributed cluster.
In some possible embodiments, after the anomaly record is performed on each server, the number of anomalies occurring on each server in the distributed cluster may be counted; when the times meet preset conditions, warning reminding can be carried out aiming at the distributed cluster; for example, when the number of times is equal to the number of servers in the distributed cluster, it may be determined that the abnormal records made for the respective servers in the distributed cluster satisfy a preset condition; at this time, the alarm reminding can be performed for a plurality of servers in the distributed cluster.
In other possible embodiments, when the execution frequency of the timing tasks is higher or the number of the timing tasks is larger, regular data archiving needs to be performed on the execution log record table, and when statistical analysis needs to be performed on information such as the frequency of competing execution rights of the server where the deployment is located, the specific operation steps are as follows:
inquiring the execution right data of the server in the execution log record table and the archive table according to the time period to be counted; the analysis results are visually presented and the data may be presented using charts, graphs, or other visualization tools. For example, a line graph or bar graph may be drawn to show the execution weight frequencies of different servers for comparison and analysis; according to the analysis result, the execution right competition result condition among different servers is obtained, so that the performance and resource utilization of the servers can be optimized, and the response speed and stability of the system are improved;
by way of example, the method can be integrated into projects in a jar packet mode for use, the problem that a large number of server resource clusters are required to be deployed like a traditional distributed timing task scheduling framework is avoided, steps of network IO are reduced during treatment, and the user is ensured to be lighter and more efficient in use.
In the above method, the following method may be further mentioned:
task slicing: the timed task is split into a plurality of small task segments, each segment being responsible for executing a portion of the task content. Therefore, tasks can be distributed to a plurality of nodes to be executed in parallel, and concurrency of the tasks is improved.
Node coordination: by a coordination mechanism, the task fragments among the nodes are ensured to be distributed evenly and repeatedly. Coordination between nodes may be achieved using distributed locks, distributed queues, and the like.
Fault tolerant mechanism: in a distributed environment, node failure is a common situation, and therefore a fault tolerance mechanism needs to be designed. When one node fails, other nodes can take over the task fragments thereof, and reliable execution of the tasks is ensured.
Task scheduling and monitoring: a centralized scheduler is required to take care of task scheduling and monitoring. The scheduler is responsible for distributing tasks to each node and monitoring the execution conditions of the tasks, such as whether the tasks are completed successfully, whether the execution time meets the requirements, and the like.
Log and alarm: in order to facilitate the problem investigation and timely treatment of abnormal conditions, it is necessary to record the execution log of the task and set an alarm mechanism to timely inform an administrator or operation and maintenance personnel.
Based on the embodiment of the invention, the realization can be realized:
1. task scheduling protection: the accuracy and reliability of task scheduling are guaranteed for the distributed timing tasks, and the tasks are prevented from being repeatedly scheduled or missed to be scheduled. Therefore, a distributed lock mechanism can be introduced, so that only one node can acquire the authority of task scheduling, and the lock is released in time after the task execution is completed, so that the repeated scheduling of other nodes is avoided.
2. Task execution protection: the execution of a distributed timing task may involve multiple nodes, and consistency and security of the task during execution need to be ensured. The distributed transaction mechanism can be adopted to ensure that the execution of the task is atomic, namely, the task is executed successfully or rolled back completely, so that the situation that part of nodes are executed successfully and part of nodes are failed to execute is avoided.
3. Task state protection: the execution state of the distributed timing task needs to be effectively managed and monitored so as to discover and process abnormal situations in task execution in time. The task state management module can be introduced to record the execution state and the execution result of the task, monitor the execution condition of the task in real time through the monitoring system, discover and process abnormal conditions in time, and ensure the correct execution of the task.
4. Task log protection: the log information generated during the execution of the distributed timing tasks needs to be effectively managed and protected for problem investigation and analysis. The log management module can be introduced to record the execution log of the task and provide log inquiry and analysis functions so as to discover and solve the problems in task execution in time.
For example, as shown in fig. 3, an open instruction transmitted from the annotation may be acquired first; if the value is false-, then it is an unopened instruction and the annotation is not valid.
If the value is true-, the annotation is valid for the open instruction; further, the time stamp may be formatted and a unique key may be generated based on the formatted time stamp and the task name in the annotation.
Constructing a transaction manager, and adding records such as a unique key, a task name, a version number (default is 0), an execution server IP and the like into an execution task record table; if the new addition fails, the task is not executed, and the number of failed tasks is accumulated; and when all the servers fail, sending early warning information.
If the new addition is successful, the version number can be updated; if the version number is updated successfully, the server executes the service code to execute the task; otherwise, if the updating fails, the service is not executed, and the number of failed services is accumulated; and when all the servers fail, sending early warning information. For failed count accumulation, self-increment 1 with key unique to the key can be used in redis.
As shown in fig. 4, a server 1, a server 2, a server n … …, may be deployed for an item. For the server 1, if the execution of the task by the server 1 fails, the unique key of the task in redis is value self-increment 1 corresponding to the key. After self-increment, the value can be removed and compared with the number of servers deployed by the user, if the value is equal, the fact that all servers do not acquire the task execution right is indicated, and at the moment, early warning information can be sent; if the two servers are not equal, the early warning information is not sent, and the other servers are waited to continue competing.
For the server 2, if the execution of the task by the server 2 fails, the unique key of the task in redis is value self-increment 1 corresponding to the key. After self-increment, the value can be removed and compared with the number of servers deployed by the user, if the value is equal, the fact that all servers do not acquire the task execution right is indicated, and at the moment, early warning information can be sent; if the two servers are not equal, the early warning information is not sent, and the other servers are waited to continue competing.
For other servers, the same flow as the server 1 and the server 2 may be performed
As shown in FIG. 5, an @ TaskExecute annotation can be added to the task in the system and the enable attribute required in the annotation-whether to turn on, is set to fire.
And each system transmits the values of each attribute in the annotation according to the task name and the server deployment condition, then the jar packet of the method is added into the project to obtain a project packet (cps_wait.war), and the project packet is deployed into the server.
Wherein @ task execution (enable=true, task name= "cps_xxxx_xxxx_xx xxxxx", execution count=x) ≡ public void excute () {
}
Wherein the enable attribute indicates whether to open the annotation (fillable true/false, true is open, false is not open, default to true-open if not filled); the taskName attribute represents a unique task name (named system name + "_" +timing task name, which is not repeatable; the executionCount attribute represents the number of servers that the task is deployed.
As shown in fig. 6, the task may be a task when determining whether the server obtains the execution right according to the result returned by the method, and executing the annotation of the method in the added annotations before executing the timed task; and; if so, executing the corresponding service code; otherwise, if not, the corresponding service code is not executed.
In the embodiment of the invention, a task execution right request of a target task of any target server in a distributed cluster is received; the task execution request comprises a task name stored in an annotation form, and a target unique key aiming at a target task is generated according to the task name and a timestamp; judging whether a target unique key is stored in a task execution record table; when the target unique key is not stored in the task execution record table, executing the operation of newly adding the target unique key into the execution task record table, and judging whether the target unique key is newly added into the execution task record table; when the target unique key is newly added into the execution task record table, the operation of updating the version number of the target task is executed; and when the version number updating for the target task is completed, issuing the task execution right of the target task for the target server so as to execute the target task through the target server. According to the embodiment of the invention, the servers of the distributed cluster can be managed, so that a plurality of servers can be prevented from executing the same task at the same time.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 7, a schematic structural diagram of a task execution device according to an embodiment of the present invention is applied to a distributed cluster, where the distributed cluster includes a plurality of servers for executing tasks, and a task execution record table is set for the distributed cluster, and the device may include the following modules:
a request module 701, configured to receive a task execution right request of a target task of any target server in the distributed cluster;
a unique key generating module 702, configured to generate a target unique key for a target task according to a task execution request;
a first judging module 703, configured to judge whether the task execution record table stores a target unique key;
and the execution module 704 is configured to, when the task execution record table does not store the target unique key, newly add the target unique key to the execution task record table, and issue the task execution right of the target task for the target server, so as to execute the target task through the target server.
In an alternative embodiment of the present invention, the task execution request includes a task name stored in the form of an annotation, and the unique key generation module 702 is configured to generate a target unique key for the target task according to the task name and the timestamp.
In an alternative embodiment of the present invention, the unique key generation module 702 is configured to format a timestamp; and generating a target unique key according to the formatted time stamp and the task name.
In an alternative embodiment of the present invention, the task execution request further includes an open instruction stored in the form of an annotation, and the apparatus further includes:
the second judging module is used for judging the type of the opening instruction, wherein the type comprises opening and non-opening;
the unique key generation module 702 is configured to generate a target unique key for a target task according to a task execution request when the type of the open instruction is open.
In an alternative embodiment of the present invention, the execution module 704 is configured to perform an operation of adding the target unique key to the execution task record table, and determine whether to add the target unique key to the execution task record table; when the target unique key is newly added into the execution task record table, the operation of updating the version number of the target task is executed; and when the version number updating aiming at the target task is completed, issuing the task execution right of the target task for the target server.
In an alternative embodiment of the present invention, the apparatus further comprises:
the abnormality detection module is used for performing abnormality recording on the target server if the target unique key is not successfully added into the execution task recording table after performing the operation of adding the target unique key into the execution task recording table; after the operation of updating the version number of the target task is executed, if the version number of the target task is not successfully updated, the exception record is carried out for the target server.
In an alternative embodiment of the present invention, the apparatus further comprises:
and the abnormality reminding module is used for carrying out alarm reminding on the distributed cluster when the abnormality records carried out on the servers in the distributed cluster meet the preset conditions.
In the embodiment of the invention, a task execution right request of a target task of any target server in a distributed cluster is received; generating a target unique key aiming at a target task according to the task execution request; judging whether a target unique key is stored in a task execution record table; when the target unique key is not stored in the task execution record table, the target unique key is newly added into the task execution record table, and the task execution right of the target task is issued for the target server so as to execute the target task through the target server. According to the embodiment of the invention, the servers of the distributed cluster can be managed, so that a plurality of servers can be prevented from executing the same task at the same time.
The embodiment of the invention also provides electronic equipment, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the execution method of the task when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the execution method of the task when being executed by a processor.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that 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 "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal 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 terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing has described in detail the methods, apparatus, electronic devices and storage media for performing tasks, and specific examples have been presented herein to illustrate the principles and embodiments of the present invention and to assist in understanding the methods and core concepts thereof; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (10)

1. A method for executing a task, the method being applied to a distributed cluster, the distributed cluster including a plurality of servers for executing the task, a task execution record table being provided for the distributed cluster, the method comprising:
receiving a task execution right request of a target task of any target server in the distributed cluster;
generating a target unique key aiming at the target task according to the task execution request;
judging whether the target unique key is stored in the task execution record table or not;
and when the target unique key is not stored in the task execution record table, newly adding the target unique key into the execution task record table, and issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
2. The method of claim 1, wherein the task execution request includes a task name stored in the form of an annotation, and wherein the generating a target unique key for the target task based on the task execution request comprises:
and generating a target unique key aiming at the target task according to the task name and the timestamp.
3. The method of claim 2, wherein generating a target unique key for the target task based on the task name and timestamp comprises:
formatting the timestamp;
and generating the target unique key according to the formatted time stamp and the task name.
4. The method of claim 1, wherein the task execution request further includes an open instruction stored in the form of an annotation, the method further comprising:
judging the type of the opening instruction, wherein the type comprises opening and non-opening;
and when the type of the opening instruction is opening, executing the step of generating a target unique key aiming at the target task according to the task execution request.
5. The method of claim 1, wherein adding the target unique key to the execution task record table and issuing the task execution right of the target task to the target server comprises:
executing the operation of newly adding the target unique key into the execution task record table, and judging whether the target unique key is newly added into the execution task record table;
when the target unique key is newly added into the execution task record table, the operation of updating the version number of the target task is executed;
and when the version number updating aiming at the target task is completed, issuing the task execution right of the target task for the target server.
6. The method of claim 5, wherein the method further comprises:
after the operation of newly adding the target unique key into the execution task record table is executed, if the target unique key is not successfully added into the execution task record table, performing abnormal record on the target server;
after the operation of updating the version number of the target task is executed, if the version number of the target task is not updated successfully, the exception record is carried out for the target server.
7. The method of claim 6, wherein the method further comprises:
and when the abnormal records carried out on each server in the distributed cluster meet the preset conditions, carrying out alarm reminding on the distributed cluster.
8. A task execution apparatus applied to a distributed cluster including a plurality of servers for executing tasks, for which a task execution record table is provided, the apparatus comprising:
the request module is used for receiving a task execution right request of a target task of any target server in the distributed cluster;
the unique key generation module is used for generating a target unique key aiming at the target task according to the task execution request;
the first judging module is used for judging whether the target unique key is stored in the task execution record table or not;
and the execution module is used for newly adding the target unique key into the execution task record table when the target unique key is not stored in the task execution record table, and issuing the task execution right of the target task for the target server so as to execute the target task through the target server.
9. An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, which computer program, when executed by the processor, implements a method of performing the tasks of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements a method of performing the tasks according to any of claims 1 to 7.
CN202311451085.0A 2023-11-02 2023-11-02 Task execution method and device, electronic equipment and storage medium Pending CN117632408A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311451085.0A CN117632408A (en) 2023-11-02 2023-11-02 Task execution method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311451085.0A CN117632408A (en) 2023-11-02 2023-11-02 Task execution method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117632408A true CN117632408A (en) 2024-03-01

Family

ID=90027854

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311451085.0A Pending CN117632408A (en) 2023-11-02 2023-11-02 Task execution method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117632408A (en)

Similar Documents

Publication Publication Date Title
CN110263054B (en) SQL work order auditing system, method and device and computer equipment
CN110716832B (en) Service operation monitoring and alarming method, system, electronic equipment and storage medium
CN105631026B (en) Safety data analysis system
US7065767B2 (en) Managed hosting server auditing and change tracking
US6397359B1 (en) Methods, systems and computer program products for scheduled network performance testing
US7949744B2 (en) System and method for synchronizing the configuration of distributed network management applications
CA2488044C (en) System and method for synchronizing the configuration of distributed network management applications
US20170004185A1 (en) Method and system for implementing collection-wise processing in a log analytics system
EP2791825B1 (en) System and method for monitoring and managing data center resources in real time incorporating manageability subsystem
EP2608061B1 (en) Method and system for update message tracking and checking
CN107888452B (en) 24-hour distributed website performance monitoring and real-time alarming method
US20100088197A1 (en) Systems and methods for generating remote system inventory capable of differential update reports
US9411969B2 (en) System and method of assessing data protection status of data protection resources
CN112751726B (en) Data processing method and device, electronic equipment and storage medium
WO2020063550A1 (en) Policy decision method, apparatus and system, and storage medium, policy decision unit and cluster
US20220237326A1 (en) System and method for certifying integrity of data assets
JP6252309B2 (en) Monitoring omission identification processing program, monitoring omission identification processing method, and monitoring omission identification processing device
CN117632408A (en) Task execution method and device, electronic equipment and storage medium
CN110633191A (en) Method and system for monitoring service health degree of software system in real time
US7606745B1 (en) System and method for tracking a billing cycle
CN113254313A (en) Monitoring index abnormality detection method and device, electronic equipment and storage medium
CN113094053A (en) Product delivery method and device and computer storage medium
KR100650584B1 (en) Statistical data error reporting method in the efficiency management module of ems
CN115396290B (en) Automatic fault recovery method, device and service system
Carlyle et al. Practical support solutions for a workflow-oriented Cray environment

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