Distributed gateway sub-device online state optimization method, system and device and storage medium

By maintaining the data reporting interval of gateway sub-devices and the Redis cache database, the accuracy and timeliness issues of distributed gateway sub-device status management are solved, enabling real-time and accurate updates and efficient management of gateway sub-device status.

CN118945008APending Publication Date: 2024-11-12XCMG HANYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410993836.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In existing technologies, the online status management of gateway sub-devices suffers from accuracy and timeliness issues. Especially in distributed environments, the uncertainty of the status of gateway sub-devices leads to management errors and a lack of timeliness.

Method used

By maintaining the data reporting interval and the time of the last data report for each gateway sub-device, the online and offline status is maintained using a Redis cache database, and the status is updated in real time using a publish-subscribe pattern. Multiple access services share the latest data time and status of the devices.

Benefits of technology

It enables real-time, accurate, and efficient management of gateway sub-device status, simplifies the workload of developers, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945008A_ABST
    Figure CN118945008A_ABST
Patent Text Reader

Abstract

The invention discloses a distributed gateway sub-device online state optimization method, system and device and a storage medium, and the online and offline states of gateway sub-devices can be accurately maintained by maintaining the specific data reporting time interval of each gateway sub-device, the last data reporting time of the device and the online state; the online state and the last data time of the maintained gateway sub-equipment are put into the redis cache database through the multiple access services at the same time, the multiple access services share the latest data time and state of the equipment, and the online and offline state problems of the distributed management gateway sub-equipment are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of intelligent gateways, and in particular relates to a method, system, device and storage medium for optimizing the online status of distributed gateway sub-devices. Background Art

[0002] Existing IoT devices are mainly divided into direct-connected devices, gateway devices, and gateway sub-devices. After the direct-connected devices and gateway devices are connected to the access service, they actively send online and offline events to manage the online and offline status of the devices and actively send collected data; for gateway sub-devices, since the gateway sub-devices are not directly connected to the access service, they will not send online and offline events, and can only communicate indirectly with the gateway device and the access service. The gateway sub-device passively reports the collected data to the platform with the help of the gateway device.

[0003] There are two main management methods for the online status of gateway sub-devices:

[0004] Solution 1: When a gateway device is online or offline, all connected gateway sub-devices are considered to be online or offline accordingly.

[0005] Solution 2: If the gateway sub-device reports data to the access service, the gateway sub-device is considered online. The access service tests all gateway sub-devices once at a certain interval. If no data is reported, the gateway sub-device is considered offline.

[0006] However, Solution 1 has the following disadvantages: the gateway device is online, but the gateway sub-device is actually not online. According to this solution, the actual online status of the gateway sub-device is obviously wrong; during the distributed collection process, a gateway sub-device may be randomly connected to a certain gateway device, and multiple connected gateway devices may appear partially online and partially offline, and the online status of the gateway sub-device is uncertain.

[0007] Solution 2 has the following disadvantages: Since the access service manages a wide variety of devices, the frequency of data reporting for each device is different. If a unified time interval is used to change the device status of the device that is online and has not reported data in the interval to offline, the timeliness is not accurate. For example, there are three types of gateway sub-devices with reporting intervals of 1, 2, and 3 minutes. If the detection is unified every 3 minutes, the device with a 1-minute interval will have to wait until 3 minutes before it is known that the device is offline. This obviously lacks 2 minutes of timeliness. A gateway sub-device may randomly switch to report data in multiple access services for distributed collection. The data interval received by the access service from the gateway sub-device is also uncertain, and the state of the network management sub-device is also uncertain. For example, the gateway sub-device switches to report to access service B. After the time interval of access service A has no data reported, access service A will set the gateway sub-device offline, and access service B will set the gateway sub-device online. The gateway sub-device switches to access service reporting data, and the state of the gateway sub-device will also switch back and forth, which will give customers the illusion that the gateway sub-device is online and offline, which is obviously incorrect.

[0008] Therefore, the existing solutions for managing gateway sub-devices still have problems with the accuracy of distributed gateway sub-device status management and the timeliness of status changes of different gateway sub-devices. Summary of the invention

[0009] The purpose of the present invention is to overcome the deficiencies in the prior art and provide a distributed gateway sub-device online status optimization method, system, device and storage medium. By maintaining the data reporting time interval of each specific gateway sub-device, the time when the device last reported data and the online status, the online and offline status of the gateway sub-device can be accurately maintained; by simultaneously accessing multiple services, the online status and the last data time of the maintained gateway sub-device are put into the redis cache database, and multiple access services share the latest data time and status of the device, thereby solving the problem of distributed management of the online and offline status of gateway sub-devices.

[0010] To achieve the above object, the present invention is implemented by adopting the following technical solutions:

[0011] In a first aspect, the present invention provides a method for optimizing the online status of a distributed gateway sub-device, comprising:

[0012] Get the expiration time of each gateway sub-device;

[0013] Determine whether the current gateway sub-device reports data within the corresponding expiration time;

[0014] If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache;

[0015] If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

[0016] Further, the obtaining of the expiration time of each gateway sub-device includes:

[0017] Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization;

[0018] The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

[0019] Further, the determining whether the current gateway sub-device reports data within the corresponding expiration time includes:

[0020] If the current gateway sub-device reports data to any access service within the corresponding expiration time, it is confirmed that the current gateway sub-device reports data within the corresponding expiration time.

[0021] Further, changing the online status of the current gateway sub-device to offline includes: changing the online status of the current gateway sub-device in the database and the redis cache to offline.

[0022] Furthermore, if the current gateway sub-device continuously reports data, the access service saves the continuous data information of the current gateway sub-device into the redis cache.

[0023] Furthermore, the data information of the gateway sub-device includes: device number, online status and current time.

[0024] In a second aspect, the present invention provides a distributed gateway sub-device online status optimization system, comprising:

[0025] The acquisition module is used to obtain the expiration time of each gateway sub-device;

[0026] A judgment module is used to judge whether the current gateway sub-device reports data within the corresponding expiration time;

[0027] If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache;

[0028] If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

[0029] Furthermore, the acquisition module is specifically used to:

[0030] Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization;

[0031] The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

[0032] In a third aspect, the present invention provides a computer device, comprising:

[0033] Memory, for storing computer instructions;

[0034] A processor is used to operate according to the instructions to execute the steps of the distributed gateway sub-device online status optimization method according to the first aspect.

[0035] In a fourth aspect, the present invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the distributed gateway sub-device online status optimization method described in the first aspect.

[0036] Compared with the prior art, the present invention has the following beneficial effects:

[0037] (1) The status change of gateway sub-devices is more real-time, which is mainly reflected in the fact that each gateway sub-device has a different data reporting frequency. Each sub-device uses the redis expiration mechanism and adopts a publish-subscribe mode to notify access services in real time, and the status changes from online to offline in real time. Any access service receives data on the gateway sub-device and updates the status of the gateway sub-device in the redis cache to online in real time.

[0038] (2) The present invention not only supports real-time online status monitoring of a single node of a gateway sub-device, but also supports distributed gateway sub-device status changes. It mainly adopts the redis cache technology. The gateway sub-device data is reported to different access services. The access service stores the relevant online data and the latest time of the gateway sub-device in the redis cache. Any other access service connects to the redis cache data for real-time communication.

[0039] (3) The present invention also supports dynamic adjustment of the data reporting interval of each gateway sub-device. The data reporting interval of each gateway sub-device only needs to update the data reporting interval in the database and redis. The expiration of the device status adopts the expiration mechanism of redis, and R&D personnel no longer need to maintain the expiration interval of each device by themselves.

[0040] Therefore, the present invention not only solves the problem of the accuracy of the state change of the distributed gateway sub-devices, but also has real-time performance, reduces the workload of developers, and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 FIG. 1 is a flow chart of a method for optimizing the online status of distributed gateway sub-devices provided in an embodiment of the present invention;

[0042] Figure 2 Shown is a network topology diagram of a distributed gateway sub-device online status optimization method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The technical concept of the present invention is: by maintaining the data reporting time interval of each specific gateway sub-device, the time when the device last reported data, and the online status, the online and offline status of the gateway sub-device can be accurately maintained; by simultaneously providing multiple access services to put the maintained online status and the last data time of the gateway sub-device into the redis cache database, multiple access services share the latest data time and status of the device, solving the problem of distributed management of the online and offline status of gateway sub-devices.

[0044] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present application and its application or use.

[0045] Example 1

[0046] This embodiment discloses a distributed gateway sub-device online status optimization method. The network topology diagram of the method is as follows: Figure 2 As shown, the method includes:

[0047] Get the expiration time of each gateway sub-device;

[0048] Determine whether the current gateway sub-device reports data within the corresponding expiration time;

[0049] If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache;

[0050] If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

[0051] The obtaining of the expiration time of each gateway sub-device includes:

[0052] Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization;

[0053] The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

[0054] The determining whether the current gateway sub-device reports data within the corresponding expiration time includes:

[0055] If the current gateway sub-device reports data to any access service within the corresponding expiration time, it is confirmed that the current gateway sub-device reports data within the corresponding expiration time.

[0056] Changing the online status of the current gateway sub-device to offline includes: changing the online status of the current gateway sub-device in the database and the redis cache to offline.

[0057] If the current gateway sub-device continuously reports data, the access service saves the continuous data information of the current gateway sub-device into the redis cache.

[0058] The data information of the gateway sub-device includes: device number, online status and current time.

[0059] The specific application of this embodiment is, for example, Figure 1 As shown, the following steps are included:

[0060] S1. The reporting frequency information of each gateway sub-device (e.g. 1 minute, 80 seconds, etc.) is manually initialized and saved in the database.

[0061] S2. Each time the access service is started, it automatically queries the reporting frequency information of each gateway sub-device from the database (for example, 1 minute, 80 seconds, etc.) and automatically maintains it in the redis cache.

[0062] S3, access service subscription (SUBSCRIBE) redis cache expiration notification (PUBLISH).

[0063] S4. After any access service receives the reported data from the gateway sub-device, the access service will save the device number, online status, and current time of the gateway sub-device to the redis cache, and the device information (device number, online status, current time) will expire in redis at the frequency of the device's data reporting (for example, 1 minute, 80 seconds, etc.).

[0064] S5. When the device continues to report data, repeat step S4.

[0065] S6. When the gateway sub-device fails to report data for a frequency period, the device information (device number, online status, current time) cached in redis will expire, and an expiration event will be triggered, and an expiration message will be published (PUBLISH).

[0066] S7. When the access service subscribes (SUBSCRIBE) to the expiration event of the gateway sub-device published by redis, it is considered that the gateway sub-device is offline, and the online status of the device is changed to offline.

[0067] Example 2

[0068] Based on Example 1, this embodiment adopts the technology of the zookeeper temporary node heartbeat expiration mechanism and the node change monitoring mechanism to replace the redis cache and redis expired publish-subscribe mechanism used in Example 1, specifically including:

[0069] The access service registers the gateway sub-device information as a temporary node in Zookeeper. If the gateway sub-device keeps sending data, the access service will keep heartbeat communication with the temporary node of Zookeeper (the frequency of heartbeat communication is: the frequency of data reporting of the gateway sub-device). If the temporary node does not expire, the device is always online. The access service also monitors the expiration status of the gateway sub-device registered as a temporary node in Zookeeper. Once the gateway sub-device does not send data and exceeds the frequency of data reporting of the gateway sub-device, the node heartbeat communication is disconnected, the temporary node expires immediately, and the access service will monitor the notification of Zookeeper, and the device has been offline.

[0070] Example 3

[0071] This embodiment provides a distributed gateway sub-device online status optimization system, including:

[0072] The acquisition module is used to obtain the expiration time of each gateway sub-device;

[0073] A judgment module is used to judge whether the current gateway sub-device reports data within the corresponding expiration time;

[0074] If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache;

[0075] If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

[0076] Furthermore, the acquisition module is specifically used to:

[0077] Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization;

[0078] The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

[0079] Example 4

[0080] This embodiment provides a computer device, including:

[0081] Memory, for storing computer instructions;

[0082] A processor is used to operate according to the instructions to execute the steps of the distributed gateway sub-device online status optimization method described in Example 1.

[0083] Example 5

[0084] This embodiment provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for optimizing the online status of distributed gateway sub-devices described in Embodiment 1 are implemented.

[0085] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0086] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0087] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0088] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0089] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A distributed gateway sub-device online status optimization method, characterized in that: include: Get the expiration time of each gateway sub-device; Determine whether the current gateway sub-device reports data within the corresponding expiration time; If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache; If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

2. The method for optimizing the online status of distributed gateway sub-devices according to claim 1, characterized in that: The obtaining of the expiration time of each gateway sub-device includes: Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization; The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

3. The method for optimizing the online status of distributed gateway sub-devices according to claim 1, characterized in that: The determining whether the current gateway sub-device reports data within the corresponding expiration time includes: If the current gateway sub-device reports data to any access service within the corresponding expiration time, it is confirmed that the current gateway sub-device reports data within the corresponding expiration time.

4. The distributed gateway sub-device online status optimization method according to claim 1, characterized in that: Changing the online status of the current gateway sub-device to offline includes: changing the online status of the current gateway sub-device in the database and the redis cache to offline.

5. The method for optimizing the online status of distributed gateway sub-devices according to claim 1, characterized in that: If the current gateway sub-device continuously reports data, the access service saves the continuous data information of the current gateway sub-device into the redis cache.

6. The method for optimizing the online status of distributed gateway sub-devices according to claim 1, characterized in that: The data information of the gateway sub-device includes: device number, online status and current time.

7. A distributed gateway sub-device online status optimization system, characterized in that: include: The acquisition module is used to obtain the expiration time of each gateway sub-device; A judgment module is used to judge whether the current gateway sub-device reports data within the corresponding expiration time; If the current gateway sub-device reports data within the corresponding expiration time, the access service saves the data information of the current gateway sub-device to the redis cache; If the current gateway sub-device does not report data within the corresponding expiration time, the access service receives the expiration message of the current gateway sub-device sent by the redis cache and changes the online state of the current gateway sub-device to offline.

8. The distributed gateway sub-device online status optimization system according to claim 7, characterized in that: The acquisition module is specifically used for: Get the reporting frequency period of each gateway sub-device, and save it to the database after initialization; The access service obtains the reporting frequency period of each gateway sub-device from the database and saves it to the redis cache; wherein the reporting frequency period of each gateway sub-device is the expiration time of each gateway sub-device.

9. A computer device, characterized in that: include: Memory, for storing computer instructions; A processor, wherein the processor is used to operate according to the instruction to execute the steps of the distributed gateway sub-device online status optimization method according to any one of claims 1 to 6.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the distributed gateway sub-device online status optimization method according to any one of claims 1 to 6 are implemented.