A task thread processing method and device for real-time monitoring data
By decomposing a single task thread into class one and class two task threads, and adjusting the allocation speed of class two task threads based on the system thread resource state, the resource tightness caused by resource waste and high concurrency in the central monitoring system is solved, and more efficient resource utilization and communication stability are achieved.
Patent Information
- Application Number
- CN202211178499.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-26
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-09-26
AI Technical Summary
In the prior art, when processing real-time monitoring data, the central monitoring system adopts a single task thread to lead to resource waste and resource tightness in high concurrency.
Decompose a single task thread into first and second class task threads, simplify the work content and execution time of task threads, improve execution efficiency and reduce resource usage. The second thread management module adjusts the allocation speed of the second type of task thread based on the system thread resource state to prevent excessive resource consumption and communication blockage.
Without changing the total amount of existing resources in the data forwarding subsystem, improve resource utilization, solve resource waste problems, and prevent communication blocking in high concurrency.
Smart Images

Figure CN115454644B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a task thread processing method and device for real-time monitoring data. Background Art
[0002] Medical institutions all have central monitoring systems for real-time ECG monitoring. Conventional central monitoring systems consist of a data forwarding subsystem and a data analysis subsystem. The data forwarding subsystem receives real-time monitoring data packets sent by remote monitoring devices, performs protocol parsing and data extraction to obtain real-time monitoring data, and then forwards the real-time monitoring data to the task call interface provided by the data analysis subsystem for data analysis. The data analysis subsystem provides task call interfaces related to analysis tasks, receives and analyzes the real-time monitoring data forwarded by the data forwarding subsystem based on each task call interface, and sends a task completion receipt back to the data forwarding subsystem after analysis is complete.
[0003] Conventional data forwarding subsystems use a single task thread approach to manage data reception and forwarding. Each received real-time monitoring data packet is assigned a corresponding task thread, which then completes the entire data parsing, forwarding, interface invocation, and receipt waiting process. Because a single task thread handles a wide range of processes, the pre-allocated thread resources are substantial, and thread resource release is slow. This inevitably leads to significant resource waste. High concurrency in remote monitoring devices can easily lead to resource constraints in the data forwarding subsystem. Summary of the Invention
[0004] The present invention addresses the shortcomings of the prior art and provides a task thread processing method, apparatus, electronic device, and computer-readable storage medium for real-time monitoring data. The present invention decomposes an existing single task thread into first and second task threads, simplifying the work content of the single task thread, shortening the execution time of the single task thread, improving the execution efficiency of the single task thread, and reducing the resource usage of the single task thread. This allows for more effective resource utilization and resolves the resource waste problem caused by the existing single task thread mechanism without changing the total amount of existing resources in the data forwarding subsystem. Furthermore, the present invention can adjust the allocation speed of the second task thread based on the current status of system thread resources. When the overall resource usage ratio is tight, the allocation speed of the second task thread is reduced to prevent excessive resource consumption. When the first task thread experiences high concurrency, the allocation speed of the second task thread is reduced to prevent communication congestion in monitoring data reception. When the second task thread experiences high concurrency, the allocation speed of the second task thread is reduced to prevent communication congestion in data analysis.
[0005] To achieve the above-mentioned object, a first aspect of an embodiment of the present invention provides a task thread processing method for real-time monitoring data, the method comprising:
[0006] Start the data receiving module and the first, second and third thread management modules;
[0007] The data receiving module performs real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forwards it to the first thread management module;
[0008] The first thread management module creates a first-class task thread for the first real-time monitoring data packet, which is recorded as the corresponding first task thread; runs the first task thread to perform data parsing on the first real-time monitoring data packet, generates a corresponding first parsed data packet, and forwards it to the second thread management module; and closes the first task thread and releases resources when the first task thread completes forwarding the first parsed data packet;
[0009] The second thread management module performs second-class task thread allocation processing based on the first parsed data packet to generate a corresponding second task thread; and runs the second task thread to perform business call processing; and when the business call processing is completed, the second task thread is closed and resources are released; during the operation of the second task thread, the third thread management module manages the use rights of the business interface application of the second task thread.
[0010] Preferably, the data receiving module is connected to a remote monitoring device via a wired or wireless manner; the data receiving module performs real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forwards it to the first thread management module, specifically comprising:
[0011] The data receiving module receives the first real-time monitoring data packet sent by the monitoring device; and forwards the first real-time monitoring data packet to the first thread management module.
[0012] Preferably, the task thread type is a task thread type for processing monitoring data parsing services; the thread type of the task thread type includes multiple first thread types, each of the first thread types corresponds to a parsing protocol version;
[0013] The second type of task thread is a task thread type for processing monitoring data analysis services; the thread type of the second type of task thread includes multiple second thread types, and each second thread type corresponds to an analysis service identifier.
[0014] Preferably, the first thread management module creates a first task thread for the first real-time monitoring data packet as a corresponding first task thread, specifically including:
[0015] The first thread management module extracts the first parsing protocol version from the first real-time monitoring data packet; and uses the first thread type corresponding to the first parsing protocol version as the current thread type; and creates a task thread of the type having the current thread type as the corresponding first task thread, and assigns a unique thread identifier to the first task thread as the corresponding first thread identifier.
[0016] Preferably, the running of the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forward it to the second thread management module specifically includes:
[0017] The first thread management module runs the first task thread and sends the first real-time monitoring data packet to the first task thread;
[0018] During the operation of the first task thread, the first task thread calls the parsing service interface corresponding to the current first parsing protocol version to parse the first real-time monitoring data packet to obtain the corresponding first device identifier, the first analysis service identifier and the first real-time monitoring data packet, and forwards the corresponding first parsing data packet to the second thread management module. When the forwarding is successful, the first completion receipt carrying the first thread identifier is sent back to the first thread management module.
[0019] Preferably, the thread closing and resource releasing processing of the first task thread when the first task thread completes forwarding the first parsed data packet specifically includes:
[0020] When receiving the first completion receipt sent back by the first task thread, the first thread management module extracts the first thread identifier therefrom; and performs thread closing and resource release processing on a type of running task thread matching the first thread identifier.
[0021] Preferably, the second thread management module performs the second task thread allocation process based on the first parsed data packet to generate the corresponding second task thread, specifically including:
[0022] The second thread management module stores the first parsed data packet into a preset first cache queue; and obtains the thread resource usage status of the current system as the corresponding first resource status; and identifies whether the first resource status can meet the creation conditions of the second type of task thread; if the identification result is not satisfied, then after a preset time interval, the thread resource usage status of the current system is obtained again as the corresponding first resource status, and again identifies whether the first resource status can meet the creation conditions of the second type of task thread until the identification result is satisfied; if the identification result is satisfied, then the oldest first parsed data packet is read from the first cache queue as the current parsed data packet, and the first device identifier, the first analysis service identifier and the first real-time monitoring data are extracted from the current parsed data packet, and the second thread type corresponding to the first analysis service identifier is used as the current thread type, and a second type of task thread with a thread type of the current thread type is created as the corresponding second task thread, and a unique thread identifier is assigned to the second task thread as the corresponding second thread identifier, and the current parsed data packet is sent to the second task thread, and the current parsed data packet is removed from the first cache queue at the end of sending.
[0023] Furthermore, the first resource state includes the total amount of first resources, the total amount of first resource usage, the total amount of first-class task threads, and the total amount of second-class task threads; and identifying whether the first resource state can meet the conditions for creating the second-class task threads specifically includes:
[0024] The second thread management module calculates a corresponding first total resource occupancy ratio according to the first total resource amount and the first remaining total resource amount, where the first total resource occupancy ratio=the first resource usage total amount / the first resource total amount;
[0025] When the first total resource occupancy ratio exceeds a preset total resource occupancy ratio alarm threshold, outputting a recognition result as unsatisfied;
[0026] When the first total resource occupancy ratio does not exceed the total resource occupancy ratio alarm threshold, it is identified whether the total amount of the first category task threads exceeds the preset first category concurrent total amount alarm threshold and whether the total amount of the second category task threads exceeds the preset second category concurrent total amount alarm threshold; if the total amount of the first category task threads does not exceed the first category concurrent total amount alarm threshold and the total amount of the second category task threads does not exceed the second category concurrent total amount alarm threshold, the output recognition result is satisfied; if the total amount of the first category task threads has exceeded the first category concurrent total amount alarm threshold or the total amount of the second category task threads has exceeded the second category concurrent total amount alarm threshold, the output recognition result is unsatisfied.
[0027] Preferably, the running of the second task thread to perform service call processing specifically includes:
[0028] The second thread management module runs the second task thread;
[0029] During the operation of the second task thread, the service interface application carrying the second thread identifier, the first device identifier and the first analysis service identifier is sent to the third thread management module, and the first application status sent back by the third thread management module is received; and the first application status is identified; when the first application status is a waiting state, the service interface application is sent to the third thread management module again after a preset time interval until the first application status sent back by the third thread management module is a successful state; when the first application status is a successful state, the analysis service interface corresponding to the current first analysis service identifier is called to perform data analysis and processing on the first real-time monitoring data, and the second completion status returned by the analysis service interface is received; when the second completion status is a successful state, a second completion receipt carrying the second thread identifier is sent back to the second thread management module.
[0030] Preferably, the thread closing and resource releasing processing of the second task thread upon completion of the service call processing specifically includes:
[0031] When receiving the second completion receipt sent back by the second task thread, the second thread management module extracts the second thread identifier therefrom; and performs thread closing and resource release processing on the running second-type task thread matching the second thread identifier.
[0032] Preferably, during the running of the second task thread, the third thread management module performs usage authority management on the service interface application of the second task thread, specifically including:
[0033] When the third thread management module receives the service interface request sent by the second task thread, it extracts the second thread identifier, the first device identifier, and the first analysis service identifier; and confirms whether there is a first task queue that matches the first device identifier and the first analysis service identifier;
[0034] If it is confirmed that it does not exist, create a first task queue that matches the first device identifier and the first analysis service identifier; and use the second thread identifier as the latest first task queue record to add a record to the first task queue; and when the record addition process is successful, send back the first application status that is specifically a success status to the second task thread corresponding to the second thread identifier; the first task queue includes multiple first task queue records;
[0035] If it is confirmed to exist, the first task queue record in the first task queue that matches the second thread identifier is recorded as the current matching task record; if the current matching task record is not empty, whether the current matching task record is the oldest first task queue record in the first task queue is confirmed, and if it is confirmed to be, the first application status, which is specifically a successful state, is sent back to the second task thread corresponding to the second thread identifier; if it is confirmed to be not, the first application status, which is specifically a waiting state, is sent back to the second task thread corresponding to the second thread identifier; if the current matching task record is empty, the second thread identifier is used as the latest first task queue record to add a record to the first task queue, and when the record addition process is successful, the first application status, which is specifically a waiting state, is sent back to the second task thread corresponding to the second thread identifier.
[0036] Preferably, the method further comprises:
[0037] The third thread management module regularly traverses each existing first task queue; during traversal, the first task queue currently traversed is used as the current task queue; and the oldest first task queue record in the current task queue is used as the current task queue record; and the second task thread corresponding to the second thread identifier of the current task queue record is used as the current task thread; and confirms whether the current task thread has been released; if it is confirmed that the current task thread has been released, the current task queue record is deleted from the current task queue, and when the record is deleted successfully, it is confirmed whether the current task queue is empty. If it is confirmed that the queue is empty, the current task queue is deleted; if it is confirmed that the current task thread has not been released, go to the next first task queue for traversal.
[0038] A second aspect of the embodiments of the present invention provides a device for implementing the method according to the first aspect, the device comprising: a startup module, a data receiving module, a first thread management module, a second thread management module, and a third thread management module;
[0039] The startup module is used to start the data receiving module and the first, second and third thread management modules;
[0040] The data receiving module is used to perform real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forward it to the first thread management module;
[0041] The first thread management module is configured to create a first-class task thread for the first real-time monitoring data packet, recorded as a corresponding first task thread; and run the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forward it to the second thread management module; and perform thread closing and resource release processing on the first task thread when the first task thread completes forwarding the first parsed data packet;
[0042] The second thread management module is used to perform a second task thread allocation process based on the first parsed data packet to generate a corresponding second task thread; and run the second task thread to perform a service call process; and when the service call process is completed, the second task thread is closed and resources are released;
[0043] The third thread management module is used to manage the use rights of the business interface application of the second task thread during the operation of the second task thread.
[0044] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0045] The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0046] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0047] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0048] Embodiments of the present invention provide a task thread processing method, apparatus, electronic device, and computer-readable storage medium for real-time monitoring data. The method improves upon a traditional single task thread management mode by utilizing a data receiving module and first, second, and third thread management modules. The data receiving module is configured to interface with a remote monitoring device and, upon receiving a first real-time monitoring data packet sent by the remote monitoring device, forward the packet to the first thread management module. The first thread management module is configured to allocate a first-class task thread to each first real-time monitoring data packet, and the first-class task thread processes multi-version parsing of the data packet. Upon completing the parsing, the first-class task thread forwards the first parsed data packet to the second thread management module and is subsequently released. The second thread management module is configured to cache data of the first parsed data packet interfaced to the first cache queue and, based on the system's thread resource status, allocate a second-class task thread to each first parsed data packet in the first cache queue. The second-class task thread performs data analysis on the real-time monitoring data in the parsed data packet via a task call interface. The second-class task thread is subsequently released upon receiving a receipt returned by the task call interface. The third thread management module is configured to manage the execution order of multiple second-class task threads corresponding to the same data analysis task of the same remote monitoring device. Through the present invention, the original single task thread is decomposed into first-class and second-class task threads, which simplifies the work content of the single task thread, shortens the execution time of the single task thread, improves the execution efficiency of the single task thread, and reduces the resource occupancy of the single task thread. Therefore, without changing the total amount of existing resources of the data forwarding subsystem, the resource utilization rate is effectively improved and the resource waste problem caused by the original single task thread mechanism is solved; at the same time, through the processing mechanism of the second thread management module of the present invention to allocate second-class task threads based on the current status of system thread resources, it is also possible to prevent excessive resource consumption by reducing the allocation speed of the second-class task threads when the overall resource occupancy ratio is tight, and to prevent communication congestion in monitoring data reception by reducing the allocation speed of the second-class task threads when high concurrency occurs in the first-class task threads, and to prevent communication congestion in data analysis by reducing the allocation speed of the second-class task threads when high concurrency occurs in the second-class task threads. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of a task thread processing method for real-time monitoring data provided by the first embodiment of the present invention;
[0050] Figure 2 A module structure diagram of a task thread processing device for real-time monitoring data provided by the second embodiment of the present invention;
[0051] Figure 3 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0052] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described herein are merely some, rather than all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0053] Based on the task thread processing method for real-time monitoring data provided in the first embodiment of the present invention, the data forwarding subsystem of the traditional central monitoring system is modified. This allows the modified data forwarding subsystem to solve the problem of resource waste and improve resource utilization without changing the total amount of existing resources. On the other hand, it can effectively control excessive resource consumption when the overall resource occupancy ratio is tight. On the other hand, it can effectively prevent communication congestion caused by high concurrency in the first and second type task threads. Figure 1 A diagram of a task thread processing method for real-time monitoring data provided by the first embodiment of the present invention is shown as follows: Figure 1 As shown, this method mainly includes the following steps:
[0054] Step 1: Start the data receiving module and the first, second and third thread management modules.
[0055] Here, the data receiving module and the first, second, and third thread management modules are four processing modules for implementing the method of the embodiment of the present invention on the data forwarding subsystem:
[0056] The data receiving module is used to connect to the remote monitoring device and forward the first real-time monitoring data packet sent by the remote monitoring device to the first thread management module upon receiving the first real-time monitoring data packet;
[0057] The first thread management module is used to assign a first-class task thread to each first real-time monitoring data packet, and run the first-class task thread to process the multi-version protocol parsing work of the data packet, and after the first-class task thread completes the parsing and forwards the first parsed data packet to the second thread management module, close the first-class task thread and release resources;
[0058] The second thread management module also includes a first cache queue; the first cache queue is managed using a first-in-first-out queue management principle; the second thread management module is used to use the first parsed data packet connected to the first cache queue for data caching, and allocate a second-class task thread to each first parsed data packet in the first cache queue based on the system's thread resource status, and run the second-class task thread to perform data analysis on the real-time monitoring data in the parsed data packet through the task call interface, and close the second-class task thread and release resources when the second-class task thread receives a receipt returned by the task call interface;
[0059] The third thread management module is used to manage the execution order of multiple second-type task threads corresponding to the same type of data analysis tasks of the same remote monitoring device.
[0060] Step 2: The data receiving module performs real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forwards it to the first thread management module;
[0061] The data receiving module is connected to the remote monitoring device via a wired or wireless method;
[0062] Specifically, the method includes: a data receiving module receiving a first real-time monitoring data packet sent by a monitoring device; and forwarding the first real-time monitoring data packet to a first thread management module.
[0063] Here, the remote monitoring device is a device, equipment, terminal or server with the ability to collect ECG signals, and may also be a device, equipment, terminal or server with other signal collection capabilities; the data receiving module is a communication data processing unit of the data forwarding subsystem, which is connected to the remote monitoring device via a wired or wireless method, such as a network cable, a coaxial data cable, a serial port data cable, a parallel port data cable, a USB data cable, etc., and a wireless method such as a mobile communication network such as 4G / 5G / LTE, a Bluetooth communication network, a wireless local area network communication network, a near field communication (NFC) network, etc.;
[0064] It should be noted that the remote monitoring device will preset a data transmission frequency, and regularly transmit a specified length of real-time monitoring data according to the data transmission frequency. When transmitting the real-time monitoring data, the monitoring device will also synchronously transmit a device identifier and an analysis service identifier; the device identifier is the unique identity code of the current monitoring device; the analysis service identifier is used to mark the data analysis service corresponding to the real-time monitoring data. For example, when the real-time monitoring data is an electrocardiogram signal, the corresponding data analysis service includes real-time heart rate analysis service (the preset service identifier is identifier 1), real-time cardiac status analysis service (the preset service identifier is identifier 2), etc. Then, the value range of the above-mentioned analysis service identifier includes identifier 1 and identifier 2; each or each type of monitoring device and the data forwarding sub- The data transmission protocol between the systems can adopt a variety of data protocol formats, such as TCP / IP, HTTP / HTTPS, WEB1.0 / 2.0 / 3.0, etc. When the monitoring device implements data transmission, the plain text data transmitted at that time will be composed of the real-time monitoring data, device identification and analysis service identification of that time, and the plain text data will be encapsulated based on the data protocol format agreed upon in advance with the data forwarding subsystem to generate a data packet, namely the first real-time monitoring data packet. The first real-time monitoring data packet should carry the corresponding parsing protocol version, which corresponds to the above-mentioned data protocol format; after obtaining the first real-time monitoring data packet, the monitoring device sends the first real-time monitoring data packet to the data forwarding subsystem via the above-mentioned wireless or wired method;
[0065] The data receiving module of the data forwarding subsystem is responsible for connecting to various remote monitoring devices, and once the first real-time monitoring data packet is received, it is immediately forwarded to the first thread management module; the data receiving module actually also handles data reception and forwarding by assigning thread tasks, but this processing method is provided by default by the underlying communication data processing unit of the operating system, and is not a thread task management method unique to the embodiment of the present invention, so it will not be further elaborated here.
[0066] Step 3: The first thread management module creates a first-class task thread for the first real-time monitoring data packet, which is recorded as the corresponding first task thread; runs the first task thread to perform data parsing on the first real-time monitoring data packet, generates a corresponding first parsed data packet, and forwards it to the second thread management module; and closes the first task thread and releases resources when the first task thread completes forwarding the first parsed data packet.
[0067] Among them, a type of task thread is a task thread type for processing monitoring data analysis business; the thread type of the type of task thread includes multiple first thread types, each first thread type corresponds to a parsing protocol version;
[0068] Here, the embodiment of the present invention classifies the task threads within the system into types, and collectively refers to the task threads used for data parsing, i.e., processing monitoring data parsing services, as a type of task thread; for the type of task thread, the embodiment of the present invention further refines it into multiple subtypes and a first thread type, and each first thread type corresponds to a parsing protocol version; the parsing protocol version includes a protocol name and a version number, for example, if the parsing protocol version is WEB1.0, then WEB is the protocol name and 1.0 is the version name; the internal processing flow of each type of task thread consists of two parts: data parsing and data forwarding, the processing flow of the data parsing part is related to the corresponding first thread type, and the data forwarding is consistent, that is, the first parsed data packet generated by the parsing is forwarded to the second thread management module; the first thread management module is actually a management module for the type of task thread, which is responsible for creating a type of task thread, i.e., the first task thread, according to the first real-time monitoring data packet and starting the operation of the first task thread, and promptly closing it and releasing resources after the first task thread processing is completed;
[0069] Step 3 specifically includes:
[0070] Step 31: The first thread management module creates a first task thread for the first real-time monitoring data packet and records it as the corresponding first task thread;
[0071] Specifically, the first thread management module extracts a first parsing protocol version from a first real-time monitoring data packet; uses a first thread type corresponding to the first parsing protocol version as a current thread type; creates a task thread of a class with the thread type of the current thread type as a corresponding first task thread, and assigns a unique thread identifier to the first task thread as the corresponding first thread identifier;
[0072] Here, as can be seen from the foregoing, each first real-time monitoring data packet carries a parsing protocol version, namely, a first parsing protocol version; after the first thread management module obtains the first parsing protocol version, it can determine the specific type of the task thread of the type being created, namely, the current thread type, based on the correspondence between the parsing protocol version and the first thread type; after obtaining the current thread type, the first thread management module can create a task thread of the type corresponding to the first task thread, namely, the first task thread; the first thread identifier is the unique thread identifier information of the first task thread created this time;
[0073] Step 32: Run the first task thread to perform data analysis on the first real-time monitoring data packet to generate a corresponding first analysis data packet and forward it to the second thread management module;
[0074] Specifically, the first thread management module runs the first task thread and sends the first real-time monitoring data packet to the first task thread; during the running process, the first task thread calls the parsing service interface corresponding to the current first parsing protocol version to parse the first real-time monitoring data packet to obtain the corresponding first device identifier, the first analysis service identifier and the first real-time monitoring data packet to form a corresponding first parsing data packet and forward it to the second thread management module, and when the forwarding is successful, sends back to the first thread management module a first completion receipt carrying the first thread identifier;
[0075] Here, from the basic knowledge of threads, we know that each thread object has a corresponding data stack for storing the thread's input data, and each thread also has a set of corresponding control instructions (such as start / run, stop / resume, close / end, etc.) for controlling the thread's processing status. Each thread can send a thread return value (similar to a function return value) to the upper control module; the first thread management module is the upper control module of the first task thread; the processing process of the first thread management module running the first task thread and sending the first real-time monitoring data packet to the first task thread is actually writing the first real-time monitoring data packet to the data stack of the first task thread (also known as a parameter passing operation) and starting the thread to enter the running state; the first task thread is a type of task thread in an embodiment of the present invention, and the present invention The embodiment stipulates that after any type of task thread enters the running state, it calls the parsing service interface corresponding to the current first parsing protocol version to parse the first real-time monitoring data packet. The parsing process is actually to parse the first real-time monitoring data packet through the parsing service interface based on the parsing processing flow corresponding to the first parsing protocol version to obtain the plaintext data mentioned above, and then extract the real-time monitoring data, device identification and analysis service identification from the plaintext data as the corresponding first real-time monitoring data, first device identification and first analysis service identification to form the first real-time monitoring data packet. After obtaining the first real-time monitoring data packet, the embodiment of the present invention stipulates that the task thread of this type should forward its second thread management module and send back the first completion receipt carrying the first thread identification to the first thread management module through the thread return value after the forwarding is completed;
[0076] Step 33: When the first task thread completes forwarding the first parsed data packet, the first task thread is closed and resources are released;
[0077] Specifically, the first thread management module extracts a first thread identifier when receiving a first completion receipt sent back by the first task thread; and performs thread closing and resource release processing on a type of running task thread matching the first thread identifier.
[0078] Here, when the first thread management module receives the first completion receipt sent back by any first task thread, it can obtain the first thread identifier that identifies the thread identity; and thus perform thread closing and resource release processing on a class of task threads corresponding to it according to the first thread identifier; here, the processing method of thread resource release on different programming languages or operating systems may be slightly different. Some programming languages or operating systems perform resource release operations synchronously when closing the thread, while others require a separate resource release operation after closing. Therefore, the specific implementation details of the above-mentioned thread closing and resource release processing may also be different based on the specific implementation platform. It should be emphasized that the thread closing and resource release processing mentioned here in the embodiment of the present invention is to achieve the purpose of timely releasing the resources occupied by the thread. Under the traditional single-task thread processing mechanism, the thread processing process is relatively long (including data parsing, data forwarding, data analysis, etc.). After the data parsing and forwarding are completed, the resources reserved for data parsing and forwarding will not be released in time because the subsequent data analysis has not been completed, resulting in a waste of resources; the embodiment of the present invention decomposes the single task thread into a first-class task thread and a second-class task thread. After the first task thread, i.e., the first-class task thread, completes the processing, the resources occupied by it can be released in time, thereby solving the problem of resource waste caused by the single task thread mechanism.
[0079] In step 4, the second thread management module performs a second-class task thread allocation process based on the first parsed data packet to generate a corresponding second task thread; runs the second task thread to perform service call processing; and closes the second task thread and releases resources when the service call processing is completed. During the operation of the second task thread, the third thread management module manages the use rights of the service interface application of the second task thread;
[0080] Among them, the second type of task thread is a task thread type for processing monitoring data analysis business; the thread type of the second type of task thread includes multiple second thread types, each second thread type corresponds to an analysis business identifier;
[0081] Here, the embodiment of this method divides the task threads in the system into types, and the task threads used for data analysis, i.e., processing monitoring data analysis services, are collectively referred to as second-type task threads; for the second-type task threads, the embodiment of this method further refines multiple subtypes and second thread types, each second thread type corresponds to an analysis service identifier; the data analysis processing flow of each second-type task thread is related to the corresponding second thread type;
[0082] The second thread management module is actually a management module for the second type of task thread. It is responsible for creating a second type of task thread, i.e., a second task thread, based on the first parsed data packet and starting the second task thread. It is also responsible for promptly shutting down the second task thread and releasing resources after the second task thread completes processing. It should be noted that, in order to achieve the purpose of controlling the allocation speed of the second type of task thread, the second thread management module of the embodiment of the present invention specifically uses the first parsed data packet connected to the first cache queue for data caching, and allocates a second type of task thread to each first parsed data packet in the first cache queue based on the system's thread resource status.
[0083] It should be noted that, according to the characteristics of the monitoring system, the remote monitoring device will continuously send multiple real-time monitoring data for the same data analysis service. For example, in the case of long-term heart rate monitoring, the same monitoring device will continuously send real-time monitoring data for continuous heart rate analysis. At this time, the order of the data analyzed each time cannot be messed up. The present embodiment will allocate a second task thread to each uploaded real-time monitoring data. Since the order of data analysis cannot be wrong, the processing order of the second task thread corresponding to the same data analysis service of the same monitoring device should also be managed in sequence. The third thread management module of the embodiment of the present invention is a control module for managing the execution order of multiple second-class task threads corresponding to the same type of data analysis task of the same remote monitoring device;
[0084] Step 4 specifically includes:
[0085] Step 41: The second thread management module performs a second-type task thread allocation process based on the first parsed data packet to generate a corresponding second task thread;
[0086] Specifically, it includes: the second thread management module stores the first parsed data packet into a preset first cache queue; and obtains the thread resource usage status of the current system as the corresponding first resource status; and identifies whether the first resource status can meet the creation conditions of the second type of task thread; if the identification result is not satisfied, then after a preset time interval, the thread resource usage status of the current system is obtained again as the corresponding first resource status, and again identifies whether the first resource status can meet the creation conditions of the second type of task thread until the identification result is satisfied; if the identification result is satisfied, the oldest first parsed data packet is read from the first cache queue as the current parsed data packet, and the first device identifier, the first analysis business identifier and the first real-time monitoring data are extracted from the current parsed data packet, and the second thread type corresponding to the first analysis business identifier is used as the current thread type, and a second type task thread with a thread type of the current thread type is created as the corresponding second task thread, and a unique thread identifier is assigned to the second task thread as the corresponding second thread identifier, and the current parsed data packet is sent to the second task thread, and after the sending is completed, the current parsed data packet is removed from the first cache queue;
[0087] The first resource status includes the total amount of first resources, the total amount of first resource usage, the total amount of first-class task threads, and the total amount of second-class task threads;
[0088] Here, the first total amount of resources is the total amount of system resources available for thread task allocation on the data forwarding subsystem, generally referring to the storage space capacity; the first total amount of resource usage is the total amount of system resources that have been occupied in the above-mentioned total amount of system resources available for thread task allocation; the first total amount of resources and the first total amount of resource usage can be obtained through the storage management unit of the operating system; the total amount of first and second category task threads is the number of currently running first and second category task threads, and these two numbers can be obtained by pre-setting two counters. The operation principle of these two counters is to increase the counter by 1 each time a new first or second category task thread is allocated, and to decrease the counter by 1 each time a first or second category task thread is closed or released;
[0089] Identify whether the first resource state can meet the conditions for creating a second type of task thread, specifically including: the second thread management module calculates the corresponding first total resource occupancy ratio based on the total amount of the first resource and the total amount of the remaining first resource, the first total resource occupancy ratio = the total amount of first resource used / the total amount of the first resource; when the first total resource occupancy ratio has exceeded the preset total resource occupancy ratio alarm threshold, output the identification result as unsatisfied; when the first total resource occupancy ratio has not exceeded the total resource occupancy ratio alarm threshold, identify whether the total amount of the first type of task threads exceeds the preset first type concurrent total alarm threshold and whether the total amount of the second type of task threads exceeds the preset second type concurrent total alarm threshold; if the total amount of the first type of task threads does not exceed the first type concurrent total alarm threshold and the total amount of the second type of task threads does not exceed the second type concurrent total alarm threshold, output the identification result as satisfied; if the total amount of the first type of task threads has exceeded the first type concurrent total alarm threshold or the total amount of the second type of task threads has exceeded the second type concurrent total alarm threshold, output the identification result as unsatisfied;
[0090] Here, the total resource usage ratio alarm threshold, the first-class concurrent total alarm threshold, and the second-class concurrent total alarm threshold are three pre-set empirical values;
[0091] The second thread management module of the embodiment of the present invention caches each first parsed data packet received in a preset first cache queue. The second thread management module then adjusts the allocation speed of the second task thread through the aforementioned process of identifying whether the first resource status satisfies the conditions for creating a second task thread. The adjustment method is as follows: if the aforementioned identification process returns a negative result, the second thread management module will not immediately create a new second task thread, but instead periodically polls to determine whether the conditions for creating a second task thread are satisfied. A new second task thread will only be created if the aforementioned identification process returns a positive result. When the aforementioned conditions are satisfied, the second thread management module of the embodiment of the present invention selects the oldest first parsed data packet from the first cache queue as the current parsed data packet and creates a corresponding second task thread, i.e., a second task thread, for it. When creating the second task thread, a corresponding subtype task thread is selected based on the corresponding first analysis service identifier, and parameters of the current parsed data packet are passed to the second task thread. After completing the creation and parameter transfer of a second task thread, the embodiment of the present invention removes the current parsed data packet from the first cache queue, thereby promptly releasing the resources occupied by the invalid data in the first cache queue, i.e., the current parsed data packet.
[0092] Step 42: The second thread management module runs the second task thread to perform service call processing; during the running of the second task thread, the third thread management module manages the use rights of the service interface application of the second task thread;
[0093] The second task thread is run to process the service call, specifically including:
[0094] The second thread management module runs the second task thread; during the running process, the second task thread sends a business interface application carrying the second thread identifier, the first device identifier and the first analysis business identifier to the third thread management module, and receives the first application status sent back by the third thread management module; and identifies the first application status; when the first application status is a waiting state, it sends a business interface application to the third thread management module again after a preset time interval until the first application status sent back by the third thread management module is a successful state; when the first application status is a successful state, it calls the analysis business interface corresponding to the current first analysis business identifier to perform data analysis and processing on the first real-time monitoring data, and receives the second completion status returned by the analysis business interface; when the second completion status is a successful state, it sends a second completion receipt carrying the second thread identifier to the second thread management module;
[0095] Here, each second-class task thread, i.e., the second task thread, will not directly call the analysis business interface corresponding to the first analysis business identifier for analysis during operation, which may cause the analysis order of the same data analysis business of the same monitoring device to be disordered; in order to avoid disorder in the analysis order, the second task thread will first send a business interface application to the third thread management module to queue for business processing authority during operation; and will only start calling the analysis business interface corresponding to the first analysis business identifier for analysis when the first application status sent back by the third thread management module is a success status; and at the end of the analysis, that is, when the second completion status returned by the analysis business interface is a success status, a second completion receipt carrying the second thread identifier is sent back to the second thread management module to activate the second thread management module to close the thread and release resources of the second-class task thread;
[0096] Correspondingly, during the operation of the second task thread, the third thread management module manages the use rights of the business interface application of the second task thread, specifically including:
[0097] Step A1: Upon receiving a service interface request from the second task thread, the third thread management module extracts the second thread identifier, the first device identifier, and the first analysis service identifier; and confirms whether there is a first task queue that matches the first device identifier and the first analysis service identifier.
[0098] Here, each time the third thread management module receives a service interface application sent by the second task thread, it first confirms the creation of the first task queue corresponding to the first device identifier + the first analysis service identifier in the application; here, the first task queue is the queue used by the third thread management module to process the second task thread, and the first task queue is managed using a first-in-first-out queue management principle. The embodiment of the present invention stipulates that each first task queue corresponds to a data analysis service of a monitoring device. The embodiment of the present invention also stipulates that only the second task thread corresponding to the oldest queue record in the queue can be executed. The embodiment of the present invention also stipulates that only the second task thread that has not yet ended or started data analysis can exist in the queue;
[0099] In step A2, if it is confirmed that the device does not exist, a first task queue is created that matches the first device identifier and the first analysis service identifier; and the second thread identifier is used as the latest first task queue record to add a record to the first task queue; and when the record addition process is successful, a first application status indicating a successful status is sent back to the second task thread corresponding to the second thread identifier;
[0100] Wherein, the first task queue includes a plurality of first task queue records;
[0101] Here, if it is confirmed that it does not exist, it means that there are no multiple second task threads queued for the current data analysis business of the current monitoring device related to the current second task thread, so the third thread management module creates a first task queue accordingly and adds the second thread identifier of the current second task thread as the latest queue record. After adding, the queue record corresponding to the current second task thread is the only queue record, which is both the latest and the oldest queue record. Therefore, at this time, the third thread management module can send back the first application status of the success status to the current second task thread to inform the current second task thread that it can be executed;
[0102] Step A3: If it is confirmed that it exists, the first task queue record that matches the second thread identifier in the first task queue is recorded as the current matching task record; if the current matching task record is not empty, whether the current matching task record is the oldest first task queue record in the first task queue is confirmed, and if it is confirmed that it is, the first application status of a successful state is sent back to the second task thread corresponding to the second thread identifier; if it is confirmed that it is not, the first application status of a waiting state is sent back to the second task thread corresponding to the second thread identifier; if the current matching task record is empty, the second thread identifier is used as the latest first task queue record to add a record to the first task queue, and when the record adding process is successful, the first application status of a waiting state is sent back to the second task thread corresponding to the second thread identifier;
[0103] Here, if it is confirmed to exist, it means that there are already multiple second task threads queued for the current data analysis business of the current monitoring device related to the current second task thread; at this time, the third thread management module cannot directly add the second thread identifier of the current second task thread as the latest queue record to the existing first task queue, because it is possible that the application is a duplicate application sent by an already queued second task thread, so the third thread management module must query the queue records in the first task queue based on the second thread identifier of the current second task thread, that is, record the first task queue record in the first task queue that matches the second thread identifier as the current matching task record;
[0104] If the current matching task record is not empty, it means that the current second task thread is a second task thread that has been queued. At this time, it is necessary to understand the queue status of the current second task thread by confirming whether the current matching task record is the oldest first task queue record in the first task queue; if it is confirmed that the current matching task record is already the oldest first task queue record, it means that the current second task thread has been queued to use the corresponding task call interface. At this time, the third thread management module sends back the first application status, which is specifically in a successful state, to the current second task thread to inform the current second task thread that it can be executed; if it is confirmed that the current matching task record is not yet the oldest first task queue record, it means that the current second task thread still needs to continue waiting. At this time, the third thread management module will send back the first application status, which is specifically in a waiting state, to the current second task thread to inform the current second task thread to continue waiting;
[0105] If the current matching task record is empty, it means that the current second task thread is not a second task thread that has already been queued, so the third thread management module will directly add the second thread identifier of the current second task thread as the latest queue record to the existing first task queue for queuing; and because the embodiment of the present invention stipulates that only second task threads that have not yet completed or started data analysis can exist in the queue, that is, as long as the first task queue exists, it means that for the newly added record, there are one or more records that are being processed or waiting to be processed in front of it, that is, the newly added record is not the oldest queue record, so at this time, after completing the record addition, the third thread management module should also send back the first application status of the waiting state to the current second task thread to inform the current second task thread to continue waiting;
[0106] In summary, the third management module uses the first task queue corresponding to each data analysis business of each monitoring device as a medium to complete the queue management of the second task thread, that is, the use permission management of the second task thread; and in the implementation process of the above-mentioned use permission management, there is an important implementation premise, that is, the embodiment of the present invention stipulates that only the second task thread that has not yet completed or started data analysis can exist in the queue; and to implement this provision of the embodiment of the present invention, it is necessary for the third management module to be able to update the queue record in the first task queue according to the execution status of the second task thread being executed; to this end, the embodiment of the present invention also includes:
[0107] The third thread management module regularly traverses each existing first task queue; during the traversal, the first task queue currently being traversed is used as the current task queue; the oldest first task queue record in the current task queue is used as the current task queue record; the second task thread corresponding to the second thread identifier of the current task queue record is used as the current task thread; and confirms whether the current task thread has been released; if it is confirmed that the current task thread has been released, the current task queue record is deleted from the current task queue, and when the record is successfully deleted, it is confirmed whether the current task queue is empty. If it is confirmed that the queue is empty, the current task queue is deleted; if it is confirmed that the current task thread has not been released, the next first task queue is traversed;
[0108] In principle, any operating system can query the status of the threads currently executing within the system. Therefore, the third thread management module can obtain the status of the current task thread through the underlying operating system. Specifically, the third thread management module sends the thread identifier of the current task thread to the underlying operating system. If the thread has not been released, the module returns the corresponding thread status. If the thread has been released, the module returns an error code such as a query error. Upon receiving the error code, it indicates that the current task thread has been released by the second thread management module, meaning that the current task thread has completed execution. At this point, the third thread management module can delete the corresponding queue record in the first task queue, i.e., the oldest first task queue record. In this way, the next first task queue record can be used as the new oldest first task queue record. The second task thread corresponding to this task queue record can receive the first application status, specifically a successful status, the next time it initiates a business interface application. In addition, if the third thread management module finds that the first task queue is empty after completing the record deletion, to ensure the correctness of the embodiment of the present invention that only second task threads that have not yet completed or started data analysis can exist in the queue, the third thread management module should also delete the empty first task queue. This process has a significant advantage in that it avoids unnecessary resource waste due to a large number of remaining empty queues.
[0109] Step 43: The second thread management module closes the second task thread and releases resources when the service call processing is completed.
[0110] Specifically, the second thread management module extracts the second thread identifier when receiving the second completion receipt sent back by the second task thread; and performs thread closing and resource release processing on the running second-type task thread matching the second thread identifier.
[0111] Here, the second thread management module can obtain the second thread identifier for identifying the thread identity when receiving the second completion receipt sent back by any second task thread; and thus perform thread closing and resource release processing on the corresponding second-type task thread according to the second thread identifier.
[0112] Figure 2 This is a module structure diagram of a task thread processing device for real-time monitoring data provided in the second embodiment of the present invention. The device can be a terminal device or server that implements the method of the embodiment of the present invention, or a device that implements the method of the embodiment of the present invention connected to the above terminal device or server. For example, the device can be a device or chip system of the above terminal device or server. Figure 2 As shown, the task thread processing device for real-time monitoring data includes: a starting module 201, a data receiving module 202, a first thread management module 203, a second thread management module 204 and a third thread management module 205.
[0113] The startup module 201 is used to start the data receiving module 201 , the first thread management module 202 , the second thread management module 203 and the third thread management module 204 .
[0114] The data receiving module 202 is used to receive and process real-time monitoring data to generate a corresponding first real-time monitoring data packet and forward it to the first thread management module 203 .
[0115] The first thread management module 203 is used to create a first-class task thread for the first real-time monitoring data packet, recorded as the corresponding first task thread; and run the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forward it to the second thread management module 204; and when the first task thread completes forwarding the first parsed data packet, it closes the first task thread and releases resources.
[0116] The second thread management module 204 is used to perform second-class task thread allocation processing based on the first parsed data packet to generate a corresponding second task thread; and run the second task thread to perform business call processing; and when the business call processing is completed, the second task thread is closed and resources are released.
[0117] The third thread management module 205 is used to manage the use rights of the business interface application of the second task thread during the operation of the second task thread.
[0118] An embodiment of the present invention provides a task thread processing device for real-time monitoring data, which can execute the method steps in the above method embodiment. Its implementation principles and technical effects are similar and will not be repeated here.
[0119] It should be noted that it should be understood that the division of the various modules of the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. Moreover, these modules can all be implemented in the form of software called by a processing element; or they can all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the startup module can be a separately established processing element, or it can be integrated into a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called by a processing element of the above device to execute the functions of the above-mentioned determined module. The implementation of other modules is similar. In addition, these modules can all or partly be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the hardware integrated logic circuit in the processor element or by instructions in the form of software.
[0120] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0121] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in accordance with the embodiment of the present invention is generated in whole or in part. The above-mentioned computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) mode. The above-mentioned computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state disks (SSDs)).
[0122] Figure 3 This is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present invention. The electronic device may be the aforementioned terminal device or server, or may be a terminal device or server connected to the aforementioned terminal device or server to implement the method of the embodiment of the present invention. Figure 3 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303's transceiver actions. Various instructions may be stored in the memory 302 for performing various processing functions and implementing the methods and processing procedures provided in the above embodiments of the present invention. Preferably, the electronic device involved in the embodiment of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripheral devices.
[0123] exist Figure 3The system bus mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0124] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0125] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, which stores instructions. When the storage medium is run on a computer, it enables the computer to execute the methods and processing procedures provided in the above embodiments.
[0126] An embodiment of the present invention further provides a chip for executing instructions, which is used to execute the methods and processing procedures provided in the above embodiments.
[0127] Embodiments of the present invention provide a task thread processing method, apparatus, electronic device, and computer-readable storage medium for real-time monitoring data. The method improves upon the traditional single task thread management model by utilizing a data receiving module and first, second, and third thread management modules. The data receiving module is configured to interface with a remote monitoring device and, upon receiving a first real-time monitoring data packet sent by the remote monitoring device, forward the packet to the first thread management module. The first thread management module is configured to allocate a first-class task thread to each first real-time monitoring data packet, and the first-class task thread processes multi-version parsing of the data packet. Upon completing the parsing, the first-class task thread forwards the first parsed data packet to the second thread management module and is subsequently released. The second thread management module is configured to cache data of the first parsed data packet interfaced to the first cache queue and, based on the system's thread resource status, allocate a second-class task thread to each first parsed data packet in the first cache queue. The second-class task thread performs data analysis on the real-time monitoring data in the parsed data packet via a task call interface. The second-class task thread is subsequently released upon receiving a receipt returned by the task call interface. The third thread management module is configured to manage the execution order of multiple second-class task threads corresponding to the same data analysis task of the same remote monitoring device. Through the present invention, the original single task thread is decomposed into first-class and second-class task threads, which simplifies the work content of the single task thread, shortens the execution time of the single task thread, improves the execution efficiency of the single task thread, and reduces the resource occupancy of the single task thread. Therefore, without changing the total amount of existing resources of the data forwarding subsystem, the resource utilization rate is effectively improved and the resource waste problem caused by the original single task thread mechanism is solved; at the same time, through the processing mechanism of the second thread management module of the present invention to allocate second-class task threads based on the current status of system thread resources, it is also possible to prevent excessive resource consumption by reducing the allocation speed of the second-class task threads when the overall resource occupancy ratio is tight, and to prevent communication congestion in monitoring data reception by reducing the allocation speed of the second-class task threads when high concurrency occurs in the first-class task threads, and to prevent communication congestion in data analysis by reducing the allocation speed of the second-class task threads when high concurrency occurs in the second-class task threads.
[0128] Professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0129] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0130] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A task thread processing method for real-time monitoring data, characterized in that: The method comprises: Start the data receiving module and the first, second and third thread management modules; The data receiving module performs real-time monitoring data receiving processing to generate a corresponding first real-time monitoring data packet and forwards it to the first thread management module; The first thread management module creates a first-class task thread for the first real-time monitoring data packet and records it as the corresponding first task thread; and runs the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forward it to the second thread management module; and when the first task thread completes forwarding the first parsed data packet, the first task thread is closed and resources are released; The second thread management module performs second-class task thread allocation processing based on the first parsed data packet to generate a corresponding second task thread; and runs the second task thread to perform business call processing; and when the business call processing is completed, the second task thread is closed and resources are released; during the operation of the second task thread, the third thread management module manages the use permissions of the business interface application of the second task thread.
2. The task thread processing method for real-time monitoring data according to claim 1, characterized in that: The data receiving module is connected to a remote monitoring device via a wired or wireless method; the data receiving module performs real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forwards it to the first thread management module, specifically including: The data receiving module receives the first real-time monitoring data packet sent by the monitoring device; and forwards the first real-time monitoring data packet to the first thread management module.
3. The task thread processing method for real-time monitoring data according to claim 1, characterized in that: The first type of task thread is a task thread type for processing monitoring data parsing services; the thread type of the first type of task thread includes a plurality of first thread types, each of which corresponds to a parsing protocol version; The second type of task thread is a task thread type for processing monitoring data analysis services; the thread type of the second type of task thread includes multiple second thread types, and each of the second thread types corresponds to an analysis service identifier.
4. The task thread processing method for real-time monitoring data according to claim 3 is characterized in that: The first thread management module creates a first-class task thread for the first real-time monitoring data packet as a corresponding first task thread, specifically including: The first thread management module extracts a first parsing protocol version from the first real-time monitoring data packet; and uses the first thread type corresponding to the first parsing protocol version as the current thread type; and creates a class of task threads whose thread type is the current thread type as the corresponding first task thread, and assigns a unique thread identifier to the first task thread as the corresponding first thread identifier.
5. The task thread processing method for real-time monitoring data according to claim 4 is characterized in that: The running of the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forwarding it to the second thread management module specifically includes: The first thread management module runs the first task thread and sends the first real-time monitoring data packet to the first task thread; During the running process, the first task thread calls the parsing service interface corresponding to the current first parsing protocol version to parse the first real-time monitoring data packet to obtain the corresponding first device identifier, the first analysis service identifier and the first real-time monitoring data, and forwards the corresponding first parsing data packet to the second thread management module, and sends the first completion receipt carrying the first thread identifier back to the first thread management module when the forwarding is successful.
6. The task thread processing method for real-time monitoring data according to claim 5, characterized in that: The performing thread closing and resource releasing processing on the first task thread when the first task thread completes forwarding the first parsed data packet specifically includes: When receiving the first completion receipt sent back by the first task thread, the first thread management module extracts the first thread identifier therefrom; and performs thread closing and resource release processing on a class of running task threads matching the first thread identifier.
7. The task thread processing method for real-time monitoring data according to claim 3, characterized in that: The second thread management module performs the second task thread allocation process based on the first parsed data packet to generate the corresponding second task thread, specifically including: The second thread management module stores the first parsed data packet into a preset first cache queue; obtains the thread resource usage status of the current system as the corresponding first resource status; and identifies whether the first resource status can meet the creation conditions of the second type of task thread; if the identification result is not satisfied, the thread resource usage status of the current system is obtained again after a preset time interval as the corresponding first resource status, and whether the first resource status can meet the creation conditions of the second type of task thread is identified again until the identification result is satisfied; if the identification result is satisfied, the oldest first parsed data packet is read from the first cache queue as the current parsed data packet, and the first device identifier, the first analysis service identifier and the first real-time monitoring data are extracted from the current parsed data packet, and the second thread type corresponding to the first analysis service identifier is used as the current thread type, and a second type of task thread with a thread type of the current thread type is created as the corresponding second task thread, and a unique thread identifier is assigned to the second task thread as the corresponding second thread identifier, and the current parsed data packet is sent to the second task thread, and the current parsed data packet is removed from the first cache queue at the end of the sending.
8. The task thread processing method for real-time monitoring data according to claim 7, characterized in that: The first resource state includes the total amount of first resources, the total amount of first resource usage, the total amount of first-class task threads, and the total amount of second-class task threads; the identifying whether the first resource state can meet the creation condition of the second-class task threads specifically includes: The second thread management module calculates a first total resource occupancy ratio according to the first total resource amount and the first remaining total resource amount, where the first total resource occupancy ratio=the first resource usage total amount / the first resource total amount; When the first total resource occupancy ratio exceeds a preset total resource occupancy ratio alarm threshold, outputting a recognition result as unsatisfied; When the first total resource occupancy ratio does not exceed the total resource occupancy ratio alarm threshold, it is identified whether the total amount of the first category of task threads exceeds the preset first category of concurrent total amount alarm threshold and whether the total amount of the second category of task threads exceeds the preset second category of concurrent total amount alarm threshold; if the total amount of the first category of task threads does not exceed the first category of concurrent total amount alarm threshold and the total amount of the second category of task threads does not exceed the second category of concurrent total amount alarm threshold, the output recognition result is satisfied; if the total amount of the first category of task threads has exceeded the first category of concurrent total amount alarm threshold or the total amount of the second category of task threads has exceeded the second category of concurrent total amount alarm threshold, the output recognition result is not satisfied.
9. The task thread processing method for real-time monitoring data according to claim 7, characterized in that: The running of the second task thread to perform service call processing specifically includes: The second thread management module runs the second task thread; During the operation of the second task thread, the service interface application carrying the second thread identifier, the first device identifier and the first analysis service identifier is sent to the third thread management module, and the first application status sent back by the third thread management module is received; and the first application status is identified; when the first application status is a waiting state, the service interface application is sent to the third thread management module again after a preset time interval until the first application status sent back by the third thread management module is a successful state; when the first application status is a successful state, the analysis service interface corresponding to the current first analysis service identifier is called to perform data analysis and processing on the first real-time monitoring data, and a second completion status returned by the analysis service interface is received; when the second completion status is a successful state, a second completion receipt carrying the second thread identifier is sent back to the second thread management module.
10. The task thread processing method for real-time monitoring data according to claim 9, characterized in that: The thread closing and resource releasing processing of the second task thread when the business call processing is completed specifically includes: When receiving the second completion receipt sent back by the second task thread, the second thread management module extracts the second thread identifier therefrom; and performs thread closing and resource release processing on the running second-type task thread matching the second thread identifier.
11. The task thread processing method for real-time monitoring data according to claim 9, characterized in that: The third thread management module performs usage authority management on the service interface application of the second task thread during the operation of the second task thread, specifically including: When receiving the service interface application sent by the second task thread, the third thread management module extracts the second thread identifier, the first device identifier and the first analysis service identifier therefrom; and confirms whether there is a first task queue matching the first device identifier and the first analysis service identifier; If it is confirmed that it does not exist, create a first task queue that matches the first device identifier and the first analysis business identifier; and use the second thread identifier as the latest first task queue record to perform record addition processing on the first task queue; and when the record addition processing is successful, send back the first application status that is specifically a success status to the second task thread corresponding to the second thread identifier; the first task queue includes multiple first task queue records; If it is confirmed to exist, the first task queue record in the first task queue that matches the second thread identifier is recorded as the current matching task record; if the current matching task record is not empty, whether the current matching task record is the oldest first task queue record in the first task queue is confirmed, and if it is confirmed to be yes, the first application status, which is a success status, is sent back to the second task thread corresponding to the second thread identifier; if it is confirmed to be no, the first application status, which is a waiting status, is sent back to the second task thread corresponding to the second thread identifier; if the current matching task record is empty, the second thread identifier is used as the latest first task queue record to perform record addition processing on the first task queue, and when the record addition processing is successful, the first application status, which is a waiting status, is sent back to the second task thread corresponding to the second thread identifier.
12. The task thread processing method for real-time monitoring data according to claim 11, characterized in that: The method further comprises: The third thread management module periodically traverses each existing first task queue; when traversing, the first task queue currently traversed is used as the current task queue; and the oldest first task queue record in the current task queue is used as the current task queue record; and the second task thread corresponding to the second thread identifier of the current task queue record is used as the current task thread; and confirms whether the current task thread has been released; if it is confirmed that the current task thread has been released, the current task queue record is deleted from the current task queue, and when the record is deleted successfully, it is confirmed whether the current task queue is empty, and if it is confirmed that the queue is empty, the current task queue is deleted; if it is confirmed that the current task thread has not been released, switch to the next first task queue for traversal.
13. A device for implementing the task thread processing method for real-time monitoring data according to any one of claims 1 to 12, characterized in that: The device comprises: a starting module, a data receiving module, a first thread management module, a second thread management module and a third thread management module; The startup module is used to start the data receiving module and the first, second and third thread management modules; The data receiving module is used to perform real-time monitoring data reception processing to generate a corresponding first real-time monitoring data packet and forward it to the first thread management module; The first thread management module is used to create a first-class task thread for the first real-time monitoring data packet, recorded as the corresponding first task thread; and run the first task thread to perform data parsing on the first real-time monitoring data packet to generate a corresponding first parsed data packet and forward it to the second thread management module; and when the first task thread completes forwarding the first parsed data packet, the first task thread is thread closed and resource released; The second thread management module is used to perform a second task thread allocation process based on the first parsed data packet to generate a corresponding second task thread; and run the second task thread to perform a service call process; and perform thread closing and resource release processing on the second task thread when the service call process is completed; The third thread management module is used to manage the use rights of the business interface application of the second task thread during the operation of the second task thread.
14. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method steps described in any one of claims 1 to 12; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which, when executed by a computer, enable the computer to execute the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Multitask process monitoring method and system in distributed system environment
CN102360310A
Thread identification processing method and apparatus, computer device and storage medium
CN108509260A