CN113806056B - Timed task processing method, device, computer equipment and storage medium - Google Patents

Timed task processing method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN113806056B
CN113806056B CN202111170557.6A CN202111170557A CN113806056B CN 113806056 B CN113806056 B CN 113806056B CN 202111170557 A CN202111170557 A CN 202111170557A CN 113806056 B CN113806056 B CN 113806056B
Authority
CN
China
Prior art keywords
task
timing
timing task
target
scanning
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111170557.6A
Other languages
Chinese (zh)
Other versions
CN113806056A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202111170557.6A priority Critical patent/CN113806056B/en
Publication of CN113806056A publication Critical patent/CN113806056A/en
Application granted granted Critical
Publication of CN113806056B publication Critical patent/CN113806056B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a timing task processing method, a timing task processing device, computer equipment and a storage medium. The method comprises the following steps: determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing locking robbery operation based on the lock path; after successful locking, scanning the timing tasks stored in the storage module, wherein each timing task is marked with a task state, the task state comprises a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed; when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to the service execution side, and the first target timing task represents the first timing task which is not expected to be executed in the scanning time window. By adopting the method, the reliability of the timing task execution can be improved. The embodiment of the application can be applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation, internet of vehicles and the like.

Description

Timed task processing method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for processing a timing task, a computer device, and a storage medium.
Background
With the development of computer technology and the increase of the demands of users for service functions, the service system has more and more functions. Timing tasks are typically set in some business systems and are performed at specified times.
In the conventional technology, timing tasks in a service system are usually implemented based on Redis Zset or Quartz, however, a plurality of services are often included in a large project, each service may contain a plurality of timing tasks, and a scheme based on Redis Zset or Quartz consumes resources in the service system to affect the execution efficiency of other services. The existing scheme for deploying independent timing service solves the problems of scattered and inconvenient unified management of each service, but does not distinguish environments in a distributed scene, and the online environment is easy to be interfered, so that the reliability of timing task execution is affected.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a timed task processing method, apparatus, computer device, and storage medium that can improve the reliability of timed task execution.
A timed task processing method, the method comprising:
determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing a lock robbing operation based on the lock path;
after successful locking, scanning timing tasks stored in a storage module, wherein each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed;
when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to a service execution side, and the first target timing task represents the first timing task which is not expected to be executed in a scanning time window.
A timed task processing device, the device comprising:
the lock robbing module is used for determining a lock path carrying a corresponding environment identifier according to the environment where the timing server is located and carrying out lock robbing operation based on the lock path;
the scanning module is used for scanning the timing tasks stored in the storage module after the successful locking, each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or is completed to be executed;
and the processing module is used for delivering the first target timing task to the service execution side when the first target timing task exists in the first timing task marked with the first task state, wherein the first target timing task represents the first timing task which is not expected to be executed in the scanning time window.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing a lock robbing operation based on the lock path;
after successful locking, scanning timing tasks stored in a storage module, wherein each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed;
when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to a service execution side, and the first target timing task represents the first timing task which is not expected to be executed in a scanning time window.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing a lock robbing operation based on the lock path;
after successful locking, scanning timing tasks stored in a storage module, wherein each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed;
when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to a service execution side, and the first target timing task represents the first timing task which is not expected to be executed in a scanning time window.
A computer program product comprising a computer program, characterized in that the computer program when executed by a processor realizes the steps of:
determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing a lock robbing operation based on the lock path;
after successful locking, scanning timing tasks stored in a storage module, wherein each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed;
when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to a service execution side, and the first target timing task represents the first timing task which is not expected to be executed in a scanning time window.
According to the timing task processing method, the timing task processing device, the computer equipment and the storage medium, the lock path carrying the corresponding environment identifier is determined according to the environment where the timing server is located, and locking robbery operation is performed based on the lock path; after successful locking, scanning the timing tasks stored in the storage module, wherein each timing task is marked with a task state, the task state comprises a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed; when a first target timing task exists in the first timing tasks marked with the first task states, the first target timing task is delivered to the service execution side, and the first target timing task represents the first timing task which is not expected to be executed in the scanning time window. Accordingly, environments in a distributed scene can be distinguished through the lock path carrying the environment identifier, business interference in different environments is avoided, and the execution reliability of timing tasks is ensured; the business party can flexibly set the timing tasks according to the needs and store the timing tasks in the storage module, and the timing server can serve as a business dispatcher to deliver the timing tasks in the storage module, modify the timing tasks in a non-invasive mode and the like, so that the development and maintenance efficiency of the timing related business is improved.
Drawings
FIG. 1 is a diagram of an architecture of a timing service system in one embodiment;
FIG. 2 is a flow diagram of a method of timing task processing in one embodiment;
FIG. 3 is a flow diagram of a method of timing task processing in one embodiment;
FIG. 4 is a block diagram of a timing task processing device in one embodiment;
fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In one embodiment, the method for processing a timing task provided by the application can be applied to a timing service system as shown in fig. 1. The timing service system includes: a server cluster (chubby cluster in this embodiment) capable of providing distributed lock services, a timing service cluster, and a traffic execution side (message queue mq in this embodiment).
The chubby cluster includes multiple servers (e.g., chubby_ svr1, chubby_ svr2, chubby_ svr 3) that provide distributed lock services, and each client (client) needs to rob to lock before proceeding to the next operation. For client machines (e.g., timing servers) of different environments (e.g., online environment and test environment), an environment identification is carried on the lock path, e.g., the lock path is represented as: the timing server (such as svr1, svr2, svr 3) of the online environment can only acquire the lock file from the lock path carrying the online environment identifier, and the timing server (such as svr _1, svr_2) of the test environment can only acquire the lock file from the lock path carrying the test environment identifier, so that mutual isolation between the environments is ensured, and mutual interference is avoided.
The timing service cluster provides delivery of timing tasks, addition, deletion, modification and query operations of timing tasks. The timing server in the timing service cluster periodically starts a lock-robbing operation, and a thread (for example, thread 1) which is successful in locking and holds the lock scans a storage module (for example, table 1, table 2 and … … table 1000) and delivers corresponding timing tasks to a service message queue.
The service message queues (e.g., mq1, mq2, … … mqN) are responsible for performing timing tasks delivered by the timing server, and may be maintained by the service party itself. The business side can issue timing tasks through user terminals, including but not limited to mobile phones, computers, intelligent voice interaction devices, intelligent home appliances, vehicle terminals and the like. The service side can configure a corresponding retry strategy according to own service characteristics, and if the task execution fails, the task execution is ensured through the retry strategy. The business side can also configure callback strategies according to the needs, and execute corresponding callback operations after the task is successfully executed. Accordingly, efficient and reliable task execution is ensured.
In one embodiment, as shown in fig. 2, a timing task processing method is provided, and an example of application of the method to the timing server in fig. 1 is described, which includes the following steps S202 to S206.
S202, determining a lock path carrying a corresponding environment identifier according to the environment where the timing server is located, and performing locking robbery operation based on the lock path.
In one embodiment, a unique environment identifier is configured for each environment, so that the environment identifiers corresponding to different environments are different, that is, the lock paths corresponding to different environments are different, so as to ensure mutual isolation between the environments. And determining an environment identifier of the environment according to the environment of the timing server, and performing locking operation based on a lock path carrying the environment identifier, wherein the locking operation can be particularly performed periodically. It should be noted that any lock robbing logic that may be present or later may be used to perform the lock robbing operation, which is not limited.
S204, after successful locking, scanning the timing tasks stored in the storage module, wherein each timing task is marked with a task state, the task state comprises a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed.
After the timing server successfully locks, scanning operation is started, and if the locking fails, the locking operation is performed again. The storage module is used for storing timing tasks, the storage module can be a table storage structure, a business party can flexibly set the timing tasks according to the needs and store the timing tasks in the storage module, and the timing server can perform operations such as adding, deleting, modifying, inquiring and the like on the timing tasks stored in the storage module. The task status is used to indicate the delivery or execution of the timed task.
S206, when the first target timing task exists in the first timing tasks marked with the first task states, delivering the first target timing task to the service execution side, wherein the first target timing task indicates that the first timing task expected to be executed is not reached in the scanning time window.
In one embodiment, the scan time window is determined based on a scan start time and a preset time span. The method for determining the scanning time window specifically comprises the following steps: the scanning start time is taken as the minimum time of the scanning time window, the time corresponding to the future preset time span from the scanning start time is taken as the maximum time of the scanning time window, and the time range between the minimum time and the maximum time is taken as the scanning time window.
The scanning start time may be time when the lock is successfully locked, and the preset time span may be set according to actual requirements, which is not limited. For example, if the scanning start time is 8:40 and the preset time span is 30 minutes, the minimum time and the maximum time of the scanning time window are 8:40 and 9:10, respectively, and the scanning time window is 8:40 to 9:10.
The first timing task refers to a timing task marked with a first task state in the memory module. The first target timed task represents a first timed task for which execution is not expected within the scan time window. The service execution side is used for executing the timing tasks delivered by the timing server, delivering the first target timing tasks to the service execution side, and executing the first target timing tasks at the appointed execution time by the service execution side.
In one embodiment, the method for determining the first target timing task may specifically include the following steps: acquiring the scheduling time of each first timing task; and determining the first timing task with the scheduling time within the scanning time window as a first target timing task.
The scheduling time of the first timing task may be understood as the execution time of the first timing task, for example, if a certain first timing task is 9:00 to remind to punch a card on duty, the scheduling time of the first timing task is 9:00. And determining the first timing task with the scheduling time in the scanning time window as a first target timing task, wherein the first target timing task refers to the first timing task with the scheduling time in the scanning time window. The scheduled time is understood to be within the scanning time window, where the scheduled time is less than or equal to the maximum time of the scanning time window and greater than or equal to the minimum time of the scanning time window. For example, if the scanning time window is 8:40-9:10, the scheduling time t of the first target timing task satisfies 8:40.ltoreq.t.ltoreq.9:10.
In the timing task processing method, the environments in the distributed scene can be distinguished through the lock path carrying the environment identifier, so that business interference in different environments is avoided, and the execution reliability of the timing task is ensured; the business party can flexibly set the timing tasks according to the needs and store the timing tasks in the storage module, and the timing server can serve as a business dispatcher to deliver the timing tasks in the storage module, modify the timing tasks in a non-invasive mode and the like, so that the development and maintenance efficiency of the timing related business is improved.
In one embodiment, after delivering the first target timing task to the service execution side, the method further comprises the steps of: and updating the task state of the first target timing task into a second task state.
The second task state indicates that the timed task has been posted and not completed execution. After the timing server delivers the first target timing task to the service execution side, the task state of the first target timing task is changed from the original first task state to the second task state, so that the delivery state change of the timing task can be timely and accurately tracked.
In one embodiment, when an execution completion instruction of a timing task marked with a second task state is received through a callback interface, the task state of the timing task corresponding to the execution completion instruction is updated to the first task state.
The service execution side can be configured with a callback strategy, the timing server is configured with a corresponding callback interface, after the timing server delivers the timing task to the service execution side, the timing task is in a second task state, the service execution side executes the timing task at the appointed execution time, after the task execution is completed, the service execution side invokes a corresponding method to execute callback operation, the timing server receives an execution completion instruction of the timing task through the callback interface, and changes the task state of the timing task from the second task state to a first task state, and the first task state at the moment indicates that the timing task is completed to be executed.
In one embodiment, after delivering the first target timing task to the service execution side, the method further comprises the steps of: if the first target timing task is a periodic timing task, the scheduling time of the first target timing task is updated to the scheduling time of the next period.
For periodic timing tasks (e.g., daily, weekly, monthly, yearly, etc.), the timing server may effect rescheduling by directly modifying the scheduled time of the periodic timing task after delivery is completed in the current period. For example, if a certain timing task is to remind to punch a card on duty 9:00 a day, after the timing task is delivered to the service execution side on the same day, the timing server updates the scheduling time of the timing task to 9:00 a next day, so that the task delivery on the next day can be realized without reconfiguring the timing task, thereby improving the development and maintenance efficiency of the periodic timing task.
In one embodiment, after scanning the timing tasks stored in the memory module, the method further comprises the steps of: when there is a second target timed task in the first timed task marked with the first task state, the second target timed task is deleted from the storage module, the second target timed task representing the expired first timed task.
The method for determining the second target timing task specifically comprises the following steps: acquiring task expiration time of each first timing task; and determining the first timing task with the task expiration time smaller than the minimum time of the scanning time window as a second target timing task.
The determination of the scanning time window may refer to the previous embodiments, and will not be described herein. The task expiration time of the timing task can be understood as the time when the timing task is smaller than the minimum time of the scanning time window, the timing task is considered to be expired up to the current time without continuing delivery and execution after the task expiration time.
In this embodiment, the expired timing task is deleted from the storage module, so that unnecessary task scanning can be reduced, and thus, the calculation amount and the resource waste are reduced.
In one embodiment, after scanning the timing tasks stored in the memory module, the method further comprises the steps of: and when a third target timing task exists in the second timing tasks marked with the second task states, re-delivering the third target timing task to the service execution side, wherein the third target timing task represents the second timing task with abnormal execution.
The second timing task refers to a timing task marked with a second task state in the storage module, wherein the second task state indicates that the timing task is delivered and not completed, i.e. the second timing task can be understood as the timing task delivered at least once.
The method for determining the third target timing task specifically comprises the following steps: acquiring the feedback time of the latest execution completion of each second timing task; and determining the second timing task with the latest execution completion feedback time smaller than the minimum time of the scanning time window as a third target timing task.
The determination of the scanning time window may refer to the previous embodiments, and will not be described herein. The latest execution completion feedback time of the timing task can be understood as that if the timing server does not receive the execution completion instruction through the callback interface at the latest execution completion feedback time, the timing task is considered to be abnormal in execution (such as execution timeout or failure). And if the latest execution completion feedback time of the timing task is smaller than the minimum time of the scanning time window, the timing server is indicated to be up to the latest execution completion feedback time, and the timing server still does not receive the execution completion instruction of the timing task, namely the timing task is considered to be abnormally executed.
In this embodiment, the timing task with abnormal execution is redelivered to the service execution side, and the service execution side re-executes the timing task, which is insensitive to time, for example, the version upgrade task, so that the task can be ensured to be successfully executed by re-executing, and the task execution reliability is improved.
In one embodiment, as shown in fig. 3, there is provided a timed task processing method, which is applied to a timed service system, including the steps of:
1. the business side adds timing task and writes the timing task and related information into the storage module (in the figure, the table is stored).
2. And the timing server starts periodic lock-robbing operation, and performs lock-robbing from the chubby cluster according to a lock path corresponding to the environment identifier of the timing server.
3. The timing server starts to scan tasks after successful locking, the timing tasks in the table storage are scanned, the task states of the timing tasks in the table storage comprise a first task state (shown by TODO) and a second task state (shown by DOING), and the task states are marked by a task state machine.
4. For the timing task marked with the first task state, the timing server judges whether the timing task expires in the scanning time window, if yes, the timing task is deleted from the table storage; if not, delivering the timing task to a message queue, changing the task state of the timing task from TODO to DOING, and otherwise, updating the next scheduling time of the timing task in a table storage if the first timing task is a periodic task.
5. And for the timing task marked with the second task state, if the timing server judges that the timing task is abnormal in execution, the timing task is delivered to the message queue again.
6. After the service execution side successfully executes the timing task, a corresponding method is called to complete callback, and the timing server receives an execution completion instruction of the timing task through a callback interface and changes the task state of the timing task from DOING to TODO.
For a specific description of each step of this embodiment, reference may be made to the foregoing embodiment, and no further description is given here. In the embodiment, the environments in the distributed scene can be distinguished through the lock path carrying the environment identifier, so that business interference in different environments is avoided, and the execution reliability of the timing task is ensured; the business party can flexibly set timing tasks according to the needs and store the timing tasks in the storage module, and the timing server can serve as a business dispatcher to deliver the timing tasks in the storage module, modify the timing tasks in a non-invasive mode and the like, so that the development and maintenance efficiency of timing related businesses is improved; by re-executing and callback strategies, successful execution of the task can be guaranteed, and the execution reliability of the timing task is further improved.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a part of the steps in the flowcharts related to the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages performed is not necessarily sequential, but may be performed alternately or alternately with at least a part of the steps or stages in other steps or other steps.
In one embodiment, as shown in FIG. 4, there is provided a timed task processing device 400 comprising: a lock module 410, a scan module 420, and a processing module 430, wherein:
the lock robbery module 410 is configured to determine a lock path carrying a corresponding environment identifier according to an environment where the timing server is located, and perform a lock robbery operation based on the lock path.
The scanning module 420 is configured to scan the timing tasks stored in the storage module after the lock is successfully locked, where each timing task is marked with a task state, and the task state includes a first task state, and the first task state indicates that the timing task is undelivered or has completed execution.
The processing module 430 is configured to, when there is a first target timing task in the first timing tasks marked with the first task state, deliver the first target timing task to the service execution side, where the first target timing task indicates that the first timing task expected to be executed is not reached within the scanning time window.
In one embodiment, the processing module 430 is further configured to: acquiring the scheduling time of each first timing task; and determining a first timing task with the scheduling time within a scanning time window as a first target timing task, wherein the scanning time window is determined based on the scanning starting time and a preset time span.
In one embodiment, the processing module 430 is further configured to: after the first target timing task is delivered to the service execution side, the task state of the first target timing task is updated to be the second task state.
In one embodiment, the processing module 430 is further configured to: after delivering the first target timing task to the service execution side, if the first target timing task is a periodic timing task, updating the scheduling time of the first target timing task to the scheduling time of the next period.
In one embodiment, the processing module 430 is further configured to: when there is a second target timed task in the first timed task marked with the first task state, the second target timed task is deleted from the storage module, the second target timed task representing the expired first timed task.
In one embodiment, the processing module 430 is further configured to: acquiring task expiration time of each first timing task; and determining a first timing task with a task expiration time smaller than the minimum time of a scanning time window as a second target timing task, wherein the scanning time window is determined based on the scanning starting time and a preset time span.
In one embodiment, the task states further include a second task state, the second task state representing that the timed task has been posted and not completed execution; the processing module 430 is further configured to: and when receiving an execution completion instruction of the timing task marked with the second task state through the callback interface, updating the task state of the timing task corresponding to the execution completion instruction into the first task state.
In one embodiment, the processing module 430 is further configured to: and when a third target timing task exists in the second timing tasks marked with the second task states, the third target timing task is delivered to the service execution side again, and the third target timing task represents the second timing task with abnormal execution.
In one embodiment, the processing module 430 is further configured to: acquiring the feedback time of the latest execution completion of each second timing task; and determining the second timing task with the latest execution completion feedback time smaller than the minimum time of the scanning time window as a fourth target timing task, wherein the scanning time window is determined based on the scanning starting time and the preset time span.
For specific limitations of the timed task processing device, reference may be made to the above limitation of the timed task processing method, and no further description is given here. The various modules in the timed task processing device described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store timed task related data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program when executed by a processor implements a timed task processing method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 5 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
It should be appreciated that the terms "first," "second," and the like in the above embodiments are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Furthermore, in the description of the present application, unless otherwise indicated, the meaning of "plurality" means at least two.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (17)

1. A timing task processing method applied to a timing server, the method comprising:
determining a lock path carrying a corresponding environment identifier according to the environment of the timing server, and performing a locking robbery operation based on the lock path to obtain the authority of scanning the timing task stored in the storage module; the lock path refers to a path for accessing a server cluster providing distributed lock service;
after successful locking, scanning timing tasks stored in a storage module, wherein each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or completed to be executed;
when a first target timing task exists in the first timing tasks marked with the first task states, delivering the first target timing task to a service execution side, wherein the first target timing task represents the first timing task which is not expected to be executed in a scanning time window; the scanning time window is determined based on a scanning start time and a preset time span.
2. The method of claim 1, wherein the method of determining the first target timing task comprises:
acquiring the scheduling time of each first timing task;
and determining a first timing task with the scheduling time within the scanning time window as a first target timing task.
3. The method of claim 2, further comprising, after delivering the first target timing task to a service execution side, at least one of:
a first item: updating the task state of the first target timing task into a second task state;
the second item: and if the first target timing task is a periodic timing task, updating the scheduling time of the first target timing task to the scheduling time of the next period.
4. The method as recited in claim 1, further comprising: and deleting a second target timing task from the storage module when the second target timing task exists in the first timing task marked with the first task state, wherein the second target timing task represents the expired first timing task.
5. The method of claim 4, wherein the method of determining the second target timing task comprises:
acquiring the task expiration time of each first timing task;
and determining a first timing task with a task expiration time smaller than the minimum time of the scanning time window as a second target timing task, wherein the scanning time window is determined based on the scanning starting time and a preset time span.
6. The method of claim 1, wherein the task state further comprises a second task state, the second task state representing that the timed task has been posted and not completed execution;
the method further comprises at least one of:
a first item: when receiving an execution completion instruction of the timing task marked with the second task state through a callback interface, updating the task state of the timing task corresponding to the execution completion instruction into a first task state;
the second item: and when a third target timing task exists in the second timing tasks marked with the second task states, the third target timing task is delivered to the service execution side again, and the third target timing task represents the second timing task with abnormal execution.
7. The method of claim 6, wherein the determining of the third target timing task comprises:
acquiring the feedback time of the latest execution completion of each second timing task;
and determining the second timing task with the latest execution completion feedback time smaller than the minimum time of the scanning time window as a third target timing task, wherein the scanning time window is determined based on the scanning starting time and the preset time span.
8. A timed task processing device for use with a timed server, the device comprising:
the lock grabbing module is used for determining a lock path carrying a corresponding environment identifier according to the environment where the timing server is located, and carrying out lock grabbing operation based on the lock path so as to obtain the authority of scanning the timing task stored in the storage module; the lock path refers to a path for accessing a server cluster providing distributed lock service;
the scanning module is used for scanning the timing tasks stored in the storage module after the successful locking, each timing task is marked with a task state, the task states comprise a first task state, and the first task state indicates that the timing task is undelivered or is completed to be executed;
the processing module is used for delivering the first target timing task to the service execution side when the first target timing task exists in the first timing tasks marked with the first task states, and the first target timing task represents the first timing task which is not expected to be executed in the scanning time window; the scanning time window is determined based on a scanning start time and a preset time span.
9. The apparatus of claim 8, wherein the processing module is further configured to: and acquiring the scheduling time of each first timing task, and determining the first timing task with the scheduling time within the scanning time window as a first target timing task.
10. The apparatus of claim 9, wherein the processing module is further configured to: and after the first target timing task is delivered to the service execution side, updating the task state of the first target timing task into a second task state.
11. The apparatus of claim 9, wherein the processing module is further configured to: after the first target timing task is delivered to the service execution side, if the first target timing task is a periodic timing task, updating the scheduling time of the first target timing task into the scheduling time of the next period.
12. The apparatus of claim 8, wherein the processing module is further configured to: and deleting a second target timing task from the storage module when the second target timing task exists in the first timing task marked with the first task state, wherein the second target timing task represents the expired first timing task.
13. The apparatus of claim 12, wherein the processing module is further configured to: acquiring task expiration time of each first timing task, determining the first timing task with the task expiration time smaller than the minimum time of the scanning time window as a second target timing task, wherein the scanning time window is determined based on the scanning starting time and a preset time span.
14. The apparatus of claim 8, wherein the task state further comprises a second task state, the second task state representing that the timed task has been posted and not completed execution; the processing module is further configured to: when receiving an execution completion instruction of the timing task marked with the second task state through a callback interface, updating the task state of the timing task corresponding to the execution completion instruction into a first task state; and when a third target timing task exists in the second timing tasks marked with the second task states, the third target timing task is delivered to the service execution side again, and the third target timing task represents the second timing task with abnormal execution.
15. The apparatus of claim 14, wherein the processing module is further configured to: and acquiring the latest execution completion feedback time of each second timing task, determining the second timing task with the latest execution completion feedback time smaller than the minimum time of the scanning time window as a third target timing task, wherein the scanning time window is determined based on the scanning starting time and the preset time span.
16. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
17. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202111170557.6A 2021-10-08 2021-10-08 Timed task processing method, device, computer equipment and storage medium Active CN113806056B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111170557.6A CN113806056B (en) 2021-10-08 2021-10-08 Timed task processing method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111170557.6A CN113806056B (en) 2021-10-08 2021-10-08 Timed task processing method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113806056A CN113806056A (en) 2021-12-17
CN113806056B true CN113806056B (en) 2023-10-27

Family

ID=78897359

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111170557.6A Active CN113806056B (en) 2021-10-08 2021-10-08 Timed task processing method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113806056B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307105A (en) * 2020-11-03 2021-02-02 平安普惠企业管理有限公司 Timing task running method, device, equipment and storage medium based on multithreading
CN112817710A (en) * 2021-01-22 2021-05-18 平安养老保险股份有限公司 Timed task processing method, timed task processing system, computer equipment and computer storage medium
CN112882812A (en) * 2021-03-16 2021-06-01 北京字节跳动网络技术有限公司 Method, device, equipment, medium and system for scheduling and storing delayed tasks
WO2021169123A1 (en) * 2020-02-26 2021-09-02 平安科技(深圳)有限公司 Cluster environment timing task processing method, system and device, and storage medium
CN113448699A (en) * 2020-12-30 2021-09-28 北京新氧科技有限公司 Distributed timed task processing system, method and related device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021169123A1 (en) * 2020-02-26 2021-09-02 平安科技(深圳)有限公司 Cluster environment timing task processing method, system and device, and storage medium
CN112307105A (en) * 2020-11-03 2021-02-02 平安普惠企业管理有限公司 Timing task running method, device, equipment and storage medium based on multithreading
CN113448699A (en) * 2020-12-30 2021-09-28 北京新氧科技有限公司 Distributed timed task processing system, method and related device
CN112817710A (en) * 2021-01-22 2021-05-18 平安养老保险股份有限公司 Timed task processing method, timed task processing system, computer equipment and computer storage medium
CN112882812A (en) * 2021-03-16 2021-06-01 北京字节跳动网络技术有限公司 Method, device, equipment, medium and system for scheduling and storing delayed tasks

Also Published As

Publication number Publication date
CN113806056A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
CN108874558B (en) Message subscription method of distributed transaction, electronic device and readable storage medium
CN107451147B (en) Method and device for dynamically switching kafka clusters
CN110611707B (en) Task scheduling method and device
WO2021104178A1 (en) Dynamic message pushing method and system and vehicle diagnosis server
CN108446172B (en) Data calling method and device, computer equipment and storage medium
CN111861482A (en) Block chain account checking method and system
CN110222535B (en) Processing device, method and storage medium for block chain configuration file
CN111159233B (en) Distributed caching method, system, computer equipment and storage medium
CN104065636A (en) Data processing method and system
CN110602165A (en) Government affair data synchronization method, device, system, computer equipment and storage medium
CN110955506A (en) Distributed job scheduling processing method
CN111314241B (en) Task scheduling method and scheduling system
EP2416526B1 (en) Task switching method, server node and cluster system
CN113946427A (en) Task processing method, processor and storage medium for multi-operating system
CA3134297A1 (en) Message pushing method and device thereof, computer equipment and storage medium
CN111447136B (en) Message pushing method and device, computer equipment and storage medium
CN113849320A (en) Development method, control method and computing device
CN113806056B (en) Timed task processing method, device, computer equipment and storage medium
CN109948994A (en) A kind of instant communicating method, device, computer system and readable storage medium storing program for executing
CN115509716A (en) Task scheduling method, system and storage medium
CN112953770B (en) Method, system, medium and cloud management system for edge cloud gateway configuration-free access
CN111510484B (en) Block chain processing method, system, device, computer equipment and storage medium
CN114020368A (en) Information processing method and device based on state machine and storage medium
CN114567664A (en) Message processing result monitoring method and device, computer equipment and storage medium
CN114116158A (en) Task scheduling method and system based on SD-WAN system

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
GR01 Patent grant
GR01 Patent grant