Data processing method, apparatus and server
By pre-configuring target files and generating environmental data on standby equipment, the problem of long equipment switching time was solved, achieving high efficiency in equipment switching and continuity in data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA GROUP HOLDING LTD
- Filing Date
- 2020-06-22
- Publication Date
- 2026-05-19
AI Technical Summary
In existing technologies, the equipment switching process is time-consuming, which affects the continuity and efficiency of data processing.
By pre-configuring target files on the backup device and monitoring the status of the primary device, environmental data related to the operating environment of the primary device is generated, and the same operating environment as the primary device is established, ensuring that the backup device can quickly switch over and continue to execute tasks when the primary device fails.
This effectively shortened the waiting time during equipment switching, reduced the impact on original data processing, and ensured the continuity and efficiency of data processing.
Smart Images

Figure CN113900862B_ABST
Abstract
Description
Technical Field
[0001] This manual pertains to the field of Internet technology, and in particular relates to data processing methods, devices, and servers. Background Technology
[0002] In the data processing process, sometimes two processing devices are deployed simultaneously so that if the master device malfunctions, the slave device can be switched to continue the relevant data processing.
[0003] Currently, there is an urgent need for a data processing method that can shorten the waiting time during equipment switching and reduce the impact of equipment switching on the original data processing. Summary of the Invention
[0004] This specification provides a data processing method, apparatus, and server to effectively shorten the waiting time during the process of switching to a second device when the first device malfunctions, and to reduce the impact of the device switching process on the execution of the original target file.
[0005] The data processing method, apparatus, and server provided in this specification are implemented as follows:
[0006] A data processing method includes: a second device monitoring the status of a first device; wherein the first device is configured to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with the target file; the second device is configured to establish a second operating environment in the second device according to the environmental data; the second device obtains execution permissions for the target file and executes the target file in the current second operating environment in the second device according to the execution permissions.
[0007] A data processing method includes: a second device monitoring the status of a first device, wherein the first device is configured to execute a target file in a first operating environment and generate and send environmental data related to the current first operating environment to the second device based on the current first operating environment in the first device; the second device is pre-configured with a target file and is configured to receive and save the environmental data; when the second device determines that the status of the first device is abnormal, it establishes a second operating environment in the second device based on the saved environmental data; the second device obtains and executes the target file in the current second operating environment of the second device according to the execution permissions for the target file.
[0008] A data processing method includes: a first device establishing a first operating environment; the first device executing a target file in the first operating environment; and the first device sending environmental data related to the current first operating environment to a second device during the execution of the target file.
[0009] A data processing method includes: a backup gateway device monitoring the status of a primary gateway device, wherein the primary gateway device is configured to execute a target file in a first operating environment, and at a preset time point, generate and send a corresponding program snapshot to the backup gateway device based on the current first operating environment in the primary gateway device; the backup gateway device is pre-configured with the target file, and is configured to restore a second operating environment in the backup gateway device that is the same as the current first operating environment of the primary gateway device based on the program snapshot; when the backup gateway device determines that the status of the primary gateway device is abnormal, it acquires execution permissions for the target file, and executes the target file in the current second operating environment of the backup gateway device based on the execution permissions.
[0010] A data processing apparatus includes: a monitoring module for monitoring the status of a first device; wherein the first device is configured to execute a target file in a first operating environment and send environmental data related to the current first operating environment to a second device; the second device is pre-configured with the target file; the second device is configured to establish a second operating environment in the second device based on the environmental data; and a processing module for obtaining execution permissions for the target file and executing the target file in the current second operating environment in the second device based on the execution permissions.
[0011] A server includes a processor and a memory for storing processor-executable instructions, wherein the processor, when executing the instructions, enables a second device to monitor the status of a first device; wherein the first device is configured to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with the target file; the second device is configured to establish a second operating environment in the second device based on the environmental data; the second device obtains execution permissions for the target file and executes the target file in the current second operating environment in the second device based on the execution permissions.
[0012] A computer-readable storage medium storing computer instructions thereon, wherein when the instructions are executed, a second device monitors the status of a first device; wherein the first device is configured to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with the target file; the second device is configured to establish a second operating environment in the second device based on the environmental data; the second device obtains execution permissions for the target file and executes the target file in the current second operating environment in the second device based on the execution permissions.
[0013] The data processing method, apparatus, and server provided in this specification allow the first device to generate and send environment data related to the current first operating environment to a second device during the execution of a target file. This serves as a backup of the current first operating environment in the first device. The second device, pre-configured with the same target file, can establish a corresponding second operating environment based on the aforementioned environment data, without executing the target file. Simultaneously, the second device can monitor the status of the first device and, if granted execution permissions for the target file, promptly continue executing the target file within the pre-established second operating environment. This allows for efficient switching of the second device to take over from the first device and continue executing the original target file when switching is required, effectively shortening the waiting time during the switching process and reducing the impact of the device switching process on the execution of the original target file. Attached Figure Description
[0014] To more clearly illustrate the embodiments of this specification, the accompanying drawings used in the embodiments will be briefly introduced below. The drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 This is a schematic diagram of an embodiment of the system architecture that applies the data processing method provided in the embodiments of this specification;
[0016] Figure 2 This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0017] Figure 3 This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0018] Figure 4This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0019] Figure 5 This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0020] Figure 6 This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0021] Figure 7 This is a flowchart illustrating a data processing method provided in one embodiment of this specification;
[0022] Figure 8 This is a flowchart illustrating a data processing method provided in one embodiment of this specification;
[0023] Figure 9 This is a schematic diagram illustrating one embodiment of the data processing method provided in the embodiments of this specification, applied in a scenario example.
[0024] Figure 10 This is a schematic diagram of the structural composition of a server provided in one embodiment of this specification;
[0025] Figure 11 This is a schematic diagram of the structural composition of a data processing apparatus provided in one embodiment of this specification. Detailed Implementation
[0026] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0027] This specification provides a data processing method, which can be specifically applied to a system architecture including a first device and a second device. For details, please refer to... Figure 1 As shown. The first and second devices can be connected via wired or wireless means.
[0028] In practice, the first device can establish a first runtime environment in its memory and execute a target file (e.g., a target program to be executed, file data to be processed, or a control scheme to be executed) within the first runtime environment. While the first device is executing the target file, it will generate environment data associated with the current first runtime environment and send the environment data to the second device.
[0029] The second device can be configured with the same target file. The second device can receive and, based on the environmental data sent by the first device, establish a corresponding second runtime environment in its memory. Simultaneously, the second device will monitor the status of the first device.
[0030] After acquiring execution permissions for the target file, the second device can take over from the first device and continue executing the target file within the pre-established second runtime environment. This allows for efficient switching of the second device to take over from the first device and continue executing the original target file when a switching requirement arises. The waiting time during the device switching process reduces the impact of the switching process on the execution of the original target file.
[0031] In this embodiment, the first device can specifically be a master device, and the second device can specifically be a slave device or a backup device. Specifically, the first and second devices can be data processing devices capable of data transmission and data processing. More specifically, the first and second devices can be electronic devices with data computation, storage, and network interaction functions. For example, the first and second devices can be servers, gateway devices, or processors. Alternatively, the first and second devices can also be software programs running on the electronic device that support data processing, storage, and network interaction. For example, an application running on a server.
[0032] In a specific scenario example, see Figure 2 As shown, the data processing methods provided in the embodiments of this specification can be used for edge computing in IoT application scenarios.
[0033] In this scenario example, a first gateway device and a second gateway device can be deployed simultaneously on the local side of the factory's product production line. The first gateway device acts as the primary gateway device (or master device), and the second gateway device acts as a backup gateway device (or slave device). The first and second gateway devices can interact via wired or wireless means. The first gateway device enters the edge computing network and connects to the production line's control equipment and the cloud server.
[0034] In this scenario example, the cloud server can generate a corresponding control scheme based on the production line's configuration parameters, overall health status, and target quantity of products to be produced, and then send this control scheme to the first gateway device. This control scheme can include specific control strategies for various different operating conditions of the production line. The first gateway device receives and saves the control scheme sent by the cloud server (as a target file). After receiving the control scheme, the first gateway device sends the same control scheme to the second gateway device, so that the second gateway also saves the control scheme.
[0035] Since the first gateway device is deployed on the local side of the production line, it can conveniently and efficiently collect operating parameters related to the specific operating status of the current production line. For example, the conveyor speed of the current production line, the quality inspection pass rate of the products on the current production line, and the specific load of the relevant equipment on the current production line, etc.
[0036] Furthermore, the first gateway device can execute the control scheme generated by the cloud server locally on the production line based on the collected operating parameters, thereby enabling more precise control over the production of products on the production line.
[0037] Specifically, the first gateway device can construct a first runtime environment in memory for executing the target file. Simultaneously, based on the latest collected operating parameters, it can calculate and determine the current operating status of the production line. Then, based on the aforementioned first runtime environment, it can execute the control strategy corresponding to the current operating status in the control scheme (hereinafter referred to as the target file for ease of discussion), thereby controlling the control equipment on the production line to timely and effectively control the production of products on the production line.
[0038] The aforementioned first operating environment may include relevant resources and data involved when the first gateway device executes the target file; and as the target file is executed, the relevant resources and parameters contained in the aforementioned first operating environment will also change accordingly.
[0039] In this scenario example, during the execution of the aforementioned control scheme to control product production on the production line, the first gateway device will detect whether a preset time point has occurred. For example, it will detect whether the process in the first gateway device used to execute the control scheme is in a non-running state.
[0040] Typically, when a device or system calls a process to execute a specific file or program, it does so using time slices. After a process completes one time slice and before entering the next, there is a short time interval, for example, 1 to 10 milliseconds. During this time interval, the process is in a non-running state.
[0041] In this scenario example, the time point when the process executing the target file in the first gateway device is in a non-running state can be used as the preset time point. In specific implementation, when the first gateway device detects the occurrence of the preset time point, it can generate a corresponding program snapshot based on the current first running environment on the first gateway device. Because the above-mentioned time point is selected as the preset time point for generating the program snapshot, the process of generating the program snapshot does not require temporarily pausing the execution of the target file on the first gateway device, and will not interfere with or affect the normal execution of the target file by the first gateway device. Of course, it should be noted that the preset time points listed above are only illustrative. In specific implementation, other suitable time points can be selected as the preset time point for generating the program snapshot, depending on the specific circumstances. For example, the first gateway device can also use the gap between executing the current part of the target file and executing the next part as the above-mentioned preset time point to generate the program snapshot.
[0042] Specifically, the aforementioned program snapshot can be understood as a copy of the relevant resources and data involved in the execution of the target file by the first gateway device. These resources and data can then be used to reconstruct and restore the corresponding first runtime environment.
[0043] Specifically, the aforementioned program snapshot includes not only memory parameters involved when the first gateway device executes the target file—such as thread information, virtual memory usage, and signal information used by the process—but also association data between the first gateway device and other external devices and / or networks during the execution of the target file. This includes network connections between the first gateway device and the cloud server, communication interfaces between the first gateway device and production line control equipment, network sockets (also known as "sockets," a convention or method for communication between computers), and IP addresses used by the first gateway device when interacting with external systems. Furthermore, the program snapshot may also include information related to the execution status of the target file, such as the execution progress.
[0044] In this scenario example, to improve the efficiency of obtaining program snapshots and thus enhance overall processing efficiency, while further reducing the impact of the snapshot acquisition process on the execution of the target file, the first gateway device can use a memory copy method to efficiently generate the corresponding program snapshot based on the current runtime environment on the first gateway device. This effectively utilizes the device's high memory throughput, enabling the corresponding program snapshot to be copied in a shorter time, reducing processing overhead and improving the efficiency of program snapshot generation.
[0045] Specifically, the first gateway device can copy the CPU register information, process element information, and virtual memory data in the first runtime environment to a newly opened memory space on the first gateway device to obtain backup information about the CPU registers, process elements, and virtual memory data of the first runtime environment, which can be used as corresponding program snapshots.
[0046] Accordingly, the program snapshots mentioned above may specifically include backup data such as backup information of the CPU registers, process metadata, and virtual memory of the first runtime environment. It should be noted, however, that the program snapshots listed above are merely illustrative. In actual implementation, depending on the specific circumstances and processing requirements, the program snapshots may further include backup data of other contents.
[0047] In this scenario example, the information in the aforementioned CPU registers may specifically include the data content of registers in the first runtime environment when the first gateway device executes the target file. Part of the data in the aforementioned CPU registers can be used to reconstruct the current progress position of the first gateway device executing the target file.
[0048] The aforementioned process metadata can be understood as information related to the process used to execute the target file in the first gateway device. Specifically, the aforementioned process metadata may be information about the kernel task_struct structure (task_struct, a process control block in the Linux kernel) in the process space of the first runtime environment. Specifically, the aforementioned process metadata may include: thread information (e.g., thread_info, a data structure related to process descriptors), the virtual memory table used by the process (e.g., mm_struct, a data structure representing memory descriptors), tty information related to the process (e.g., tty_struct, a structure in the TTY driver architecture), signal information held by the process (e.g., signal_struct), file handles and / or network handles (e.g., files_struct), virtual memory partition address information, etc.
[0049] Of course, the process metadata listed above is only an illustrative example. In actual implementation, depending on the specific circumstances and processing requirements, the process metadata may further include information related to the files currently opened by the process, such as the inode of the target file and network sockets. This data can be used to reconstruct the disk files, memory files, and network connection parameters opened by the process of the first gateway device when executing the target file.
[0050] The aforementioned virtual memory data can be understood as data stored in the virtual memory of the first runtime environment. This portion of data is typically relatively large. In practice, the virtual memory data can be located based on the virtual memory table (mm_struct) used by the process in the process metadata.
[0051] In this scenario example, during the execution of the target file, the first gateway device can generate and send multiple corresponding program snapshots according to preset time points.
[0052] For specific implementation, please refer to Figure 3 As shown, when the first gateway device generates a program snapshot for the first time, it can copy the full information of the CPU registers, the full information of the process elements, and the full data of the virtual memory in the current first running environment to a new memory space using the memory copying method described above, thereby obtaining a first type of program snapshot. The resulting first type of program snapshot can contain a full backup of the CPU registers, the full backup of the process elements, and the full backup of the virtual memory.
[0053] Furthermore, the first gateway device can save the aforementioned first type of program snapshot as a disk file format, and then, based on the connection with the second gateway device, synchronously transmit the first type of program snapshot in disk file format to the second gateway device via, for example, NFS or a file synchronization tool like rsync. Saving and transmitting program snapshots in disk file format avoids the risk of loss due to sudden interruptions during transmission, thus improving the reliability of program snapshot transmission.
[0054] After receiving the aforementioned first type of program snapshot, the second gateway device can refer to... Figure 4 As shown, without executing the target file, a second operating environment identical to the first operating environment of the current first gateway device is first created and restored in the memory of the second gateway device based on the above program snapshot.
[0055] Specifically, the second gateway device first extracts the backup information of the CPU registers from the aforementioned program snapshot, and then reconstructs the corresponding CPU register information in the second device's memory based on this backup information. For example, the second gateway device can restore the backup information of the CPU registers to its kernel memory.
[0056] Furthermore, the second gateway device can parse and extract backup information of process elements from the aforementioned program snapshot, and reconstruct the corresponding process space in the memory of the second device based on the backup information of the process elements. For example, the second gateway device can restore the backup information of process elements, including thread information (e.g., thread_info), the virtual memory table used by the process (e.g., mm_struct), the signal information held by the process (e.g., signal_struct), file and / or network handles (e.g., files_struct), etc., to the kernel memory space of the second gateway device to reconstruct the corresponding task_struct structure.
[0057] Finally, the second gateway device can parse and extract the backup data of virtual memory from the aforementioned program snapshot, and reconstruct the corresponding virtual memory space in its own memory based on this backup data. This allows it to establish a second runtime environment identical to the first gateway device's current runtime environment. For example, it can reconstruct the virtual memory content in the second gateway device using the backup data and the virtual memory table in the process metadata. In this way, the second gateway device can prepare a second runtime environment identical to the first gateway device's current runtime environment without executing the target file.
[0058] After the first gateway device sends the first type of program snapshot, the process enters the next time slice to continue executing the target file. When the next preset time point is detected, the first gateway device can generate the corresponding second type of program snapshot according to the current first operating environment.
[0059] For details, please refer to Figure 5As shown, considering that the amount of data contained in the full information of CPU registers and the full information of process elements is relatively small, the first gateway device can copy the full backup information of CPU registers and the full backup information of process elements in the current first running environment through memory copying, in the same way as generating the first type of program snapshot. When copying virtual memory data, considering that the amount of data in the full virtual memory is relatively large, in specific implementation, it is not necessary to copy the full virtual memory data. Instead, based on the virtual memory data in the first running environment when the program snapshot was last generated and the virtual memory data in the current first running environment, differential processing is performed, and only the differential data between the two virtual memory data is copied. This is then compressed according to memory segments to obtain the differential backup data of virtual memory in the current first running environment. Then, based on the full backup information of CPU registers, the full backup information of process elements, and the differential backup data of virtual memory in the current first running environment, a second type of program snapshot with a relatively smaller amount of data can be obtained. This can effectively reduce the amount of data processing involved in generating a new program snapshot after the first type of program snapshot, further reducing the time consumed in generating program snapshots and improving the efficiency of obtaining new program snapshots.
[0060] After obtaining the second type of program snapshot, the first gateway device can synchronously send the second type of program snapshot to the second gateway device.
[0061] Upon receiving a second type of program snapshot, the second gateway device can extract and update the CPU information in the existing second runtime environment previously established based on the first type of program snapshot, using the backup information of the CPU registers in the second type of program snapshot. It can also extract and update the process space in the existing second runtime environment, using the backup information of the process elements in the second type of program snapshot. Furthermore, it can extract and update the virtual memory space in the existing second runtime environment, using the differential backup data of the virtual memory in the second type of program snapshot. This allows for efficient updates to the existing second runtime environment, ensuring that the current second runtime environment on the second gateway device remains synchronized with the current first runtime environment on the first gateway device.
[0062] Following the above method, during the subsequent execution of the target file, the first gateway device will continue to generate and send corresponding new second-type program snapshots to the second gateway device. The second gateway device can then update its second runtime environment based on these newly received second-type program snapshots, ensuring good synchronization between the second runtime environment on the second gateway device and the first runtime environment on the first gateway device.
[0063] In this scenario example, while the first gateway device is executing the target file, the second gateway device will also monitor the status of the first gateway device.
[0064] For example, the second gateway device can send a test signal (e.g., a heartbeat signal) to the test channel (e.g., a critical communication channel in the first gateway device) of the first gateway device at preset time intervals (e.g., every 10 seconds), and detect whether it receives a response signal from the first gateway device in response to the test signal within a preset time threshold (e.g., 20 seconds).
[0065] If the second gateway device receives a response signal from the first gateway device within a preset time period threshold, it can be determined that the first gateway device is in normal condition. In this case, the first gateway device can continue to act as the primary gateway device to execute the target file, while the second gateway device continues to act as the backup gateway device to obtain and update the second runtime environment based on the program snapshot sent by the first gateway device without executing the target file.
[0066] Conversely, if the second gateway device does not receive a response signal from the first gateway device within a preset time threshold, it can be determined that the first gateway device is in an abnormal state. In this case, to ensure continued and relatively precise control over product production on the production line, the second gateway device can acquire execution permissions for the target file. Furthermore, based on these execution permissions, the second gateway device can act as the new master gateway device, taking over from the first gateway device to continue executing the target file.
[0067] For details, please refer to Figure 6 As shown, the second gateway device can load the code and data areas into memory space based on the pre-acquired target file and the pre-established second runtime environment. Then, based on the execution permissions, it can load the target file into the second runtime environment to rebuild a process for that target file on the second device. Furthermore, the second gateway device can use this process to start and continue executing the target file in the second runtime environment, based on the progress position of the first gateway device's execution of the target file.
[0068] Since the second gateway device executes the target file in a second runtime environment identical to the first runtime environment, established based on a program snapshot, this second runtime environment not only contains the memory parameters involved in the execution of the target file by the first gateway device itself and data related to the execution status of the target file, but also includes the pre-processed connection relationships between the first gateway device and other external devices and / or external networks during the execution of the target file. For example, in the second runtime environment, based on the connection relationships between the first gateway device and other external devices and / or external networks, the network connection between the second gateway device and the cloud server, the communication interface between the second gateway device and the control equipment of the production line, the network socket of the second gateway device, the IP address used by the second gateway device when interacting with the outside world, etc., have already been established.
[0069] Based on the aforementioned second operating environment, the second gateway device not only does not need to spend time re-establishing the internal environment related to the execution target file within the second gateway device, but also does not need to spend time re-establishing the external environment related to the execution target file outside the second gateway device. Thus, it can efficiently replace the malfunctioning first gateway device through the already established second operating environment, connect to the cloud server and the production line control equipment, and continue the execution progress of the first gateway device in this second operating environment, continuing to execute the target file, thereby continuing to effectively and precisely control the product production on the production line.
[0070] See Figure 7 As shown in the embodiments of this specification, a data processing method is provided. In specific implementation, the method may include the following:
[0071] S701: The second device monitors the status of the first device, wherein the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with a target file; the second device is used to establish a second operating environment in the second device according to the environmental data.
[0072] In some embodiments, the first device and the second device may specifically be electronic devices with data processing capabilities, such as servers, gateway devices, processors, etc. Of course, the first device and the second device may also be application programs running on the aforementioned electronic devices, responsible for data processing. Specifically, the first device and the second device may also be gateway devices deployed on the terminal device side in an IoT scenario, used to participate in relevant edge computing locally on the terminal device.
[0073] In some embodiments, the above data processing method can be specifically applied to the second device side.
[0074] In some embodiments, the first device can specifically be a master device, and the second device can specifically be a slave device. Typically, when the first device is functioning normally, it connects to the system or network to execute the target file and participate in data processing. If the first device malfunctions, the second device will switch to the system or network as a backup device to execute the target file and participate in data processing. Of course, in specific implementations, the second device can be selected as the master device and the first device as the slave device, depending on the specific circumstances. This specification does not limit this choice.
[0075] In some embodiments, the target file described above may specifically be an executable program instruction, a data processing task to be processed, or file data to be processed. Of course, the target files listed above are merely illustrative. In specific implementations, depending on the specific application scenario and processing requirements, the target file may also include data of other content or forms. This specification does not limit this.
[0076] In some embodiments, when the first device executes the target file, it first establishes the runtime environment required for executing the target file, denoted as the first runtime environment. This first runtime environment may include relevant resources and data involved in the execution of the target file by the first device.
[0077] Specifically, the aforementioned first runtime environment may include: the internal environment required by the first device when executing the target file (e.g., the memory environment inside the first device), and the external environment required by the first device when executing the target file (e.g., the IP address used by the first device, the communication interface between the first device and the cloud server, terminal devices, etc.). It should be noted that the resources and data contained in the aforementioned first runtime environment will change dynamically as the target file is executed.
[0078] In some embodiments, the execution of the target file by the first device in the first operating environment may specifically include: in the first operating environment, the first device starts and calls the corresponding process to execute the target file.
[0079] In some embodiments, during the execution of a target file in a first operating environment, the first device may generate and send environmental data related to the current first operating environment to the second device based on the current first operating environment.
[0080] In some embodiments, as specifically implemented, refer to Figure 7 As shown, the first device can send environmental data related to the current first operating environment at a preset time point.
[0081] In some embodiments, the aforementioned preset time point may specifically include: the time point when the process state of the process executing the target file in the first device is in a non-running state, etc. Of course, it should be noted that the preset time points listed above are only illustrative. In specific implementations, other suitable time points can be selected as the preset time points depending on the specific circumstances. For example, the gap time between executing the current part of the target file and executing the next part can also be used as the aforementioned preset time point, etc.
[0082] In some embodiments, the process by which the first device executes the target file through a process can be implemented using time slices. Specifically, during the time slice allocated to the process responsible for executing the target file, the process is in a running state and executes the target file. When the time slice ends, the process enters a non-running state, waiting for the next time slice to be allocated to resume the running state and continue executing the target file.
[0083] There is typically a short time interval between two time slices, for example, a time interval of 1 to 10 milliseconds. During this time interval, the process is in a non-running state.
[0084] In this embodiment, the time point when the aforementioned process is in a non-running state (e.g., the start time point of the aforementioned time interval) can be used as a preset time point. A program snapshot corresponding to the first operating environment of the first device is obtained at this time point. This ensures that the process does not need to be paused when obtaining the program snapshot, and will not interfere with or affect the normal execution of the target file on the first device.
[0085] In some embodiments, during the execution of the target file by the first device in the first operating environment, the device can detect whether a preset time point has occurred by detecting whether the process state of the process responsible for executing the target file in the first device is in a non-running state. When it is determined that the process state of the process is in a non-running state, it can be determined that a preset time point has occurred. Then, the first device can obtain the corresponding program snapshot according to the first operating environment.
[0086] In some embodiments, the aforementioned environmental data can be specifically understood as parameter data used to describe the operating environment on which the first device executes the target file.
[0087] In some embodiments, the aforementioned environmental data may specifically include program snapshots. Of course, in specific implementations, depending on the specific circumstances, the aforementioned environmental data may also include other parameter data that can describe the runtime environment when the first device executes the target file. For example, the aforementioned environmental data may also include log records of the first device executing the target file.
[0088] In some embodiments, the aforementioned program snapshot can be specifically understood as a copy of the relevant resources, data, etc., involved in the execution of the target file on the first device. The relevant resources, data, etc., involved in the execution of the target file can be used to reconstruct and restore the corresponding first runtime environment.
[0089] In some embodiments, it should be noted that the program snapshot described above includes not only memory parameters involved when the first device executes the target file (e.g., thread information, virtual memory usage, and signal information used by the process during execution), but also association data between the first device and other external devices and / or external networks during the execution of the target file. This includes network connections between the first device and a cloud server, communication interfaces between the first device and terminal devices, network sockets of the first device, and IP addresses used by the first device when interacting with external systems. Furthermore, the program snapshot may also include information related to the execution status of the target file, such as the execution progress.
[0090] In some embodiments, the program snapshot described above may specifically include one or more of the following listed data: backup information of CPU registers, backup information of process bytes, backup data of virtual memory, etc. Of course, the program snapshots listed above are merely illustrative. In specific implementations, the program snapshot may also include other content or forms of data, depending on the specific circumstances. This specification does not limit this.
[0091] In some embodiments, the first device can obtain information from the CPU registers in the first operating environment as backup information for the CPU registers, information from the process elements in the first operating environment as backup information for the process elements, and virtual memory data in the first operating environment as backup data for the virtual memory. Then, based on the aforementioned backup information for the CPU registers, backup information for the process elements, and backup data for the virtual memory, a corresponding program snapshot can be obtained.
[0092] In some embodiments, when the first device is implemented, the backup information of the CPU registers, the backup information of the process elements, and the backup data of the virtual memory can be obtained from the first operating environment through memory copying to obtain the corresponding program snapshot. This effectively utilizes the device's large memory throughput, allowing for the copying of the corresponding program snapshot in a shorter time, reducing processing overhead and improving the efficiency of program snapshot generation.
[0093] Specifically, the first device can copy the CPU register information, process element information, and virtual memory data in the first runtime environment to a newly opened memory space on the first device to obtain backup information about the CPU registers, process elements, and virtual memory data of the first runtime environment, which can then be used as corresponding program snapshots.
[0094] In some embodiments, the information in the CPU registers may specifically include the data content of registers in the first runtime environment when the first device executes the target file. Part of the data in the CPU registers may be used to reconstruct the current progress position of the first device executing the target file.
[0095] The aforementioned process metadata can be understood as information related to the process used to execute the target file in the first device. Specifically, the aforementioned process metadata may be information about the kernel task_struct structure of the process space in the first runtime environment. Specifically, the aforementioned process metadata may include: thread information (e.g., thread_info), the virtual memory table used by the process (e.g., mm_struct), tty information related to the process (e.g., tty_struct), signal information held by the process (e.g., signal_struct), file handles and / or network handles (e.g., files_struct), virtual memory partition address information, etc.
[0096] Of course, the process metadata listed above is only an illustrative example. In actual implementation, depending on the specific circumstances and processing requirements, the process metadata may further include information related to the files currently opened by the process, such as the inode of the target file and network sockets. This data can be used to reconstruct the disk files, memory files, and network connection parameters involved when the process on the first device executes the target file.
[0097] The aforementioned virtual memory data can be understood as data stored in the virtual memory of the first runtime environment. This portion of data is typically relatively large. In practice, the virtual memory data can be located based on the virtual memory table used by the process within the process metadata.
[0098] In some embodiments, when the first device generates a program snapshot for the first time, it can obtain full backup information of CPU registers, full backup information of process elements, and full backup data of virtual memory from the current first operating environment to generate a corresponding program snapshot, denoted as a first type of program snapshot. Accordingly, the aforementioned first type of program snapshot may include data such as full backup information of CPU registers, full backup information of process elements, and full backup data of virtual memory.
[0099] In some embodiments, considering that the virtual memory data itself is relatively large, in order to reduce the amount of data processing involved in the program snapshot generation process and improve the efficiency of program snapshot generation, after the first program snapshot is generated for the first time, when the first device generates a program snapshot again, it is not necessary to obtain the full backup data of the virtual memory in the current first running environment to generate the corresponding program snapshot.
[0100] In some embodiments, specifically, the first device can, based on the virtual memory data in the current first runtime environment and the virtual memory data in the first runtime environment at the time the program snapshot was last generated, perform differential processing to copy only the differential data of virtual memory between the current first runtime environment and the first runtime environment at the time the program snapshot was last generated. This data is then compressed according to memory segments to obtain differential backup data of virtual memory in the current first runtime environment. Furthermore, based on this smaller virtual memory backup data, combined with the acquired backup information of CPU registers and process elements in the current first runtime environment, a corresponding program snapshot can be generated more efficiently, referred to as a second type of program snapshot. Correspondingly, the second type of program snapshot may not contain a full backup of virtual memory data, but rather a differential backup of virtual memory data.
[0101] In some embodiments, the first device may generate a corresponding program snapshot at a preset time point, according to the above-described manner, based on the current first operating environment in the first device. Furthermore, the first device may synchronously send the program snapshot as environmental data related to the current first operating environment to the second device.
[0102] In some embodiments, the first device can directly send the program snapshot to the second device. Alternatively, the first device can first save the program snapshot as a disk file and then send the disk file format program snapshot to the second device. This can prevent the program snapshot from being lost during transmission and improve the reliability of data processing.
[0103] In some embodiments, the second device may receive the aforementioned environmental data and establish a corresponding second operating environment in the second device based on the aforementioned environmental data.
[0104] In some embodiments, the second operating environment may specifically include an operating environment that is the same as the first operating environment in the first device.
[0105] In some embodiments, the second device receives a program snapshot sent by the first device. Based on the program snapshot, the second device can create and restore a second operating environment identical to the current first operating environment of the first device.
[0106] In some embodiments, when the program snapshot received by the second device is a first type of program snapshot, the second device can reconstruct the CPU register information in its memory based on the backup information of the CPU registers in the program snapshot; reconstruct the process space in its memory based on the backup information of the process elements in the program snapshot; and reconstruct the virtual memory space in its memory based on the backup data of the virtual memory in the program snapshot, so as to establish a second operating environment in the second device that is the same as the current first operating environment of the first device.
[0107] In some embodiments, when the program snapshot received by the second device is a second type of program snapshot, the second device can update the CPU information in the existing second running environment according to the backup information of the CPU registers in the program snapshot; update the process space in the existing second running environment according to the backup information of the process elements in the program snapshot; and update the virtual memory space in the existing second running environment according to the backup data of the virtual memory in the program snapshot, so as to establish a second running environment in the second device that is the same as the current first running environment of the first device.
[0108] In this way, the second operating environment on the second device can be synchronized with the first operating environment on the first device during the execution of the target file on the first device.
[0109] In some embodiments, the second device may be pre-configured with the same target file as the first device. Alternatively, the first device may obtain the target file and then send it separately to the second device.
[0110] In some embodiments, during the execution of the target file by the first device, the second device monitors whether the status of the first device is normal. Based on the monitoring results, if the second device determines that the status of the first device is normal, it will not execute the target file.
[0111] In some embodiments, the second device may monitor the status of the first device in a variety of ways to determine whether the first device is in a normal state.
[0112] For example, the second device can send a test signal to the test channel of the first device at preset time intervals and detect whether it receives a response signal from the first device in response to the test signal within a preset time threshold. If a response signal from the first device is detected within the preset time threshold, it can be determined that the first device is in a normal state. Conversely, if no response signal is received from the first device beyond the preset time threshold, it can be determined that the first device is in an abnormal state.
[0113] For example, the second device can collect metrics from the first device, such as CPU utilization. Based on these metrics and corresponding preset risk thresholds, it determines whether the first device is functioning correctly. If the metrics on the first device exceed the preset risk threshold, the device is considered abnormal. Conversely, if the metrics are less than or equal to the preset risk threshold, the device is considered functioning correctly. It should be noted that the methods described above for the second device to monitor the first device's status are merely illustrative. In practice, depending on the specific circumstances and processing requirements, the second device can employ other suitable methods to monitor the first device's status. Furthermore, the first device can also monitor its own status using the methods described above.
[0114] S702: The second device obtains execution permissions for the target file, and executes the target file in the current second operating environment of the second device according to the execution permissions.
[0115] In some embodiments, the aforementioned execution permission can be understood as a credential for executing a target file.
[0116] In some embodiments, the second device described above may specifically obtain execution permissions for the target file when there is a switching requirement.
[0117] In some embodiments, the aforementioned situations requiring switching may specifically include detecting an abnormal state of the first device, receiving a user-initiated switching command, or receiving a switching request initiated by the first device, etc. Of course, the situations requiring switching listed above are merely illustrative. In specific implementations, depending on the specific application scenario, the aforementioned situations requiring switching may also include other types of situations.
[0118] In some embodiments, a case where a switchover requirement is triggered by detecting an abnormal state of the first device is taken as an example. Upon determining that the first device's state is abnormal, the second device acquires execution permissions for the target file and, based on these permissions, executes the target file in the second device's current second operating environment.
[0119] In some embodiments, if the second device determines that the state of the first device is abnormal through monitoring, it can obtain execution permissions for the target file and, based on the execution permissions, take over as the master device from the first device to continue pointing to the target file in the second operating environment that the second device has established in advance.
[0120] In some embodiments, specifically, when the first device is functioning normally, the first device possesses the execution permission and executes the target file in a first runtime environment on the first device according to the execution permission, while the second device does not possess the execution permission. If the second device detects an abnormality in the status of the first device, the second device can obtain the execution permission and execute the target file in a second runtime environment on the second device according to the execution permission.
[0121] In some embodiments, when implemented, the second device can load the code area and data area into the memory space based on the target file obtained in advance and the second running environment that has been established in advance and synchronized with the first running environment on the first device. Then, based on the execution permissions, the second device can use the progress position of the target file executed by the first device as the starting position to continue executing the target file in the second running environment.
[0122] Since the second device executes the target file in a second runtime environment established based on a program snapshot, which is identical to the first runtime environment on the first device, this second runtime environment not only contains the memory parameters involved in the execution of the target file by the first device itself and data related to the execution status of the target file, but also includes the pre-processed connection relationships between the first device and other external devices and / or external networks during the execution of the target file. For example, in the second runtime environment, based on the connection relationships between the first device and other external devices and / or external networks, the network connection between the second device and the cloud server, the communication interface between the second device and the control equipment of the production line, the IP address used by the second device when interacting with the outside world, etc., have already been established.
[0123] Therefore, based on the aforementioned second operating environment, the second device not only does not need to spend time rebuilding its internal environment related to the execution target file, but also does not need to spend time rebuilding its external environment related to the execution target file. Thus, it can efficiently replace the malfunctioning first device through the already established second operating environment, accessing a data processing system or network (e.g., connecting to a cloud server and terminal devices), and continuing the execution progress of the first device within this second operating environment to execute the target file. This allows it to quickly take over from the first device to continue executing the target file, participate in edge computing in IoT scenarios, and perform corresponding control over the connected terminal devices.
[0124] In this embodiment, during the execution of the target file, the first device generates and sends a program snapshot to the second device at a preset time point, based on the current first operating environment, to back up the current first operating environment. The second device, pre-configured with the same target file, can restore a second operating environment identical to the first device's current first operating environment based on the program snapshot, without executing the target file. Simultaneously, the second device monitors the status of the first device. If it determines that the first device is in an abnormal state, it can promptly obtain and, based on the execution permissions for the target file, continue executing the target file in the pre-established second operating environment on the second device. This allows for efficient switching to the second device to continue executing the target file when the first device malfunctions, effectively shortening the waiting time during device switching and reducing the impact of the device switching process on the original target file execution.
[0125] In some embodiments, the preset time point may specifically include the time point when the process state of the process executing the target file in the first device is in a non-running state. Of course, in specific implementations, multiple time points can be further selected from the above-mentioned time points when the process state is in a non-running state, for example, equally spaced time points, as the above-mentioned preset time nodes.
[0126] In some embodiments, the program snapshot may specifically include: backup information of CPU registers, backup information of process metadata, backup data of virtual memory, etc. Of course, the program snapshots listed above are merely illustrative. In specific implementations, depending on the specific circumstances, the program snapshot may also include other resources or data related to the execution of the target file.
[0127] In some embodiments, when the program snapshot belongs to a first type of program snapshot, the first type of program snapshot includes the program snapshot first generated and sent by the first device, and the backup data of the virtual memory includes the full backup data of the virtual memory of the current first runtime environment.
[0128] In this embodiment, the aforementioned first type of program snapshot can be specifically understood as the program snapshot generated by the first device for the first time.
[0129] In this embodiment, when the first device generates a program snapshot for the first time, that is, a first type of program snapshot, the first device can obtain the full backup information of the CPU registers, the full backup information of the process element, and the full backup data of the virtual memory according to the first device's current first operating environment to generate the corresponding first type of program snapshot.
[0130] In some embodiments, when the program snapshot belongs to the second type of program snapshot, the second type of program snapshot includes a program snapshot generated and sent by the first device after the first type of program snapshot, and the backup data of the virtual memory includes differential backup data of the virtual memory obtained based on the virtual memory data of the current first operating environment and the virtual memory data of the first operating environment when the program snapshot was last generated.
[0131] In this embodiment, the aforementioned second type of program snapshot can be specifically understood as a program snapshot generated by the first device after generating the first type of program snapshot. For example, a program snapshot generated a second time by the first device, a program snapshot generated a third time, etc.
[0132] In this embodiment, when the first device generates a second type of program snapshot, the first device can obtain backup information of CPU registers, backup information of process elements, and differential backup data of virtual memory based on the current first operating environment of the first device to generate the corresponding second type of program snapshot. This effectively reduces the amount of virtual memory data to be obtained when generating the program snapshot, thus improving the efficiency of program snapshot generation.
[0133] In some embodiments, the backup information of the CPU registers includes differential backup information of the CPU registers and / or differential backup information of the process element.
[0134] In this embodiment, when generating the second type of program snapshot, differential backup information of the CPU register and / or differential backup information of the process element can be obtained instead of full backup information of the CPU register and / or full backup information of the process element to generate the corresponding program snapshot. This can further reduce the amount of data processing involved in generating the program snapshot and further improve the efficiency of generating the program snapshot.
[0135] In this embodiment, the differential backup information of the CPU register and the differential backup information of the process element can be obtained by referring to the method of obtaining differential backup data of virtual memory. For example, the corresponding differential backup information of the CPU register and the differential backup information of the process element can be obtained by combining the CPU register information and the process element information of the first running environment when the program snapshot was generated.
[0136] In some embodiments, the above-mentioned generation of a corresponding program snapshot based on the current first operating environment may specifically include the following: the first device, based on the current first operating environment, obtains the backup information of the CPU register, the backup information of the process element, and the backup data of the virtual memory through memory copying; and generates a corresponding program snapshot based on the backup information of the CPU register, the backup information of the process element, and the backup data of the virtual memory.
[0137] In some embodiments, the above-mentioned sending of the corresponding program snapshot to the second device may include the following: the first device saves the program snapshot as a disk file format; and sends the program snapshot in disk file format to the second device.
[0138] In some embodiments, when the program snapshot is a first type of program snapshot, a second running environment identical to the current first running environment of the first device is established in the second device based on the program snapshot. Specifically, this may include: the second device reconstructing CPU register information in its memory based on backup information of CPU registers in the program snapshot; the second device reconstructing process space in its memory based on backup information of process elements in the program snapshot; and the second device reconstructing virtual memory space in its memory based on backup data of virtual memory in the program snapshot, so as to establish a second running environment identical to the current first running environment of the first device in the second device.
[0139] In some embodiments, when the program snapshot is a second type of program snapshot, a second running environment identical to the current first running environment of the first device is established in the second device based on the program snapshot. Specifically, this may include the following: the second device updates the CPU information in the existing second running environment based on the backup information of the CPU registers in the program snapshot; the second device updates the process space in the existing second running environment based on the backup information of the process elements in the program snapshot; and the second device updates the virtual memory space in the existing second running environment based on the backup data of the virtual memory in the program snapshot, so as to establish a second running environment identical to the current first running environment of the first device in the second device.
[0140] In some embodiments, the first device may specifically include a main gateway device participating in edge computing in an IoT application scenario, such as a first gateway device. Correspondingly, the second device may specifically include a backup gateway device in an IoT application scenario. Of course, depending on the specific circumstances, the first and second devices may also be devices in other application scenarios. For example, the first device may also include a main server in cloud computing, and correspondingly, the second device may also include a backup server in cloud computing, and so on.
[0141] In some embodiments, the first device may be specifically disposed on one side of the terminal device and connected to the terminal device. The first device may be specifically used to collect the working parameters of the terminal device. The first device is connected to a cloud server and is further used to transmit the working parameters to the cloud server and receive a target file generated and fed back by the cloud server based on the working parameters. The first device is further used to control the terminal device by executing the target file.
[0142] In this embodiment, in an IoT application scenario, the first device can initially connect to a data processing system or network, connecting to both the terminal device and a cloud server. This first device is deployed locally on the terminal device, and a corresponding first operating environment is established on it to execute a target file, directly participating in edge computing. Furthermore, by executing the target file, the first device can perform timely, precise, and efficient control of the terminal device based on the edge computing results.
[0143] The second device, acting as a backup, acquires a program snapshot generated and sent by the first device. Without executing the target file or connecting to the aforementioned data processing system or network, the second device recreates a second operating environment identical to the first operating environment on the first device, maintaining synchronization between the two. Simultaneously, the second device monitors the status of the first device. If an anomaly is detected in the first device's status, the second device can acquire and, based on its execution permissions, quickly replace the first device using the pre-established second operating environment. It then connects to the data processing system or network and continues executing the target file within the pre-established second operating environment, starting from the first device's execution progress position, thus participating in edge computing to control the terminal device.
[0144] In some embodiments, after obtaining the target file, the first device also obtains a configuration file corresponding to the target file. Specifically, the configuration file may include data used to facilitate the execution of the target file. Subsequently, the first device can execute the target file in a first operating environment according to the configuration file.
[0145] Specifically, the first device can obtain a pre-generated configuration file corresponding to the target file from a cloud server. Alternatively, the first device can generate its own configuration file corresponding to the target file. After obtaining the configuration file, the first device can send it to the second device so that the second device can obtain and save it.
[0146] As can be seen from the above, the data processing method provided in this embodiment of the specification, during the execution of the target file by the first device, generates and sends a program snapshot to the second device at a preset time point based on the current first running environment in the first device, in order to back up the current first running environment; the second device, which is pre-configured with the same target file, restores a second running environment identical to the current first running environment of the first device based on the program snapshot; simultaneously, the second device monitors the status of the first device, and if it determines that the status of the first device is abnormal, it can promptly obtain and continue executing the target file in the pre-established second running environment of the second device according to the execution permissions. Therefore, when the first device malfunctions, the second device can be efficiently switched to continue the execution of the target file, effectively shortening the waiting time caused by the device switching process when the first device malfunctions, and reducing the impact of the device switching process on the execution of the original target file. Furthermore, the program snapshot used for backing up the first running environment is generated and transmitted via memory copy, reducing the amount of data processed by the device and improving processing efficiency. When generating the second type of program snapshot, instead of acquiring and using the full backup data of virtual memory, only the differential backup data of the virtual memory of the current first runtime environment relative to the first runtime environment at the time of the last backup is acquired and used. This further reduces data processing and improves processing efficiency.
[0147] See Figure 8 As shown in the embodiments of this specification, another data processing method is also provided. In specific implementation, this method may include the following:
[0148] S801: The second device monitors the status of the first device, wherein the first device is used to execute a target file in a first operating environment, and generate and send environmental data related to the current first operating environment to the second device according to the current first operating environment in the first device; the second device is pre-configured with a target file, and the second device is used to receive and save the environmental data.
[0149] S802: When the second device determines that the state of the first device is abnormal, it establishes a second operating environment in the second device based on the saved environmental data.
[0150] S803: The second device obtains and executes the target file in the current second operating environment of the second device according to the execution permissions for the target file.
[0151] In some embodiments, the environmental data may specifically include program snapshots, etc.
[0152] In some embodiments, before determining that the state of the first device is abnormal, the second device may receive and save the program snapshot generated and sent by the first device. The second device may neither execute the target file nor establish a second runtime environment on the second device.
[0153] If the second device determines that the first device is in an abnormal state, it can obtain and restore a second runtime environment on the second device that is identical to the current first runtime environment on the first device, based on a previously saved program snapshot. Then, it can take over from the first device and continue executing the target file based on the aforementioned second runtime environment.
[0154] In some embodiments, the program snapshot may specifically include: backup information of CPU registers, backup information of process elements, backup data of virtual memory, etc.
[0155] In some embodiments, when the program snapshot belongs to a first type of program snapshot, the first type of program snapshot includes the program snapshot first generated and sent by the first device, and the backup data of the virtual memory includes the full backup data of the virtual memory of the current first runtime environment.
[0156] In some embodiments, when the program snapshot belongs to the second type of program snapshot, the second type of program snapshot includes a program snapshot generated and sent by the first device after the first type of program snapshot, and the backup data of the virtual memory includes differential backup data of the virtual memory obtained based on the virtual memory data of the current first operating environment and the virtual memory data of the first operating environment when the program snapshot was last generated.
[0157] In some embodiments, where the program snapshots stored in the second device only include first-type program snapshots, a second operating environment identical to the current first operating environment of the first device is established in the second device based on the stored program snapshots. Specifically, this may include the following: the second device reconstructs CPU register information in its memory based on backup information of CPU registers in the program snapshots; the second device reconstructs process space in its memory based on backup information of process elements in the program snapshots; and the second device reconstructs virtual memory space in its memory based on backup data of virtual memory in the program snapshots, thereby establishing a second operating environment identical to the current first operating environment of the first device in the second device.
[0158] In some embodiments, when the program snapshots stored in the second device include a first type of program snapshot and a second type of program snapshot, a second operating environment identical to the current first operating environment of the first device is established in the second device based on the stored program snapshots. Specifically, this may include: the second device reconstructing CPU register information in its memory based on backup information of CPU registers from the most recently received second type of program snapshot; the second device reconstructing process space in its memory based on backup information of process elements from the most recently received second type of program snapshot; the second device extracting backup data of multiple virtual memory instances from the first type of program snapshot and the second type of program snapshot respectively, and merging the backup data of the multiple virtual memory instances to obtain merged backup data of virtual memory; and the second device reconstructing virtual memory space in its memory based on the merged backup data of virtual memory, thereby establishing a second operating environment identical to the current first operating environment of the first device in the second device.
[0159] In some embodiments, when saving a program snapshot, the second device may save the program snapshot according to the time it was received. Correspondingly, when merging backup data of multiple virtual memory instances, the second device may merge the backup data of multiple virtual memory instances extracted from different program snapshots in the order of their receipt times, thereby obtaining a full backup of the virtual memory for the current first runtime environment to establish the second runtime environment.
[0160] For specific examples, please refer to Figure 9 As shown, when the first device is determined to be in an abnormal state, the second device stores one first-type program snapshot and multiple second-type program snapshots (e.g., N second-type program snapshots numbered 1 to N). The second device can arrange these multiple second-type program snapshots in chronological order of reception time. Among them, the second-type program snapshot numbered N is the second-type program snapshot with the latest reception time, that is, the most recently received second-type program snapshot. The second device can extract and reconstruct the CPU register information in the memory of the second-type program snapshot numbered N based on the backup information of the CPU registers. The second device can extract and reconstruct the process space in the memory of the second-type program snapshot numbered N based on the backup information of the process elements. The second device can extract and merge the backup data of virtual memory from the first-type program snapshot and the N second-type program snapshots numbered 1 to N, and then use the merged virtual memory backup data to reconstruct the virtual memory space, so as to establish a second running environment in the second device that is the same as the current first running environment of the first device.
[0161] In some embodiments, for the second type of program snapshot, the included CPU register backup information may specifically include differential backup information of the CPU registers. The included process element backup information may specifically include differential backup information of the process elements. Accordingly, when establishing the second runtime environment, the second device may merge the backup information of multiple CPU registers and the backup information of multiple process elements by referring to the method of merging differential backup data of multiple virtual memories, to obtain the merged CPU register backup information and the merged process element backup information, and then establish the corresponding second runtime environment based on the merged CPU register backup information and the merged process element backup information.
[0162] This specification also provides another data processing method in its embodiments. In specific implementation, this method may include the following:
[0163] S1: The first device establishes the first operating environment.
[0164] S2: The first device executes the target file in the first operating environment; during the execution of the target file, the first device sends environmental data related to the current first operating environment to the second device.
[0165] In this embodiment, the above data processing method can be specifically applied to the first device side.
[0166] In some embodiments, environmental data related to the current first operating environment is sent to the second device. In specific implementation, this may include sending environmental data related to the current first operating environment at a preset time point, wherein the preset time point may specifically include the time point when the process state of the process used to execute the target file in the first device is in a non-running state.
[0167] In some embodiments, the program snapshot may specifically include: backup information of CPU registers, backup information of process elements, backup data of virtual memory, etc.
[0168] In some embodiments, when the program snapshot belongs to a first type of program snapshot, the first type of program snapshot includes the program snapshot first generated and sent by the first device, and the backup data of the virtual memory includes the full backup data of the virtual memory of the current first runtime environment.
[0169] In some embodiments, when the program snapshot belongs to the second type of program snapshot, the second type of program snapshot includes a program snapshot generated and sent by the first device after the first type of program snapshot, and the backup data of the virtual memory includes differential backup data of the virtual memory obtained based on the virtual memory data of the current first operating environment and the virtual memory data of the first operating environment when the program snapshot was last generated.
[0170] In some embodiments, generating a corresponding program snapshot based on the current first operating environment in the first device may specifically include the following: performing a memory copy in the first device for the current first operating environment to generate a corresponding program snapshot.
[0171] In some embodiments, sending a corresponding program snapshot to a second device may include the following: saving the program snapshot as a disk file format; and sending the program snapshot in disk file format to the second device.
[0172] This specification provides another data processing method for IoT application scenarios, which may include the following in specific implementation.
[0173] The backup gateway device monitors the status of the primary gateway device. The primary gateway device is used to execute a target file in a first operating environment and, at a preset time point, generates and sends a corresponding program snapshot to the backup gateway device based on the current first operating environment in the primary gateway device. The backup gateway device is pre-configured with a target file and is used to restore a second operating environment in the backup gateway device that is the same as the current first operating environment of the primary gateway device based on the program snapshot.
[0174] When the backup gateway device determines that the status of the primary gateway device is abnormal, it acquires execution permissions for the target file and executes the target file in the current second operating environment of the backup gateway device according to the execution permissions.
[0175] This specification also provides a server, including a processor and a memory for storing processor-executable instructions. Specifically, the processor can perform the following steps according to the instructions: monitoring the status of a first device; wherein the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to a second device; the second device is pre-configured with the target file; the second device is used to establish a second operating environment in the second device based on the environmental data; obtaining execution permissions for the target file, and executing the target file in the current second operating environment in the second device based on the execution permissions.
[0176] To execute the above instructions more accurately, please refer to... Figure 10 As shown in the embodiments of this specification, another specific server is also provided, wherein the server includes a network communication port 1001, a processor 1002 and a memory 1003, and the above structures are connected by internal cables so that the various structures can perform specific data interaction.
[0177] Specifically, the network communication port 1001 can be used to obtain the indicator parameters of the first device.
[0178] The processor 1002 is specifically used to monitor the status of the first device according to the index parameters of the first device; wherein, the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to a second device; the second device is pre-configured with a target file; the second device is used to establish a second operating environment in the second device according to the environmental data; the second device obtains execution permissions for the target file and executes the target file in the current second operating environment in the second device according to the execution permissions.
[0179] The memory 1003 can be used to store the corresponding instruction program.
[0180] In this embodiment, the network communication port 1001 can be a virtual port bound to different communication protocols, thereby enabling the sending or receiving of different data. For example, the network communication port can be a port responsible for web data communication, a port responsible for FTP data communication, or a port responsible for email data communication. Furthermore, the network communication port can also be a physical communication interface or communication chip. For example, it can be a wireless mobile network communication chip, such as GSM or CDMA; it can also be a Wi-Fi chip; or it can be a Bluetooth chip.
[0181] In this embodiment, the processor 1002 can be implemented in any suitable manner. For example, the processor can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers, etc. This specification is not limiting.
[0182] In this embodiment, the memory 1003 may include multiple layers. In a digital system, anything that can store binary data can be a memory. In an integrated circuit, a circuit with storage function but no physical form is also called a memory, such as RAM, FIFO, etc. In a system, a storage device with a physical form is also called a memory, such as a memory stick, TF card, etc.
[0183] This specification also provides a computer storage medium based on the above data processing method. The computer storage medium stores computer program instructions, which, when executed, perform the following: monitoring the status of a first device; wherein the first device is configured to execute a target file in a first operating environment and send environmental data related to the current first operating environment to a second device; the second device is pre-configured with a target file; the second device is configured to establish a second operating environment in the second device according to the environmental data; obtain execution permissions for the target file, and execute the target file in the current second operating environment in the second device according to the execution permissions.
[0184] In this embodiment, the storage medium includes, but is not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), cache, hard disk drive (HDD), or memory card. The memory can be used to store computer program instructions. The network communication unit can be an interface configured according to standards specified in the communication protocol for network connection communication.
[0185] In this embodiment, the specific functions and effects implemented by the program instructions stored in the computer storage medium can be explained in comparison with other implementation methods, and will not be repeated here.
[0186] See Figure 11 As shown, at the software level, this specification also provides a data processing apparatus, which may specifically include the following structural modules.
[0187] The monitoring module 1101 is specifically used to monitor the status of the first device; wherein, the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with the target file; the second device is used to establish a second operating environment in the second device according to the environmental data.
[0188] The processing module 1102 can be specifically used to obtain execution permissions for the target file, and execute the target file in the current second operating environment in the second device according to the execution permissions.
[0189] It should be noted that the units, devices, or modules described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. For ease of description, the above devices are described by dividing them into various modules according to their functions. Of course, in implementing this specification, the functions of each module can be implemented in one or more software and / or hardware, or the module that implements the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection between the devices or units shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0190] As can be seen from the above, the data processing apparatus provided in the embodiments of this specification can efficiently switch to a second device to continue the execution of the target file when the first device malfunctions, effectively shortening the waiting time caused by the device switching process when the first device malfunctions, and reducing the impact of the device switching process on the execution of the original target file.
[0191] This specification also provides another data processing device, including the following structural modules: a creation module, specifically used to create a first operating environment; an execution module, specifically used to execute a target file in the first operating environment; and during the execution of the target file, the first device sends environmental data related to the current first operating environment to the second device.
[0192] While this specification provides the steps of operation for the methods described in the embodiments or flowcharts, more or fewer steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or client product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, 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, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded. The terms "first," "second," etc., are used to denote names and do not indicate any particular order.
[0193] Those skilled in the art will also know that, besides implementing the controller using purely computer-readable program code, the same functions can be achieved by logically programming the method steps, making the controller function as logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers (PLCs), and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the devices within it used to implement various functions can also be considered structures within that hardware component. Alternatively, the devices used to implement various functions can be considered as both software modules implementing the method and structures within a hardware component.
[0194] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0195] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this specification can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions of this specification can essentially be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, mobile terminal, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments of this specification.
[0196] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. This specification can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable electronic devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices, etc.
[0197] Although this specification has been described by way of examples, those skilled in the art will recognize that many variations of this specification are possible without departing from the spirit of this specification, and it is intended that the appended claims cover such variations and changes without departing from the spirit of this specification.
Claims
1. A data processing method, comprising: The second device monitors the status of the first device; wherein, the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to the second device; the second device is pre-configured with the target file; the second device is used to establish a second operating environment synchronized with the first operating environment on the first device based on the environmental data; the first device includes a main gateway device participating in edge computing in an IoT application scenario, and the second device includes a backup gateway device; the environmental data includes a program snapshot, and the program snapshot includes at least one of the following: backup information of CPU registers, backup information of process elements, and backup data of virtual memory; The second device obtains execution permissions for the target file, and based on the execution permissions, continues to execute the target file in the second operating environment, using the progress position of the first device executing the target file as the starting position.
2. The method according to claim 1, wherein the second device obtains execution permissions for the target file, comprising: When the second device detects an abnormality in the status of the first device, it acquires execution permissions for the target file.
3. The method according to claim 1, wherein the first device sends environmental data related to the current first operating environment to the second device, including: The first device sends environmental data related to the current first operating environment at a preset time point, wherein the preset time point includes the time point when the process of executing the target file in the first device is in a non-running state.
4. The method according to claim 1, wherein, when the program snapshot belongs to the first type of program snapshot, the backup data of the virtual memory includes a full backup data of the virtual memory of the current first runtime environment, wherein, The first type of program snapshot includes the program snapshot that the first device generates and sends for the first time.
5. The method according to claim 4, wherein when the program snapshot belongs to the second type of program snapshot, the backup data of the virtual memory includes differential backup data of the virtual memory obtained based on the virtual memory data of the current first runtime environment and the virtual memory data of the first runtime environment at the time the program snapshot was last generated, wherein, The second type of program snapshot includes program snapshots generated and sent by the first device after the first type of program snapshot.
6. The method according to claim 5, wherein the backup information of the CPU register includes differential backup information of the CPU register and / or differential backup information of the process element.
7. The method of claim 1, wherein the first device generates a program snapshot related to the current first operating environment in the following manner: Based on the current first operating environment, the first device acquires the backup information of the CPU register, the backup information of the process element, and the backup data of the virtual memory through memory copying. The first device generates a corresponding program snapshot based on the backup information of the CPU registers, the backup information of the process element, and the backup data of the virtual memory.
8. The method according to claim 1, wherein the first device sends environmental data related to the current first operating environment to the second device, including: The first device saves the program snapshot as a disk file format; The first device sends a program snapshot in the disk file format to the second device.
9. The method according to claim 4, wherein when the program snapshot is a first type of program snapshot, the second device establishes a second operating environment in the second device based on the environmental data, comprising: The second device reconstructs the CPU register information in its memory based on the backup information of the CPU registers in the program snapshot. The second device reconstructs the process space in its memory based on the backup information of the process elements in the program snapshot. The second device reconstructs the virtual memory space in its memory based on the backup data of the virtual memory in the program snapshot, so as to establish a second operating environment in the second device that is the same as the current first operating environment of the first device.
10. The method according to claim 5, wherein when the program snapshot is a second type of program snapshot, the second device establishes a second operating environment in the second device based on the environmental data, comprising: The second device updates the existing CPU information in the second operating environment based on the backup information of the CPU registers in the program snapshot; The second device updates the process space in the existing second runtime environment based on the backup information of the process element in the program snapshot; The second device updates the virtual memory space in the existing second runtime environment based on the backup data of the virtual memory in the program snapshot, so as to establish a second runtime environment in the second device that is the same as the current first runtime environment of the first device.
11. The method according to claim 1, wherein the first device is disposed on one side of the terminal device and connected to the terminal device, and the first device is used to collect the operating parameters of the terminal device; The first device is also connected to a cloud server, and is further configured to transmit the working parameters to the cloud server and receive a target file generated and fed back by the cloud server based on the working parameters; the first device is also configured to control the terminal device by executing the target file.
12. A data processing method, comprising: The second device monitors the status of the first device. The first device executes a target file in a first operating environment and generates and sends environmental data related to the current first operating environment to the second device. The second device is pre-configured with the target file and receives and saves the environmental data. The first device includes a main gateway device participating in edge computing in an IoT application scenario, and the second device includes a backup gateway device. The environmental data includes a program snapshot, which includes at least one of the following: backup information of CPU registers, backup information of process elements, and backup data of virtual memory. When the second device determines that the state of the first device is abnormal, it establishes a second operating environment in the second device that is synchronized with the first operating environment on the first device, based on the saved environmental data. The second device obtains and, based on the execution permissions for the target file, continues to execute the target file in the second operating environment, using the progress position of the first device executing the target file as the starting position.
13. The method according to claim 12, wherein, when the program snapshot belongs to the first type of program snapshot, the backup data of the virtual memory includes a full backup data of the virtual memory of the current first runtime environment, wherein, The first type of program snapshot includes the program snapshot that the first device generates and sends for the first time.
14. The method according to claim 13, wherein when the program snapshot belongs to the second type of program snapshot, the backup data of the virtual memory includes differential backup data of the virtual memory obtained based on the virtual memory data of the current first runtime environment and the virtual memory data of the first runtime environment at the time the program snapshot was last generated, wherein, The second type of program snapshot includes program snapshots generated and sent by the first device after the first type of program snapshot.
15. The method according to claim 14, wherein when the program snapshots stored in the second device only include first-type program snapshots, establishing a second operating environment in the second device based on the stored environment data, comprising: The second device reconstructs the CPU register information in its memory based on the backup information of the CPU registers in the program snapshot. The second device reconstructs the process space in its memory based on the backup information of the process elements in the program snapshot. The second device reconstructs the virtual memory space in its memory based on the backup data of the virtual memory in the program snapshot, so as to establish a second operating environment in the second device that is the same as the current first operating environment of the first device.
16. The method according to claim 15, wherein when the program snapshots stored in the second device include a first type of program snapshot and a second type of program snapshot, establishing a second operating environment in the second device based on the stored environment data, includes: The second device reconstructs the CPU register information in its memory based on the backup information of the CPU registers in the most recently received second-type program snapshot. The second device reconstructs the process space in its memory based on the backup information of the process element in the most recently received second-type program snapshot. The second device extracts backup data of multiple virtual memory from the saved first type program snapshot and second type program snapshot respectively, and merges the backup data of multiple virtual memory to obtain the merged backup data of virtual memory. The second device reconstructs the virtual memory space in its memory based on the backup data of the merged virtual memory, so as to establish a second operating environment in the second device that is the same as the current first operating environment of the first device.
17. A data processing method, comprising: The backup gateway device monitors the status of the primary gateway device. The primary gateway device executes a target file in a first operating environment and, at a preset time point, generates and sends a corresponding program snapshot to the backup gateway device based on the current first operating environment in the primary gateway device. The backup gateway device is pre-configured with the target file and, based on the program snapshot, restores a second operating environment in the backup gateway device that is identical to the current first operating environment of the primary gateway device. The primary gateway device participates in edge computing in IoT application scenarios. The environment data includes the program snapshot, which includes at least one of the following: backup information of CPU registers, backup information of process elements, and backup data of virtual memory. When the backup gateway device determines that the status of the main gateway device is abnormal, it obtains execution permission for the target file and, based on the execution permission, continues to execute the target file in the second operating environment, using the progress position of the main gateway device executing the target file as the starting position.
18. A data processing apparatus, comprising: A monitoring module is used to monitor the status of a first device; wherein the first device is used to execute a target file in a first operating environment and send environmental data related to the current first operating environment to a second device; the second device is pre-configured with the target file; the second device is used to establish a second operating environment synchronized with the first operating environment on the first device based on the environmental data; the first device includes a main gateway device participating in edge computing in an IoT application scenario, and the second device includes a backup gateway device; the environmental data includes a program snapshot, and the program snapshot includes at least one of the following: backup information of CPU registers, backup information of process elements, and backup data of virtual memory; The processing module is used to obtain execution permissions for the target file, and based on the execution permissions, to continue executing the target file in the second operating environment, using the progress position of the main gateway device executing the target file as the starting position.
19. A server comprising a processor and a memory for storing processor-executable instructions, wherein the processor, when executing the instructions, implements the steps of the method of any one of claims 1 to 11.
20. A computer-readable storage medium having stored thereon computer instructions that, when executed, perform the steps of the method according to any one of claims 1 to 11.