A data acquisition method, device, computer storage medium and system
By integrating the APScheduler and nanomsg modules into the Twisted framework, a single service can complete the data collection task, solving the problems of high resource consumption and low performance caused by the Celery scheduling framework, improving system performance and supporting real-time task adjustment.
Patent Information
- Application Number
- CN202110546529.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-19
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2041-05-19
AI Technical Summary
In existing technologies, data acquisition methods based on the Celery scheduling framework require the startup of multiple services, resulting in high system resource consumption, cumbersome management, and low system performance.
The APScheduler and nanomsg modules are integrated into the Twisted framework, enabling data collection tasks to be performed through a single service, reducing the number of services and saving system resources.
It reduces system resource consumption, improves system performance, and supports real-time task adjustments without requiring service restarts.
Smart Images

Figure CN115373808B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a data acquisition method, device, computer storage medium and system. Background Technology
[0002] With the advent of the big data era, cluster and distributed architectures have been adopted by many enterprises for product and system deployment. The operation and maintenance of products require enterprises to monitor and manage the performance of cluster devices and distributed systems in order to detect errors in a timely manner, perform maintenance, ensure the normal operation of products, and avoid losses.
[0003] Currently, the Celery scheduling framework is used to process large numbers of messages to achieve data collection. This requires starting multiple services such as worker, beat, and rabbitMQ, which makes service management cumbersome and leads to high system resource consumption, thus reducing system performance. Summary of the Invention
[0004] This application provides a data acquisition method, apparatus, computer storage medium, and system that can complete the data acquisition task by enabling only a single service, thereby reducing the number of services to be enabled, saving system resources, reducing system resource occupancy, and thus improving system performance.
[0005] The technical solution of this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a data acquisition method applied to a user equipment, the user equipment including an APScheduler module and a nanomsg module, wherein the APScheduler module and the nanomsg module are integrated in the Twisted framework, the method comprising:
[0007] Identify the data acquisition tasks to be performed;
[0008] After scheduling the data acquisition task through the APScheduler module, the data acquisition task is executed, and the task execution result is obtained.
[0009] The nanomsg module processes the task execution result and sends the processed target data to the service device.
[0010] In some embodiments, determining the data acquisition task to be performed includes:
[0011] Obtain system information;
[0012] Based on the system information, determine the currently running operating system;
[0013] The data acquisition task corresponding to the operating system is identified as the data acquisition task to be executed.
[0014] In some embodiments, after performing the data acquisition task and obtaining the task execution result, the method further includes:
[0015] The task execution result is serialized and stored in a cache queue in a preset format;
[0016] If data exists in the cache queue, the task execution result can be read directly from the cache queue through the nanomsg module.
[0017] In some embodiments, the method further includes:
[0018] Based on the Twisted framework, enable the reactor mode for waiting events;
[0019] The APScheduler module is instantiated to obtain the first event in the Twisted framework;
[0020] The underlying interface of the nanomsg module is called through the preset library, and the nanomsg module is instantiated to obtain the second event in the Twisted framework.
[0021] Based on the first event and the second event, the APScheduler module and the nanomsg module are placed in the same service process.
[0022] In some embodiments, the method further includes:
[0023] When the same service process to which the APScheduler module and the nanomsg module belong stops, check whether the input / output IO files of the data acquisition task are closed;
[0024] If the IO file is not closed, then close the IO file.
[0025] In some embodiments, the method further includes:
[0026] When the nanomsg module establishes a communication connection with the service device, it receives task configuration information sent by the service device through the nanomsg module.
[0027] Obtain the task name and task parameters of the task to be adjusted from the task configuration information;
[0028] Based on the task name and the task parameters, perform task adjustment operations on the task to be adjusted; wherein, the task adjustment operations include at least one of the following: removing the task, adding a task, closing the task, pausing the task, and modifying the task cycle.
[0029] In some embodiments, the method further includes:
[0030] When the nanomsg module does not establish a communication connection with the service device, after processing the task execution result through the nanomsg module, the processed target data is discarded.
[0031] Secondly, embodiments of this application provide a data acquisition device applied to a user equipment, the user equipment including an APScheduler module and a nanomsg module, wherein the APScheduler module and the nanomsg module are integrated in a Twisted framework; the data acquisition device includes a determination unit, an execution unit, and a transmission unit; wherein...
[0032] The determining unit is configured to determine the data acquisition task to be executed.
[0033] The execution unit is configured to execute the data acquisition task and obtain the task execution result after the data acquisition task is scheduled through the APScheduler module.
[0034] The sending unit is configured to process the task execution result through the nanomsg module and send the processed target data to the service device.
[0035] Thirdly, embodiments of this application provide a computer storage medium storing a computer program, which, when executed by a processor, implements the data acquisition method as described in any one of the first aspects.
[0036] Fourthly, embodiments of this application provide a data acquisition system, which includes at least a user device, the user device including a memory and a processor, wherein...
[0037] The memory is used to store computer programs that can run on the processor;
[0038] The processor is configured to execute the data acquisition method as described in any one of the first aspects when running the computer program.
[0039] This application provides a data acquisition method, apparatus, computer storage medium, and system. The method is applied to a user equipment (UE), which includes an APScheduler module and a nanomsg module, both integrated within the Twisted framework. The method involves determining a data acquisition task to be executed; scheduling the task through the APScheduler module; executing the task; obtaining the task execution result; processing the task execution result through the nanomsg module; and sending the processed target data to a service device. By integrating the APScheduler and nanomsg modules into the same service process within the Twisted framework, only a single service needs to be started to complete the data acquisition task. This reduces the number of services required, saves system resources, lowers system resource occupancy, and ultimately improves system performance. Attached Figure Description
[0040] Figure 1 A flowchart illustrating a data acquisition method provided in an embodiment of this application;
[0041] Figure 2 A flowchart illustrating another data acquisition method provided in an embodiment of this application;
[0042] Figure 3a This is a schematic diagram of the composition structure of a data acquisition system provided in an embodiment of this application;
[0043] Figure 3b A schematic diagram of the application framework for a data acquisition method provided in this application embodiment.
[0044] Figure 4 A flowchart illustrating an event loop process provided in an embodiment of this application;
[0045] Figure 5 This is a schematic diagram of the composition structure of a data acquisition device provided in an embodiment of this application;
[0046] Figure 6 This is a schematic diagram of the hardware structure of a user equipment provided in an embodiment of this application;
[0047] Figure 7 This is a schematic diagram of the composition structure of another data acquisition system provided in an embodiment of this application. Detailed Implementation
[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are merely for explaining the relevant application and not for limiting the application. Furthermore, it should be noted that, for ease of description, only the parts relevant to the application are shown in the accompanying drawings.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0050] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0051] It should be noted that the terms "first, second, and third" used in the embodiments of this application are merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0052] With the continuous development of the Internet, cluster and distributed architectures are being adopted by many enterprises for product and system deployment. The operation and maintenance of products require enterprises to monitor and manage the performance of cluster devices and distributed systems in order to detect errors in a timely manner, perform maintenance, ensure the normal operation of products, and avoid losses.
[0053] Currently, one proposed data acquisition method is based on the Celery scheduling framework. Celery is a distributed asynchronous message queue developed in Python, enabling asynchronous task processing and handling of large numbers of messages; it is a message queue focused on real-time processing. This approach uses Celery to handle scheduled and periodic asynchronous tasks for data collection, with RabbitMQ as the message queue. Received messages are routed to queues on the server for storage and output via RabbitMQ exchanges. However, this approach primarily utilizes the Celery scheduling framework and the RabbitMQ message queue. Celery startup involves two services, worker and beat, plus the RabbitMQ service, resulting in a large number of services being started during data acquisition, cumbersome management, high system resource consumption, and low performance.
[0054] In this application embodiment, considering the complexity and uncertainty of data collection in many application scenarios, there is an urgent need to provide a controllable task scheduling and proactive data push method so as to uniformly manage and schedule tasks that need to collect data.
[0055] Based on this, this application provides a data acquisition method applied to a user equipment, which includes an APScheduler module and a nanomsg module, both integrated within the Twisted framework. The basic idea of this method is as follows: determine the data acquisition task to be executed; after scheduling the data acquisition task through the APScheduler module, execute the data acquisition task and obtain the task execution result; process the task execution result through the nanomsg module and send the processed target data to a service device. In this way, by integrating the APScheduler module and the nanomsg module into the same service process using the Twisted framework, only a single service needs to be started to complete the data acquisition task, thereby reducing the number of services started, saving system resources, reducing system resource occupancy, and ultimately improving system performance.
[0056] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0057] In one embodiment of this application, see [link to embodiment]. Figure 1 This illustrates a flowchart of a data acquisition method provided in an embodiment of this application. Figure 1 As shown, the method may include:
[0058] S101. Determine the data acquisition task to be executed.
[0059] It should be noted that the data acquisition method provided in this application embodiment can be applied to a user equipment, which can implement the data acquisition method described in this application embodiment. Alternatively, the data acquisition method provided in this application embodiment can also be applied to a data acquisition device, which can be integrated into the user equipment, enabling the user equipment to implement the data acquisition method described in this application embodiment. Here, the user equipment can be such as a computer, smartphone, tablet computer, laptop computer, handheld computer, personal digital assistant (PDA), navigation device, etc., and this application embodiment does not specifically limit it in this regard.
[0060] It should also be noted that, for user equipment, this user equipment may include the APScheduler module and the nanomsg module, and the APScheduler module and the nanomsg module are integrated into the Twisted framework. Here, the APScheduler module schedules the various data acquisition tasks that need to be executed.
[0061] Due to differences in operating system versions, the shells (also called command-line interpreters) of different operating systems vary, and their built-in system commands also differ. During data acquisition tasks, the corresponding system commands will be invoked for different operating systems. Therefore, before scheduling each data acquisition task, it is necessary to determine the currently running operating system through a pre-task. Thus, in some embodiments, determining the data acquisition task to be executed may include:
[0062] Obtain system information;
[0063] Based on the system information, determine the currently running operating system;
[0064] The data acquisition task corresponding to the operating system is identified as the data acquisition task to be executed.
[0065] It should be noted that the pre-processing task is the task executed before the data acquisition task is scheduled by APScheduler. The pre-processing task obtains the current system information and then confirms the currently running operating system based on the system information. For example, the operating system can be Windows, Linux, etc. Then, the data acquisition task corresponding to the currently running operating system is selected and determined as the data acquisition task to be executed.
[0066] In other words, the system commands can be invoked and system information can be obtained through Python's OS module. Then, the operating system currently in operation can be determined based on the system information, such as Windows, and the corresponding data acquisition task can be determined.
[0067] S102. After scheduling the data acquisition task through the APScheduler module, the data acquisition task is executed to obtain the task execution result.
[0068] It should be noted that the data acquisition method provided in this application embodiment is based on the Twisted framework. Twisted is an event-driven network engine framework implemented in Python, and is a powerful asynchronous I / O library in Python. It implements the reactor pattern in design patterns. The twisted.application.service.MutilService class in Twisted is a service container that treats the APScheduler module and the nanomsg module as its sub-services. That is, the Twisted framework integrates the APScheduler module and the nanomsg module into the same service process. In this way, when performing data acquisition, only this one service needs to be started to achieve data acquisition.
[0069] It's also worth noting that Advanced Python Scheduler (APScheduler), or the APScheduler module, is a lightweight Python scheduled task framework (Python library) that can execute specified jobs according to specified time rules. APScheduler mainly includes the following components: triggers, which contain scheduling logic describing when a task is triggered; job stores, which specify where jobs are stored (by default in memory, but can also be stored in various databases; when stored in a database, jobs are serialized, and deserialized upon reloading); executors, which can submit specified jobs (call functions) to a thread pool or process pool for execution; and schedulers, which, as the task scheduler, play a control role, configuring job stores, executors, and triggers, and adding, modifying, and deleting tasks. The nanomsg module (also known as "nanomsg message queue", "nanomsg", etc.) is a Socket communication library written in C. It is applicable to multiple operating systems and can realize one-to-one, one-to-many, and many-to-many data transmission through different protocols.
[0070] Furthermore, since the embodiments of this application require placing the APScheduler module and the nanomsg module in the same process, and are implemented using the event-driven networking framework Twisted, the method may further include the following in some embodiments:
[0071] Based on the Twisted framework, enable the reactor mode for waiting events;
[0072] The APScheduler module is instantiated to obtain the first event in the Twisted framework;
[0073] The underlying interface of the nanomsg module is called through the preset library, and the nanomsg module is instantiated to obtain the second event in the Twisted framework.
[0074] Based on the first event and the second event, the APScheduler module and the nanomsg module are placed in the same service process.
[0075] It should be noted that, in this embodiment, integrating the APScheduler module and the nanomsg module into the same service using the Twisted framework can be achieved as follows: Twisted first initiates a loop-based waiting mode, i.e., reactor mode, to wait for events to enter. Specifically, reactor mode is an event design pattern for handling concurrent service requests and submitting them to one or more service handlers. Then, the APScheduler module is instantiated. Specifically, since the data acquisition method in this embodiment is based on the Twisted framework, in this application scenario, the scheduler selected when configuring the scheduler is TwistedScheduler. By instantiating the scheduler TwistedScheduler of the APScheduler module (scheduler = TwistedScheduler()), the APScheduler module is added to the Twisted framework as an event. After instantiation, the APSchedule module can perform operations such as adding, removing, closing, pausing, or modifying tasks using methods like add_job, remove_job, shutdown, pause, and modify. Here, the APScheduler module can be considered the first event in the Twisted framework.
[0076] It's also worth noting that since the nanomsg module, i.e., the nanomsg message queue, is written in C, it needs to call the underlying interface of the nanomsg module through a pre-defined library in the Twisted framework to implement its functionality. This pre-defined library can be the Pynng library, a Python library used here to implement the nanomsg module's functionality. Simultaneously, the nanomsg module is instantiated and added to the Twisted framework as an event. Here, the nanomsg module can be considered a second event in the Twisted framework. This way, based on the first and second events, the APScheduler module and the nanomsg module can reside in the same service process. Furthermore, a port can be bound to the nanomsg module for connection, communication, and data transmission with external devices.
[0077] In addition, when scheduling data acquisition tasks through the APScheduler module, scheduling also needs to be based on the task name and cycle time. Data acquisition tasks can be scheduled from the user device's task module. Here, the task module can be a package of tasks to be executed, which includes not only various data acquisition tasks but also other tasks such as pre-processing tasks and post-processing tasks. Pre-processing tasks check and confirm the currently running operating system before scheduling data acquisition tasks and select the data acquisition task corresponding to the current operating system. Post-processing tasks are generally executed when a service shutdown or exit signal is received, ensuring that IO files are closed properly, or updating the data acquisition task's configuration file when task configuration information is received from the service device.
[0078] Here, since only the data acquisition task needs to be scheduled, the selected data acquisition task's task function can be added to the scheduler using the `scheduler.add_job(<task name>, <period>)` method. The period can be obtained in the following ways: for example, through the data acquisition task's configuration file; if the configuration file does not contain any period-related parameters, the default value can be set to the period, which can be a fixed value set during code writing; alternatively, the period can be configured by sending the corresponding period data from the service device.
[0079] It should also be noted that the data acquisition method provided in this application embodiment can execute multiple data acquisition tasks asynchronously. Therefore, the number of data acquisition tasks can be one or more.
[0080] It should also be noted that the data collection method provided in this application embodiment can provide data support for product operation, equipment performance monitoring, etc., therefore the collected data is diverse and flexible. Specifically, in some embodiments, the data collection task may include at least one of the following:
[0081] Hardware information collection tasks, including CPU usage collection tasks, memory usage collection tasks, disk usage collection tasks, program running status collection tasks, and log analysis and error information collection tasks.
[0082] In this embodiment, the data acquisition task can run at a set period (i.e., the period obtained above). The hardware information acquisition task collects information about hardware such as processors, memory, hard disks, and network cards. The CPU utilization acquisition task, memory utilization acquisition task, and disk utilization acquisition task can monitor the utilization of CPU, memory, and disk. These tasks can be executed as three separate tasks, two separate tasks, or as a single task, depending on the actual task configuration and requirements. This embodiment does not impose specific limitations on this. The program running status acquisition task monitors the running status of a specified program. There can be one or more specified programs. When there are multiple specified programs, they can be executed as multiple tasks or as a single task, depending on the actual task configuration and requirements. This embodiment does not impose specific limitations on this. The log analysis and error information acquisition task analyzes the operating system and various programs' logs, extracting error information if errors are found in the logs.
[0083] It should be noted that after the data collection task is scheduled through the APScheduler module, once the data collection task is loaded, it will start executing after its specified period, and the collected data will be the result of the task execution.
[0084] S103. The nanomsg module processes the task execution result and sends the processed target data to the service device.
[0085] It should be noted that, in this embodiment, the nanomsg module can provide data transmission and communication functions between the user equipment and the communication device. After obtaining the task execution result, the nanomsg module can process the task execution result and send the processed target data to the service device.
[0086] It should also be noted that since the APScheduler module and the nanomsg module are integrated into the same service process through the Twisted framework, they are two threads within the same service process and can share data through a cache queue mechanism. Therefore, in some embodiments, after executing the data acquisition task and obtaining the task execution result, the method further includes:
[0087] The task execution result is serialized and stored in a cache queue in a preset format;
[0088] If data exists in the cache queue, the task execution result can be read directly from the cache queue through the nanomsg module.
[0089] In one specific embodiment, the preset form can be a key-value pair form.
[0090] It should be noted that the cache queue can be the queue standard library, which enables data sharing between threads. Here, after executing the data acquisition task and obtaining the task execution result, the task execution result is first serialized in a preset format and stored in the cache queue. Preferably, the preset format is a key-value pair format, and the task execution result is serialized into JSON format and stored in the queue standard library. The task execution result can also be serialized in other formats and stored in the cache queue, such as serializing the task execution result into XML format; this embodiment does not specifically limit this approach.
[0091] After the task execution result is stored in the cache queue, the cache queue will contain data (i.e., the serialized task execution result). With data present in the cache queue, the task execution result can be read from it using the nanomsg module. It should also be noted that after the nanomsg module reads the task execution result from the cache queue, since the task execution result has been "retrieved," the cache queue will no longer retain the read task execution result.
[0092] Furthermore, after the nanomsg module reads the task execution results from the cache queue, it is necessary to describe two different cases.
[0093] In the first scenario, as mentioned earlier, a port can be bound to the nanomsg module for communication and data transmission with external devices. The external device could be, for example, a service device that needs to receive data. Specifically, the service device establishes a communication connection with the nanomsg module by connecting to the nanomsg module via the user device's Internet Protocol (IP) address, the bound port number, and the pair protocol. This ensures communication between the service device and the user device through the nanomsg module. The pair protocol is a "one-to-one" mode, meaning end-to-end bidirectional communication. Once the nanomsg module establishes a communication connection with the service device through the port, the user device can send target data to the service device via the nanomsg module. After receiving the target data, the service device processes it according to its actual needs; for example, it can issue alarms upon receiving error messages from logs, but this is irrelevant to the data acquisition task.
[0094] In the second scenario, if no external device, such as a service device, establishes a connection with nanomsg via a port, the user equipment cannot communicate with the external device through the nanomsg module. Therefore, in some embodiments, the method may further include:
[0095] When the nanomsg module does not establish a communication connection with the service device, after processing the task execution result through the nanomsg module, the processed target data is discarded.
[0096] It's important to note that if no communication connection is established between the service device and the nanomsg module, they cannot communicate or transmit data. In this case, the nanomsg module will retrieve the task execution results from the cache queue, process them, and then discard them. This ensures that when the user device and the service device establish a communication connection through the nanomsg module, the data sent by the nanomsg module to the service device is real-time.
[0097] During the execution of data acquisition tasks, it is sometimes necessary to add new data acquisition tasks; or to modify certain data acquisition tasks (e.g., modify their execution cycle); or to pause a data acquisition task; or a data acquisition task that will no longer be executed needs to be deleted; or a data acquisition task whose cycle has been too long to be executed needs to be executed. In related technologies, if it is necessary to remove, add, close, pause, or modify the cycle of some tasks in a data acquisition task, it is necessary to modify the task configuration and then restart the service (process), which will reduce data acquisition efficiency and cause inconvenience. To address this, the embodiments of this application can realize real-time modification of data acquisition tasks without restarting the service. Therefore, in some embodiments, the method may further include:
[0098] When the nanomsg module establishes a communication connection with the service device, it receives task configuration information sent by the service device through the nanomsg module.
[0099] Obtain the task name and task parameters of the task to be adjusted from the task configuration information;
[0100] Based on the task name and the task parameters, perform task adjustment operations on the task to be adjusted; wherein, the task adjustment operations include at least one of the following: removing the task, adding a task, closing the task, pausing the task, and modifying the task cycle.
[0101] It should be noted that, in this embodiment, if it is necessary to remove, add, close, pause, or modify the execution cycle of a task, when the nanomsg module establishes a communication connection with the service device, it can receive task configuration information sent by the service device through the nanomsg module. The task configuration information may include, for example, a task configuration file and execution instructions. After receiving the task configuration information sent by the service device, the nanomsg module can obtain the task name and related task parameters of the task to be adjusted. The asynchronous task within the APScheduler module will update the configuration file of the data acquisition task in real time based on the task name and task parameters of the task to be adjusted, modify the data acquisition task, and execute the data acquisition task according to the modified parameters. The APScheduler module can then perform task adjustment operations such as adding, removing, closing, pausing, or modifying tasks through the aforementioned instantiated methods such as add_job, remove_job, shutdown, pause, and modify.
[0102] For example, if the execution cycle of a data acquisition task is 5 seconds, but due to certain requirements, it is necessary to adjust the execution cycle to 10 seconds, then the relevant task configuration information can be sent through the service device to modify the execution cycle of the task to 5 seconds, and thereafter the data acquisition task will be executed according to the new execution cycle of 5 seconds.
[0103] For example, if a data acquisition task does not need to be executed temporarily, the service device can send the task name and a pause command, and the user device will stop executing the data acquisition task.
[0104] For example, if a data acquisition task is no longer needed, the service device can send the task name and deletion command to the user device, which will then delete the configuration file for the data acquisition task and stop executing it.
[0105] It's also worth noting that a post-task can be executed at this point to update the data acquisition task's settings to the initially loaded configuration file. This ensures that the data acquisition task's configuration file on the user's device is the latest configuration updated based on the task configuration information sent by the service device. In this way, if the service restarts, the data acquisition task will retain the updated configuration.
[0106] For example, if during the execution of a data acquisition task, the execution cycle of a certain data acquisition task is changed from 10 seconds to 5 seconds, and the service unexpectedly restarts or needs to be restarted for some reason, the data acquisition task needs to be reloaded and executed after the restart. If the task configuration information sent by the service device has not been updated in the configuration file of the data acquisition task, the configuration file of the data acquisition task will still have the original configuration, and it will still execute according to the 10-second cycle. However, since the task configuration information of the data acquisition task has been updated in the task configuration file in this embodiment, after the service restarts, the data acquisition task will be executed according to the updated 5-second cycle.
[0107] Furthermore, in some embodiments, the method may further include:
[0108] When the processes to which the APScheduler module and the nanomsg module belong stop, check whether the IO file of the data acquisition task is closed;
[0109] If the IO file is not closed properly, then close the IO file.
[0110] It's worth noting that when the service process stops, another post-processing task is triggered to check if all open file I / Os have been properly closed. If not, the I / O files are closed. In other words, this post-processing task is executed when a close or exit signal is received. At this time, some data acquisition tasks are still in progress and will wait for those tasks to complete. Essentially, this is a cleanup process for the acquisition tasks, ensuring that the I / O files are properly closed.
[0111] It should also be noted that, in this embodiment, after establishing a communication connection with the service device, the user equipment sends the target data to the service device, and the service device receives the target data and performs specific processing. In some embodiments, if the service device is used as the executing entity of the data acquisition method, then the method may include:
[0112] Receive target data sent by user equipment via the nanomsg module;
[0113] The target data is then processed.
[0114] It should be noted that if the nanomsg module of the service device and the user device successfully establishes a communication connection, after the user device collects the data, i.e. the task execution result, nanomsg will process the task execution result and send the processed target data to the service device. After receiving the target data, the service device will process it itself. For example, if the target data contains error information from the system log, it will issue an alarm.
[0115] Furthermore, in some embodiments, for the service device, the method may further include: sending task configuration information to the user device.
[0116] It should be noted that if adjustments to the data acquisition task are needed, such as removing, adding, closing, pausing, or modifying the task cycle, the service device can send the corresponding task configuration information to the user device. Upon receiving the task configuration information, the user device can then make the appropriate adjustments to the data acquisition task.
[0117] This embodiment provides a data acquisition method applied to a user equipment, which includes an APScheduler module and a nanomsg module integrated within the Twisted framework. The method involves determining a data acquisition task to be executed; scheduling the task through the APScheduler module; executing the task; obtaining the execution result; and then processing the result through the nanomsg module and sending the processed target data to a service device. By integrating the APScheduler and nanomsg modules into the same service process within the Twisted framework, only a single service needs to be started to complete the data acquisition task, reducing the number of services required, saving system resources, lowering resource consumption, and improving system performance. Furthermore, when it is necessary to remove, add, close, pause, or modify the execution cycle of a task, the service device can issue corresponding task configuration information. The service device can then adjust the task in real time based on the configuration information, enabling real-time operation or modification of the data acquisition task without restarting the service.
[0118] In another embodiment of this application, see Figure 2 This illustrates a detailed flowchart of another data acquisition method provided in an embodiment of this application. Figure 2 As shown, the method may include:
[0119] S201. Start the system. The Twisted framework starts the loop mode for waiting for events, and the waiting event tasks begin to run.
[0120] It should be noted that the data acquisition method provided in this application embodiment can be applied to a data acquisition system, which may include at least the user equipment (also referred to as a client / user terminal) described in the foregoing embodiments. For example, through... Figure 3a The data acquisition system shown implements the data acquisition method described in the embodiments of this application.
[0121] like Figure 3aThe diagram illustrates the structural composition of a data acquisition system according to an embodiment of this application. This data acquisition system includes at least user equipment and may also include service equipment (also referred to as a server). The user equipment may include the following modules: a tasks module, an APScheduler module (also referred to as an APScheduler task scheduling module), a nanomsg module (also referred to as a nanomsg message queue module), and a Twisted framework module (also referred to as a Twisted event-driven network framework module).
[0122] It should also be noted that, when the data acquisition method provided in this application embodiment is executed in the data acquisition system, it can be as follows: Figure 3b The diagram illustrates an application framework schematic of a data acquisition method provided in an embodiment of this application. It can be combined with... Figure 3b The provided data acquisition method application framework diagram and Figure 2 The specific flowchart of the data acquisition method provided is used to help understand the embodiments of this application.
[0123] It should be noted that, in this embodiment, the scheduled task framework Apscheduler (i.e., the APScheduler module) and the nanomsg message queue (i.e., the nanomsg module) are integrated into a single service process using the Twisted framework (i.e., the Twisted framework module). During data collection, only a single service needs to be started to complete tasks such as data collection. The Twisted framework is an event-driven network model, and the core of Twisted is the reactor's event loop. Therefore, in this embodiment, when the system (i.e., the data collection system) starts, the Twisted framework module enters a loop mode waiting for events, i.e., reactor mode, waiting for event tasks to begin execution.
[0124] S202. Add the Apscheduler module as an event to the Twisted framework module.
[0125] It should be noted that Apscheduler is a distributed task scheduling framework that can execute specified jobs according to specified event rules. The scheduler is the scheduler of the Apscheduler module. The data acquisition method provided in this embodiment is based on the Twisted framework; therefore, the scheduler used in this embodiment is TwistedScheduler. The scheduler TwistedScheduler is instantiated by `scheduler = TwistedScheduler()`, and the Apscheduler module is added as an event to the Twisted framework module. This instantiation operation allows the Apscheduler module to execute methods such as `remove_job`, `add_job`, `shutdown`, `pause`, and `modify` in subsequent steps to remove, add, close, pause, and modify data acquisition tasks.
[0126] It should also be noted that since the data acquisition system has just started up and has not yet received external commands or task configuration information from the service device, this step only uses the `add_job` method. The `scheduler.add_job(<task name>, <period>)` method adds the corresponding data acquisition task function from the `tasks` module to the scheduling task. Here, the period is obtained from the data acquisition task's configuration file. If the configuration file does not contain period configuration data, the period is set to the default value. Alternatively, it can be configured by sending the corresponding period data from the service device.
[0127] S203. Add the nanomsg module as an event to the Twisted framework module.
[0128] It should be noted that in this embodiment, the nanomsg underlying interface is called through the Python Pynng library to start a nanomsg message queue (nanomsg module) and bind it to a port. After the nanomsg module is instantiated, it is also added as an event to the Twisted framework module, thereby binding the Apscheduler module and the nanomsg module to the same service process. At this time, the nanomsg module can wait to communicate with the service device.
[0129] S204. Instantiate the queue standard library to temporarily store the collected data.
[0130] It should be noted that the queue standard library, i.e. the preferred cache queue in the aforementioned embodiments, serves to temporarily store the task execution results of data acquisition tasks and provide them for the nanomsg module to read.
[0131] S205. Before the APScheduler module starts scheduling, a pre-task is executed to create an environment for the data acquisition task.
[0132] It's important to note that after system startup, before APScheduler begins scheduling tasks, a pre-processing task must be executed first. This task creates the environment for the data acquisition tasks scheduled by APScheduler, determines the currently running operating system, and checks the dependencies required by the data acquisition tasks. For example, it first obtains system information to determine whether the running system is Windows or Linux, then selects the appropriate data acquisition task for each system; next, it reads the configuration file of the data acquisition task to obtain the scheduling cycle and related parameters for each task; and finally, it loads the selected data acquisition task and its corresponding scheduling cycle. It's also worth noting that this pre-processing task is executed during service startup, before the APScheduler module begins scheduling data acquisition tasks, to check the system. After this initial execution, it will not be repeated unless the service is shut down and then restarted.
[0133] S206. The service equipment establishes a communication connection with the user equipment.
[0134] It should be noted that in the aforementioned step S203, the nanomsg module has already bound a port for communication with the service device. Therefore, in this step, the service device can connect to the nanomsg module through the user device's IP address, the bound port number, and the pair protocol, thereby ensuring that the service device and the user device can communicate through the nanomsg module. That is, in this embodiment, the communication between the user device and the service device is implemented through the nanomsg module.
[0135] S207. After the data acquisition task period is reached, execute the data acquisition task and store the task results in a serialized format in the queue standard library.
[0136] After the APScheduler module loads the data acquisition task (since the data acquisition task in this application embodiment is usually executed periodically, the data acquisition task in this application embodiment can also be called a periodic task), the corresponding data acquisition task will be executed when the specified period arrives, and the task execution result will be stored in the queue standard library in serialized format.
[0137] It should be noted that once the data acquisition task is loaded, if the task's timeout period has arrived, the data acquisition task will begin execution, yielding the task results. These results can be the collected data, which will be stored in the queue standard library in a serialized format. Specifically, the task results can be serialized into key-value pairs and stored in the queue standard library as JSON.
[0138] It should also be noted that APScheduler supports asynchronous task execution; therefore, in this example, multiple data acquisition tasks can be scheduled and executed simultaneously.
[0139] The S208 and nanomsg modules read data from the queue standard library and send the data to the service device.
[0140] In this embodiment, when there is data in the queue, the nanomsg module directly reads the corresponding data and sends it to the service device, which then processes the data itself.
[0141] It should be noted that the queue standard library is used to store the task execution results obtained from data acquisition tasks. After the task execution results are stored in the queue standard library, the queue standard library contains data. The nanomsg module can directly read the task execution results from the queue standard library, process the read task execution results, and send them to the service device. After receiving the task execution results, the service device processes them according to its requirements.
[0142] It should also be noted that after the nanomsg module reads data from the queue standard library, the queue standard library will no longer save the execution results of the tasks that have been read.
[0143] It should also be noted that if the nanomsg module does not establish a connection with the service device in step S206, the nanomsg module will also obtain the task execution result from the queue standard library and then discard it to ensure that the target data obtained when the user device establishes a connection with the service device is real-time.
[0144] S209. If it is necessary to remove, add, close, or pause a data acquisition task, or modify the execution cycle of a data acquisition task, the corresponding task configuration information can be sent through the service device.
[0145] It should be noted that during the operation of the system after startup, if it is necessary to remove, add, close, or pause a data acquisition task, or modify the execution cycle of a data acquisition task, the service device can directly send the corresponding task configuration information, such as task configuration and running instructions, to the user device.
[0146] S2010. Process the task according to the task configuration information sent by the service device.
[0147] After receiving the relevant data, the nanomsg module calls the remove_job, add_job, shutdown, pause, and modify methods of the scheduler instance, and performs the corresponding operation on the corresponding task with the corresponding task name.
[0148] It should be noted that after the nanomsg module of the user device obtains the relevant task configuration and execution instructions issued by the user device, it performs corresponding operations according to the content indicated by the task configuration and execution instructions. From the task configuration information, it can obtain the name of the task to be modified and the corresponding parameters required for modification. By calling the scheduler instance's remove_job, add_job, shutdown, pause, modify and other methods, it performs the corresponding operation on the corresponding task with the corresponding task name.
[0149] It should also be noted that after receiving the task configuration information from the service device, a follow-up task will update this configuration information to the data acquisition task's configuration file. During the event loop, the system will detect changes to the configuration file and then execute the data acquisition task according to the latest configuration file.
[0150] In this way, during system operation, tasks can be modified in real time by sending task configuration information through the service device, without needing to restart the service. Moreover, if the service is unexpectedly shut down or restarted, the system can be restarted to ensure that the configuration information of the loaded data acquisition tasks is updated, maintaining the configuration of the last executed task.
[0151] When the service process stops, a follow-up task is also triggered to check whether all open file I / O operations of the program have been closed properly. If not, it is closed manually.
[0152] In short, the functional modules of the data acquisition system provided in this application embodiment can be used to achieve the following functions:
[0153] The tasks module contains the task packages to be executed, including pre-tasks, post-tasks, and various data collection tasks.
[0154] Among them, the pre-processing tasks are those executed after system startup and before the data acquisition tasks are scheduled. First, system information is obtained to determine whether the currently running system is Windows or Linux, and then the data acquisition task corresponding to the currently running system is selected; then, the configuration file of the data acquisition task is read to obtain the scheduling cycle and related parameters of each data acquisition task, and the selected data acquisition task and its corresponding scheduling cycle and related parameters are loaded.
[0155] The data acquisition task can be run periodically by setting parameters. It can include collecting hardware information; monitoring the usage of CPU, memory and disk; monitoring the running status of specified programs; and analyzing the logs of the operating system and each program, extracting error information when there are errors in the logs.
[0156] The post-task is triggered in two situations: First, when the service process stops, it checks whether all open file I / Os of the program have been closed properly. If not, it closes them proactively. That is, it is only executed when a close or exit signal is received, which is mainly the finishing work of the entire data acquisition process. Second, during the communication with the service device through nanomsg, if a task configuration instruction is received, the post-task is called to reset the data acquisition task and update the configuration file of the data acquisition task loaded when the system starts, so that the previous task execution configuration can be maintained when the system restarts next time.
[0157] The APScheduler module is responsible for scheduling data acquisition tasks in the tasks module, loading task functions from tasks, and implementing asynchronous execution on a timed, periodic, or real-time basis.
[0158] The nanomsg module connects to the service device via the pair protocol to achieve bidirectional communication (i.e., communication between the user device and the service device). The nanomsg module can also receive task configuration and execution instructions issued by the service device; obtain the task name and parameters to perform corresponding operations such as adding, starting, pausing, and removing tasks; and actively send the execution results of asynchronous tasks scheduled by APScheduler to the service device.
[0159] The Twisted framework module includes Twisted and Pynng; Pynng is a Python library used to call the nanomsg interface and implement the functionality of the nanomsg module. The nanomsg module's pair protocol can be used to start a nanomsg module and bind it to a port for service devices to connect and communicate. The queue standard library is used to temporarily store data acquisition results. Twisted is an asynchronous I / O network framework based on the Reactor pattern, responsible for the event task loop; that is, after starting the Twistedreactor, the reactor loop begins, waiting for events to arrive.
[0160] For the specific process of the data acquisition method provided in the embodiments of this application, please refer to [link / reference]. Figure 4 This illustrates a flowchart of an event loop process provided in an embodiment of this application. Figure 4 As shown, this event loop process is based on the Twisted framework. After starting the Twisted reactor mode, the reactor loop continuously scans and listens for events. When an event arrives, it completes the data acquisition task through logical processing. As can be seen from the above, in this embodiment, the APScheduler module and the nanomsg module are instantiated and added as events to the Twisted framework, binding them to a single service process. Specifically, as... Figure 4 As shown, the APScheduler module schedules data acquisition tasks using the scheduler.add_iob(task) method. After executing the data acquisition task and obtaining the task results, it loads the results into the queue standard library using the queue.put(task_result) method. The nanomsg module then retrieves the task results from the queue standard library using the queue.get(task_result) method and sends the target data out, such as to the service device, using the nanomsg.send(task_result) method.
[0161] In summary, the data acquisition method based on the Twisted framework provided in this application embodiment may include the following steps:
[0162] Step 1: Initialization. This includes the following steps:
[0163] Step 1-1: Start the system, enable the Twisted Reactor to enter the event waiting loop mode, and wait for the event task to start running.
[0164] Steps 1-2: After the system starts, the scheduling module TwistedScheduler in the Apscheduler framework is instantiated as scheduler = TwistedScheduler(). Then, the corresponding task functions of the modules in tasks are added to the scheduling task through the scheduler.add_job(<task name>, <period>) method. The period can be obtained through configuration files or preset default values, or it can be configured by sending corresponding data through the service device.
[0165] Steps 1-3: After the system starts, the nanomsg underlying interface is called through the Python Pynng library to start a nanomsg module and bind it to a port for communication with the service device.
[0166] Steps 1-4: After starting the system, instantiate the queue to temporarily store the collected data.
[0167] Step 2: Before the APScheduler module starts scheduling, it will first execute a pre-task to create the necessary environment for the data acquisition task.
[0168] Step 3: The service device connects to the nanomsg module through the user equipment IP address and the port number and pair protocol bound in Step 1-3, ensuring that the service device and the user equipment communicate through the nanomsg module.
[0169] Step 4: After the APScheduler module loads the periodic tasks in Steps 1-2, it will start executing the corresponding data collection tasks when the specified period arrives, and serialize the task results into JSON format in key-value pairs and store them in the queue.
[0170] Step 5: When there is data in the queue, the nanomsg module directly reads the corresponding data and sends it to the service device. The service device processes the data itself after receiving it.
[0171] Step 6: If you want to remove, add, close, pause, or modify the execution cycle of a task, the service device can send the corresponding task name and parameters.
[0172] Step 7: After receiving the corresponding data, the nanomsg module calls the remove_job, add_job, shutdown, pause, and modify methods of the scheduler instance in steps 1-2, and performs the corresponding operation on the corresponding task with the corresponding task name.
[0173] Furthermore, if the nanomsg module fails to establish a connection with the service device in step 3, the nanomsg module will also retrieve data from the queue and discard it to ensure that the data is real-time when the service device is connected.
[0174] This application primarily addresses the drawbacks of high resource consumption and numerous service startups during data acquisition. It proposes a data acquisition system and method based on the Twisted framework. By integrating the APScheduler and nanomsg modules into a single service process within the Twisted framework, data acquisition can be achieved by starting only a single service. Furthermore, this application's embodiment utilizes the nanomsg module for message processing, enabling virtually seamless message sending to user / service devices, saving system resources, and improving system resource utilization. In other words, the purpose of this application is to provide a data acquisition system and method based on the Twisted framework, overcoming the shortcomings of existing Celery scheduling framework data acquisition methods, such as numerous services and high resource consumption, thereby improving server resource utilization and reducing the number of services for easier maintenance.
[0175] Compared with related technologies, the data acquisition method and data acquisition system provided in this application have the following advantages:
[0176] (1) In related technologies, Celery startup is divided into two services: worker and beat, resulting in a large number of services. In this embodiment, the APScheduler module and the nanomsg module are placed in the same process. Through the event-driven networking programming framework Twisted, after starting and running the Twisted Reactor mode, the scheduler of APScheduler is instantiated and added to the Twisted reactor as an event. Then, the Pynng library is used to call the underlying interface of the nanomsg module, bind the nanomsg module to a port and instantiate it, and add it to the Twisted reactor as an event as well. This achieves the binding of the two in the same service process, thereby reducing the number of services, optimizing service resources, and only needing to start one service when collecting data. The system resource consumption is low, which is convenient for management and maintenance.
[0177] (2) In related technologies, if some tasks in the data acquisition task need to be removed, added, closed, paused or modified, the task cycle needs to be modified and the service needs to be restarted. However, in this application embodiment, the task cycle can be removed, added, closed, paused or modified in real time by issuing task configuration information through the service device, and the service does not need to be restarted.
[0178] This embodiment provides a data acquisition method. The specific implementation of the aforementioned embodiments has been described in detail through the above embodiments. It can be seen that the data acquisition method provided in this embodiment places the APScheduler module and the nanomsg module in the same service process. Using the event-driven networking programming framework Twisted, after starting and running the Twisted Reactor mode, the APScheduler scheduler is instantiated and added as an event to the Twisted reactor. Then, the Pynng library is used to call the underlying interface of the nanomsg module, bind it to a port, and instantiate it, which is also added as an event to the Twisted reactor. This achieves the binding of both modules within the same service process, reducing the number of services and optimizing service resources. Furthermore, this embodiment uses task instructions issued by the service device to remove, add, close, pause, or modify task cycles in real time without restarting the service, thus ensuring the efficiency of data acquisition.
[0179] In another embodiment of this application, see [link to application]. Figure 5 This illustration shows a schematic diagram of the composition structure of a data acquisition device 50 provided in an embodiment of this application. The data acquisition device 50 is applied to a user equipment, which includes an APScheduler module and a nanomsg module, both integrated within a Twisted framework. Figure 5 As shown, the data acquisition device 50 may include: a determining unit 501, an execution unit 502, and a sending unit 503, wherein,
[0180] The determining unit 501 is configured to determine the data acquisition task to be executed.
[0181] The execution unit 502 is configured to execute the data acquisition task and obtain the task execution result after the data acquisition task is scheduled through the APScheduler module;
[0182] The sending unit 503 is configured to process the task execution result through the nanomsg module and send the processed target data to the service device.
[0183] In some embodiments, the determining unit 501 is further configured to acquire system information; determine the currently running operating system based on the system information; and determine the data acquisition task corresponding to the operating system as the data acquisition task to be executed.
[0184] In some embodiments, after executing the data acquisition task and obtaining the task execution result, the execution unit 502 is further configured to serialize and store the task execution result in a cache queue in a preset form; and if there is data in the cache queue, to directly read the task execution result from the cache queue through the nanomsg module.
[0185] In some embodiments, the data acquisition task includes at least one of the following:
[0186] Hardware information collection tasks, including CPU usage collection tasks, memory usage collection tasks, disk usage collection tasks, program running status collection tasks, and log analysis and error information collection tasks.
[0187] In some embodiments, such as Figure 5 As shown, the data acquisition device 50 may further include a startup unit 504, configured to enable reactor mode for waiting for events based on the Twisted framework; and to instantiate the APScheduler module to obtain a first event in the Twisted framework; and to call the underlying interface of the nanomsg module through a preset library and instantiate the nanomsg module to obtain a second event in the Twisted framework; and to make the APScheduler module and the nanomsg module run in the same service process based on the first event and the second event.
[0188] In some embodiments, such as Figure 5 As shown, the data acquisition device 50 may further include a detection unit 505, configured to detect whether the IO file of the data acquisition task is closed when the same service process to which the APScheduler module and the nanomsg module belong stops; and to close the IO file if the IO file is not closed properly.
[0189] In some embodiments, such as Figure 5 As shown, the data acquisition device 50 may further include a receiving unit 506 and an adjustment unit 507; wherein,
[0190] The receiving unit 506 is configured to receive task configuration information sent by the service device through the nanomsg module when the nanomsg module establishes a communication connection with the service device.
[0191] The adjustment unit 507 is configured to perform a task adjustment operation on the task to be adjusted according to the task name and the task parameters; wherein the task adjustment operation includes at least one of the following: removing the task, adding a task, closing the task, pausing the task, and modifying the task cycle.
[0192] In some embodiments, the data acquisition device 50 may further include a discarding unit 508, configured to discard the processed target data after the task execution result is processed by the nanomsg module when the nanomsg module has not established a communication connection with the service device.
[0193] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0194] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0195] Therefore, this embodiment provides a computer storage medium storing a computer program that, when executed by at least one processor, implements the steps of any of the methods described in the foregoing embodiments.
[0196] The aforementioned data acquisition device 50 can be applied to user equipment. Based on the composition of the data acquisition device 50 and the computer storage medium described above, see [link to relevant documentation]. Figure 6 This illustrates a schematic diagram of the specific hardware structure of a user equipment 60 provided in an embodiment of this application. For example... Figure 6As shown, it may include: a communication interface 601, a memory 602, and a processor 603; the various components are coupled together through a bus system 604. It is understood that the bus system 604 is used to implement communication between these components. In addition to a data bus, the bus system 604 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 6 The general designates all buses as Bus System 604.
[0197] The communication interface 601 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0198] Memory 602 is used to store computer programs that can run on processor 603;
[0199] Processor 603, when running the computer program, performs the following:
[0200] Identify the data acquisition tasks to be performed;
[0201] After scheduling the data acquisition task through the APScheduler module, the data acquisition task is executed, and the task execution result is obtained.
[0202] The nanomsg module processes the task execution result and sends the processed target data to the service device.
[0203] It is understood that the memory 602 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 602 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0204] The processor 603 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 603 or by instructions in software form. The processor 603 can be a general-purpose processor, 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, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 602, and the processor 603 reads the information in memory 602 and, in conjunction with its hardware, completes the steps of the above method.
[0205] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0206] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented within the processor or externally.
[0207] Alternatively, as another embodiment, the processor 603 is further configured to perform the steps of the data acquisition method described in any of the foregoing embodiments when running the computer program.
[0208] Based on the above-described composition and hardware structure diagram of user equipment 60, see [link to diagram]. Figure 7 This illustration shows a schematic diagram of the composition structure of a data acquisition system 70 provided in an embodiment of this application. Figure 7 As shown, the data acquisition system 70 may include user equipment 701 and service equipment 702. User equipment 701 may be user equipment 60 as described in the preceding embodiments, and service equipment 702 may be service equipment, server, etc., as described in the preceding embodiments.
[0209] In this embodiment, since the APScheduler module and the nanomsg module are integrated into the same service process through the Twisted framework, when the data acquisition system 70 performs data acquisition, the APScheduler module schedules the data acquisition task and executes it; then the nanomsg module sends the target data obtained after processing the task execution results to the service device. In this way, the data acquisition task can be completed in a single service, and the task cycle can be removed, added, closed, paused or modified without restarting the service. This not only reduces the number of services to be started and saves system resources, but also improves resource utilization.
[0210] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.
[0211] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0212] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0213] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0214] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0215] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0216] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data acquisition method, characterized in that, The method is applied to a user equipment, which includes an APScheduler module and a nanomsg module, and the APScheduler module and the nanomsg module are integrated in the Twisted framework. The method includes: Identify the data acquisition tasks to be performed; After scheduling the data acquisition task through the APScheduler module, the data acquisition task is executed, and the task execution result is obtained. The nanomsg module processes the task execution result and sends the processed target data to the service device. The APScheduler module and the nanomsg module are integrated into the same service process using the Twisted framework.
2. The method according to claim 1, characterized in that, The process of determining the data acquisition task to be executed includes: Obtain system information; Based on the system information, determine the currently running operating system; The data acquisition task corresponding to the operating system is identified as the data acquisition task to be executed.
3. The method according to claim 1, characterized in that, After executing the data acquisition task and obtaining the task execution result, the method further includes: The task execution result is serialized and stored in a cache queue in a preset format; If data exists in the cache queue, the task execution result can be read directly from the cache queue through the nanomsg module.
4. The method according to claim 1, characterized in that, The method further includes: Based on the Twisted framework, enable the reactor mode for waiting events; The APScheduler module is instantiated to obtain the first event in the Twisted framework; The underlying interface of the nanomsg module is called through the preset library, and the nanomsg module is instantiated to obtain the second event in the Twisted framework. Based on the first event and the second event, the APScheduler module and the nanomsg module are placed in the same service process.
5. The method according to claim 4, characterized in that, The method further includes: When the same service process to which the APScheduler module and the nanomsg module belong stops, check whether the input / output IO files of the data acquisition task are closed; If the IO file is not closed properly, then close the IO file.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: When the nanomsg module establishes a communication connection with the service device, it receives task configuration information sent by the service device through the nanomsg module. Obtain the task name and task parameters of the task to be adjusted from the task configuration information; Based on the task name and the task parameters, perform task adjustment operations on the task to be adjusted; wherein, the task adjustment operations include at least one of the following: removing the task, adding a task, closing the task, pausing the task, and modifying the task cycle.
7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: When the nanomsg module does not establish a communication connection with the service device, after processing the task execution result through the nanomsg module, the processed target data is discarded.
8. A data acquisition device, characterized in that, Applied to user equipment, the user equipment includes an APScheduler module and a nanomsg module, and the APScheduler module and the nanomsg module are integrated in the Twisted framework; the data acquisition device includes a determination unit, an execution unit, and a transmission unit, wherein, The determining unit is configured to determine the data acquisition task to be executed. The execution unit is configured to integrate the APScheduler module and the nanomsg module into the same service process through the Twisted framework; after scheduling the data collection task through the APScheduler module, the data collection task is executed to obtain the task execution result; The sending unit is configured to process the task execution result through the nanomsg module and send the processed target data to the service device.
9. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which, when executed by a processor, implements the data acquisition method as described in any one of claims 1 to 7.
10. A data acquisition system, characterized in that, The data acquisition system includes at least user equipment, which includes a memory and a processor. The memory is used to store computer programs that can run on the processor; The processor is configured to execute the data acquisition method as described in any one of claims 1 to 7 when running the computer program.
