CN113760665B - Operation method and device for reminding task - Google Patents

Operation method and device for reminding task Download PDF

Info

Publication number
CN113760665B
CN113760665B CN202010484392.9A CN202010484392A CN113760665B CN 113760665 B CN113760665 B CN 113760665B CN 202010484392 A CN202010484392 A CN 202010484392A CN 113760665 B CN113760665 B CN 113760665B
Authority
CN
China
Prior art keywords
reminding
task
time interval
thread
tasks
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
CN202010484392.9A
Other languages
Chinese (zh)
Other versions
CN113760665A (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 CN202010484392.9A priority Critical patent/CN113760665B/en
Publication of CN113760665A publication Critical patent/CN113760665A/en
Application granted granted Critical
Publication of CN113760665B publication Critical patent/CN113760665B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Retry When Errors Occur (AREA)

Abstract

The invention provides a method and a device for running reminding tasks, electronic equipment and a computer-readable storage medium; is applied to a distributed system, wherein the distributed system comprises a plurality of servers; the method comprises the following steps: the server receives the set reminding tasks and stores the reminding tasks according to the time interval of the reminding time of the received reminding tasks; setting a thread for executing the reminding task to be in a blocking state, and attempting to acquire a distributed lock in the distributed system; when the distributed lock is acquired, converting the thread in the blocking state into an executable state, and executing a reminding task in a current time interval through the thread to send a reminding message corresponding to the executed reminding task; the current time interval is a time interval in which the thread acquires the distributed lock. The invention can provide stable reminding service.

Description

Operation method and device for reminding task
Technical Field
The present invention relates to the field of internet technologies, and in particular, to a method and apparatus for running a reminding task, an electronic device, and a computer readable storage medium.
Background
With the development of internet technology, users can perform various services using applications installed on terminals. For example, a user may record personal work schedule through a calendar application, and may initiate a schedule of multiple people to participate, such as meetings, team activities, and the like. Meanwhile, in order to avoid forgetting the user, a lot of businesses need to use reminding services, such as business of schedule, meeting, waiting and the like. Particularly, when the number of services is large, the reminding service is important.
In the related art, the reminding task is usually executed through a single server, however, there is a single point effect when the reminding task is executed through the single server, and the reminding task is lost when the server fails, so that a stable reminding service cannot be provided for a user.
Disclosure of Invention
The embodiment of the invention provides a method and a device for running a reminding task, electronic equipment and a computer-readable storage medium, which can provide stable reminding service.
The technical scheme of the embodiment of the invention is realized as follows:
the embodiment of the invention provides a method for running reminding tasks, which is applied to a distributed system, wherein the distributed system comprises a plurality of servers and comprises the following steps:
the server receives the set reminding tasks and stores the reminding tasks according to the time interval of the reminding time of the received reminding tasks;
Setting a thread for executing the reminding task to be in a blocking state, and attempting to acquire a distributed lock in the distributed system;
when the distributed lock is acquired, converting the thread in the blocking state into an executable state, and executing a reminding task in the current time interval through the thread to
Sending a reminding message corresponding to the executed reminding task;
the current time interval is a time interval in which the thread acquires the distributed lock.
The embodiment of the invention provides a running device for reminding tasks, which is applied to a distributed system, wherein the distributed system comprises a plurality of servers and comprises:
The storage module is used for receiving the set reminding tasks and storing the set reminding tasks according to the time interval of the reminding time of the received reminding tasks;
The acquisition module is used for setting a thread for executing the reminding task to be in a blocking state and attempting to acquire a distributed lock in the distributed system;
The execution module is used for converting the thread in the blocking state into an executable state when the distributed lock is acquired, and executing a reminding task in a current time interval through the thread, wherein the current time interval is the time interval in which the thread acquires the distributed lock;
and the sending module is used for sending the reminding message corresponding to the executed reminding task.
In the above scheme, the storage module is further configured to divide each day into a plurality of time intervals according to a set time granularity, and establish a corresponding index table for each time interval;
And determining a time interval in which the reminding time of the received reminding task is positioned in the divided time intervals, and storing the received reminding task into an index table corresponding to the determined time interval.
In the above scheme, the device further comprises a dividing module, configured to perform modulo arithmetic according to the numbers of the plurality of reminding tasks for the plurality of reminding tasks stored in any time interval in the index table;
Dividing the modular operation result into a plurality of number segments according to the set granularity, and dividing the plurality of reminding tasks into corresponding number segments according to the numbers of the plurality of reminding tasks.
In the above solution, the execution module is further configured to adjust, according to the number of number segments in the current time interval, the number of threads started in the server, so that
Each thread reads the reminding task in one number segment and adds the read reminding task into a corresponding circulation queue;
And executing reminding tasks in any one of the circular queues by threads corresponding to the any one of the circular queues according to any one of the circular queues.
In the above solution, the executing module is further configured to execute, by the thread, a reminder service in a current time interval during an effective period of the distributed lock;
When the validity period of the distributed lock is exceeded, the distributed lock is released, and the thread in the executable state is converted into a blocking state again.
In the above scheme, the executing module is further configured to add the reminding task to be executed in the current time interval to the message queue in an asynchronous manner, so as to send a reminding message corresponding to the executed reminding task through the message queue.
In the above scheme, the execution module is further configured to read, by the task reading thread, the reminding task to be executed in the current time interval when the number of the reminding tasks to be executed in the current time interval is greater than a preset threshold, store the read reminding task in a memory container, and
And acquiring the reminding task to be executed from the memory container through an execution task thread and executing the reminding task.
In the above scheme, the executing module is further configured to switch the task reading thread to a sleep state after the reminding task to be executed in the current time interval is read;
When the time of the next time interval arrives, a group of new task reading threads are started to read reminding tasks to be executed in the next time interval, wherein the number of the new task reading threads is the same as the number of the number segments in the next time interval.
In the above scheme, the executing module is further configured to add the reminding task with the execution failure to a retry queue when the execution of the reminding task fails, so as to re-execute the reminding task through the retry queue;
when the execution of the reminding task is successful, deleting the reminding task which is successfully executed, and
And when the deletion is failed, adding the reminding task with the deletion failure into the retry queue to be deleted again through the retry queue.
An embodiment of the present invention provides an electronic device, including:
A memory for storing executable instructions;
And the processor is used for realizing the operation method of the reminding task provided by the embodiment of the invention when executing the executable instructions stored in the memory.
The embodiment of the invention provides a computer readable storage medium which stores executable instructions for realizing the running method of the reminding task provided by the embodiment of the invention when a processor is caused to execute.
The embodiment of the invention has the following beneficial effects:
The reminding task is executed through each thread based on a plurality of servers included in the distributed system, and the state of the thread for executing the reminding task on the server is controlled based on the distributed lock, so that the efficient and orderly execution of the reminding task is realized; and the servers realize disaster tolerance of the reminding service and can provide stable reminding service.
Drawings
FIG. 1 is a schematic diagram of an alternative architecture of a system for executing reminder tasks provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of an alternative architecture of a server provided by an embodiment of the present invention;
FIG. 3 is a schematic flow chart of an alternative method for running a reminder task according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of another alternative method for running a reminder task according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an interface of a reminding task set by a user for a schedule according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of an interface of a reminding task set by a user for a conference according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of an interface of a reminding task set by a user for to-do according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of an architecture for providing reminder services based on distributed locks chubby according to an embodiment of the present invention;
Fig. 9 is a schematic flow chart of executing reminding tasks with different number segments through multiple threads according to an embodiment of the present invention.
Detailed Description
The present invention will be further described in detail with reference to the accompanying drawings, for the purpose of making the objects, technical solutions and advantages of the present invention more apparent, and the described embodiments should not be construed as limiting the present invention, and all other embodiments obtained by those skilled in the art without making any inventive effort are within the scope of the present invention.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
Before describing embodiments of the present invention in further detail, the terms and terminology involved in the embodiments of the present invention will be described, and the terms and terminology involved in the embodiments of the present invention will be used in the following explanation.
1) The reminding service, namely meeting, schedule, waiting and other business support events, reminds participants when or before the occurrence of the business support events.
2) When one machine fails accidentally to stop working, other machines can work normally, and service is provided normally.
3) A distributed system, components are distributed on networked computers, and the components communicate and act in concert by passing messages between them. In a distributed system, a server typically includes multiple machines that together form a cluster, with each machine providing the same service.
4) And (3) a thread, namely, a minimum unit capable of performing operation scheduling in an operating system. It is contained in the process and is the actual unit of operation in the process. One thread refers to a single sequential control flow in a process, and a process can concurrently execute multiple threads, each of which concurrently executes different tasks.
5) The message queue, an important component in the distributed system, can provide a reliable asynchronous communication mechanism based on the message, can store the received and transmitted messages between different applications of distributed deployment in the reliable and effective message queue, and prevent the message from being lost. The message queue supports simultaneous reading and writing of multiple processes, and the receiving and the transmitting are not interfered with each other, so that all applications or components are not required to be in an operation state all the time.
The inventor finds that in the process of implementing the embodiment of the invention, in the related technology, the reminding task is usually executed through a single server, however, a single-point effect exists when the reminding task is executed through the single server, the reminding task is lost when the server fails, disaster tolerance is avoided, and stable reminding service cannot be provided for users.
In this regard, the embodiment of the invention provides a method for running a reminding task, which provides a reminding service based on a distributed system, so that the method can be applied to the distributed system, and the distributed system comprises a plurality of servers; the server receives the set reminding tasks and stores the reminding tasks according to the time interval of the reminding time of the received reminding tasks; setting a thread for executing a reminding task to be in a blocking state, and attempting to acquire a distributed lock in a distributed system; when the distributed lock is acquired, converting a thread in a blocking state into an executable state, and executing a reminding task in a current time interval through the thread to send a reminding message corresponding to the executed reminding task; the current time interval is the time interval in which the thread acquires the distributed lock.
In view of this, the embodiment of the invention provides a method and a device for running a reminding task, electronic equipment and a computer readable storage medium, which can provide stable reminding service.
The following describes an exemplary application of the method for running a reminding task according to the embodiment of the present invention, where the method for running a reminding task according to the embodiment of the present invention may be implemented by various electronic devices, for example, may be implemented by a server cluster, or may be implemented in a manner of cooperation between a user terminal and the server cluster.
Referring to fig. 1, fig. 1 is an optional architecture schematic diagram of a task reminding running system 100 according to an embodiment of the present invention, where the task reminding running system 100 includes: distributed system 200 (where distributed system 200 includes a server cluster of multiple servers 300, server 300-1, server 300-2, and server 300-N are shown in fig. 1 by way of example), network 400, and terminal 500 (terminal 500-1, terminal 500-2, and terminal 500-N are shown by way of example), terminal 500 connects distributed system 200 through network 400, and network 400 can be a wide area network or a local area network, or a combination of both.
The operation method of the reminding task provided by the embodiment of the invention can be realized through the following processes: first, the terminal 500 transmits a plurality of reminding tasks set by a user for a service to the distributed system 200 through the network 400, the distributed system 200 stores the plurality of reminding tasks in the server 300-1 according to a time interval in which a reminding time of the received reminding task is located after receiving the plurality of reminding tasks transmitted by the terminal 500, and then the distributed system 200 backs up the reminding tasks stored in the server 300-1 to the servers 300-2 to 300-N so that each server stores the same reminding task. Subsequently, servers 300-1 through 300-N respectively set the threads each for performing the reminder task to a blocked state and attempt to acquire a distributed lock in distributed system 200. When a thread started by one of the servers acquires the distributed lock, the thread is converted from a blocking state to an executable state, a reminding task in a current time interval is executed through the thread, and a reminding message corresponding to the executed reminding task is sent to the terminal 500. The distributed lock is limited in time, and when the validity period of the distributed lock is exceeded, the distributed lock is released so that other threads which acquire the distributed lock and are opened in a server execute reminding tasks.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a server 300 according to an embodiment of the present invention, and the server 300 shown in fig. 2 includes: at least one processor 310, a memory 340, at least one network interface 320. The various components in server 300 are coupled together by bus system 330. It is understood that the bus system 330 is used to enable connected communications between these components. The bus system 330 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various buses are labeled as bus system 330 in fig. 2.
The Processor 310 may be an integrated circuit chip with signal processing capabilities such as a general purpose Processor, such as a microprocessor or any conventional Processor, a digital signal Processor (DSP, digital Signal Processor), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
The memory 340 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard drives, optical drives, and the like. Memory 340 optionally includes one or more storage devices physically located remote from processor 310.
Memory 340 includes volatile memory or nonvolatile memory, and may also include both volatile and nonvolatile memory. The non-volatile memory may be read only memory (ROM, read Only Me mory) and the volatile memory may be random access memory (RAM, random Access Memor y). The memory 340 described in embodiments of the present invention is intended to comprise any suitable type of memory.
In some embodiments, memory 340 is capable of storing data to support various operations, examples of which include programs, modules and data structures, or subsets or supersets thereof, as exemplified below.
An operating system 341 including system programs for handling various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and handling hardware-based tasks;
The network communication module 342 is used to reach other computing devices via one or more (wired or wireless) network interfaces 320, the exemplary network interfaces 320 include: bluetooth, wireless compatibility authentication (WiFi), and universal serial bus (USB, universal Serial Bus), etc.;
in some embodiments, the running device for reminding tasks provided by the embodiments of the present invention may be implemented in a software manner, and fig. 2 shows the running device 343 for reminding tasks stored in the memory 340, which may be software in the form of a program, a plug-in, etc., and includes the following software modules: the storage module 3431, the acquisition module 3432, the execution module 3433 and the transmission module 3434 are logical, and thus may be arbitrarily combined or further split according to the implemented functions. The functions of the respective modules will be described hereinafter.
In other embodiments, the task-reminding running device provided by the embodiment of the present invention may be implemented in hardware, and by way of example, the task-reminding running device provided by the embodiment of the present invention may be a processor in the form of a hardware decoding processor, which is programmed to execute the task-reminding running method provided by the embodiment of the present invention, for example, the processor in the form of a hardware decoding processor may use one or more Application specific integrated circuits (ASICs, applications SPECIFIC INTEGRATED circuits), DSPs, programmable logic devices (PLDs, programmable Logic Device), complex programmable logic devices (CPLDs, complex Programmable Logic Device), field programmable gate arrays (FPGAs, field-Pro programmable GATE ARRAY) or other electronic components.
The following specifically describes an operation method of the reminding task provided by the embodiment of the invention. Referring to fig. 3, fig. 3 is a schematic flowchart of an alternative method for running a reminding task according to an embodiment of the present invention, and will be described with reference to the steps shown in fig. 3.
In step S301, the distributed system receives a plurality of set alert tasks sent by the user terminal.
Here, the user may set a reminder task for various services, and then the user terminal transmits a plurality of reminder tasks set by the user for the services to the distributed system.
For example, a user may set a reminder task for a calendar, for example, the user may fill in a specific schedule (e.g., 2 months 18 days afternoon 4 hours of the meeting, 1 hour of the meeting, 15 minutes before the meeting begins, etc.) in an interface of a calendar application, and then the calendar application sends the reminder task containing the above information to the distributed system.
For example, the user may set a reminder task for the meeting, e.g., the user may fill in a specific meeting schedule (e.g., start time of the meeting, duration of the meeting, participants of the meeting, etc.) in an interface of the enterprise WeChat, which then sends the reminder task containing the above information to the distributed system.
For example, the user may set a reminder task for the to-do, for example, the user may fill in specific items to-do in an interface of the calendar application (for example, the to-do item is a write-through report, the reminder time is 3 pm on friday, etc.), and then the calendar application sends the reminder task containing the above information to the distributed system.
In some embodiments, chubby, chubby may be a lock service for a loosely coupled distributed system, which is generally used to provide a highly available lock service for a loosely coupled distributed system formed by a large number of small computers, and may be used to implement synchronization, metadata storage, topology, configuration information, and other functions in the distributed system. In terms of system architecture, a typical chubby-server cluster is usually composed of 5 servers, and these replica servers adopt the Paxos protocol and determine a server as a main server by voting. Once one server becomes the primary server chubby ensures that other servers will not become the primary server for a period of time, referred to as a lease. During operation, the main server is continuously rented, and if the main server fails, the rest servers can elect a new server to become the main server. In actual operation, only the primary server can write data, and other servers use the Paxos protocol to copy data from the database of the primary server. In this way, after receiving a plurality of reminding tasks sent by the user terminal, the received reminding tasks are firstly stored in a database of the main server, and then the reminding tasks are backed up to other servers so as to store the same reminding tasks in each server.
In other embodiments, the distributed system may also use a Zookeeper, which is an open-source scalable high-throughput distributed coordination system, where the Zookeeper cluster service is also composed of multiple servers (at least 3), and 1 master server and multiple slave servers are generated by election. The client can read the required data from any one of the servers, but the written or modified data must be executed on the primary server. When the client connects with the slave server to write or update data, the slave server forwards the request to the master server, the master server completes the writing or updating of the data, and the corresponding information is notified to all the slave servers. The Zookeeper cluster is generally composed of 2n+1 (odd number) servers, can tolerate the faults of n secondary servers at maximum, and has stronger disaster recovery capability.
According to the embodiment of the invention, the plurality of reminding tasks set by the user aiming at the service are sent to the distributed system to be stored in the plurality of servers included in the distributed system, so that when a certain server fails to stop working, other servers can still work normally, the disaster tolerance of the service is improved, and more stable reminding service can be provided for the user.
In step S302, the server stores the time interval in which the reminder time of the received reminder task is located.
In some embodiments, the server stores the time interval in which the reminding time of the received reminding task is located, by the following way: dividing each day into a plurality of time intervals according to a set time granularity, and establishing a corresponding index table for each time interval; and determining a time interval in which the reminding time of the received reminding task is positioned in the divided time intervals, and storing the received reminding task into an index table corresponding to the determined time interval.
For example, the set time granularity may be minutes, dividing each day into 1440 (24 hours by 60 minutes) different time intervals according to minutes, and establishing a corresponding index table for each time interval, namely, scattering the received multiple reminding tasks and storing the scattered reminding tasks in 1440 different tables, wherein table 1 is used for storing the reminding tasks with reminding time of 00:00-00:01; table 2 is used to store alert tasks with alert times at 00:01-00:02, and so on.
For example, the set time granularity may be an hour, each day is divided into 24 different time intervals according to the hour, and a corresponding index table is established for each time interval, that is, the received multiple reminding tasks are scattered and stored in 24 different tables respectively, wherein table 1 is used for storing the reminding tasks with the reminding time of 00:00-01:00; table 2 is used to store alert tasks with alert times in the range of 01:00-02:00, and so on.
It should be noted that, the time granularity may be set according to the number of reminding tasks that need to be executed actually, for example, when the number of reminding tasks that need to be executed is small, a larger time granularity may be set; conversely, when the number of alert tasks to be performed is greater, a smaller time granularity may be set, which is not particularly limited in the embodiment of the present invention.
In other embodiments, in order to support multithreading to execute the reminding task, the plurality of reminding tasks stored in each time interval may be further divided, for example, modulo operation may be performed on numbers of the plurality of reminding tasks stored in each time interval, and a result of the modulo operation may be divided into a plurality of number segments according to a set granularity, so as to divide the plurality of reminding tasks into corresponding number segments. And then, the server simultaneously starts the same number of threads according to the number of the number segments in the current time interval, and each thread executes the reminding task in one number segment.
It should be noted that, for the reminding tasks stored in different time intervals, after the numbers of the reminding tasks are subjected to modulo operation, the granularity of dividing the modulo operation result is also different, for example, when the number of the reminding tasks stored in a certain time interval is large, the larger granularity can be set to divide the modulo operation result, for example, the modulo operation result can be divided into 5 different number segments, and at the moment, the server starts 5 threads to execute the reminding tasks in the corresponding number segments; when the number of reminding tasks stored in a certain time interval is small, a small granularity can be set to divide the modular operation result, for example, the modular operation result can be divided into 2 different number segments, and at the moment, the server starts 2 threads to execute the reminding tasks in the corresponding number segments.
In other embodiments, the specific storage mode of the reminding task may be stored by using a distributed key value database, for example, using PKV (Paxosstore Key Value) with high disaster tolerance. PKV is a high availability storage system that employs a modular design in the storage layer to develop different storage engines for different storage models. PKV is characterized in that it abstracts the Paxos-based distributed consistency protocol as a middleware that the underlying multimodal storage engine can access in each case. This facilitates adjustment, maintenance, scaling and expansion of the storage engine. The overall architecture of PKV includes a programming model, a consistency layer, and a storage layer 3 layer, where the programming model provides a variety of data architectures for various external applications. The consistency layer executes the Paxos-based storage protocol. The storage layer contains a plurality of storage engines constructed according to different storage models, which can meet a variety of performance requirements. The architecture of PKV differs from conventional storage designs in that it can abstract the coherence protocol application as a middleware that provides data coherence guarantees for all potential storage engines. The PK V adopts a combined storage design, a plurality of storage models are applied to a storage layer, only the realization problem of high availability is processed, and the consistency problem is processed by a consistency layer. This allows each storage engine and the entire storage tier to be expanded as desired. Since the coherence protocol application has been decoupled from the storage engine, all supported storage models can in various cases take advantage of data coherence guarantees, which also makes cross-model data access easier to implement. The index of PKV adopts the leftmost matching principle, so that a minute time field is added in the index of the reminding task in the table, the index can be completely hit through the field, and the query efficiency can be greatly improved.
According to the embodiment of the invention, after the plurality of reminding tasks sent by the user terminal are received, the reminding tasks are stored according to the time interval where the reminding time of the received reminding tasks is, namely, the plurality of reminding tasks are scattered and stored in different index tables, so that the writing and inquiring efficiency of the reminding tasks is improved.
In step S303, the server sets a thread for executing the reminder task to a blocked state and attempts to acquire a distributed lock in the distributed system.
Here, the plurality of servers in the distributed system set the threads each for executing the reminder task to a blocked state, respectively, and attempt to acquire the distributed lock in the distributed system.
By way of example, multiple servers in a distributed system each initiate a respective GetLock thread and attempt to acquire a distributed lock in the distributed system in a blocking manner. The GetLock thread judges whether the distributed lock is acquired or not through a CHECKHEL D (fd) method, when the CHECKHELD (FD) method returns true, the corresponding GetLock thread is determined to acquire the distributed lock, and when the CHECKHELD (FD) method returns false, the corresponding GetLock thread is determined to not acquire the distributed lock.
In step S304, when the distributed lock is acquired, the server converts the thread in the blocked state into an executable state, and executes the reminding task in the current time interval through the thread.
In some embodiments, when a thread corresponding to a certain server in the distributed system acquires the distributed lock, the thread is converted from a blocking state to an executable state, and a reminding task in a current time interval is executed through the thread, wherein the current time interval is a time interval in which the thread acquires the distributed lock.
In other embodiments, the execution of the alert task in the current time interval by the thread in step S304 may be implemented by steps S401 to S405 shown in fig. 4, which will be described in connection with the steps shown in fig. 4.
In step S401, the distributed system first determines, according to the number of number segments in the current time interval, the number of threads in the server for executing the reminding task.
Here, when the number of reminding tasks to be executed is large, backlog is easily formed by executing the reminding tasks through a single thread, and further the reminding tasks are lost. In this regard, according to the method for running the reminding task provided by the embodiment of the invention, the reminding task to be executed is divided into different number segments according to the number of the reminding task, and then the number of the number segments in the current time interval is determined to be used for executing the reminding task in the server.
For example, assuming that the number of number segments in the current time interval is 5 (i.e., the alert task to be executed is divided into 5 parts), 5 threads are simultaneously started in the server.
In step S402, the thread 1 reads the reminding task in the number segment 1, and adds the read reminding task to the circular queue 1.
In step S403, the thread N reads the reminding task in the number segment N, and adds the read reminding task to the circular queue N.
Here, there is a one-to-one correspondence between threads, number segments, and circular queues. Thread 1 is used for reading the reminding task in number segment 1 and adding the read reminding task into the circular queue 1, thread 2 is used for reading the reminding task in number segment 2 and adding the read reminding task into the circular queue 2, and so on.
In step S404, the thread 1 executes the reminding task in the circular queue 1.
In step S405, the thread N executes the reminding task in the circular queue N.
Here, considering mutual independence among reminding tasks, therefore, a plurality of circulation queues are used, different threads only execute the reminding tasks in the corresponding circulation queues, and therefore, the execution speed of the reminding tasks can be increased by executing the reminding tasks of different number segments through the plurality of threads, and the reminding tasks are prevented from being lost due to backlog.
In some embodiments, in order to avoid the reminding task from being lost, the reading task and the executing task may be separated into 2 threads, where the reading task thread is responsible for reading the reminding task to be executed in the current time interval and adding the read reminding task into the memory container, and the executing task thread is responsible for acquiring the reminding task of the reading task thread stored in the memory container from the memory container and executing the reminding task. In addition, after the task reading thread finishes reading the reminding task in the current time interval, if the number of the reminding tasks to be executed is greater than zero, the task reading thread can enter a sleep state, and at the moment, the newly added reminding task can be lost after the task reading is finished. Therefore, the server can independently start a group of threads for reading the creation time and the scheduling time as reminding tasks in the next time interval, wherein the number of the threads is the same as the number of the number segments in the next time interval, and therefore the reminding tasks can be prevented from being lost.
In other embodiments, to avoid repeated execution of the reminder task, it is also desirable to delete the successfully executed reminder task from the list of reminder tasks. The deleting process is a remote process call, and a failure may exist, so that a retry queue may be started in each server, the reminding task of the deleting failure is added into the retry queue, and the retry queue is used for deleting again.
According to the embodiment of the invention, the reminding task is divided, a plurality of threads are started in the server at the same time, and each thread only executes the reminding task of one number segment, so that the execution speed of the reminding task is greatly increased, and the backlog of the reminding task is avoided.
In step S305, a reminder message corresponding to the reminder task being executed is sent to the terminal.
In some embodiments, the reminding task to be executed can be added into the message queue, and the message queue sends the reminding message corresponding to the executed reminding task to the terminal, so that based on asynchronous logic, the server only needs to trigger the reminding task, and specific task processing logic is executed by the message queue, thereby greatly accelerating the execution speed of the reminding task.
It should be noted that, the reminding task to be executed is added to the message queue, the specific task processing logic executed by the message queue is a remote procedure call, and there may be a problem that the reminding task is lost due to timeout, so that for the reminding task which fails to be executed, the reminding task can be added to the retry queue, and the retry queue re-executes the reminding task, so as to avoid the loss of the reminding task.
In step S306, when the validity period of the distributed lock is exceeded, the distributed lock is released and the thread is reconverted to a blocked state.
Here, the distributed lock is time-limited (e.g., 5 seconds timeout), and when the validity period of the distributed lock is exceeded, the thread releases the distributed lock and the server reconverts the thread to a blocked state. At this time, other servers in the distributed system can try to acquire the distributed lock so that other servers acquiring the distributed lock execute the reminding task, so that the reminding task is executed through a plurality of servers, and when one of the servers fails to stop working, the other servers can still work normally, the disaster tolerance of the reminding service is improved, and reliable reminding service can be provided for users.
Continuing with the description below of an exemplary configuration of the alert task execution device 343 provided in the embodiment of the present invention implemented as a software module, in some embodiments, as shown in fig. 2, the software module stored in the alert task execution device 343 of the memory 340 may include: a storage module 3431, an acquisition module 3432, an execution module 3433, and a transmission module 3434.
The storage module 3431 is configured to receive the set plurality of reminding tasks, and store the set plurality of reminding tasks according to a time interval in which a reminding time of the received reminding task is located; an acquisition module 3432 for setting a thread for performing a reminder task to a blocked state and attempting to acquire a distributed lock in the distributed system; the execution module 3433 is configured to, when the distributed lock is acquired, convert the thread in the blocked state into an executable state, and execute, by the thread, a reminder task in a current time interval, where the current time interval is a time interval in which the thread acquires the distributed lock; and the sending module 3434 is configured to send a reminder message corresponding to the executed reminder task.
In some embodiments, the storage module 3431 is further configured to divide each day into a plurality of time intervals according to a set time granularity, and build a corresponding index table for each time interval; and determining a time interval in which the reminding time of the received reminding task is positioned in the divided time intervals, and storing the received reminding task into an index table corresponding to the determined time interval.
In some embodiments, the running device 343 for reminding tasks further includes a dividing module 3435, configured to perform modulo arithmetic according to numbers of the plurality of reminding tasks for the plurality of reminding tasks stored in any time interval in the index table; dividing the modular operation result into a plurality of number segments according to the set granularity, so as to divide a plurality of reminding tasks into corresponding number segments according to the numbers of the plurality of reminding tasks.
In some embodiments, the execution module 3433 is further configured to adjust, according to the number of number segments in the current time interval, the number of threads started in the server, so that each thread reads a reminder task in one number segment, and adds the read reminder task to a corresponding circular queue; and executing reminding tasks in any one of the circular queues by threads corresponding to the any one of the circular queues according to any one of the circular queues.
In some embodiments, the execution module 3433 is further configured to execute, by the thread, the reminder service in the current time interval during the validity period of the distributed lock; when the validity period of the distributed lock is exceeded, the distributed lock is released and the thread in the executable state is reconverted to the blocked state.
In some embodiments, the execution module 3433 is further configured to add the alert task to be executed in the current time interval to the message queue in an asynchronous manner, so as to send an alert message corresponding to the alert task to be executed through the message queue.
In some embodiments, the execution module 3433 is further configured to read, by the read task thread, the reminder task to be executed in the current time interval when the number of reminder tasks to be executed in the current time interval is greater than the preset threshold, store the read reminder task in the memory container, and obtain, by the execute task thread, the reminder task to be executed from the memory container and execute the reminder task.
In some embodiments, the execution module 3433 is further configured to switch the task thread to a sleep state after the reminding task to be executed in the current time interval is read; when the time of the next time interval arrives, a group of new reading task threads are started to read reminding tasks to be executed in the next time interval, wherein the number of the new reading task threads is the same as the number of the number segments in the next time interval.
In some embodiments, the execution module 3433 is further configured to, when the execution of the reminder task fails, add the reminder task that fails to execute to the retry queue for re-execution by the retry queue; when the reminding task is successfully executed, deleting the reminding task which is successfully executed, and when the deleting is failed, adding the reminding task which is failed to be deleted into a retry queue so as to delete again through the retry queue.
It should be noted that, the description of the apparatus according to the embodiment of the present invention is similar to the description of the embodiment of the method described above, and has similar beneficial effects as the embodiment of the method, so that a detailed description is omitted. The technical details of the reminding task running device provided by the embodiment of the invention, which are not described in detail, can be understood according to the description of any one of the figures 3-4.
In the following, an exemplary application of the embodiment of the present invention in a practical application scenario will be described.
With the development of internet technology, users can install various applications on terminals and perform different services based on the installed applications. For example, a user may record personal work schedule of the user through a calendar application installed on the terminal, and may initiate a schedule of participation of multiple persons, such as a meeting, team activities, and the like. Meanwhile, in order to avoid forgetting the user, a reminding service is needed for a plurality of businesses, and particularly when the number of businesses is large, the reminding service is very important. The specific implementation process of the reminding service is as follows: the user firstly sets a reminding task aiming at the service in a graphical interface of the terminal, then the terminal sends the reminding task set by the user aiming at the service to the server, and the server executes the reminding task so as to send a reminding message to the terminal at preset time to remind the user.
In the related art, the reminding service is generally provided by means of a delay message queue (delaymq), but the delay time is short in this way, so that the reminding service after one month is not supported; in addition, problems such as queue backlog are also easy to cause, and delay of reminding service or loss of reminding tasks are caused.
Aiming at the problems, the embodiment of the invention provides a method for running a reminding task, which can provide reliable reminding service, is more suitable for business, and can enable more business to access the reminding service, thereby providing various reminding functions for users.
The operation method of the reminding task provided by the embodiment of the invention supports the reminding service of various businesses.
For example, referring to fig. 5, fig. 5 is a schematic diagram of an interface of a reminding task set by a user for a schedule according to an embodiment of the present invention. As shown in fig. 5, a user may set information such as a reminder time (501), a duration of a meeting (502), a participant of the meeting (503), whether to repeat the reminder (504), and the like for a schedule, and then, the terminal sends a reminder task including the information to the distributed system, and a server in the distributed system sends a corresponding reminder message to the terminal at a preset time.
For example, referring to fig. 6, fig. 6 is a schematic interface diagram of a reminding task set by a user for a conference according to an embodiment of the present invention, as shown in fig. 6, the user may set information such as a reminding time (601) for the conference, a duration (602) of the conference, and a participant (603) of the conference, and then, a terminal sends the reminding task including the information to a distributed system, and a server in the distributed system sends a corresponding reminding message to a corresponding terminal at a preset time.
For example, referring to fig. 7, fig. 7 is an interface schematic diagram of a reminding task set by a user for to-do according to an embodiment of the present invention, as shown in fig. 7, the user may set specific information such as to-do event (701), reminding time (702), etc., and then, the terminal sends the reminding task including the information to the distributed system, and a server in the distributed system sends a corresponding reminding message to the terminal at a preset time.
The following specifically describes an operation method of the reminding task provided by the embodiment of the invention.
The implementation process of the reminding service can be mainly divided into two parts, namely a reminding task receiving part and a reminding task executing part, and the two parts are respectively and specifically described below.
(One) receiving a reminder task
The running method of the reminding task provided by the embodiment of the invention adopts a distributed system, wherein the distributed system comprises a plurality of servers, and the user terminal sends the plurality of reminding tasks set by the user aiming at the service to the distributed system so as to store the plurality of reminding tasks in the plurality of servers included in the distributed system. The execution of the subsequent reminder task is performed by the server that acquired the distributed lock. Specifically, the running method of the reminding task provided by the embodiment of the invention adopts the distributed lock, a plurality of servers are started, and threads in the servers, which acquire the distributed lock, execute the reminding task. Each thread in the server determines whether the distributed lock is acquired by the CHECKHELD (FD) method (when the return value of the CHECKHELD (FD) function is true, it is determined that the thread acquires the distributed lock, and when the return value of the CHECKHELD (FD) function is false, it is determined that the thread does not acquire the distributed lock). Each server initiates GetLock a thread to attempt to acquire a distributed lock in a blocking manner. Meanwhile, the distributed lock has timeliness (for example, 5 seconds are overtime), the distributed lock is automatically released after overtime, other servers which acquire the distributed lock execute reminding tasks, the switching time is quick, and the reminding tasks cannot be lost.
In some embodiments, the distributed lock may employ chubby, chubby, which is a lock service oriented to loosely coupled distributed systems, typically used to provide highly available lock services for loosely coupled distributed systems consisting of a large number of small computers. The purpose of a distributed lock service is to allow its client processes to synchronize each other's operations and agree on basic state information of the environment in which it is currently located. A typical chubby cluster may consist of, for example, 5 servers that are identical in configuration and are in peer-to-peer position at the very beginning of the system.
Referring to fig. 8, fig. 8 is a schematic diagram of an architecture for providing a reminder service based on a distributed lock chubby according to an embodiment of the present invention, as shown in fig. 8, each server starts GetLock a thread to attempt to acquire the distributed lock in a blocking manner, executes a reminder task by the thread that acquires the distributed lock, and sends a reminder message corresponding to the executed reminder task to a corresponding terminal. And when the expiration date of the distributed lock is exceeded, the distributed lock is automatically released, and other servers acquiring the distributed lock execute reminding tasks. Therefore, the reminding task is executed through the servers, when one of the servers fails to stop working, the other servers can still work normally, the service is continuously provided, the disaster tolerance of the reminding service is improved, and more reliable reminding service can be provided for users.
In some embodiments, in order to further improve the writing and searching efficiency of the reminding task, the method for running the reminding task provided by the embodiment of the invention uses the distributed key value database with high disaster tolerance to store a plurality of reminding tasks, and the storage uses a minute level table for storage, and determines which table the reminding task is stored in according to the minutes of the reminding time, and the execution precision of the reminding task is specific to the minute level, namely, the reminding task which needs to be executed every day is scattered in 1440 (24 hours and 60 minutes) tables, so as to improve the writing and searching efficiency. Meanwhile, in order to support multithreading to execute the reminding task, the reminding task to be executed in each minute can be further split into a plurality of number segments, each thread executes the reminding task in one number segment, and the reminding task to be executed is inquired according to the number segments.
For example, PKV (Paxosstore Key Value) storage alert tasks with high disaster tolerance may be used. PKV is a distributed storage system that replicates synchronously across campus data centers, provides flexible data patterns and access interfaces, supports single billions of rows, has fast scalability, low latency, low cost, strong consistency, and high availability. The indexes of PKV adopt leftmost matching principle, namely leftmost priority, any continuous indexes can be matched by taking leftmost as a starting point, and the matching is stopped when range query is encountered. Therefore, a minute time field is added in the index of the reminding task in the table, the index can be completely hit through the minute time field, and the query efficiency is greatly improved. The query mode may be:
select*from RemindSched%02d%02d where minTime=xxx and num>=minNum and num<maxNum。
(II) executing the reminder task
In some embodiments, in order to avoid too slow execution of a reminding task, the method for running the reminding task provided by the embodiment of the invention adopts asynchronous logic, adds the reminding task to be executed into a Message Queue (MQ), executes specific task processing logic through the Message Queue (i.e. sends a reminding Message to a terminal through the Message Queue), and the reminding service is only responsible for triggering the reminding task, so that the execution speed of the reminding task can be greatly increased, and backlog is avoided. In addition, it should be noted that, when a specific task processing logic is executed by the message queue, an asynchronous task is added to be a remote procedure call, and a reminding task may be lost due to a timeout or other problem. Therefore, the reminding task with the failure execution is added into a retry queue started by the server to be re-executed, and the reminding task is prevented from being lost.
In other embodiments, when an excessive number of alert tasks that need to be performed within a certain minute results in a time period exceeding a preset time period (e.g., exceeding 2 minutes), the alert tasks may be lost. Therefore, the reading reminding task and the executing reminding task can be separated into 2 threads, the reading task thread reads the reminding task to be executed and stores the reminding task into the memory container, and the executing task thread obtains the reminding service stored by the reading task thread from the memory container and executes the reminding service. The multithread execution reminding task has concurrent problems, the memory container needs to be locked, and a circular queue can be used for replacing the lock so as to improve the efficiency.
In other embodiments, when one thread reads the reminding task but does not execute the reminding task, the distributed lock is lost, at this time, after the other threads started by the server acquire the distributed lock, the thread continues to read the reminding task in the current minute and execute the reminding task, and if the whole process occurs in the same minute, the repeated execution of the reminding task is caused. In contrast, according to the running method of the reminding task provided by the embodiment of the invention, after each time the reminding task is executed, the executed reminding task is deleted from the task list. The deletion procedure is a remote procedure call (RPC, remote Procedure Call) and there may be a failure. Therefore, each server starts a retry queue, if the reminding task fails to be deleted, the reminding task which fails to be deleted is added into the retry queue for re-deleting, and thus, the situation that the reminding task is repeatedly executed is greatly reduced.
In some embodiments, after the reminding task is read, if the number of the reminding tasks to be executed is greater than zero, the thread of the reading task sleeps to the next minute, and at this time, the reminding task of the current minute newly added after the reading is lost. To this end, the server may individually start a set of threads for reading the reminder task for the next minute in creation time and scheduling time, thereby avoiding the loss of reminder tasks.
In other embodiments, when the number of reminding tasks to be executed is greater, the reminding tasks are further split, for example, a plurality of reminding tasks can be divided into different number segments according to unique identification accounts in enterprises of the reminding tasks, meanwhile, considering mutual independence of the reminding tasks, a plurality of circulation queues can be used, a plurality of threads are started in a server at the same time to read the reminding tasks of the different number segments, the read reminding tasks of the different number segments are added into the different circulation queues, and each thread executes the reminding tasks in the corresponding circulation queues.
Referring to fig. 9, fig. 9 is a schematic flow chart of executing reminding tasks with different number segments through multiple threads according to an embodiment of the present invention. As shown in fig. 9, after dividing the plurality of alert tasks into N different number segments, the server correspondingly starts N threads to correspondingly execute the alert tasks in the N different number segments (i.e., execute the alert task in the number segment 1 by the thread 1, execute the alert task in the number segment 2 by the thread 2, and so on), and adds respective corresponding thread locks for the N threads (i.e., lock 1 for the thread 1, lock 2 for the thread 2, and so on).
Taking thread 2 as an example, when thread 2 acquires lock 2, the reminding task divided into number segment 2 is read from a relational database management system (MySQL) or PKV storing the reminding task, the reminding task in the read number segment 2 is added to the circular queue 2, and after all the reminding tasks in the number segment 2 are added to the circular queue 2, thread 2 sleeps to the next minute. The reminding task in the number segment 2 can be obtained by setting a time range, a numerical range of the number segment and the like and searching MySQL or PKV based on a leftmost matching principle, and when the reminding task of the number segment 2 cannot be searched from MySQL or PKV, the thread 2 sleeps for 5 seconds.
Then, for the reminding task stored in the circulation queue 2, one reminding task is sequentially fetched for execution, specifically, each time when one reminding task is executed, one reminding task is removed from the head of the circulation queue 2, whether the current circulation queue 2 is an empty POP (namely, whether the reminding task to be executed exists in the current circulation queue 2 or not is judged), and when the current circulation queue 2 is the empty POP, it is determined that all the reminding tasks in the circulation queue 2 are executed.
The specific execution process of the reminding task may adopt asynchronous logic, that is, the reminding task to be executed is added into a Message Queue (MQ), and the Message Queue executes a specific logic processing process (that is, according to the specific content of the reminding task, a corresponding reminding Message is sent to a corresponding terminal at a set time point). After the execution of the reminding task is completed, the successfully executed reminding task needs to be deleted from MyS QL or PKV.
And when the deletion is failed, adding the reminding task with the deletion failure into a retry queue opened by the server for re-deleting, for example, polling the retry queue by the server with a period of 1 second, and when the reminding task with the deletion failure exists in the retry queue, re-deleting the reminding task with the deletion failure.
It should be noted that, the specific process of executing the reminding task by the thread 1 and the thread N is similar to the executing process by the thread 2, and for saving the space, the subsequent specific executing process of the thread 1 and the thread N is not shown in fig. 9.
The operation method of the reminding task can support the reminding service of various service supporting events, can provide more reliable reminding service, is more suitable for the service, can enable more services to be accessed into the reminding service, and provides various reminding functions for users.
Embodiments of the present invention provide a computer readable storage medium storing executable instructions that, when executed by a processor, cause the processor to perform a method for executing a reminder task provided by embodiments of the present invention, for example, a method for executing a reminder task as shown in fig. 3 or 4.
In some embodiments, the storage medium may be FRAM, ROM, PROM, EPROM, EE PROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; but may be a variety of devices including one or any combination of the above memories.
In some embodiments, the executable instructions may be in the form of programs, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and they may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
As an example, the executable instructions may, but need not, correspond to files in a file system, may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a hypertext markup language (HT ML, hyper Text Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
As an example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices located at one site or distributed across multiple sites and interconnected by a communication network.
In summary, the embodiment of the invention has the following beneficial effects:
the operation method of the reminding task can support the reminding service of various businesses, can provide more reliable reminding service, is more suitable for the businesses, can enable more businesses to access the reminding service, and provides various reminding functions for users.
The foregoing is merely exemplary embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and scope of the present invention are included in the protection scope of the present invention.

Claims (10)

1. The running method of the reminding task is characterized by being applied to a distributed system, wherein the distributed system comprises a plurality of servers;
The method comprises the following steps:
the server receives the set reminding tasks and stores the reminding tasks according to the time interval of the reminding time of the received reminding tasks;
Setting a thread for executing the reminding task to be in a blocking state, and attempting to acquire a distributed lock in the distributed system;
when the distributed lock is acquired, converting the thread in the blocking state into an executable state, and executing a reminding task in the current time interval through the thread to
Sending a reminding message corresponding to the executed reminding task;
the current time interval is a time interval in which the thread acquires the distributed lock.
2. The method of claim 1, wherein the storing according to the time interval in which the reminder time of the reminder task is received comprises:
Dividing each day into a plurality of time intervals according to a set time granularity, and establishing a corresponding index table for each time interval;
And determining a time interval in which the reminding time of the received reminding task is positioned in the divided time intervals, and storing the received reminding task into an index table corresponding to the determined time interval.
3. The method according to claim 2, wherein the method further comprises:
Performing modular operation according to the serial numbers of a plurality of reminding tasks aiming at the plurality of reminding tasks stored in any time interval in the index table;
Dividing the modular operation result into a plurality of number segments according to the set granularity, and dividing the plurality of reminding tasks into corresponding number segments according to the numbers of the plurality of reminding tasks.
4. A method according to claim 3, wherein said executing, by the thread, a reminder task within a current time interval comprises:
according to the number of the number segments in the current time interval, the number of the threads started in the server is adjusted so that
Each thread reads the reminding task in one number segment and adds the read reminding task into a corresponding circulation queue;
And executing reminding tasks in any one of the circular queues by threads corresponding to the any one of the circular queues according to any one of the circular queues.
5. The method of claim 1, wherein the executing, by the thread, the reminder task within the current time interval comprises:
Executing reminding service in the current time interval through the thread in the valid period of the distributed lock;
releasing the distributed lock when the validity period of the distributed lock is exceeded, and reconverting the thread in the executable state to a blocking state.
6. The method of claim 1, wherein the executing, by the thread, the reminder task within the current time interval comprises:
And adding the reminding task to be executed in the current time interval into a message queue in an asynchronous mode, so as to send a reminding message corresponding to the executed reminding task through the message queue.
7. The method of claim 1, wherein the executing, by the thread, the reminder task within the current time interval comprises:
when the number of the reminding tasks to be executed in the current time interval is larger than a preset threshold value, reading the reminding tasks to be executed in the current time interval through a reading task thread, storing the read reminding tasks into a memory container, and
And acquiring the reminding task to be executed from the memory container through an execution task thread and executing the reminding task.
8. The method of claim 7, wherein the method further comprises:
after the reminding task to be executed in the current time interval is read, switching the reading task thread to a sleep state;
When the time of the next time interval arrives, a group of new task reading threads are started to read reminding tasks to be executed in the next time interval, wherein the number of the new task reading threads is the same as the number of the number segments in the next time interval.
9. The method according to any one of claims 1 to 8, further comprising:
when the reminding task fails to be executed, adding the reminding task which fails to be executed into a retry queue to be executed again through the retry queue;
when the execution of the reminding task is successful, deleting the reminding task which is successfully executed, and
And when the deletion is failed, adding the reminding task with the deletion failure into the retry queue to be deleted again through the retry queue.
10. An operation device for reminding tasks is characterized by being applied to a distributed system, wherein the distributed system comprises a plurality of servers;
The device comprises:
The storage module is used for receiving the set reminding tasks and storing the set reminding tasks according to the time interval of the reminding time of the received reminding tasks;
The acquisition module is used for setting a thread for executing the reminding task to be in a blocking state and attempting to acquire a distributed lock in the distributed system;
The execution module is used for converting the thread in the blocking state into an executable state when the distributed lock is acquired, and executing a reminding task in a current time interval through the thread, wherein the current time interval is the time interval in which the thread acquires the distributed lock;
and the sending module is used for sending the reminding message corresponding to the executed reminding task.
CN202010484392.9A 2020-06-01 2020-06-01 Operation method and device for reminding task Active CN113760665B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010484392.9A CN113760665B (en) 2020-06-01 2020-06-01 Operation method and device for reminding task

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010484392.9A CN113760665B (en) 2020-06-01 2020-06-01 Operation method and device for reminding task

Publications (2)

Publication Number Publication Date
CN113760665A CN113760665A (en) 2021-12-07
CN113760665B true CN113760665B (en) 2024-05-07

Family

ID=78782506

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010484392.9A Active CN113760665B (en) 2020-06-01 2020-06-01 Operation method and device for reminding task

Country Status (1)

Country Link
CN (1) CN113760665B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464884A (en) * 2008-12-31 2009-06-24 阿里巴巴集团控股有限公司 Distributed task system and data processing method using the same
CN101931553A (en) * 2009-06-17 2010-12-29 智能技术Ulc公司 Be used to manage the distributed system and the method for multi-user and multi-work space
CN103581611A (en) * 2013-11-19 2014-02-12 北京兆维电子(集团)有限责任公司 Implementation method for audio and video recording based on routing server and routing server
CN108965587A (en) * 2018-06-26 2018-12-07 恒生电子股份有限公司 A kind of message prompt method, device and equipment
CN109582466A (en) * 2017-09-29 2019-04-05 北京金山软件有限公司 A kind of timed task executes method, distributed server cluster and electronic equipment
WO2019174129A1 (en) * 2018-03-13 2019-09-19 平安科技(深圳)有限公司 Event reminder method, apparatus, computer device, and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7669015B2 (en) * 2006-02-22 2010-02-23 Sun Microsystems Inc. Methods and apparatus to implement parallel transactions
US20130182713A1 (en) * 2012-01-18 2013-07-18 LineRate Systems, Inc. State management using a large hash table
US9652491B2 (en) * 2013-04-15 2017-05-16 International Business Machines Corporation Out-of-order execution of strictly-ordered transactional workloads
US9887995B2 (en) * 2015-03-20 2018-02-06 Cyberdeadbolt Inc. Locking applications and devices using secure out-of-band channels
CN112187621B (en) * 2016-08-29 2022-09-27 阿里巴巴集团控股有限公司 Task reminding method and device for multiple information sources

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464884A (en) * 2008-12-31 2009-06-24 阿里巴巴集团控股有限公司 Distributed task system and data processing method using the same
CN101931553A (en) * 2009-06-17 2010-12-29 智能技术Ulc公司 Be used to manage the distributed system and the method for multi-user and multi-work space
CN103581611A (en) * 2013-11-19 2014-02-12 北京兆维电子(集团)有限责任公司 Implementation method for audio and video recording based on routing server and routing server
CN109582466A (en) * 2017-09-29 2019-04-05 北京金山软件有限公司 A kind of timed task executes method, distributed server cluster and electronic equipment
WO2019174129A1 (en) * 2018-03-13 2019-09-19 平安科技(深圳)有限公司 Event reminder method, apparatus, computer device, and storage medium
CN108965587A (en) * 2018-06-26 2018-12-07 恒生电子股份有限公司 A kind of message prompt method, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
分布式文件系统的研究——并发通信及网络互斥的设计与实现;丘志杰;《中国优秀硕士学位论文全文数据库(电子期刊)》;20050131;第1-10页 *

Also Published As

Publication number Publication date
CN113760665A (en) 2021-12-07

Similar Documents

Publication Publication Date Title
US9983957B2 (en) Failover mechanism in a distributed computing system
US9984140B1 (en) Lease based leader election system
ES2703901T3 (en) Distributed file system through consensus nodes
US9596301B2 (en) Distributed-leader-election service for a distributed computer system
US8495266B2 (en) Distributed lock
US20080071878A1 (en) Method and system for strong-leader election in a distributed computer system
WO2006113434A2 (en) Fault tolerant distributed lock management
CN105700939A (en) Method and system for multi-thread synchronization in distributed system
CN103870570A (en) HBase (Hadoop database) data usability and durability method based on remote log backup
CN102724304A (en) Information warehouse federation in subscription/release system and data synchronization method
US9836331B2 (en) Shared resource updating
WO2021104178A1 (en) Dynamic message pushing method and system and vehicle diagnosis server
KR101296778B1 (en) Method of eventual transaction processing on nosql database
CN111177254B (en) Method and device for data synchronization between heterogeneous relational databases
EP4276651A1 (en) Log execution method and apparatus, and computer device and storage medium
CN113760513A (en) Distributed task scheduling method, device, equipment and medium
CN115550384B (en) Cluster data synchronization method, device and equipment and computer readable storage medium
CN108108119B (en) Configuration method and device for extensible storage cluster things
CN109347906B (en) Data transmission method, device and server
CN116149827A (en) Distributed task scheduling system and distributed task scheduling execution system
CN113760665B (en) Operation method and device for reminding task
WO2024032298A1 (en) Hosting system for scenarios and configurations in power system, and hosting method
CN103761106A (en) Process control method and process engine
CN111158930A (en) Redis-based high-concurrency time-delay task system and processing method
US20100275217A1 (en) Global attribute uniqueness (gau) using an ordered message service (oms)

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