WO2022127302A1 - 一种定时器系统及方法 - Google Patents

一种定时器系统及方法 Download PDF

Info

Publication number
WO2022127302A1
WO2022127302A1 PCT/CN2021/122331 CN2021122331W WO2022127302A1 WO 2022127302 A1 WO2022127302 A1 WO 2022127302A1 CN 2021122331 W CN2021122331 W CN 2021122331W WO 2022127302 A1 WO2022127302 A1 WO 2022127302A1
Authority
WO
WIPO (PCT)
Prior art keywords
timer
service
node
record
module
Prior art date
Application number
PCT/CN2021/122331
Other languages
English (en)
French (fr)
Inventor
陶海平
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2022127302A1 publication Critical patent/WO2022127302A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • G06F11/0754Error or fault detection not based on redundancy by exceeding limits
    • G06F11/0757Error or fault detection not based on redundancy by exceeding limits by exceeding a time limit, i.e. time-out, e.g. watchdogs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Definitions

  • the present application relates to the field of mobile communications, and in particular, to a timer system and method.
  • an embodiment of the present application provides a timer system, which can simultaneously support a timer service accessed by multiple business services.
  • the timer system provided by the embodiment of the present application includes:
  • the timer service subsystem according to the timer setting request of the business service system, saves the timer record, deletes the timeout timer record, and expands or shrinks the capacity according to the change of the node information.
  • an embodiment of the present application further provides a timer method, including:
  • an embodiment of the present application also provides a working method of the above timer system, including:
  • the node expansion or reduction process is performed.
  • FIG. 1 is a schematic flowchart of a timer method according to an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a timer method according to another embodiment of the present application.
  • FIG. 3 is a specific flowchart of an implementation manner of a timer method according to an embodiment of the present application
  • FIG. 4 is a schematic diagram of capacity expansion and capacity reduction processing of a timer method according to an embodiment of the present application
  • FIG. 5 is a schematic structural diagram of a timer system according to an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a timer service subsystem according to an embodiment of the present application.
  • Fig. 1 is a schematic flowchart of a timer method according to an embodiment of the present application. The timer method in an embodiment of the present application will be described in detail below with reference to Fig. 1 .
  • step 101 service information is registered, and a timer request is set.
  • the business service system registers nodes and services in the service management center subsystem, and sends a timer setting request to the timer service subsystem.
  • the timer service node registers the service and its own node information to the service management center subsystem
  • the business service system registers the business service to the service management center subsystem at the same time
  • the business service system subscribes to the timer service subsystem, and sends the set timing The timer requests to the distribution module of the timer service subsystem.
  • user A of the business service system (the service name is serv1) needs to set message retry, and after the retry time is 10 minutes (600 seconds), the message content B is retried; the business service system serv1 serves according to the subscribed timer.
  • Subsystem service name timer send a set timing request to the timer service subsystem timer.
  • Portable fields user number A, timeout time of 600 seconds, additional information B, record index C, timer type set, service name serv1, etc.
  • the timer service subsystem distributes the timer setting request.
  • the distribution module of the timer service subsystem sends the request to a certain timer setting module thread according to the distribution policy; the timer service subsystem subscribes to the business service system at the same time, and service registration and subscription are used for distributed services Administration and messaging.
  • timer service subsystem timer after a certain distribution module of the timer service subsystem timer receives the request, it decides according to the distribution policy to send this message to the thread 1 of the timer setting module, and forwards the request to the thread 1 of the timer setting module.
  • step 102 the timer event record in the distributed database cluster is processed according to the type of the timer request.
  • the timer setting module parses the service request, and executes a specific database operation instruction according to the service request.
  • the timer setting module parses the service request, and parses out the user number A, the timeout period of 600 seconds, the additional information B, the record index C, and the timer type is set.
  • the information of this node is registered in the database, and the validity period of the record is set.
  • step 103 the timer event records in the distributed database cluster are scanned, and the timeout timer records are deleted.
  • the scanning module regularly scans the timer event records, takes out the expired timer records, and sends them to the message notification module.
  • the notification message module notifies the service service system of the timer message according to the service name.
  • the scanning module continuously scans the qualified timer records in the database; to retrieve the timer records that have reached the timeout time, the retrieval method may be batch query mode, and the range of the scanned table is determined by the node management calculation; the scanning module will retrieve The timer records are distributed to the message notification module.
  • the scanning module thread scans the timer record table M, finds that the timer of record index C expires, fetches the record corresponding to record index C, and updates the next record timeout time to 10 seconds later (The role is to retry if the notification service fails).
  • the scanning module sends the retrieved timer record C to the message notification module.
  • the fields in the request are parsed to verify whether the timer setting request meets the requirements. For example, check whether the set timeout time is valid.
  • the message notification module after receiving the request of the scanning module, the message notification module sends a timer notification message to the service system.
  • the timeout time recorded by this timer is updated to trigger the next retry notification message if the business system fails or times out; constructs a notification message request and sends the request to the business system; receives the notification returned by the business system Response message, if the response is successful, the timer record is deleted; if the response fails or times out, the timer record is not deleted.
  • the message notification module sends the information corresponding to the timer record index C: the user number A and the additional information B to the service service system serv1.
  • the business service system serv1 after receiving the notification message, the business service system serv1 sends the additional information B, that is, the content of the retry message, to the user. If the message delivery is successful, the business service system returns a success response to the timer service subsystem, and if the message delivery fails, the business service system returns a failure response to the timer service subsystem.
  • the timer service subsystem after receiving the successful response, deletes the database record corresponding to the record index C; if it receives a failure response or the business system does not return a response, the timer service subsystem does not delete the database record, Retry to notify the business service system after waiting for 10 seconds.
  • FIG. 2 is a schematic flowchart of a timer method according to another embodiment of the present application. The timer method in the embodiment of the present application will be described in detail below with reference to FIG. 2 .
  • step 201 the node information registered in the distributed database cluster is scanned.
  • the node management module of the timer service subsystem registers and updates the node information to the distributed database cluster of the timer service subsystem, and sets the record validity period.
  • the node management module periodically (for example, 3 seconds) queries the number of existing system nodes.
  • step 202 according to the scanning result, the node capacity expansion or capacity reduction process is performed.
  • the node management module regularly queries the information of all registered nodes, and allocates the scope of the scanning timer record table of the node.
  • the abnormal or reduced node information is no longer registered in the database system, and the abnormal or reduced node information is deleted after the validity period expires; the range of the scanning timer record table of the node is recalculated and allocated.
  • the node information is no longer registered in the database system, and the deletion operation is performed after the validity period of the node information is reached, and the remaining nodes are recalculated and assigned to scan the current node. Timer log table range.
  • the new node or the restored node is registered in the database system, and the range of the scanning timer record table of this node is recalculated and allocated to all nodes.
  • the new node and the restored node are registered in the database system, and all nodes are recalculated and allocated the range of the scan timer record table of this node.
  • FIG. 3 is a schematic flowchart of an implementation of a timer method according to an embodiment of the present application. The timer method in the embodiment of the present application will be described in detail below with reference to FIG. 3 .
  • the distribution module receives the service service system setting timer request message, and distributes the message to the timer setting module.
  • the business service system successfully subscribes to the timer service subsystem, sends a timer setting request to the distribution module of the timer service subsystem, and the distribution module sends the request to a timer setting module thread according to the distribution policy.
  • user A of the business service system (the service name is serv1) needs to set message retry, and retry message content B after the retry time is 10 minutes (600 seconds);
  • the business service system serv1 sends a set timing request to the timer service subsystem timer according to the subscribed timer service subsystem service name timer.
  • Portable fields user number A, timeout time of 600 seconds, additional information B, record index C, timer type set, service name serv1, etc.
  • timer service subsystem timer After a certain distribution module of the timer service subsystem timer receives the request, it decides according to the distribution policy to send this message to the thread 1 of the timer setting module, and forwards the request to the thread 1 of the timer setting module.
  • step 302 the timer setting module parses the request and saves the timer record to the distributed database system.
  • the timer setting module parses the service request, and executes specific database operation instructions according to the service request.
  • the timer setting module parses the service request, and parses out the user number A, the timeout period of 600 seconds, the additional information B, the record index C, and the timer type is set.
  • step 303 a distributed database system.
  • step 304 the scanning module regularly scans the timer records, and retrieves the expired timer records and sends them to the message notification module.
  • the scanning module regularly scans the timer records, takes out the expired timer records, and sends them to the message notification module.
  • the scanning module thread scans the timer record table M, finds that the timer of record index C expires, fetches the record corresponding to record index C, and updates the next record timeout time to 10 seconds later (The role is to retry if the notification service fails).
  • the scanning module sends the retrieved timer record C to the message notification module.
  • step 305 the message notification module sends the timer record to the service service system.
  • the notification message module notifies the service service system of the timer message according to the service name.
  • the message notification module sends the information corresponding to the timer record index C: the user number A and the additional information B to the service service system serv1.
  • the business service system serv1 After receiving the notification message, the business service system serv1 sends the additional information B, that is, the content of the retry message, to the user. If the message delivery is successful, the business service system returns a success response to the timer service subsystem, and if the message delivery fails, the business service system returns a failure response to the timer service subsystem.
  • step 306 the message notification module deletes the timer record after receiving the successful response from the business service system.
  • the notification message module deletes the timer record after receiving the successful response from the business service system.
  • the timer service subsystem after receiving the successful response, deletes the database record corresponding to the record index C; if it receives a failure response or the business system does not return a response, the timer service subsystem does not delete the database record, Retry to notify the business service system after waiting for 10 seconds.
  • FIG. 4 is a schematic diagram of capacity expansion and capacity reduction processing of the timer method according to an embodiment of the present application. Referring to FIG. 4 , the capacity expansion and capacity reduction processing of the timer method will be described in detail below.
  • the node management module regularly registers the node information to the database system, and sets the record validity period.
  • the timer service subsystem has three nodes 1, 2, and 3, and the node management module of each node regularly updates the node information to the database, and the update information carries the node number and the record validity period, such as 5 seconds.
  • the node management module periodically queries the information of all registered nodes, and allocates the scope of the scanning timer record table of the node.
  • the node management module periodically (for example, 3 seconds) queries the number of existing system nodes and sorts them according to the size of the node number, and allocates the scope of the scanning timer record table of this node; assuming that the timer system has numbers 0-23, a total of 24 There are 3 nodes queried by nodes 1, 2 and 3, so node 1 is allocated to scan the timer record table of No. 0-7, node 2 is allocated to scan the timer record table of No. 8-15, and node 3 is allocated to scan the timer record table of No. 8-15. Timer 16-23 record sheet.
  • step 403 the abnormal or reduced node information is no longer registered in the database system, and the abnormal or reduced node information is deleted after the validity period expires; the scope of the scanning timer record table of the current node is recalculated and allocated.
  • node service of node 3 in the service center is updated to the offline state, and the request sent by the business service system will not be delivered to node 3.
  • the information of node 3 in the database reaches the validity period, and the record of node 3 is deleted; there are 2 nodes left in the query of nodes 1 and 2, so node 1 is allocated to scan the timer record table No. 0-11, and node 2 is allocated to scan the 12 -23 timer record table, realize disaster recovery or capacity reduction function.
  • step 404 when a node is restored or a node is added, the new node or the restored node is registered in the database system, and the range of the scanning timer record table of the current node is recalculated and allocated to all nodes.
  • node 3 In the embodiment of the present application, it is assumed that the function of node 3 is restored after a period of time, the node service of node 3 in the service center is updated to an online state, and the request sent by the business service system can be delivered to node 3.
  • the node management module of node 3 restores and updates the node information to the database. Nodes 1, 2, and 3 query 3 nodes respectively. Therefore, node 1 allocates and scans the timer record table No. 0-7, and node 2 allocates scans 8-15. No. 16-23 timer record table is allocated and scanned by node 3 to realize the function of capacity expansion or automatic recovery of service capacity.
  • FIG. 5 is a schematic structural diagram of a timer system according to an embodiment of the present application. Referring to FIG. 5 , the following will describe in detail the schematic structural diagram of a timer system according to an embodiment of the present application.
  • the timer system includes: a business service system and a timer service subsystem.
  • the business service system which registers nodes and business services, sends a timer setting request to the timer service subsystem.
  • the timer service subsystem saves the timer record and deletes the timeout timer record according to the timer setting request of the business service system.
  • the timer system further includes a service management center subsystem.
  • the service management center subsystem is used to manage the service nodes registered in the center, and provide the service node detection, online and offline functions.
  • the timer service subsystem provides functions such as message distribution, scanning, timer setting, and message notification functions.
  • the timer service subsystem further includes the following modules: a distribution module 601 , a timer setting module 602 , a message notification module 603 , a scanning module 604 , a service management module 605 , a node management module 606 , and a distributed database cluster 607 .
  • FIG. 6 is a schematic structural diagram of a timer service subsystem according to an embodiment of the present application. Referring to FIG. 6 , the structure of the timer service subsystem in an embodiment of the present application will be described in detail below.
  • the distribution module 601 receives a timer setting request from the business service system, and distributes the timer setting request to the timer setting module.
  • this module receives a request message for setting a timer from the business service system, and distributes the request message to the timer setting module in a balanced manner.
  • the timer setting module 602 parses the timer setting request, and stores the timer setting request record in the distributed database cluster.
  • this module adopts multi-thread processing, and is used for parsing the timer setting request.
  • the timer setting request may be setting a timer or deleting a timer.
  • the timer setting module converts the information to be stored in the request into a database operation interface request, and stores the timer setting request into the distributed database cluster.
  • the timer setting request sent by the business service carries necessary fields, such as timer trigger time, unique index, etc.; it can also carry other business information that needs to be stored, such as timer type, extension information, etc.
  • the timer setting module executes the operation of deleting the database record.
  • the message notification module 603 receives the timer trigger event message sent by the scanning module and notifies the service service system, and at the same time receives the response message returned by the service service system, and sends the timer record when the timeout time is reached to the service service system.
  • the module receives the timer trigger event sent by the scanning module, and notifies the service service system of the message.
  • the content of the notified message includes the service information carried when the service sets the timer, which greatly increases the service setting timing. flexibility and scalability of the device.
  • the message sending module simultaneously receives the notification response message returned by the business service system, and deletes the timer record in the database after receiving the successful response from the business service system.
  • the scanning module 604 scans the timer record table that has reached the timeout time, retrieves records that meet the trigger conditions, and sends the records to the message notification module.
  • this module adopts multi-thread processing, and is responsible for scanning a specific timer record table every second, fetching records that meet the triggering conditions, and distributing them to the message sending module, which sends them to the business service system.
  • the service management module 605 registers the node information and service information to the service management center subsystem, and subscribes to the required services.
  • the service management module is used to register the service of the node and subscribe to the business service.
  • the node management module 606 is used to register and update the information of this node to the distributed database cluster, and set the record validity period, query the information of the timer node from the distributed database cluster, and calculate the number of nodes that this node needs to scan according to the number of existing nodes. Timer table range.
  • the module regularly updates node information to the database; regularly obtains all node information in the current system; and regularly obtains all node information in the current system.
  • this module is used to update the information of the node to the database cluster regularly, update the node and set the validity period of the record at the same time. If the node is abnormal, the information of the node will be automatically expired and deleted in the database cluster.
  • the node management module is also used to regularly query the information of all timer nodes from the database cluster, and calculate the range of the timer table that the node needs to scan according to the number of existing nodes, so as to balance the processing capacity of each node and achieve capacity reduction. , expansion, disaster recovery functions.
  • the distributed database cluster 607 keeps and stores related records of timers.
  • the high-performance, large-capacity, and persistent features of a distributed database cluster are used to provide reliable, high-performance, and large-capacity timer services to ensure that timer events are not lost;

Abstract

一种定时器系统及方法,其中该定时器系统包括业务服务系统和定时器服务子系统,该定时器服务子系统根据业务服务系统的定时器设置请求,保存定时器记录,并删除超时定时器记录。

Description

一种定时器系统及方法
相关申请的交叉引用
本申请基于申请号为202011496671.3、申请日为2020年12月17日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本申请涉及移动通信领域,尤其是一种定时器系统及方法。
背景技术
通常的定时器系统由于自身系统资源的限制,很难满足大容量、高性能的要求,一旦出现异常或资源不足,不可避免会丢失定时器事件,可靠性得不到保证。
发明内容
为了至少部分解决上述技术问题之一,本申请实施例提供一种定时器系统,可以同时支持多个业务服务接入的定时器服务。
为达到上述目的,本申请实施例提供的定时器系统,包括:
业务服务系统和定时器服务子系统;
定时器服务子系统,其根据业务服务系统的定时器设置请求,保存定时器记录,删除超时定时器记录及根据节点信息变化进行扩容或缩容。
为达到上述目的,本申请实施例还提供一种定时器方法,包括:
注册服务信息,并设置定时器请求;
根据定时器请求的类型,对分布式数据库集群中定时器事件记录进行处理;以及
扫描分布式数据库集群中定时器事件记录,删除超时定时器记录。
为达到上述目的,本申请实施例还提供一种上述定时器系统的工作方法,包括:
扫描分布式数据库集群中注册的节点信息;以及
根据扫描结果,进行节点扩容或缩容处理。
附图说明
图1为根据本申请实施例的定时器方法流程示意图;
图2为根据本申请又一实施例的定时器方法流程示意图;
图3为根据本申请实施例的定时器方法的一种实施方式的具体流程示意图;
图4为根据本申请实施例的定时器方法的扩容、缩容处理示意图;
图5为根据本申请实施例的定时器系统结构示意图;
图6为根据本申请实施例的定时器服务子系统结构示意图。
具体实施方式
以下结合附图对本申请的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本申请,并不用于限定本申请。
实施例1
图1为根据本申请实施例的定时器方法流程示意图,下面将参考图1,对本申请实施例 的定时器方法进行详细描述。
首先,步骤101,注册服务信息,并设置定时器请求。
本申请实施例中,业务服务系统将节点和服务注册到服务管理中心子系统,并发送设置定时器请求到定时器服务子系统。
本申请实施例中,定时器服务节点注册服务及本节点信息到服务管理中心子系统,业务服务系统同时注册业务服务到服务管理中心子系统,业务服务系统订阅定时器服务子系统,发送设置定时器请求给定时器服务子系统的分发模块。
本申请实施例中,业务服务系统(服务名为serv1)用户A需设置消息重试,重试时间10分钟(600秒)后,重试消息内容B;业务服务系统serv1根据订阅的定时器服务子系统服务名timer,发送设置定时请求给定时器服务子系统timer。携带字段:用户号码A、超时时间600秒,附加信息B,记录索引C,定时器类型为set,服务名为serv1等。
本申请实施例中,定时器服务子系统分发设置定时器请求。
本申请实施例中,定时器服务子系统的分发模块按照分发策略将该请求发给某个定时器设置模块线程;定时器服务子系统同时订阅业务服务系统,服务注册和订阅用于分布式服务管理和消息发送。
本申请实施例中,定时器服务子系统timer某个分发模块收到请求后,按照分发策略决策本条消息发给定时器设置模块线程1,将请求转发给定时器设置模块线程1。
在步骤102,根据定时器请求的类型,对分布式数据库集群中定时器事件记录进行处理。
本申请实施例中,定时器设置模块解析业务请求,根据业务请求执行具体的数据库操作指令。
本申请实施例中,定时器设置模块解析业务请求,解析出用户号码A、超时时间600秒,附加信息B,记录索引C,定时器类型为set。根据定时器类型构建insert数据库语句并根据记录索引C唯一确认一张定时器记录表M,将号码A、超时时间600秒,附加信息B,记录索引C插入数据库定时器记录表M。
本申请实施例中,注册本节点信息到数据库,并设置记录有效期。
在步骤103,扫描分布式数据库集群中定时器事件记录,删除超时定时器记录。
本申请实施例中,扫描模块定时扫描定时器事件记录,将到期的定时器记录取出并发送给消息通知模块。
本申请实施例中,通知消息模块将定时器消息按照服务名通知给业务服务系统。
本申请实施例中,扫描模块持续扫描数据库中符合条件的定时器记录;检索到达超时时间的定时器记录,检索方式可以是批量查询方式,扫描的表范围由节点管理计算确定;扫描模块将取出的定时器记录分发到消息通知模块。
本申请实施例中,600秒后,扫描模块线程扫描定时器记录表M,发现记录索引C定时器到期,将记录索引C对应的记录取出,同时更新下一次记录超时时间为10秒钟后(作用是若通知业务失败执行重试)。扫描模块将取出的定时器记录C发给消息通知模块。
本申请实施例中,解析请求中的字段,校验定时器设置请求是否符合要求。如检查设置的超时时间是否有效。
本申请实施例中,消息通知模块接收到扫描模块的请求后,发送定时器通知消息给业务系统。
本申请实施例中,更新本条定时器记录的超时时间,用于如果业务系统处理失败或超时,触发下次重试通知消息;构建通知消息请求并发送请求给业务系统;接收业务系统返回的通知响应消息,若响应成功,删除定时器记录;若响应失败或超时,不删除定时器记录。
本申请实施例中,消息通知模块将定时器记录索引C对应的信息:用户号码A、附加信息B发给业务服务系统serv1。
本申请实施例中,业务服务系统serv1收到通知消息后,将附加信息B即重试消息内容下发给用户。若消息下发成功,业务服务系统返回成功响应给定时器服务子系统,若消息下发失败,业务服务系统返回失败响应给定时器服务子系统。
本申请实施例中,定时器服务子系统收到成功响应后,删除记录索引C对应的数据库记录;若收到的是失败响应或者业务系统未返回响应,定时器服务子系统不删除数据库记录,等待10秒后重试通知业务服务系统。
实施例2
图2为根据本申请又一实施例的定时器方法流程示意图,下面将结合图2,对本申请实施例的定时器方法进行详细描述。
首先,在步骤201,扫描分布式数据库集群中注册的节点信息。
本申请实施例中,定时器服务子系统的节点管理模块注册和更新节点信息到定时器服务子系统的分布式数据库集群,并设置记录有效期。
本申请实施例中,节点管理模块定时(如3秒)查询现有系统节点个数。
在步骤202,根据扫描结果,进行节点扩容或缩容处理。
本申请实施例中,节点管理模块定时查询所有注册的节点信息,分配本节点扫描定时器记录表范围。
本申请实施例中,不再注册异常或减少的节点信息到数据库系统,异常或减少的节点信息在有效期到达后删除;重新计算分配本节点扫描定时器记录表范围。
本申请实施例中,出现某个节点异常或减少一个节点,不再注册该节点信息到数据库系统,并在该节点信息的有效期到达后进行删除操作,并对剩余的节点重新计算分配本节点扫描定时器记录表范围。
本申请实施例中,节点恢复或增加一个节点时,新节点或恢复节点注册到数据库系统,对所有节点重新计算分配本节点扫描定时器记录表范围。
本申请实施例中,当出现节点恢复或增加一个新的节点时,将新的节点及恢复的节点注册到数据库系统,对所有节点重新计算分配本节点扫描定时器记录表范围。
实施例3
图3为根据本申请实施例的定时器方法的一种实施方式的具体流程示意图,下面将参考图3,对本申请实施例的定时器方法进行详细描述。
首先,在步骤301,分发模块接收到业务服务系统设置定时器请求消息,将该消息分发给定时器设置模块。
本申请实施例中,业务服务系统成功订阅定时器服务子系统,发送设置定时器请求给定时器服务子系统的分发模块,分发模块按照分发策略将请求发给某个定时器设置模块线程。
本申请实施例中,业务服务系统(服务名为serv1)用户A需设置消息重试,重试时间10分钟(600秒)后,重试消息内容B;
业务服务系统serv1根据订阅的定时器服务子系统服务名timer,发送设置定时请求给定时器服务子系统timer。携带字段:用户号码A、超时时间600秒,附加信息B,记录索引C,定时器类型为set,服务名为serv1等。
定时器服务子系统timer某个分发模块收到请求后,按照分发策略决策本条消息发给定时器设置模块线程1,将请求转发给定时器设置模块线程1。
在步骤302,定时器设置模块解析请求并保存定时器记录到分布式数据库系统。
本申请实施例中,定时器设置模块解析业务请求,根据业务请求执行具体的数据库操作指令。
本申请实施例中,定时器设置模块解析业务请求,解析出用户号码A、超时时间600秒,附加信息B,记录索引C,定时器类型为set。根据定时器类型构建insert数据库语句并根据记录索引C唯一确认一张定时器记录表M,将号码A、超时时间600秒,附加信息B,记录索引C插入数据库定时器记录表M。
在步骤303,分布式数据库系统。
在步骤304,扫描模块定时扫描定时器记录,并将到期的定时器记录取出发给消息通知模块。
本申请实施例中,扫描模块定时扫描定时器记录,将到期的定时器记录取出并发送给消息通知模块。
本申请实施例中,600秒后,扫描模块线程扫描定时器记录表M,发现记录索引C定时器到期,将记录索引C对应的记录取出,同时更新下一次记录超时时间为10秒钟后(作用是若通知业务失败执行重试)。扫描模块将取出的定时器记录C发给消息通知模块。
在步骤305,消息通知模块将定时器记录发给业务服务系统。
本申请实施例中,通知消息模块将定时器消息按照服务名通知给业务服务系统。
本申请实施例中,消息通知模块将定时器记录索引C对应的信息:用户号码A、附加信息B发给业务服务系统serv1。
业务服务系统serv1收到通知消息后,将附加信息B即重试消息内容下发给用户。若消息下发成功,业务服务系统返回成功响应给定时器服务子系统,若消息下发失败,业务服务系统返回失败响应给定时器服务子系统。
在步骤306,消息通知模块收到业务服务系统成功响应后删除定时器记录。
本申请实施例中,通知消息模块收到业务服务系统成功响应后删除定时器记录。
本申请实施例中,定时器服务子系统收到成功响应后,删除记录索引C对应的数据库记录;若收到的是失败响应或者业务系统未返回响应,定时器服务子系统不删除数据库记录,等待10秒后重试通知业务服务系统。
实施例4
图4为根据本申请实施例的定时器方法的扩容、缩容处理示意图,下面将参考图4,对定时器方法的扩容、缩容处理进行详细描述。
首先,在步骤401,节点管理模块定时注册本节点信息到数据库系统,设置记录有效期。
本申请实施例中,假设定时器服务子系统有三个节点1、2、3,每个节点的节点管理模 块定时更新节点信息到数据库,更新信息中携带节点号和记录有效期,如5秒。
在步骤402,节点管理模块定时查询所有注册的节点信息,分配本节点扫描定时器记录表范围。
本申请实施例中,节点管理模块定时(如3秒)查询现有系统节点个数并按节点号大小排序,分配本节点扫描定时器记录表范围;假设定时器系统有0-23号共24张定时器记录表,节点1、2、3分别查询有3个节点,于是节点1分配扫描0-7号定时器记录表,节点2分配扫描8-15号定时器记录表,节点3分配扫描16-23号定时器记录表。
在步骤403,不再注册异常或减少的节点信息到数据库系统,异常或减少的节点信息在有效期到达后删除;重新计算分配本节点扫描定时器记录表范围。
本申请实施例中,假设其中一个节点3出现异常,失去处理业务能力。节点3在服务中心的节点服务更新为下线状态,业务服务系统发送的请求不会投递到节点3。同时,5秒钟后数据库中节点3信息到达有效期,节点3记录被删除;节点1、2查询还剩2个节点,于是节点1分配扫描0-11号定时器记录表,节点2分配扫描12-23号定时器记录表,实现容灾或缩容功能。
在步骤404,节点恢复或增加一个节点时,新节点或恢复节点注册到数据库系统,对所有节点重新计算分配本节点扫描定时器记录表范围。
本申请实施例中,假设过一段时间后节点3功能恢复,节点3在服务中心的节点服务更新为上线状态,业务服务系统发送的请求可以投递到节点3。同时,节点3的节点管理模块重新恢复更新节点信息到数据库,节点1、2、3分别查询有3个节点,于是节点1分配扫描0-7号定时器记录表,节点2分配扫描8-15号定时器记录表,节点3分配扫描16-23号定时器记录表,实现扩容或业务能力自动恢复功能。
实施例5
图5为根据本申请实施例的定时器系统结构示意图,下面将参考图5,对根据本申请实施例的定时器系统结构示意图进行详细描述。
本申请实施例中,定时器系统包括:业务服务系统和定时器服务子系统。
业务服务系统,注册节点和业务服务,发送定时器设置请求到定时器服务子系统。
定时器服务子系统,其根据业务服务系统的定时器设置请求,保存定时器记录,并删除超时定时器记录。
本申请实施例中,定时器系统还包括,服务管理中心子系统。
本申请实施例中,服务管理中心子系统,用于管理注册到本中心的服务节点,提供服务节点检测,上线、下线功能。
本申请实施例中,定时器服务子系统提供消息分发,扫描,定时器设置,消息通知功能等功能。
本申请实施例中,定时器服务子系统还包括如下模块:分发模块601、定时器设置模块602、消息通知模块603、扫描模块604、服务管理模块605、节点管理模块606以及分布式数据库集群607。
实施例6
图6为根据本申请实施例的定时器服务子系统结构示意图,下面将参考图6,对本申请实施例的定时器服务子系统结构进行详细描述。
分发模块601,接收业务服务系统的设置定时器请求,并将设置定时器请求分发到定时器设置模块。
本申请实施例中,该模块接收业务服务系统的设置定时器请求消息,并将请求消息均衡的分发到定时器设置模块,分发策略可以是轮询、按照关键字如号码取模、一致性哈希等。
定时器设置模块602,解析设置定时器请求,并将设置定时器请求记录存入分布式数据库集群。
本申请实施例中,此模块采用多线程处理,用于解析定时器设置请求,定时器设置请求可以是设置定时器,也可以是删除定时器。
本申请实施例中,设置定时器请求,定时器设置模块将请求中的需要存储的信息转换为数据库操作接口请求,将定时器设置请求存入分布式数据库集群。业务服务发送的定时器设置请求携带必要字段,如定时器触发时间,唯一索引等;也可以携带其他需要存储的业务信息,比如定时器类型,扩展信息等。
本申请实施例中,删除定时器请求,定时器设置模块执行删除数据库记录操作。
消息通知模块603,接收扫描模块发送的定时器触发事件消息通知给业务服务系统,同时接收业务服务系统返回的响应消息,,将达到超时时间的定时器记录发给业务服务系统。
本申请实施例中,该模块接收扫描模块发送的定时器触发事件,并将消息通知给业务服务系统,通知的消息内容包括业务设置定时器时携带的业务信息,极大的增加了业务设置定时器的灵活性和可扩展性。消息发送模块同时接收业务服务系统返回的通知响应消息,收到业务服务系统成功响应后删除数据库中的定时器记录。
扫描模块604,扫描达到超时时间的定时器记录表,取出符合触发条件的记录并发给消息通知模块。
本申请实施例中,此模块采用多线程处理,负责每秒扫描特定的定时器记录表,取出符合触发条件的记录并分发给消息发送模块,由消息发送模块发给业务服务系统。
服务管理模块605,将本节点信息和服务信息注册到服务管理中心子系统,并订阅所需服务。
本申请实施例中,服务管理模块用于注册本节点服务和订阅业务服务。
节点管理模块606,用于注册和更新本节点信息到分布式数据库集群,并设置记录有效期,从分布式数据库集群中查询定时器节点的信息,并根据已有节点个数计算本节点需要扫描的定时器表范围。
本申请实施例中,该模块定时更新节点信息到数据库;定时获取当前系统内所有节点信息;定时获取当前系统内所有节点信息。
本申请实施例中,该模块用于定时更新本节点信息到数据库集群,更新节点并同时设置记录有效期,若本节点异常,本节点信息将在数据库集群中自动过期删除。节点管理模块还用于定时从数据库集群中查询所有定时器节点的信息,并根据已有节点个数计算本节点需要扫描的定时器表范围,从而达到均衡各个节点处理能力的作用以及实现缩容、扩容、容灾功能。
分布式数据库集群607,保持存储定时器相关记录。
本申请实施例中,采用了分布式数据库集群的高性能、大容量、持久化特性,提供可 靠、高性能、大容量的定时器服务,确保定时器事件不丢失;不仅可以解决通常做法实现的定时器的不足,而且大大提升了定时器系统的可靠性,灵活性。
虽然本申请所揭露的实施方式如上,但的内容仅为便于理解本申请而采用的实施方式,并非用以限定本申请。任何本申请所属领域内的技术人员,在不脱离本申请所揭露的精神和范围的前提下,可以在实施的形式及细节上进行任何的修改与变化,但本申请的专利保护范围,仍须以所附的权利要求书所界定的范围为准。

Claims (16)

  1. 一种定时器系统,包括:
    业务服务系统;以及
    定时器服务子系统,根据所述业务服务系统的定时器设置请求,保存定时器记录,并删除超时定时器记录。
  2. 如权利要求1所述的定时器系统,其中,所述定时器服务子系统包括:
    分发模块,接收所述业务服务系统的设置定时器请求,并将所述设置定时器请求分发到所述定时器设置模块;
    定时器设置模块,解析所述设置定时器请求,并将所述设置定时器请求记录存入所述分布式数据库集群;以及
    分布式数据库集群,根据所述设置定时器请求记录保存定时器记录。
  3. 如权利要求2所述的定时器系统,其中,所述定时器服务子系统还包括:
    节点管理模块,用于:
    注册和更新本节点信息到所述分布式数据库集群,并设置记录有效期;以及
    从所述分布式数据库集群中查询定时器节点信息,并根据已有节点个数计算本节点需要扫描的定时器表范围。
  4. 如权利要求1所述的定时器系统,其中,所述定时器服务子系统还包括:
    扫描模块,扫描达到超时时间的定时器记录表,取出符合触发条件的记录并发给所述消息通知模块;以及
    消息通知模块,接收所述扫描模块发送的达到超时时间的定时器记录通知给所述业务服务系统,同时接收所述业务服务系统返回的确认信息。
  5. 如权利要求1所述的定时器系统,其中,所述定时器服务子系统还包括:
    服务管理模块,将所述节点信息和所述服务信息注册到服务管理中心子系统,并订阅所需服务。
  6. 一种定时器方法,包括:
    注册服务信息,并设置定时器请求;
    根据所述定时器请求的类型,对分布式数据库集群中定时器事件记录进行处理;以及
    扫描所述分布式数据库集群中定时器事件记录,删除超时定时器记录。
  7. 如权利要求6所述的定时器方法,其中,所述注册服务信息,并设置定时器请求,包括:
    业务服务系统将服务注册到服务管理中心子系统,并发送设置定时器请求到定时器服务子系统。
  8. 如权利要求7所述的定时器方法,其中,所述设置定时器请求,包括:
    设置定时器或删除定时器;
    其中,所述设置定时器请求中携带唯一特征信息。
  9. 如权利要求7所述的定时器方法,其中,所述方法还包括:
    所述定时器服务子系统分发设置定时器请求;以及
    所述定时器服务子系统的分发模块接收到所述业务服务系统设置定时器请求,按照轮询、 按关键字取模或一致性哈希的分发规则将所述设置定时器请求分发给所述定时器服务子系统的定时器设置模块。
  10. 如权利要求6所述的定时器方法,其中,定时器服务子系统的定时器设置模块解析所述设置定时器请求中的字段,保存定时器记录到所述定时器服务子系统的分布式数据库集群并校验设置的超时时间是否有效;
    如果是设置定时器,计算定时器记录过期时间,检查定时器记录是否存在,是则更新,否则插入定时器记录;
    如果是删除定时器,删除指定唯一特征信息的定时器事件记录。
  11. 如权利要求6所述的定时器方法,其中,所述扫描所述分布式数据库集群中定时器事件记录,还包括:
    定时器服务子系统的扫描模块扫描定时器服务子系统的分布式数据库集群中定时器记录;以及
    批量查询达到超时时间的定时器记录并分发给所述定时器服务子系统的消息通知模块。
  12. 如权利要求11所述的定时器方法,其中,所述消息通知模块将所述定时器记录发给业务服务系统,所述消息通知模块收到所述业务服务系统确认后删除定时器记录。
  13. 一种如权利要求1-5任意一项所述定时器系统的工作方法,包括:
    扫描分布式数据库集群中注册的节点信息;以及
    根据扫描结果,进行节点扩容或缩容处理。
  14. 如权利要求13所述的定时器系统的工作方法,其中,
    定时器服务子系统的节点管理模块注册和更新节点信息到定时器服务子系统的分布式数据库集群,并设置记录有效期;以及
    所述节点管理模块扫描所述注册的节点信息,并分配节点扫描定时器记录表范围。
  15. 如权利要求13所述的定时器系统的工作方法,其中,
    不注册异常节点信息到所述定时器服务子系统的分布式数据库集群,并将所述异常节点信息到期后删除;以及
    根据节点个数重新分配本节点扫描定时器记录表范围。
  16. 如权利要求13所述的定时器系统的工作方法,其中,将恢复节点注册到所述定时器服务子系统的分布式数据库集群,并对恢复后的节点重新分配扫描定时器记录表范围。
PCT/CN2021/122331 2020-12-17 2021-09-30 一种定时器系统及方法 WO2022127302A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011496671.3 2020-12-17
CN202011496671.3A CN114647696A (zh) 2020-12-17 2020-12-17 一种定时器系统及方法

Publications (1)

Publication Number Publication Date
WO2022127302A1 true WO2022127302A1 (zh) 2022-06-23

Family

ID=81990547

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/122331 WO2022127302A1 (zh) 2020-12-17 2021-09-30 一种定时器系统及方法

Country Status (2)

Country Link
CN (1) CN114647696A (zh)
WO (1) WO2022127302A1 (zh)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007108657A1 (en) * 2006-03-22 2007-09-27 Electronics And Telecommunications Research Institute Method for requesting resource based on timer in mobile telecommunication systems
CN103197969A (zh) * 2013-03-27 2013-07-10 百度在线网络技术(北京)有限公司 一种分布式定时任务控制装置及方法
CN105100259A (zh) * 2015-08-18 2015-11-25 北京京东尚科信息技术有限公司 一种分布式定时任务执行方法和系统
US20160140066A1 (en) * 2014-11-14 2016-05-19 Cavium, Inc. Distributed timer subsystem
CN106126332A (zh) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 分布式定时任务调度系统及方法
CN106557522A (zh) * 2015-09-30 2017-04-05 阿尔卡特朗讯 一种用于提供定时功能的方法与设备
CN108255515A (zh) * 2018-01-17 2018-07-06 广州汇智通信技术有限公司 一种实现定时器服务的方法和装置
CN109408210A (zh) * 2018-09-27 2019-03-01 北京车和家信息技术有限公司 分布式定时任务管理方法及系统

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007108657A1 (en) * 2006-03-22 2007-09-27 Electronics And Telecommunications Research Institute Method for requesting resource based on timer in mobile telecommunication systems
CN103197969A (zh) * 2013-03-27 2013-07-10 百度在线网络技术(北京)有限公司 一种分布式定时任务控制装置及方法
US20160140066A1 (en) * 2014-11-14 2016-05-19 Cavium, Inc. Distributed timer subsystem
CN105100259A (zh) * 2015-08-18 2015-11-25 北京京东尚科信息技术有限公司 一种分布式定时任务执行方法和系统
CN106557522A (zh) * 2015-09-30 2017-04-05 阿尔卡特朗讯 一种用于提供定时功能的方法与设备
CN106126332A (zh) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 分布式定时任务调度系统及方法
CN108255515A (zh) * 2018-01-17 2018-07-06 广州汇智通信技术有限公司 一种实现定时器服务的方法和装置
CN109408210A (zh) * 2018-09-27 2019-03-01 北京车和家信息技术有限公司 分布式定时任务管理方法及系统

Also Published As

Publication number Publication date
CN114647696A (zh) 2022-06-21

Similar Documents

Publication Publication Date Title
KR100451211B1 (ko) 이동 컴퓨팅 환경에서 트랜잭션 캐시 일관성 유지 시스템및 방법
JP3442919B2 (ja) 移動コンピュータのためのエネルギー効率のよりキャッシュを含む通信システム及び方法
US6721907B2 (en) System and method for monitoring the state and operability of components in distributed computing systems
US9734199B1 (en) Data replication framework
US9715522B2 (en) Information processing apparatus and control method
EP0924941B1 (en) System and method for multi-node data synchronization
CN107870954B (zh) 一种分布式数据库的扩展方法及装置
CN1437355A (zh) 移动网络中多播用户的管理方法
WO2008038271A1 (en) An apparatus and method for a distributed storage global database
CN107623703B (zh) 全局事务标识gtid的同步方法、装置及系统
US10198492B1 (en) Data replication framework
EP3018593A1 (en) Data storage method and device for distributed database
CN105472002A (zh) 基于集群节点间即时拷贝的会话同步方法
TWI454917B (zh) Access control method, access control device and access control program
US8428624B2 (en) Method and system for network support for optimized paging of communication devices
WO1999027733A1 (en) Customer administrative system management of redundant database network elements in a telecommunications system
CN109600323A (zh) 一种拜占庭共识机制
WO2022127302A1 (zh) 一种定时器系统及方法
US9432841B2 (en) Technique for HLR address allocation in a UDC network
JP2013065120A (ja) 負荷分散システム、データアクセス装置、及び負荷分散方法
CN107395406B (zh) 在线系统的在线状态数据处理方法、装置及系统
US20180314602A1 (en) Method for redundancy of a vlr database of a virtualized msc
EP3326398B1 (en) Operating a pool of mobility nodes
CN110798349A (zh) 一种配置分发、接收方法、设备及计算机可读存储介质
CN110032548B (zh) 电力通信网监控平台非结构化数据分布式管理方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21905231

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21905231

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.11.2023)