Disclosure of Invention
In view of the foregoing problems, an object of embodiments of the present invention is to provide a method and an apparatus for processing alarm information by a cloud access controller, which can improve the real-time performance and accuracy of processing the alarm information by the cloud access controller.
In order to achieve the above object, an embodiment of the present invention provides a method for processing alarm information by a cloud access controller, including: receiving alarm information sent by preset access point equipment, and storing the alarm information into message middleware corresponding to the preset access point equipment; the message middleware sequences the alarm information according to the generation time of the alarm information; reading an alarm information list in the message middleware, and comparing first alarm information in the alarm information list with alarm information in a current processing thread; when the first alarm information in the alarm information list is the same as the alarm information in the current processing thread, processing the first alarm information in the alarm information list; and after the current processing thread finishes processing the first alarm information in the alarm information list, deleting the first alarm information in the alarm information list, and pushing processing finish prompt information to other threads.
Further, an alarm information list in the message middleware is constructed according to a list type of a redis database; correspondingly, storing the alarm information in the message middleware corresponding to the preset access point device includes: and inserting the alarm information into the tail end of an alarm information list in the message middleware.
Further, the processing the first alarm information in the alarm information list includes:
inquiring whether a primary key of the preset access point equipment exists in the message middleware; if the preset access point equipment does not exist, setting a main key of the preset access point equipment in the message middleware, and processing first alarm information in the alarm information list; and after the current processing thread finishes processing the first alarm information in the alarm information list, deleting the main key of the preset access point equipment from the message middleware.
Further, after the setting of the primary key of the preset access point device in the message middleware, the method further includes: setting an effective period for the main key of the preset access point equipment; and when the time for processing the first alarm information in the alarm information list by a preset server reaches the validity limit, the message middleware deletes the main key of the preset access point equipment and sends out main key expiration prompt information to other servers.
Further, the method further comprises: and when other servers receive the main key expiration prompting information, reading an alarm information list in the message middleware, and reestablishing a processing thread to process the first alarm information in the alarm information list.
Further, the method further comprises: and when the first alarm information in the alarm information list is different from the alarm information in the current processing thread, the current processing thread monitors processing completion prompt information sent by other threads.
Further, the method further comprises: and when the alarm information in the current processing thread does not exist in the alarm information list, deleting the alarm information in the current processing thread.
In order to achieve the above object, an embodiment of the present invention further provides a cloud access controller, including: the alarm information sequencing unit is used for receiving alarm information sent by preset access point equipment and storing the alarm information into message middleware corresponding to the preset access point equipment; the message middleware sequences the alarm information according to the generation time of the alarm information; the warning information comparison unit is used for reading a warning information list in the message middleware and comparing the first warning information in the warning information list with the warning information in the current processing thread; the alarm information processing unit is used for processing the first alarm information in the alarm information list when the first alarm information in the alarm information list is the same as the alarm information in the current processing thread; and the processing completion pushing unit is used for deleting the first alarm information in the alarm information list after the current processing thread processes the first alarm information in the alarm information list, and pushing processing completion prompt information to other threads.
Therefore, according to the method and the device for processing the alarm information by the cloud access controller provided by the embodiment of the invention, the alarm information sent by the access point equipment is sequenced according to the generation time, so that each alarm information can be processed according to the time sequence, and the condition of AP equipment state error in the cloud AC caused by time sequence disorder is avoided. Furthermore, by setting the effective time limit of the main key, when the server for processing the alarm information is abnormal, other servers can continue to process the alarm information, so that the alarm information can be processed normally, and the state of the AP equipment can be further ensured to be updated in time.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings of the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
The embodiment of the invention provides a method for processing alarm information by a cloud access controller. Referring to fig. 1, the method includes the following steps:
s1: receiving alarm information sent by preset access point equipment, and storing the alarm information into message middleware corresponding to the preset access point equipment; and sequencing the alarm information in the message middleware according to the generation time of the alarm information.
In the present embodiment, processing alarm information in time series in a distributed environment can be realized based on redis. Specifically, in the cloud AC, the reception of the alarm information may be performed by an alarm reception process. When the cloud AC receives the alarm information sent by the preset AP device, the alarm information may be packaged as an alarm event, and the alarm event is written in an alarm information list of the message middleware.
In this embodiment, the alarm information list may be constructed according to a list type of a redis database. The List type is a linked List of strings sorted in insertion order. As with the normal linked list in the data structure, new elements can be added at its head (left) and end (right). From the efficiency of element insertion and deletion point of view, it would be a very efficient operation if elements were inserted or deleted at both ends of the linked list.
Therefore, in the present embodiment, the received alarm information may be inserted into the end of the alarm information list. Thus, the later the generated alert information, the more to the right the position in the alert information list.
S2: and reading an alarm information list in the message middleware, and comparing the first alarm information in the alarm information list with the alarm information in the current processing thread.
In this embodiment, since the servers in the cloud AC are in a distributed architecture, the alarm information in the alarm information list may be processed by a plurality of servers according to a time sequence.
In this embodiment, the alarm information in the alarm information list may be processed through an alarm processing procedure. When processing the alarm information, the server in the cloud AC may read the alarm information in the alarm information list. And then comparing the first alarm information in the alarm information list with the alarm information in the current processing thread. The significance of comparing the first alarm information with the alarm information in the current processing thread is that if the first alarm information and the alarm information are the same, the current processing thread is ready to process the first alarm information. And if the two are different, the first alarm information is processed by other threads.
S3: and when the first alarm information in the alarm information list is the same as the alarm information in the current processing thread, processing the first alarm information in the alarm information list.
In this embodiment, when the first alarm information in the alarm information list is the same as the alarm information in the current processing thread, the current processing thread may process the first alarm information.
Specifically, before processing the first alarm information, the current processing thread may query whether the primary key of the preset access point device exists in the message middleware. If the alarm information exists, the alarm information of the preset access point device is indicated to be processed by other threads currently, and the processing can be started after the other threads are processed. If the preset access point device does not exist, setting a primary key of the preset access point device in the message middleware, wherein the primary key may include an identifier of the preset access point device. The identification may be, for example, a MAC address of the preset access point device. Then the format of the primary key may be "AP device MAC address: task ". After the primary key is set, the current processing thread can process the first alarm information.
In this embodiment, it is considered that when an abnormality occurs in the server, the first warning information may not be processed all the time, and thus the subsequent warning information may not be processed, so that the state of the AP device may not be updated. In view of this, in this embodiment, an effective period may be set for the primary key of the preset access point device, and the effective period may be used as an upper time limit for the duration of the primary key. For example, if the server normally processes an alarm message for 100ms, the validity period may be set to 5 s. Therefore, when the time for processing the first alarm information in the alarm information list by the preset server reaches the validity limit, the server is in an abnormal state and cannot process the alarm information normally. At this time, the redis in the message middleware may delete the primary key of the preset access point device and send a prompt message indicating that the primary key expires to another server.
Therefore, after other servers receive the main key expiration prompting information, the alarm information list in the message middleware can be read, and the processing thread can be reestablished so as to process the first alarm information in the alarm information list. The process of processing the first alarm information by other servers is similar to the above steps, and is not described herein again.
In this embodiment, when the first alarm information in the alarm information list is different from the alarm information in the current processing thread, the current processing thread may monitor the processing completion notification information sent by another thread. When the processing completion prompt information sent by other threads is monitored, the first alarm information in the current alarm information list can be continuously compared with the alarm information of the first alarm information list.
In this embodiment, when the alarm information in the current processing thread does not exist in the alarm information list, it indicates that the alarm information in the current processing thread has been processed, and then the alarm information in the current processing thread does not need to be processed again, so that the alarm information in the current processing thread can be deleted.
S4: and after the current processing thread finishes processing the first alarm information in the alarm information list, deleting the first alarm information in the alarm information list, and pushing processing finish prompt information to other threads.
In this embodiment, after the current processing thread finishes processing the first alarm information in the alarm information list, the first alarm information may be deleted from the alarm information list, so that the alarm information originally located at the second position becomes the current first alarm information. Meanwhile, the current processing thread can also push processing completion prompt information to other threads, so that the other threads can start to process the local alarm information according to the steps. Specifically, the processing completion prompt information may be pushed to other threads through a pub/sub (Publish/Subscribe) function in the redis.
In this embodiment, after the current processing thread finishes processing the first alarm information in the alarm information list, the main key of the preset access point device may be deleted from the message middleware. In this way, other threads can thus establish the primary key of the pre-set access point device in the message middleware.
Referring to fig. 2, an embodiment of the present invention further provides a cloud access controller, including:
the device comprises an alarm information sequencing unit 100, a message middleware and a message processing unit, wherein the alarm information sequencing unit is used for receiving alarm information sent by a preset access point device and storing the alarm information into a message middleware corresponding to the preset access point device; the message middleware sequences the alarm information according to the generation time of the alarm information;
an alarm information comparison unit 200, configured to read an alarm information list in the message middleware, and compare a first alarm information in the alarm information list with an alarm information in a current processing thread;
an alarm information processing unit 300, configured to process the first alarm information in the alarm information list when the first alarm information in the alarm information list is the same as the alarm information in the current processing thread;
and a processing completion pushing unit 400, configured to delete the first alarm information in the alarm information list after the current processing thread completes processing of the first alarm information in the alarm information list, and push a processing completion prompt message to other threads.
In one embodiment of the present invention, the alarm information list in the message middleware is constructed according to the list type of the redis database; accordingly, the alarm information sorting unit 100 includes:
and the information insertion module is used for inserting the alarm information into the tail end of an alarm information list in the message middleware.
In one embodiment of the present invention, the warning information processing unit 300 includes:
a primary key query module, configured to query whether a primary key of the preset access point device exists in the message middleware;
a main key setting module, configured to set a main key of the preset access point device in the message middleware and process a first alarm information in the alarm information list when the main key does not exist;
and the main key deleting module is used for deleting the main key of the preset access point device from the message middleware after the current processing thread processes the first alarm information in the alarm information list.
It should be noted that the specific implementation manners of the above functional modules are consistent with those described in steps S1 to S4, and are not described herein again.
Therefore, according to the method and the device for processing the alarm information by the cloud access controller provided by the embodiment of the invention, the alarm information sent by the access point equipment is sequenced according to the generation time, so that each alarm information can be processed according to the time sequence, and the condition of AP equipment state error in the cloud AC caused by time sequence disorder is avoided. Furthermore, by setting the effective time limit of the main key, when the server for processing the alarm information is abnormal, other servers can continue to process the alarm information, so that the alarm information can be processed normally, and the state of the AP equipment can be further ensured to be updated in time.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments.
Finally, it should be noted that: the foregoing description of various embodiments of the invention is provided to those skilled in the art for the purpose of illustration. It is not intended to be exhaustive or to limit the invention to a single disclosed embodiment. Various alternatives and modifications of the invention, as described above, will be apparent to those skilled in the art. Thus, while some alternative embodiments have been discussed in detail, other embodiments will be apparent or relatively easy to derive by those of ordinary skill in the art. The present invention is intended to embrace all such alternatives, modifications, and variances which have been discussed herein, and other embodiments which fall within the spirit and scope of the above application.