A data processing method, device, equipment and readable storage medium
By allocating operation failure time and healthy node selection to MQTT proxy nodes, the business interruption problem when MQTT server performance is insufficient is solved, and dynamic expansion of proxy nodes and data accuracy is improved.
Patent Information
- Application Number
- CN202110633960.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-07
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2041-06-07
AI Technical Summary
Existing MQTT servers need to suspend services and reconfigure subscription information when performance is insufficient, resulting in business interruption and unable to effectively share the pressure.
By allocating operation failure time for online proxy nodes, dynamically expanding the proxy node cluster, using distributed cluster deployment and database storage key identifiers, accurately selecting healthy nodes for data pulling, and avoiding data pauses for non-healthy nodes.
It realizes that when dynamically expanding the proxy node, it improves the accuracy of data pulling of newly launched proxy nodes, reduces business interruptions, and improves system performance.
Smart Images

Figure CN113204560B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a data processing method, apparatus, device, and readable storage medium. Background Art
[0002] Message Queuing Telemetry Transport (MQTT) is an instant messaging protocol that adopts a publish / subscribe mode and can be applied to Internet of Things (IoT) devices with low power consumption and limited network bandwidth. As an important transmission protocol for the IoT, MQTT supports almost all platforms.
[0003] In the publish and subscribe mode, a publisher can send a message with a specific topic to an MQTT server, and a subscriber can subscribe to this topic from the server, thereby receiving messages sent from the server.
[0004] In existing solutions, each MQTT server is deployed in a single point, that is, a stand-alone MQTT service. When some servers have insufficient performance and are unable to support a large number of services, a new MQTT server needs to be put into operation to share the service pressure of these servers and enhance the service performance of the servers. When the new server goes online, it is necessary to suspend the services of all stand-alone running servers and reconfigure all subscription information so that the services of some servers with insufficient performance can be allocated to the newly launched server, thereby improving the service performance of these servers and ensuring the smooth progress of the services. Summary of the Invention
[0005] Embodiments of this application provide a data processing method, apparatus, device, and readable storage medium, which can improve the accuracy of data pulled by newly launched proxy nodes while realizing dynamic expansion of proxy nodes.
[0006] On the one hand, embodiments of this application provide a data processing method, including:
[0007] A first proxy node in an offline state traverses a database based on an online request; the database includes the key identifiers of each online proxy node in the set of online proxy nodes and the corresponding running failure time of the key identifier; each online proxy node includes synchronized subscription information;
[0008] According to the set of running failure times corresponding to the set of online proxy nodes and the request time, valid nodes are obtained from the set of online proxy nodes, and during the process of storing target subscription information in the remaining proxy nodes, synchronized subscription information is synchronously requested and pulled from the valid nodes; the remaining proxy nodes are the online proxy nodes in the set of online proxy nodes except the valid nodes; the synchronized subscription information does not include the target subscription information;
[0009] Store the synchronization subscription information, and change the status of the first proxy node in the offline state from the offline state to the online state;
[0010] The first proxy node in the online state sends a storage success prompt message to the database, so that the database assigns a target running failure time to the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running failure time of the first proxy node in the online state to the database.
[0011] In one aspect, an embodiment of the present application provides a data processing device, which is applied to the first proxy node. The device includes:
[0012] A traversal module, configured to traverse the database based on an online request when the first proxy node is in the offline state; the database includes the key identifier of each online proxy node in the set of online proxy nodes and the running failure time corresponding to the key identifier; each online proxy node includes synchronization subscription information;
[0013] A node acquisition module, configured to acquire valid nodes in the set of online proxy nodes according to the set of running failure times corresponding to the set of online proxy nodes and the request time corresponding to the online request;
[0014] An information pulling module, configured to synchronously request and pull the synchronization subscription information from the valid nodes during the process of the remaining proxy nodes storing the target subscription information; the remaining proxy nodes are the online proxy nodes in the set of online proxy nodes except the valid nodes; the synchronization subscription information does not include the target subscription information;
[0015] An information storage module, configured to store the synchronization subscription information, and change the status of the first proxy node in the offline state from the offline state to the online state;
[0016] An information sending module, configured to send a storage success prompt message to the database when the first proxy node is in the online state, so that the database assigns a target running failure time to the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running failure time of the first proxy node in the online state to the database.
[0017] In one embodiment, the synchronization subscription information includes a subscription tree; the subscription tree is used to store the association relationship between the subscription client, the topic information subscribed by the subscription client, and the proxy node corresponding to the subscription client;
[0018] The data processing device further includes:
[0019] A message forwarding module, configured to receive a publishing request from a publishing client for a target message; the publishing request includes the topic information of the target message.
[0020] The message forwarding module is further configured to traverse a subscription tree based on the publishing request, and obtain a proxy node to be transmitted from the proxy nodes stored in the subscription tree; the subscription topic information subscribed by the subscription client to be transmitted corresponding to the proxy node to be transmitted matches the topic information of the target message; the subscription clients include the subscription clients to be transmitted.
[0021] The message forwarding module is further configured to send the target message to the proxy node to be transmitted, so that the proxy node to be transmitted forwards the target message to the subscription client to be transmitted corresponding to the proxy node to be transmitted.
[0022] In one embodiment, the data processing device further includes:
[0023] A message detection module, configured to obtain a detection rule library; the detection rule library includes abnormal texts and abnormal audios.
[0024] The message detection module is further configured to match the target message with the abnormal texts and abnormal audios in the detection rule library.
[0025] The message detection module is further configured to, if there is text content in the target message that is the same as the abnormal text, or there is audio content in the target message that is the same as the abnormal audio, determine the target message as a violation message, generate a violation prompt message, and send the violation prompt message to the publishing client and the proxy node to be transmitted.
[0026] A step execution module, configured to, if there is no text content in the target message that is the same as the abnormal text and there is no audio content in the target message that is the same as the abnormal audio, execute the step of sending the target message to the proxy node to be transmitted.
[0027] In one embodiment, the data processing device further includes:
[0028] A time matching module, configured to match the request time with the set of running expiration times corresponding to the set of online proxy nodes.
[0029] A tree construction module, configured to, if there is no running expiration time later than the request time in the set of running expiration times, construct an empty subscription tree including a root node.
[0030] The tree construction module is further configured to, if there is a running expiration time later than the request time in the set of running expiration times, execute the step of obtaining valid nodes from the set of online proxy nodes according to the set of running expiration times corresponding to the set of online proxy nodes and the request time corresponding to the online request.
[0031] In one embodiment, the node acquisition module includes:
[0032] A candidate time determination unit, configured to determine a running failure time later than the request time in the running failure time set as a candidate failure time;
[0033] The candidate time determination unit is further configured to determine the key identifier corresponding to the candidate failure time as a candidate key identifier;
[0034] A node acquisition unit, configured to determine an online proxy node corresponding to the candidate key identifier as a candidate proxy node, and acquire valid nodes from the candidate proxy nodes.
[0035] In one embodiment, the number of candidate proxy nodes is at least two;
[0036] The node acquisition unit includes:
[0037] A quantity statistics subunit, configured to acquire the candidate key identifier corresponding to each candidate proxy node among at least two candidate proxy nodes, and in the database, acquire the running failure time corresponding to each candidate key identifier;
[0038] The quantity statistics subunit is further configured to count the quantity of the running failure time corresponding to each candidate key identifier among at least two candidate key identifiers;
[0039] A node deletion subunit, configured to determine a candidate key identifier with the quantity of the running failure time greater than or equal to a quantity threshold among at least two candidate key identifiers as an error identifier, and delete the candidate proxy node corresponding to the error identifier from at least two candidate proxy nodes to obtain candidate proxy nodes to be selected;
[0040] A node determination subunit, configured to acquire valid nodes from the candidate proxy nodes to be selected.
[0041] In one embodiment, the node determination subunit is further specifically configured to acquire a network quality parameter corresponding to the candidate proxy node to be selected;
[0042] The node determination subunit is further specifically configured to determine the candidate proxy node corresponding to the maximum network quality parameter in the network quality parameters as a valid node.
[0043] In one embodiment, the number of target subscription information is at least two;
[0044] The data processing device further includes:
[0045] A time acquisition module, configured to acquire the subscription time corresponding to each target subscription information among at least two target subscription information;
[0046] A sorting module, configured to sort at least two target subscription information in chronological order of the subscription time to obtain sorted target subscription information;
[0047] An information storage module, configured to store the sorted target subscription information into a subscription tree in sequence to obtain a target subscription tree.
[0048] In one embodiment, the data processing device further includes:
[0049] A sequence processing module, configured to receive a second data pull request sent by a second proxy node when a first proxy node in an online state is a valid node determined by a second proxy node in an offline state; the second proxy node in an offline state is a proxy node to be online;
[0050] The sequence processing module is further configured to obtain a target subscription tree based on the second data pull request;
[0051] The sequence processing module is further configured to perform serialization processing on the target subscription tree to obtain a serialized subscription tree;
[0052] A tree sending module, configured to send the serialized subscription tree to the second proxy node in an offline state, so that the second proxy node in an offline state performs deserialization processing on the serialized subscription tree to obtain a target subscription tree, and stores the target subscription tree.
[0053] In one embodiment, the sequence processing module includes:
[0054] A template acquisition unit, configured to acquire a logic code template corresponding to serialization processing;
[0055] A variable determination unit, configured to acquire subscription clients in the target subscription tree and subscription topic information subscribed by the subscription clients, and use the subscription clients and the subscription topic information subscribed by the subscription clients as variables;
[0056] A fusion unit, configured to fuse the variables with the logic code template to obtain a serialized subscription tree.
[0057] In one embodiment, the data processing device further includes:
[0058] A time update module, configured to determine an update time according to a request time and a target running expiration time;
[0059] The time update module is further configured to generate a time update request when the system time reaches the update time, and send the time update request to the database, so that the database updates the target running expiration time based on the time update request; the updated target running expiration time is later than the target running expiration time.
[0060] In one embodiment, the time update module includes:
[0061] A duration determination unit, configured to determine the total duration between the request time and the target running failure time;
[0062] A duration calculation unit, configured to multiply the total duration by a configured duration ratio value to obtain a calculated duration; the calculated duration is less than or equal to the total duration;
[0063] The duration calculation unit is further configured to add the request time and the calculated duration to obtain an updated time.
[0064] One aspect of the embodiments of the present application provides a computer device, including: a processor and a memory;
[0065] The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the method in the embodiments of the present application.
[0066] One aspect of the embodiments of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions, and when the program instructions are executed by the processor, the method in the embodiments of the present application is executed.
[0067] One aspect of the present application provides a computer program product or a computer program, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in one aspect of the embodiments of the present application.
[0068] In the embodiments of the present application, the proxy nodes can be deployed in a distributed cluster manner. Each online proxy node can store the same synchronization subscription information. At the same time, the present application can assign a running failure time to each online proxy node, and jointly store the key identifier of each online proxy node and the running failure time of each online proxy node in the database. By assigning a running failure time to each online proxy node, it is possible to accurately know the time when each online proxy node cannot run. Thus, when a new proxy node (a proxy node not in the online proxy node cluster, such as the first proxy node in the offline state) requests to go online, the database can be traversed. Through the key identifier and running failure time in the database, it is possible to accurately query which online proxy nodes in the online proxy node cluster have not failed at that time (the request time when the proxy node requests to go online). The proxy node requesting to go online can use these as valid nodes and send a data pull request to them to pull the synchronization subscription information stored in the valid nodes. Since the running failure time can be used to more accurately determine which nodes are running normally, that is, the valid nodes can be determined as the normally running nodes, the synchronization subscription information obtained from the valid nodes will also be more accurate. Then, the accuracy of the synchronization subscription information pulled by the newly online proxy node can be improved. At the same time, when the proxy node requesting to go online pulls the synchronization subscription information from the valid nodes, the remaining proxy nodes in the online proxy node cluster other than the valid nodes do not need to pause running like the valid nodes, but can continue to run. That is to say, when expanding the proxy nodes, it is not necessary to stop running all the proxy nodes in the online proxy node cluster. Only the proxy node that receives the data pull request needs to be paused, and the dynamic expansion of the proxy nodes can be realized. In summary, the present application can improve the accuracy of the data pulled by the proxy node requesting to go online while realizing the dynamic expansion of the proxy nodes. Description of the Drawings
[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0070] Figure 1 is a network architecture diagram provided by an embodiment of the present application;
[0071] Figure 2 is a schematic diagram of a scenario for adding a new proxy node provided by an embodiment of the present application;
[0072] Figure 3 is a schematic flowchart of a data processing method provided by an embodiment of the present application;
[0073] Figure 4 It is a schematic flowchart for serializing and sending a target subscription tree provided by an embodiment of the present application;
[0074] Figure 5 It is a schematic system flowchart provided by an embodiment of the present application;
[0075] Figure 6 It is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
[0076] Figure 7 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0077] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0078] Please refer to Figure 1 , Figure 1 It is a schematic network architecture diagram provided by an embodiment of the present application. As Figure 1 shown, the network architecture may include a server 1000, a proxy node cluster 100, and a user terminal cluster 10. The user terminal cluster 10 may include one or more user terminals, and the number of user terminals will not be limited here; the proxy node cluster 100 may include one or more proxy nodes (MQTT servers, that is, client proxies, also referred to as brokers), and the number of proxy nodes will not be limited here. As Figure 1 shown, multiple user terminals may include user terminal 10a, user terminal 10b, user terminal 10c,..., user terminal 10n; multiple proxy nodes may include proxy node 100a, proxy node 100b, proxy node 100c,..., proxy node 100n. As Figure 1As shown, user terminals 10a, 10b, 10c, …, 10n can be respectively network-connected to any proxy node in proxy node 100, so that each user terminal can perform data interaction with proxy node 100 through this network connection; proxy nodes in proxy node 100 can be network-connected to each other, so that data interaction can be performed between proxy nodes through this network connection; proxy nodes 100a, 100b, 100c, …, 100n can be respectively network-connected to server 1000, so that each proxy node can perform data interaction with server 1000 through this network connection.
[0079] When each user terminal is network-connected to a certain proxy node and this proxy node is network-connected to server 1000, this user terminal can perform data interaction with other user terminals through this network connection, this proxy node, and server 1000 to publish or subscribe to messages, etc.
[0080] As Figure 1 shown, server 1000 in the embodiments of the present application can be a server that provides various services. For example, it is a background cloud server that provides storage or forwarding functions for messages subscribed by user terminals 10a, 10b, …, 10n through proxy node cluster 100. It can store the received subscription information according to time and sort it according to time, and then forward the subscription information to each proxy node in sequence, so that each proxy node can store each subscription information in sequence. Server 1000 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers (such as, kafka distributed system), or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0081] For ease of understanding, in the embodiments of the present application, Figure 1 one user terminal can be selected from the multiple user terminals shown as the target user terminal. This user terminal can include: intelligent terminals with data processing functions such as smart phones, tablet computers, laptop computers, desktop computers, smart TVs, smart speakers, desktop computers, smart watches, etc., but is not limited thereto. For example, in the embodiments of the present application, Figure 1 user terminal 100a shown can be used as the target user terminal.
[0082] In the embodiments of the present application, the user terminal can be understood as a client. The proxy node cluster 100 and the server 1000 can provide MQTT services. Users can subscribe to topics of interest through the user terminal cluster 10, the proxy node cluster 100, and the server 1000, and can also receive messages published by the publishing client. When the user terminal corresponding to a user is connected to the proxy node, the user can subscribe to topics of interest through the user terminal. Similarly, when the user terminal corresponding to a user is connected to the proxy node, the user can also publish a message on a topic, and other users can subscribe to the topic through their corresponding user terminals and receive the message published by the user.
[0083] For example, taking the user terminals 10a, 10b, and 10c as target user terminals, the user corresponding to the user terminal 10a is user a, the user corresponding to the user terminal 10b is user b, and the user corresponding to the user terminal 10c is user c. The proxy node connected to the user terminal 10a is the proxy node 100a, the proxy node connected to the user terminal 10b is the proxy node 10b, and the proxy node connected to the user terminal 10c is the proxy node 10c. User a can subscribe to topic A through the user terminal 10a, and the proxy node 100a connected to the user terminal 10a can send the subscription information of the user terminal 10a for topic A to the server 1000. User b can also subscribe to topic A through the user terminal 10b, and the proxy node 100b connected to the user terminal 10b can also send the subscription information of the user terminal 10b for topic A to the server 1000.
[0084] Further, in the server 1000, according to the subscription time t1 of the user terminal 10a for subscribing to topic A and the subscription time t2 of the user terminal 10b for subscribing to topic A, the subscription information of the user terminal 10a and the subscription information of the user terminal 10b can be sorted (for example, if the subscription time t1 is earlier than the subscription time t2, the subscription information with a smaller subscription time can be arranged before the subscription information with a larger subscription time, and the obtained sorting result is {the subscription information of the user terminal 10a, the subscription information of the user terminal 10b}). Further, the server 1000 can sequentially (for example, in the order from front to back, that is, in the order of increasing subscription time) send the subscription information of the user terminal 10a and the subscription information of the user terminal 10b to the proxy nodes 100a, 100b, and 100c in sequence, and the proxy nodes 100a, 100b, and 100c can sequentially store the subscription information of the user terminal 10a and the subscription information of the user terminal 10c in their local machines. That is to say, the subscription information stored in the proxy nodes 100a, 100b, and 100c is synchronized and consistent.
[0085] It should be understood that user a can publish a message on topic A through user terminal 10c. At this time, the proxy node 100c corresponding to user terminal 10c can check the subscription information stored in the local machine, and through the subscription information, it can query that the user terminals subscribing to this topic A include user terminal 10a and user terminal 10b. The proxy node corresponding to user terminal 10a is proxy node 100a, and the proxy node corresponding to user terminal 10b is proxy node 100b. Then, proxy node 100c can forward the message of topic A published by user a to proxy node 100a and proxy node 100b. And proxy node 100a can send the message of topic A to user terminal 10a, and proxy node 100b can send the message of topic A to user terminal 10b.
[0086] It can be understood that when each proxy node in this application is deployed in a distributed cluster mode, it can support the online operation of a new proxy node to complete the expansion of the proxy node cluster. When a new proxy node requests to go online, it is necessary to select any proxy node from the online proxy node cluster as a data pulling node and send a data pulling request to it. Thus, this data pulling node can push the subscription information stored in the local machine to the new proxy node based on this data pulling request. In order to improve the accuracy of the subscription information received by the newly requested online proxy node, this application provides a method for selecting a data pulling node: that is, assign a running failure time to each proxy node in the online proxy node cluster. It can be understood that after each proxy node goes online successfully, a running failure time can be assigned to it. Once this running failure time is exceeded, this proxy node is a proxy node that does not support business processing functions (publishing / subscribing messages).
[0087] In view of this, when a new proxy node requests to go online, based on the running expiration time of each online proxy node, it is possible to accurately find out which proxy nodes are no longer operational and which proxy nodes are healthy nodes (running). Subsequently, after the discovery, the proxy node requesting to go online can select any healthy node as the data pull node and send a data pull request to it. It should be understood that the method of finding healthy nodes based on the running expiration time can prevent the proxy node requesting to go online from using a proxy node that no longer has the business processing function as the data pull node and pulling incomplete and inaccurate subscription information. At the same time, since the proxy nodes in this application are deployed in a distributed cluster, the subscription information stored by each proxy node is consistent. When the proxy node requesting to go online requests to pull subscription information from an online proxy node (data pull node), the proxy nodes other than the data pull node among the online proxy nodes can continue to execute the business function of publishing / subscribing messages and continue to store new subscription information. That is to say, when expanding the proxy nodes in this application, it is not necessary to stop the operation of all online proxy nodes, and dynamic expansion can be achieved.
[0088] For ease of understanding, please also refer to Figure 2 , Figure 2 which is a schematic diagram of a scenario for adding a proxy node provided by an embodiment of this application.
[0089] Please refer to Figure 2 , in the online proxy node cluster, there are online proxy node 20a, online proxy node 20b, and online proxy node 20c. Among them, the running expiration time of online proxy node 20a is 11:00 on June 1, 2021, the running expiration time of online proxy node 20b is 11:02 on June 1, 2021, and the running expiration time of online proxy node 20c is 11:05 on June 1, 2021. The running expiration time of each online proxy node can be stored in the database together with its corresponding node key identifier. When a new proxy node requests to go online, the database can be traversed to query for valid nodes (proxy nodes whose running expiration time has not expired).
[0090] For example, as Figure 2As shown in the figure, the proxy node 200 can be a newly requested proxy node to go online. When the proxy node 200 requests to go online, it can traverse the database based on the online request to query for valid nodes. Taking the request time for the proxy node 200 to go online as 10:55 on June 1, 2021 as an example, the proxy node 200 can compare the running expiration times corresponding to the already online proxy nodes 20a, 20b, and 20c respectively with this request time of 10:55 on June 1, 2021. If the running expiration time of a certain already online proxy node is greater than (i.e., later than) this request time, then it can be determined that this already online proxy node is a healthy node that is running. For example, as Figure 2 shown, after comparing the running expiration times of 11:00 on June 1, 2021, 11:02 on June 1, 2021, and 11:05 on June 1, 2021 with the request time of 10:55 on June 1, 2021 respectively, it can be determined that the running expiration times of 11:00 on June 1, 2021, 11:02 on June 1, 2021, and 11:05 on June 1, 2021 are all later than this request time, and the already online proxy nodes 20a, 20b, and 20c can all be determined as healthy nodes.
[0091] Furthermore, the proxy node 200 can select any one of the healthy nodes (including the already online proxy nodes 20a, 20b, and 20c) as a valid node (i.e., a data pulling node) and send a data pulling request to it. Among them, the way for the proxy node 200 to select a valid node among the healthy nodes can be a random selection method, or it can select the healthy node with the best network quality parameter as the valid node, or it can also select the healthy node with the optimal hardware device parameter as the valid node. For the way for a newly requested proxy node to go online to select a valid node among the healthy nodes, this application will not make any restrictions.
[0092] As Figure 2 shown, the valid node selected by the proxy node 200 is the already online proxy node 20a. The proxy node 200 can send a data pulling request to the already online proxy node 20a, and the already online proxy node 20a can, based on this data pulling request, send the subscribed information stored on its own machine to the proxy node 200.
[0093] It can be understood that the running expiration time can be regarded as proof that each online proxy node is "alive" (i.e., running normally). Each online proxy node can apply to the database for extending and updating the running expiration time when it is approaching the running expiration time. Thus, due to the continuous requests for update from the online proxy nodes, the running expiration time will also change continuously. As long as each online proxy node is still "alive", the running expiration time of this online proxy node will exist in the database. The newly requested online proxy node can accurately obtain which online proxy nodes are healthy nodes running normally based on this running expiration time.
[0094] It should be noted that if the proxy node 200 does not query the running expiration time later than the request time after traversing the database when requesting to go online, then the proxy node 200 can directly apply to the database for the running expiration time, obtain its own running expiration time and start running.
[0095] Furthermore, please refer to Figure 3 , Figure 3 which is a schematic flowchart of a data processing method provided by an embodiment of the present application. Among them, this method can be executed by a proxy node (for example, any proxy node in the proxy node cluster 100 shown above Figure 1 , such as the proxy node 100a). Among them, this method can at least include the following steps S101 - step S104:
[0096] Step S101, the first proxy node in the un-online state traverses the database based on the online request; the database includes the key identifier of each online proxy node in the set of online proxy nodes and the running expiration time corresponding to the key identifier; each online proxy node includes synchronization subscription information.
[0097] In this application, the proxy node can refer to the client proxy (also known as the broker) in the MQTT protocol. When the user terminal is connected to the proxy node, based on the principles of publishing messages and subscribing to topics in MQTT, the user terminal can support the MQTT service, and the user can subscribe to the topics of their interest in the user terminal; the user can also publish messages on a topic in the user terminal, and then other users can subscribe to the same topic through other user terminals that support the MQTT service. After subscribing, they can receive the messages published by the user for that topic. Among them, the topic can include one or more levels (hierarchies) like a file system, and each two levels can be divided by the slash symbol " / ". For example, each computer can publish the temperature information (temperature) of its own hardware driver (sensors) on the following topic, where the name of the computer (COMPUTER_NAME) and the name of the hardware (HARDDRIVE_NAME) can be appropriately replaced:
[0098] "sensors / COMPUTER_NAME / temperature / HARDDRIVE_NAME".
[0099] Among them, in the above topic, "sensors" can be a level (hierarchy); "COMPUTER_NAME" can be a level; "temperature" can be a level; "HARDDRIVE_NAME" can be a level. It can be understood that the level before each slash can be considered higher than the level after the slash. For example, the "sensors" level can be considered higher than the "COMPUTER_NAME" level, and the "COMPUTER_NAME" is higher than the "temperature" level, and so on.
[0100] It should be understood that each proxy node in this application can store subscription information (which can include the topic information subscribed by the client, and here the subscription information stored by each proxy node can be called synchronous subscription information), so that when receiving a message for a specific topic sent by the publishing client, it can forward the message of the specific topic to the client that has subscribed to the specific topic.
[0101] To ensure that the subscription information stored by each proxy node is synchronized and consistent, the proxy nodes in this application can be deployed in a distributed cluster mode. When each proxy node receives the subscription information sent by the client, it can first store the subscription information in a message queue (such as a Kafka queue). Then, in this message queue, the subscription information sent by one or more proxy nodes can be temporarily stored. Subsequently, these subscription information can be sorted according to the chronological order (from early to late) of their subscription times, and each proxy node can obtain these subscription information in order and store them in its local machine in order.
[0102] In a feasible way, to further ensure that the subscription information stored by each proxy node is synchronized and consistent, a subscription tree (prefix tree or dictionary tree, also known as Trie) can be used to store the subscription information. Thus, even if there is a problem of disordered storage in a certain proxy node, due to the insertable and deletable mechanism of the Trie, when a proxy node should have stored but has not yet stored a certain subscription information, this subscription information can be inserted into the dictionary tree of this proxy node (or when a proxy node should not have stored but has prematurely stored a certain subscription information, this subscription information can be deleted from the dictionary tree). Using the subscription tree can well solve the disorder problem of proxy nodes, making the subscription information stored by each proxy node remain synchronized and consistent.
[0103] When each proxy node is deployed in a distributed cluster mode, to enhance the performance of the proxy node cluster, new proxy nodes can be supported to go online and run (join this distributed cluster), thereby completing the expansion of the proxy node cluster. When a new proxy node requests to go online, it needs to select any proxy node from the already online proxy node cluster as a data pulling node and send a data pulling request to it. Thus, this data pulling node can push the subscription information stored in its local machine to this new proxy node based on this data pulling request.
[0104] It can be understood that to improve the accuracy of the subscription information received by a newly requested proxy node going online, this application provides a method for selecting a data pulling node (which can be called an effective node): that is, using a Remote Dictionary Server (Redis; also known as a key-valve database) to assign a running expiration time to each proxy node in the already online proxy node cluster. This database can store the key identifier (key value) and the running expiration time of each already online proxy node; when a newly requested proxy node goes online, it can traverse the database to obtain the healthy nodes that are running and obtain the effective nodes from the healthy nodes. Any newly requested proxy node going online in this application can be called a first proxy node in an offline state, and the states of proxy nodes that have not successfully gone online (including the state of requesting to go online) can all be called offline states.
[0105] Step S102, according to the operation expiration time set and the request time corresponding to the online proxy node set, obtain the valid node in the online proxy node set, and in the process of the remaining proxy nodes executing the storage target subscription information, synchronously request to pull the synchronization subscription information from the valid node; the remaining proxy nodes are the online proxy nodes in the online proxy node set except the valid nodes; the synchronization subscription information does not include the target subscription information.
[0106] In the present application, the first proxy node in the offline state can compare the operation expiration time of each online proxy node in the database with the request time (that is, the request time can be matched with the operation expiration time set corresponding to the online proxy node set). If there is no operation expiration time later than the request time in the operation expiration time set, the first proxy node in the offline state does not need to pull the subscription information. The first proxy node in the offline state can obtain the subscription information from the message queue in sequence from the beginning and store the subscription information in sequence (when the subscription information is stored in the form of a subscription tree, the first proxy node in the offline state can build an empty subscription tree containing only the root node, and store the subscription information in sequence in the subscription tree); and if there is a operation validity period later than the request time in the operation expiration time set, the first proxy node in the offline state can obtain a valid node in the online proxy node set according to the operation expiration time set and the request time.
[0107] Among them, the specific method for obtaining a valid node in the online proxy node set based on the running failure time set and the request time may be: the running failure time in the running failure time set that is later than the request time may be determined as the candidate failure time; then, the key identifier corresponding to the candidate failure time may be determined as the candidate key identifier; then, the online proxy node corresponding to the candidate key identifier may be determined as the candidate proxy node, and a valid node may be obtained from the candidate proxy node.
[0108] Among them, the specific method for obtaining a valid node from the candidate proxy nodes may be: a candidate key identifier corresponding to each candidate proxy node in at least two candidate proxy nodes may be obtained, and then the operation failure time corresponding to each candidate key identifier may be obtained in the database; then the number of operation failure times corresponding to each candidate key identifier in at least two candidate key identifiers may be counted; a candidate key identifier in at least two candidate key identifiers whose number of operation failure times is greater than or equal to a quantity threshold may be determined as an error identifier, and the candidate proxy node corresponding to the error identifier may be deleted from the at least two candidate proxy nodes to obtain a proxy node to be selected; then, a valid node may be obtained from the proxy node to be selected.
[0109] Among them, the specific method for obtaining valid nodes from the to-be-selected proxy nodes can be as follows: the network quality parameters corresponding to the to-be-selected proxy nodes can be obtained; subsequently, the to-be-selected proxy node corresponding to the maximum network quality parameter in the network quality parameters can be determined as the valid node.
[0110] Optionally, in a feasible manner, the specific method for obtaining valid nodes from the to-be-selected proxy nodes can be as follows: the hardware device parameters corresponding to the proxy nodes can be obtained; subsequently, the to-be-selected proxy node corresponding to the optimal device parameter in the hardware device parameters can be determined as the valid node.
[0111] Optionally, in a feasible manner, the specific method for obtaining valid nodes from the to-be-selected proxy nodes can be as follows: first, the network quality parameters of multiple to-be-selected proxy nodes can be sorted in descending order, and then the top N (N is a positive integer) to-be-selected proxy nodes with larger network quality parameters can be obtained; subsequently, from these N to-be-selected proxy nodes, the to-be-selected proxy node with the optimal hardware device parameter can be obtained and used as the valid node.
[0112] Optionally, in a feasible manner, the specific method for obtaining valid nodes from the to-be-selected proxy nodes can be as follows: any one of the to-be-selected proxy nodes can be randomly selected as the valid node among multiple to-be-selected proxy nodes.
[0113] It should be understood that the database can assign a running failure time to each online proxy node. If an online proxy node is restarted and the restart speed is very fast, then after the restarted online proxy node is quickly restarted, the database will assign a new running failure time to it. If the historical running failure time stored in the database for the restarted online proxy node has not been deleted in time, then the restarted online proxy node will have two running failure times in the database; at this time, although the running failure time of the restarted online proxy node has not expired, the service corresponding to it cannot be called (the subscription information stored on the restarted online proxy node itself is inaccurate). Then, if the valid node determined by the newly requested online proxy node is the restarted online proxy node, the newly requested online proxy node (such as the first proxy node in the offline state) will pull inaccurate subscription information or be unable to pull subscription information.
[0114] In view of this, the new proxy node requesting to go online (the first proxy node in the offline state) can first obtain the running expiration time later than the request time after comparing the request time with the running expiration time, and then obtain the corresponding key identifiers of these running expiration times. Through the key identifiers, it can be determined whether there are two running expiration times for the online proxy nodes in the database. If so, it can be determined that it is a restarted online proxy node, which can be deleted, and then the valid nodes can be obtained from the remaining online proxy nodes.
[0115] Step S103: Store the synchronization subscription information and change the state of the first proxy node in the offline state from the offline state to the online state.
[0116] In this application, the first proxy node in the offline state can store the synchronization subscription information pulled from the valid nodes and change its state from the offline state to the online state. It can be understood that the first proxy node in the offline state can change its state from the offline state to the online state when it obtains the synchronization subscription information; the first proxy node in the offline state can also change its state from the offline state to the online state after storing the synchronization subscription information; the first proxy node in the offline state can also change its state from the offline state to the online state during the process of storing the synchronization subscription information.
[0117] Step S104: The first proxy node in the online state sends a storage success prompt message to the database, so that the database assigns a target running expiration time to the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running expiration time of the first proxy node in the online state to the database.
[0118] In this application, after successful storage, the first proxy node in the online state can send a storage success prompt message to the database, and the database can assign a target running expiration time to the first proxy node in the online state based on the storage success prompt message, and add the target key identifier and the target running expiration time of the first proxy node in the online state to the database. Thus, when other new proxy nodes request to go online, it can be determined whether the first proxy node is a healthy node through the target running expiration time.
[0119] It should be understood that after the first proxy node goes online and runs, it can receive messages for a certain topic sent by the client. The first proxy node can, based on the synchronous subscription information stored on the local machine, find the clients that have subscribed to the topic and forward the message to the clients. For the sake of understanding, the following will take the proxy node storing subscription information in the form of a subscription tree (that is, the synchronous subscription information includes a subscription tree, and the subscription tree stores a subscription tree; the subscription tree is used to store the association relationships between subscribed clients, the topic information subscribed by the subscribed clients, and the proxy nodes corresponding to the subscribed clients) as an example to illustrate the process of the proxy node forwarding messages to clients. The specific method can be: receiving a publishing request from the publishing client for a target message; where the publishing request includes the topic information of the target message; subsequently, the first proxy node can traverse the subscription tree based on the publishing request and obtain the proxy node to be transmitted among the proxy nodes stored in the subscription tree; the subscribed topic information subscribed by the subscribed client corresponding to the proxy node to be transmitted matches the topic information of the target message; the subscribed client includes the subscribed client to be transmitted; sending the target message to the proxy node to be transmitted so that the proxy node to be transmitted forwards the target message to the subscribed client to be transmitted corresponding to the proxy node to be transmitted.
[0120] That is to say, because the subscription tree stores the subscribed clients, the proxy nodes connected by the subscribed clients, and the topic information subscribed by the subscribed clients, after the first proxy node receives the publishing request for the target message, it can obtain through the subscription tree which subscribed clients have subscribed to the topic of the target message and obtain the proxy nodes connected by these subscribed clients (which can be used as the proxy nodes to be transmitted). Then the first proxy node can forward the target message to these proxy nodes to be transmitted without broadcasting to each proxy node in the entire proxy node cluster, which can save transmission traffic.
[0121] Optionally, in a feasible manner, before forwarding the target message to the proxy node to be transmitted, the first proxy node can also first detect the target message to detect whether there is abnormal text and abnormal audio in the target message. The specific method can be: obtaining a detection rule library; where the detection rule library includes abnormal text and abnormal audio; subsequently, matching the target message with the abnormal text and abnormal audio in the detection rule library; if there is text content in the target message that is the same as the abnormal text or there is audio content that is the same as the abnormal audio, then determine the target message as a violation message, generate a violation prompt message, and send the violation prompt message to the publishing client and the proxy node to be transmitted; and if there is no text content in the target message that is the same as the abnormal text and there is no audio content that is the same as the abnormal audio, then execute the step of sending the target message to the proxy node to be transmitted.
[0122] It should be understood that the abnormal text and abnormal audio can be preset and placed in the rule detection library. When the proxy node forwards the target message each time, it can obtain the text and audio included in the target message, and match the text included in the target message with the abnormal text to determine whether there is abnormal text in the target message; at the same time, it can also match the audio included in the target message with the abnormal audio to determine whether there is abnormal audio in the target message. Only when there is no abnormal text and no abnormal audio in the target message, the target message is sent to the node to be transmitted. If there is abnormal text or abnormal audio in the target message, a violation prompt message can be generated and returned to the publishing client. At the same time, the target message may not be sent to the node to be transmitted (the violation prompt message can also be sent to the node to be transmitted at the same time).
[0123] It should be understood that during the process of the first proxy node pulling the synchronization subscription information from the valid node, the proxy nodes other than the valid node in the set of online proxy nodes can continue to execute services (such as publishing / subscribing messages and continuing to store the subscription information in the message queue). After the first proxy node finishes pulling the synchronization subscription information, it can also obtain the un-stored (not included in the synchronization subscription information) subscription information from the message queue in order and store it on the local machine in order. For the convenience of understanding, the following will take the proxy node storing the subscription information in the form of a subscription tree (that is, the synchronization subscription information includes a subscription tree, and the subscription tree stores a subscription tree; the subscription tree is used to store the association relationship between the subscription client, the topic information subscribed by the subscription client, and the proxy node corresponding to the subscription client) as an example to illustrate the specific method for the first proxy node to store the target subscription information. The specific method can be: obtain the subscription time corresponding to each of at least two target subscription information (the remaining subscription information in the message queue other than the synchronization subscription information); then, sort the at least two target subscription information in the chronological order of the subscription time to obtain the sorted target subscription information; store the sorted target subscription information in the subscription tree in order to obtain the target subscription tree.
[0124] It should be understood that after the first proxy node goes online and synchronizes the subscription information, it can also receive a data pull request sent by other newly online nodes. The first proxy node can serialize the target subscription tree stored on the local machine and send the serialized subscription tree to the newly online node; thus, the newly online node can deserialize the received serialized subscription tree and store it on the local machine. The specific implementation process can refer to the description in the corresponding embodiments in the following Figure 4 description of the corresponding embodiments.
[0125] It should be understood that after the first proxy node goes online and runs, to prove that it is "alive" (i.e., running normally), the first proxy node can apply to the database for an extension of the running failure time before reaching the running failure time, thereby proving that the first proxy node is running normally continuously. The specific method can be as follows: Determine the update time according to the request time and the target running failure time; when the system time reaches the update time, generate a time update request and send the time update request to the database so that the database updates the target running failure time based on the time update request; the updated target running failure time is later than the target running failure time.
[0126] Among them, for the method of determining the update time according to the request time and the target running failure time, it can be: Determine the total duration between the request time and the target running failure time; subsequently, multiply the total duration by the configured duration ratio value to obtain the operation duration; among them, the operation duration is less than or equal to the total duration; subsequently, add the request time and the operation duration to obtain the update time. Among them, the above-mentioned configured duration ratio value can be a manually specified value, and the configured duration ratio value can be presented in forms such as decimals, percentages, fractions, etc. For example, the configured duration ratio value can be 1 / 2, 50%, 60%, 0.8... Examples are not given one by one here.
[0127] Exemplarily, if the target running failure time of the first proxy node is 11:00 and the request time is 10:54, then the total duration between the target running failure time and the request time is 6 minutes. Assume that the configured duration ratio value is 1 / 2; after multiplying the total duration by the configured duration ratio value, the operation duration can be obtained as 3 minutes; subsequently, add the request time 11:00 and the operation duration 3 minutes to obtain the update time of 11:03. Then the first proxy node can send a time update request to the database at 11:03, and the database can extend the target running failure time based on this time update request. Among them, for the method of the database extending the target running failure time, it can be: Manually specify a configured update duration or the database randomly selects a certain duration (such as 10s, 1 minute, 20 minutes...) as the configured update duration. The database can add the target running failure time and the configured update duration to obtain the updated target running failure time, and the updated target running failure time can be used as the new running failure time of the first proxy node.
[0128] It should be understood that the proxy node can prove that it is running (still healthy) by continuously sending time update requests to the database to update the running expiration time. That is to say, by continuously sending time update requests to update the running expiration time, it can further provide a "health certificate" for the proxy node (that is, prove that the proxy node is a normally running node). Then, when a newly requested online proxy node obtains valid nodes through the continuously updated running expiration time, it can more accurately obtain the proxy nodes that are running normally, and thus can more accurately pull the accurate subscription information.
[0129] In the embodiment of the present application, the proxy nodes can be deployed in a distributed cluster manner. Each online proxy node can store the same synchronized subscription information. At the same time, the present application can assign a running expiration time to each online proxy node, and jointly store the key identifier of each online proxy node and the running expiration time of each online proxy node in the database; by assigning a running expiration time to each online proxy node, it is possible to accurately know the time when each online proxy node cannot run, and each online proxy node can continuously request to update the running expiration time to prove that it is running normally. Thus, when a new proxy node (a proxy node not in the online proxy node cluster, such as the first proxy node in the offline state) requests to go online, the database can be traversed. Through the key identifier and the running expiration time in the database, it is possible to accurately query which online proxy nodes in the online proxy node cluster have not expired at that time (the request moment when the online request is made). The proxy node requesting to go online can use them as valid nodes and send a data pull request to them to pull the synchronized subscription information stored in the valid nodes; since it is possible to more accurately determine which nodes are running normally through the running expiration time, that is, it can be determined that the valid nodes are normally running nodes, the synchronized subscription information obtained from the valid nodes will also be more accurate. Then, the accuracy of the synchronized subscription information pulled by the newly online proxy node can be improved. At the same time, when the newly requested online proxy node pulls the synchronized subscription information from the valid nodes, the remaining proxy nodes in the online proxy node cluster other than the valid nodes do not need to pause running like the valid nodes, but can continue to run. That is to say, when expanding the proxy nodes, it is not necessary to stop all the proxy nodes from running. Only the proxy node that receives the data pull request needs to be paused. The dynamic expansion of the proxy nodes can be realized. In summary, the present application can improve the accuracy of the data pulled by the newly online proxy node while realizing the dynamic expansion of the proxy nodes.
[0130] Further, please refer to Figure 4 , Figure 4It is a schematic flowchart of serializing and sending a target subscription tree provided by an embodiment of the present application. In the embodiment of the present application, it is described with at least two target subscription trees, and the process may include the following steps S201 to step S203:
[0131] Step S201, when the first proxy node in the online state is a valid node determined by the second proxy node in the offline state, receive the second data pull request sent by the second proxy node; the second proxy node in the offline state is a proxy node to be online.
[0132] In the present application, as described above, after the first proxy node goes online, when other new online proxy nodes (such as the second proxy node in the offline state) go online, the first proxy node in the online state may also be determined as a valid node. At this time, the first proxy node can receive the data pull request (which can be called the second data pull request) sent by the second proxy node in the offline state.
[0133] Step S202, based on the second data pull request, obtain the target subscription tree, and serialize the target subscription tree to obtain a serialized subscription tree.
[0134] In the present application, the specific method for serializing the target subscription tree may be: obtain the logic code template corresponding to the serialization process; subsequently, obtain the subscription client in the target subscription tree and the subscription topic information subscribed by the subscription client, and use the subscription client and the subscription topic information subscribed by the subscription client as variables; subsequently, fuse the variables with the logic code template to obtain the serialized subscription tree.
[0135] It should be understood that the above logic code template may be as shown in Table 1:
[0136] Table 1
[0137]
[0138]
[0139] It should be understood that when storing subscription information, the subscription tree of the present application can store the subscription information in a hierarchical structure storage mode, that is, each node stores the first level in the subscription topic. Among them, the highest level in the topic (such as level "a" in the topic "a / b / c / d") can be stored as the parent node in the subscription tree, and the next level "b" of level "a" can be stored as the child node of the parent node "a"; the next level "c" of level "b" can be stored as the next child node of the child node "b", and so on until all levels in the topic are stored. It should be understood that the leaf node in the Trie (that is, the node corresponding to the last level, such as the node corresponding to the above level "d") can store the information of the subscription client and the broker (proxy node) connected by the subscription client. That is to say, the subscription tree can include a root node, a parent node, and child nodes (including leaf nodes), and the child nodes shown in Table 1 above can be the child nodes in the subscription tree; the subscriber can be the subscription client, and the tree structure of the target subscription tree of the proxy node (including subscription topic information, the number of child nodes, the number of subscription clients, etc.) can be written into the logic code template in a recursive manner. The fusion is to perform serialization processing on the target subscription tree, and after fusion, the serialized subscription tree (i.e., the sequence subscription tree) can be obtained.
[0140] Step S203: Send the sequence subscription tree to the second proxy node in the offline state, so that the second proxy node in the offline state performs deserialization processing on the sequence subscription tree to obtain the target subscription tree and stores the target subscription tree.
[0141] In the present application, the first proxy node can send the sequence subscription tree to the second proxy node in the offline state, and the second proxy node can perform deserialization processing on the sequence subscription tree to obtain the target subscription tree.
[0142] In the embodiments of the present application, the proxy nodes can be deployed in a distributed cluster manner. Each online proxy node can store the same synchronization subscription information. At the same time, the present application can assign a running failure time to each online proxy node, and jointly save the key identifier of each online proxy node and the running failure time of each online proxy node in the database. By assigning a running failure time to each online proxy node, it is possible to accurately know the time when each online proxy node cannot run, and each online proxy node can continuously request to update the running failure time to prove that it is running normally. Thus, when a new proxy node (a proxy node not in the online proxy node cluster, such as the first proxy node in the offline state) requests to go online, the database can be traversed. Through the key identifier and running failure time in the database, it is possible to accurately query which online proxy nodes in the online proxy node cluster have not failed at that time (the request moment when the proxy node requests to go online). The proxy node requesting to go online can use them as valid nodes and send a data pull request to them to pull the synchronization subscription information stored in the valid nodes. Since it is possible to more accurately determine which nodes are running normally through the running failure time, that is, to determine that the valid nodes are normal running nodes, the synchronization subscription information obtained from the valid nodes will also be more accurate. Then, the accuracy of the synchronization subscription information pulled by the proxy node requesting to go online can be improved. At the same time, when the proxy node requesting to go online pulls the synchronization subscription information from the valid nodes, the remaining proxy nodes in the online proxy node cluster other than the valid nodes do not need to pause running like the valid nodes, but can continue to run. That is to say, when expanding the proxy nodes, it is not necessary to stop running all the proxy nodes in the online proxy node cluster. It is only necessary to pause running a certain proxy node that receives the data pull request, and dynamic expansion of the proxy nodes can be achieved. In summary, the present application can improve the accuracy of the data pulled by the proxy node requesting to go online while realizing the dynamic expansion of the proxy nodes.
[0143] For ease of understanding, please refer to Figure 5 , Figure 5 which is a schematic diagram of a system process provided by an embodiment of the present application. The process may include the following steps 51-step 515:
[0144] Step 51, the first node goes online.
[0145] Specifically, proxy node 1 is the first node to go online, and there are no other online proxy nodes before proxy node 1.
[0146] Step 52, proxy node 1 queries healthy nodes from the database.
[0147] Specifically, the proxy node 1 can query the healthy nodes from the database, that is, query whether there is an unexpired key (critical identifier) in the database. Since the database can store the critical identifier of each online proxy node and the running expiration time (which can be called the expiration time); if there is no unexpired key in the database, it can be explained that the proxy node 1 is the first online node, and then the proxy node can establish an empty subscription tree; if there is one or more unexpired keys in the database, the proxy node 1 can determine that the proxy nodes corresponding to these key values are all healthy nodes, and the proxy node 1 can choose any one of the healthy nodes as the valid node to learn the subscription tree from it.
[0148] Step 53, the proxy node 1 establishes an empty subscription tree.
[0149] Specifically, since the proxy node 1 is the first online node, there is no key with an unexpired time in the database. At this time, the proxy node 1 can establish an empty subscription tree.
[0150] Step 54, the proxy node 1 registers as a healthy node and maintains a heartbeat.
[0151] Specifically, after the proxy node 1 establishes an empty subscription tree, it can send a registration request to the database, and the database can allocate an expiration time (i.e., the running expiration time) for it based on this registration request. The proxy node 1 can periodically apply to the database to extend and update this expiration time, thereby proving to the database that it is still "maintaining a heartbeat" (i.e., in a normal running state).
[0152] It should be noted that if the proxy node 1 still does not request the database to update the expiration time when it reaches the expiration time, the database can determine that the proxy node 1 is an abnormal node (this proxy node 1 no longer has a heartbeat and cannot run normally), and the database can delete the proxy node 1 from the cluster of online proxy nodes.
[0153] Step 55, the proxy node 1 starts to consume from the message queue.
[0154] Specifically, the message queue (such as a kafka queue) stores the subscription information sent by each proxy node (since the proxy node 1 is the first online proxy node, there is currently no subscription information stored in the message queue). After the proxy node 1 completes registration, it can start to consume from the message queue (that is, store each subscription information in order according to the time order of the subscription information in the message queue). Since the proxy node 1 is the first online proxy node and there is no subscription information in the message queue at this time, the proxy node 1 does not need to store the subscription information in the subscription tree.
[0155] It should be noted that after the proxy node 1 receives the subscription information sent by the client, it can store the subscription information in the message queue and then consume it sequentially from the message queue.
[0156] Step 56, a new node goes online.
[0157] Specifically, taking the proxy node 2 as the second online node after the proxy node 1 as an example, when the proxy node 2 goes online, the proxy node 1 has already completed registration and gone online.
[0158] Step 57, the proxy node 2 queries the healthy nodes from the database.
[0159] Specifically, the proxy node 1 can query the healthy nodes from the database, that is, query whether there is an unexpired key (key identifier) in the database.
[0160] Step 58, the database returns the information of the proxy node 1.
[0161] Specifically, because the proxy node 1 has completed registration and gone online, if the expiration time of this proxy node 1 has not expired at this time, the proxy node 1 can be determined as a healthy node, and the information of the proxy node 1 can be returned to the proxy node 2.
[0162] Step 59, the proxy node 2 requests to learn the subscription tree from the proxy node 1.
[0163] Specifically, the proxy node 2 can send a data pull request to the proxy node 1 to pull the subscription tree stored on the local machine of the proxy node 1 (that is, request to learn the subscription tree).
[0164] Step 510, the proxy node serializes the subscription tree.
[0165] Specifically, after receiving the data pull request, the proxy node 1 can first obtain the mutex lock and add the mutex lock to pause consuming from the message queue. After pausing consumption, the proxy node 1 can perform serialization processing on the subscription tree.
[0166] It should be noted that if there are healthy nodes other than the proxy node 1 at this time, these other healthy nodes do not need to add the mutex lock and can continue to run, that is, continue to consume from the message queue.
[0167] Step 511, the proxy node 1 returns the serialized subscription tree to the proxy node 2.
[0168] Specifically, after serialization is completed, the proxy node 1 can return the serialized subscription tree to the proxy node 2.
[0169] Step 512, the proxy node 1 releases the mutex lock and continues to consume from the message queue.
[0170] Specifically, after the proxy node 1 completes the serialization of the sequence tree, it can unlock the mutex to continue consuming from the message queue. It can be understood that step 512 can be carried out simultaneously with step 511, that is, after the proxy node 1 completes the serialization processing of the subscription tree, it can return the serialized subscription tree to the proxy node 2, and at the same time unlock the mutex to continue consuming from the message queue.
[0171] Step 513, the proxy node 2 deserializes to obtain the subscription tree.
[0172] Specifically, the proxy node 2 can perform deserialization processing on the received serialized subscription tree, thereby obtaining the subscription tree, and the proxy node 2 can store the subscription tree on the local machine.
[0173] Step 514, the proxy node 2 registers as a healthy node and maintains a heartbeat.
[0174] Specifically, after the proxy node 2 stores the subscription tree, it can initiate a registration request to the database. The database can allocate an expiration time (i.e., the running failure time) for it based on this registration request. The proxy node 2 can periodically apply to the database to extend and update this expiration time, thereby proving to the database that it is still "maintaining a heartbeat" (i.e., in a normal running state).
[0175] It should be noted that, similarly, if the proxy node 2 still does not request the database to update the expiration time when the expiration time arrives, the database can determine that the proxy node 2 is an abnormal node (this proxy node 2 no longer has a heartbeat and cannot run normally), and the database can delete this proxy node 2 from the cluster of online proxy nodes. It should be understood that in addition to the proxy node 1 and the proxy node 2, other online nodes are the same. They will periodically request the database to update the expiration time. Once they do not timely initiate a time update request to the database, the database can consider this proxy node as an abnormal node and will delete it.
[0176] Step 515, the proxy node 2 starts consuming from the message queue.
[0177] Specifically, after the proxy node 2 completes registration, it can start consuming from the message queue, that is, sequentially obtain subscription information from the message queue that has not been stored in the subscription tree.
[0178] In an embodiment of the present application, proxy nodes can be deployed in a distributed cluster manner. Each online proxy node can store the same synchronization subscription information. At the same time, the present application can assign a running failure time to each online proxy node, and jointly save the key identifier of each online proxy node and the running failure time of each online proxy node in a database. By assigning a running failure time to each online proxy node, it is possible to accurately know the time when each online proxy node cannot run, and each online proxy node can continuously request to update the running failure time to prove that it is running normally. Thus, when a new proxy node (a proxy node not in the online proxy node cluster, such as the first proxy node in an offline state) requests to go online, the database can be traversed. Through the key identifier and running failure time in the database, it is possible to accurately query which online proxy nodes in the online proxy node cluster have not failed at that time (at the request time when the proxy node requests to go online). The proxy node requesting to go online can use these as valid nodes and send a data pulling request to them to pull the synchronization subscription information stored in the valid nodes. Since it is possible to more accurately determine which nodes are running normally through the running failure time, that is, it is possible to determine that the valid nodes are running normally, the synchronization subscription information obtained from the valid nodes will also be more accurate. Then, the accuracy of the synchronization subscription information pulled by the newly online proxy node can be improved. At the same time, when the proxy node requesting to go online pulls the synchronization subscription information from the valid nodes, the remaining proxy nodes in the online proxy node cluster other than the valid nodes do not need to pause running like the valid nodes, but can continue to run. That is to say, when expanding the proxy nodes, it is not necessary to stop all the proxy nodes of the online proxy nodes. It is only necessary to pause the operation of a certain proxy node that receives the data pulling request, and dynamic expansion of the proxy nodes can be achieved. In summary, the present application can improve the accuracy of the data pulled by the proxy node requesting to go online while realizing the dynamic expansion of the proxy nodes.
[0179] Further, please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a data processing device provided by an embodiment of the present application. The data processing device can be a computer program (including program code) running in a computer device. For example, the data processing device is an application software. The data processing device can be used to execute Figure 3 the method shown. As Figure 6 shown, the data processing device 1 can include: a traversal module 11, a node acquisition module 12, an information pulling module 13, an information storage module 14, and an information sending module 15.
[0180] The traversal module 11 is used to traverse the database based on the online request when the first proxy node is not online; the database includes the key identifier of each online proxy node in the online proxy node set and the operation expiration time corresponding to the key identifier; each online proxy node includes synchronization subscription information;
[0181] A node acquisition module 12, configured to acquire a valid node from the online proxy node set according to the operation expiration time set corresponding to the online proxy node set and the request time corresponding to the online request;
[0182] The information pulling module 13 is used to synchronously request and pull the synchronization subscription information from the valid nodes during the process of the remaining proxy nodes executing the storage of the target subscription information; the remaining proxy nodes are the online proxy nodes other than the valid nodes in the online proxy node set; the synchronization subscription information does not include the target subscription information;
[0183] The information storage module 14 is used to store synchronization subscription information and switch the state of the first proxy node in the offline state from the offline state to the online state;
[0184] The information sending module 15 is used to send a storage success prompt message to the database when the first proxy node is in an online state, so that the database assigns a target operation expiration time to the first proxy node in an online state based on the storage success prompt message, and adds the target key identifier and target operation expiration time of the first proxy node in an online state to the database.
[0185] The specific implementation of the traversal module 11, the node acquisition module 12, the information pulling module 13, the information storage module 14 and the information sending module 15 can be found in the above Figure 3 The description of step S101 to step S104 in the corresponding embodiment will not be repeated here.
[0186] In one embodiment, the synchronization subscription information includes a subscription tree; the subscription tree is used to store the association relationship between the subscription client, the subject information subscribed by the subscription client, and the proxy node corresponding to the subscription client;
[0187] See also Figure 6 , the data processing device 1 may further include: a message forwarding module 16.
[0188] The message forwarding module 16 is used to receive a publishing request from a publishing client for a target message; the publishing request includes subject information of the target message;
[0189] The message forwarding module 16 is further configured to traverse the subscription tree based on the publishing request, and obtain the proxy node to be transmitted from the proxy nodes stored in the subscription tree; the subscription topic information subscribed by the subscription client to be transmitted corresponding to the proxy node to be transmitted matches the topic information of the target message; the subscription clients include the subscription clients to be transmitted.
[0190] The message forwarding module 16 is further configured to send the target message to the proxy node to be transmitted, so that the proxy node to be transmitted forwards the target message to the subscription client to be transmitted corresponding to the proxy node to be transmitted.
[0191] Among them, for the specific implementation manner of the message forwarding module 16, reference can be made to the description of step S104 in the corresponding embodiment above. Figure 3 Details will not be described here again.
[0192] Please refer to Figure 6 , the data processing device 1 may further include: a message detection module 17 and a step execution module 18.
[0193] The message detection module 17 is configured to obtain a detection rule library; the detection rule library includes abnormal texts and abnormal audios.
[0194] The message detection module 17 is further configured to match the target message with the abnormal texts and abnormal audios in the detection rule library.
[0195] The message detection module 17 is further configured to, if there is text content in the target message that is the same as the abnormal text, or there is audio content in the target message that is the same as the abnormal audio, determine the target message as a violation message, generate a violation prompt message, and send the violation prompt message to the publishing client and the proxy node to be transmitted.
[0196] The step execution module 18 is configured to, if there is no text content in the target message that is the same as the abnormal text and there is no audio content in the target message that is the same as the abnormal audio, execute the step of sending the target message to the proxy node to be transmitted.
[0197] Among them, for the specific implementation manners of the message detection module 17 and the step execution module 18, reference can be made to the description of step S104 in the corresponding embodiment above. Figure 3 Please refer to the description.
[0198] Please refer to Figure 6 , the data processing device 1 may further include: a time matching module 19 and a tree building module 20.
[0199] The time matching module 19 is configured to match the request time with the set of running expiration times corresponding to the set of online proxy nodes.
[0200] A tree construction module 20, configured to construct an empty subscription tree including a root node if there is no running failure time later than the request time in the set of running failure times;
[0201] The tree construction module 20 is further configured to, if there is a running failure time later than the request time in the set of running failure times, perform the step of obtaining valid nodes in the set of online proxy nodes according to the set of running failure times corresponding to the set of online proxy nodes and the request time.
[0202] Among them, for the specific implementation manners of the time matching module 19 and the tree construction module 20, reference may be made to the description of step S102 in the corresponding embodiment above. Figure 3 The description corresponding to the embodiment.
[0203] Please refer to Figure 6 , the node obtaining module 12 may include: a candidate time determination unit 121 and a node obtaining unit 122.
[0204] The candidate time determination unit 121 is configured to determine the running failure times later than the request time in the set of running failure times as candidate failure times;
[0205] The candidate time determination unit 121 is further configured to determine the key identifier corresponding to the candidate failure time as a candidate key identifier;
[0206] The node obtaining unit 122 is configured to determine the online proxy nodes corresponding to the candidate key identifiers as candidate proxy nodes, and obtain valid nodes among the candidate proxy nodes.
[0207] Among them, for the specific implementation manners of the candidate time determination unit 121 and the node obtaining unit 122, reference may be made to the description in step S102 in the corresponding embodiment above, and details will not be elaborated here. Figure 3 The description corresponding to the embodiment will not be elaborated here.
[0208] In one embodiment, the number of candidate proxy nodes is at least two;
[0209] Please refer to Figure 6 , the node obtaining unit 122 may include: a quantity statistics subunit 1221, a node deletion subunit 1222, and a node determination subunit 1223.
[0210] The quantity statistics subunit 1221 is configured to obtain the candidate key identifiers respectively corresponding to each candidate proxy node among at least two candidate proxy nodes, and obtain the running failure time corresponding to each candidate key identifier in the database;
[0211] The quantity statistics subunit 1221 is further configured to count the quantity of the running failure times corresponding to each candidate key identifier among at least two candidate key identifiers;
[0212] The node deletion subunit 1222 is configured to determine, as error identifiers, candidate key identifiers among at least two candidate key identifiers for which the number of running failure times is greater than or equal to a quantity threshold, and delete, from the at least two candidate proxy nodes, the candidate proxy nodes corresponding to the error identifiers, so as to obtain candidate proxy nodes to be selected;
[0213] The node determination subunit 1223 is configured to obtain valid nodes from the candidate proxy nodes to be selected.
[0214] Among them, for the specific implementation manners of the quantity statistics subunit 1221, the node deletion subunit 1222, and the node determination subunit 1223, reference may be made to the description in step S102 of the corresponding embodiment above, and details will not be elaborated here. Figure 3 The description in step S102 of the corresponding embodiment above will not be repeated here.
[0215] In one embodiment, the node determination subunit 1223 is further specifically configured to obtain network quality parameters corresponding to the candidate proxy nodes to be selected;
[0216] The node determination subunit 1223 is further specifically configured to determine, as valid nodes, the candidate proxy nodes corresponding to the maximum network quality parameter among the network quality parameters.
[0217] In one embodiment, the number of target subscription information is at least two;
[0218] Please refer to Figure 6 , and the data processing apparatus 1 may further include: a time acquisition module 21, a sorting module 22, and an information storage module 23.
[0219] The time acquisition module 21 is configured to acquire the subscription time corresponding to each of the at least two target subscription information;
[0220] The sorting module 22 is configured to sort the at least two target subscription information in chronological order of the subscription time to obtain sorted target subscription information;
[0221] The information storage module 23 is configured to sequentially store the sorted target subscription information into a subscription tree to obtain a target subscription tree.
[0222] Among them, for the specific implementation manners of the time acquisition module 21, the sorting module 22, and the information storage module 23, reference may be made to the description in step S104 of the corresponding embodiment above, and details will not be elaborated here. Figure 3 The description in step S104 of the corresponding embodiment above will not be repeated here.
[0223] In one embodiment, the data processing apparatus 1 may further include: a sequence processing module 24.
[0224] The sequence processing module 24 is configured to receive a second data pull request sent by a second proxy node when the first proxy node in the online state is a valid node determined by the second proxy node in the offline state; the second proxy node in the offline state is a proxy node to be online.
[0225] The sequence processing module 24 is further configured to obtain a target subscription tree based on the second data pull request.
[0226] The sequence processing module 24 is further configured to perform serialization processing on the target subscription tree to obtain a serialized subscription tree.
[0227] The tree sending module is configured to send the serialized subscription tree to the second proxy node in the offline state, so that the second proxy node in the offline state performs deserialization processing on the serialized subscription tree to obtain the target subscription tree and stores the target subscription tree.
[0228] Among them, for the specific implementation manner of the sequence processing module 24, reference may be made to the description in steps S201 - S203 in the corresponding embodiment above, which will not be elaborated here. Figure 4 The description in steps S201 - S203 in the corresponding embodiment above, which will not be elaborated here.
[0229] In one embodiment, the sequence processing module 24 may include: a template acquisition unit 241, a variable determination unit 242, and a fusion unit 243.
[0230] The template acquisition unit 241 is configured to obtain a logic code template corresponding to the serialization processing.
[0231] The variable determination unit 242 is configured to obtain the subscription client in the target subscription tree and the subscription topic information subscribed by the subscription client, and use the subscription client and the subscription topic information subscribed by the subscription client as variables.
[0232] The fusion unit 243 is configured to fuse the variables with the logic code template to obtain a serialized subscription tree.
[0233] Among them, for the specific implementation manners of the template acquisition unit 241, the variable determination unit 242, and the fusion unit 243, reference may be made to the description in step S202 in the corresponding embodiment above, which will not be elaborated here. Figure 4 The description in step S202 in the corresponding embodiment above, which will not be elaborated here.
[0234] In one embodiment, the data processing device 1 may further include: a time update module 25.
[0235] The time update module 25 is configured to determine an update time according to the request time and the target running expiration time.
[0236] The time update module 25 is further configured to generate a time update request when the system time reaches the update time, and send the time update request to the database, so that the database updates the target running expiration time based on the time update request; the updated target running expiration time is later than the target running expiration time.
[0237] Wherein, for the specific implementation manner of the time update module 25, reference may be made to the description in step S104 in the corresponding embodiment above. Figure 3 Details will not be elaborated here.
[0238] In one embodiment, the time update module 25 may include: a duration determination unit 251 and a duration calculation unit 252.
[0239] The duration determination unit 251 is configured to determine the total duration between the request time and the target running expiration time.
[0240] The duration calculation unit 252 is configured to multiply the total duration by the configured duration ratio value to obtain a calculated duration; the calculated duration is less than or equal to the total duration.
[0241] The duration calculation unit 252 is further configured to add the request time and the calculated duration to obtain an update time.
[0242] Wherein, for the specific implementation manners of the duration determination unit 251 and the duration calculation unit 252, reference may be made to the description in step S104 in the corresponding embodiment above. Figure 3 Details will not be elaborated here.
[0243] In the embodiments of the present application, the proxy nodes can be deployed in a distributed cluster manner. Each online proxy node can store the same synchronization subscription information. At the same time, the present application can assign a running failure time to each online proxy node, and jointly save the key identifier of each online proxy node and the running failure time of each online proxy node in the database. By assigning a running failure time to each online proxy node, it is possible to accurately know the time when each online proxy node cannot run, and each online proxy node can continuously request to update the running failure time to prove that it is running normally. Thus, when a new proxy node (a proxy node not in the online proxy node cluster, such as the first proxy node in the offline state) requests to go online, the database can be traversed. Through the key identifier and running failure time in the database, it is possible to accurately query which online proxy nodes in the online proxy node cluster have not failed at that time (the request moment when the online request is made). The proxy node requesting to go online can use them as valid nodes and send a data pull request to them to pull the synchronization subscription information stored in the valid nodes. Since the running failure time can be used to more accurately determine which nodes are running normally, that is, the valid nodes can be determined as the normally running nodes, the synchronization subscription information obtained from the valid nodes will also be more accurate. Then, the accuracy of the synchronization subscription information pulled by the newly online proxy node can be improved. At the same time, when the proxy node requesting to go online pulls the synchronization subscription information from the valid nodes, the remaining proxy nodes in the online proxy node cluster other than the valid nodes do not need to pause running like the valid nodes, but can continue to run. That is to say, when expanding the proxy nodes, it is not necessary to stop running all the proxy nodes in the online proxy node cluster. Only the proxy node that receives the data pull request needs to be paused to run, and the dynamic expansion of the proxy nodes can be realized. In summary, the present application can improve the accuracy of the data pulled by the proxy node requesting to go online while realizing the dynamic expansion of the proxy nodes.
[0244] Further, please refer to Figure 7 , Figure 7 which is a schematic structural diagram of a computer device provided by an embodiment of the present application. As Figure 7 shown, the above Figure 6The data processing device 1 in the corresponding embodiment can be applied to the above-mentioned computer device 1000. The computer device 1000 may include: a processor 1001, a network interface 1004, and a memory 1005. In addition, the computer device 1000 further includes: a user interface 1003 and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display) and a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. Optionally, the memory 1005 may further be at least one storage device located far from the aforementioned processor 1001. As Figure 7 shown, the memory 1005, as a computer-readable storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.
[0245] In Figure 7 the computer device 1000 shown, the network interface 1004 can provide network communication functions; while the user interface 1003 is mainly used to provide an input interface for users; and the processor 1001 can be used to call the device control application program stored in the memory 1005 to achieve:
[0246] When the first proxy node is in an offline state, traverse the database based on the online request; the database includes the key identifiers of each online proxy node in the set of online proxy nodes and the corresponding running failure time of the key identifier; each online proxy node includes synchronization subscription information;
[0247] According to the set of running failure times corresponding to the set of online proxy nodes and the request time, obtain valid nodes in the set of online proxy nodes. During the process of storing the target subscription information in the remaining proxy nodes, synchronously request and pull the synchronization subscription information from the valid nodes; the remaining proxy nodes are the online proxy nodes in the set of online proxy nodes except the valid nodes; the synchronization subscription information does not include the target subscription information;
[0248] Store the synchronization subscription information, and switch the state of the first proxy node in the offline state from the offline state to the online state;
[0249] When the first proxy node is in the online state, send a storage success prompt message to the database, so that the database assigns a target running failure time to the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running failure time of the first proxy node in the online state to the database.
[0250] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method in the corresponding embodiments mentioned above, and can also execute the description of the data processing device 1 in the corresponding embodiments mentioned above, which will not be elaborated here. In addition, the description of the beneficial effects of the same method will not be elaborated either. Figures 3 to 4 The description of the data processing method in the corresponding embodiments mentioned above, and the description of the data processing device 1 in the corresponding embodiments mentioned above, which will not be elaborated here. In addition, the description of the beneficial effects of the same method will not be elaborated either. Figure 6 In addition, it should be pointed out here that: the embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium stores the computer program executed by the computer device 1000 for data processing mentioned above, and the computer program includes program instructions. When the above-mentioned processor executes the above-mentioned program instructions, it can execute the description of the above-mentioned data processing method in the corresponding embodiments mentioned above. Therefore, it will not be elaborated here. In addition, the description of the beneficial effects of the same method will not be elaborated either. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application.
[0251] The above computer-readable storage medium may be the data processing device provided in any of the foregoing embodiments or the internal storage unit of the above computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store the data that has been output or will be output. Figures 3 to 4 The description of the data processing method in the corresponding embodiments mentioned above, and the description of the beneficial effects of the same method will not be elaborated either. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application.
[0252] The above computer-readable storage medium may be the data processing device provided in any of the foregoing embodiments or the internal storage unit of the above computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store the data that has been output or will be output.
[0253] In one aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in one aspect of the embodiments of the present application.
[0254] In the description of the embodiments of the present application, the terms "first", "second", etc. in the claims and the accompanying drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product or device that includes a series of steps or units is not limited to the listed steps or modules, but optionally further includes steps or modules not listed, or optionally further includes other step units inherent to these processes, methods, apparatuses, products or devices.
[0255] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0256] The method and related device provided in the embodiments of the present application are described with reference to the method flowcharts and / or structural schematic diagrams provided in the embodiments of the present application. Specifically, each process and / or block of the method flowchart and / or structural schematic diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or structural schematic Figure 1 one block or multiple blocks. These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in Figure 1 one process or multiple processes and / or structural schematic Figure 1The functions specified in one or more boxes. These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide for implementing in the process Figure 1 The steps of one or more processes and / or structural diagrams indicating the functions specified in one or more boxes.
[0257] The foregoing disclosure is only for the preferred embodiments of this application, and of course, it cannot be used to limit the scope of rights of this application. Therefore, equivalent changes made according to the claims of this application still fall within the scope covered by this application.
Claims
1. A data processing method, characterized in that, Including: The first proxy node in the offline state traverses the database based on the online request; The database includes the key identifiers of each online proxy node in the set of online proxy nodes and the corresponding running failure time of the key identifier; Each of the online proxy nodes includes synchronized subscription information; According to the set of running failure times corresponding to the set of online proxy nodes and the request time corresponding to the online request, obtain valid nodes in the set of online proxy nodes, and during the process of storing the target subscription information in the remaining proxy nodes, synchronously request and pull the synchronized subscription information from the valid nodes; the remaining proxy nodes are the online proxy nodes in the set of online proxy nodes except the valid nodes; the synchronized subscription information does not include the target subscription information; Store the synchronized subscription information, and switch the state of the first proxy node in the offline state from the offline state to the online state; The first proxy node in the online state sends a storage success prompt message to the database, so that the database assigns a target running failure time to the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running failure time of the first proxy node in the online state to the database.
2. The method according to claim 1, wherein The synchronized subscription information includes a subscription tree; the subscription tree is used to store the association relationship between the subscription client, the topic information subscribed by the subscription client, and the proxy node corresponding to the subscription client; The method further includes: Receiving a publishing request from a publishing client for a target message; the publishing request includes the topic information of the target message; Traversing the subscription tree based on the publishing request, and obtaining a proxy node to be transmitted among the proxy nodes stored in the subscription tree; the subscription topic information subscribed by the subscription client to be transmitted corresponding to the proxy node to be transmitted matches the topic information of the target message; the subscription client includes the subscription client to be transmitted; Sending the target message to the proxy node to be transmitted, so that the proxy node to be transmitted forwards the target message to the subscription client to be transmitted corresponding to the proxy node to be transmitted.
3. The method according to claim 2, wherein The method further includes: Obtaining a detection rule library; the detection rule library includes abnormal texts and abnormal audios; Matching the target message with the abnormal texts and abnormal audios in the detection rule library; If there is text content in the target message that is the same as the abnormal text, or there is audio content in the target message that is the same as the abnormal audio, then determine the target message as a violation message, generate a violation prompt message, and send the violation prompt message to the publishing client and the proxy node to be transmitted; If there is no text content in the target message that is the same as the abnormal text, and there is no audio content in the target message that is the same as the abnormal audio, then execute the step of sending the target message to the proxy node to be transmitted.
4. The method according to claim 2, wherein The method further includes: Match the requested time with the set of running failure times corresponding to the set of online proxy nodes; If there is no running failure time later than the requested time in the set of running failure times, construct an empty subscription tree including a root node; If there is a running failure time later than the requested time in the set of running failure times, perform the step of obtaining valid nodes in the set of online proxy nodes according to the set of running failure times corresponding to the set of online proxy nodes and the requested time corresponding to the online request.
5. The method according to claim 4, wherein The step of obtaining valid nodes in the set of online proxy nodes according to the set of running failure times corresponding to the set of online proxy nodes and the requested time corresponding to the online request includes: Determine the running failure times later than the requested time in the set of running failure times as candidate failure times; Determine the key identifiers corresponding to the candidate failure times as candidate key identifiers; Determine the online proxy nodes corresponding to the candidate key identifiers as candidate proxy nodes, and obtain the valid nodes among the candidate proxy nodes.
6. The method according to claim 5, wherein The number of the candidate proxy nodes is at least two; Obtaining the valid nodes among the candidate proxy nodes includes: Obtain the candidate key identifiers respectively corresponding to each candidate proxy node among the at least two candidate proxy nodes, and obtain the running failure time corresponding to each candidate key identifier in the database; Count the number of running failure times corresponding to each candidate key identifier among the at least two candidate key identifiers; Determine the candidate key identifiers with the number of running failure times greater than or equal to the quantity threshold among the at least two candidate key identifiers as error identifiers, and delete the candidate proxy nodes corresponding to the error identifiers from the at least two candidate proxy nodes to obtain candidate proxy nodes to be selected; Obtain the valid nodes among the candidate proxy nodes to be selected.
7. The method according to claim 6, wherein Obtaining the valid nodes among the candidate proxy nodes to be selected includes: Obtain the network quality parameters corresponding to the candidate proxy nodes to be selected; Determine the candidate proxy node corresponding to the maximum network quality parameter in the network quality parameters as the valid node.
8. The method according to claim 2, wherein The number of the target subscription information is at least two; The method further includes: Obtain the subscription time respectively corresponding to each target subscription information among the at least two target subscription information; Sort the at least two target subscription information in chronological order of the subscription time to obtain the sorted target subscription information; Store the sorted target subscription information into the subscription tree in order to obtain a target subscription tree.
9. The method according to claim 8, wherein The method further includes: When the first proxy node in the online state is the valid node determined by the second proxy node in the offline state, receive a second data pull request sent by the second proxy node in the offline state; Based on the second data pull request, obtain the target subscription tree, and perform serialization processing on the target subscription tree to obtain a serialized subscription tree; Send the sequence subscription tree to the second proxy node in the offline state, so that the second proxy node in the offline state deserializes the sequence subscription tree to obtain the target subscription tree and stores the target subscription tree.
10. The method according to claim 9, wherein The serializing the target subscription tree to obtain a sequence subscription tree includes: Obtain the logic code template corresponding to the serialization process; Obtain the subscription client in the target subscription tree and the subscription topic information subscribed by the subscription client, and use the subscription client and the subscription topic information subscribed by the subscription client as variables; Fuse the variables with the logic code template to obtain the sequence subscription tree.
11. The method according to claim 1, wherein The method further includes: Determine the update time according to the request time and the target running expiration time; When the system time reaches the update time, generate a time update request and send the time update request to the database, so that the database updates the target running expiration time based on the time update request; the updated target running expiration time is later than the target running expiration time.
12. The method according to claim 11, wherein The determining the update time according to the request time and the target running expiration time includes: Determine the total duration between the request time and the target running expiration time; Multiply the total duration by the configured duration ratio value to obtain an operation duration; the operation duration is less than or equal to the total duration; Add the request time and the operation duration to obtain the update time.
13. A data processing device, characterized in that, The data processing device is applied to the first proxy node, and the device includes: A traversal module, configured to traverse the database based on an online request when the first proxy node is in an offline state; the database includes the key identifier of each online proxy node in the set of online proxy nodes and the running expiration time corresponding to the key identifier; each online proxy node includes synchronization subscription information; An information pulling module, configured to obtain valid nodes from the set of online proxy nodes according to the set of running expiration times corresponding to the set of online proxy nodes and the request time corresponding to the online request, and synchronously request and pull the synchronization subscription information from the valid nodes during the process of storing the target subscription information in the remaining proxy nodes; the remaining proxy nodes are the online proxy nodes in the set of online proxy nodes except the valid nodes; the synchronization subscription information does not include the target subscription information; An information storage module, configured to store the synchronization subscription information and switch the state of the first proxy node in the offline state from the offline state to the online state; An information sending module, configured to send a storage success prompt message to the database when the first proxy node is in the online state, so that the database allocates a target running failure time for the first proxy node in the online state based on the storage success prompt message, and adds the target key identifier and the target running failure time of the first proxy node in the online state to the database.
14. A computer device, characterized in that, Comprising: A processor, a memory, and a network interface; The processor is connected to the memory and the network interface. Among them, the network interface is used to provide network communication functions, the memory is used to store program codes, and the processor is used to call the program codes so that the computer device executes the method according to any one of claims 1-12.
15. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and the computer program is adapted to be loaded and executed by a processor to execute the method according to any one of claims 1-12.
Citation Information
Patent Citations
Command line service method and system for distributed storage, terminal and storage medium
CN112463144A
Elastic and scalable publish / subscribe service
US20120191856A1