A data processing method, apparatus, electronic device, and readable storage medium
By storing data in the local storage space of electronic devices and using indexing technology and proxy services to monitor connection status, the problem of low data transmission efficiency between services is solved, and efficient and secure data transmission is achieved.
Patent Information
- Application Number
- CN202411928656.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-12-25
AI Technical Summary
When data is transferred between services deployed on the same electronic device, retrieving device data from a third-party database can reduce transmission efficiency.
Device data is stored in the local storage space of the electronic device, and data transfer between services is achieved through the local storage space. Spatial indexes and address indexes are used to quickly locate target data. Proxy services are used to monitor connection status and cache data, and data sources are verified to ensure security.
It improves the efficiency of data transmission between services, reduces data mistransmission and redundancy, improves response speed and network resource utilization efficiency, and enhances the accuracy and security of data transmission.
Smart Images

Figure CN119766882B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a data processing method, apparatus, electronic device, and readable storage medium in the field of computer technology. Background Technology
[0002] Currently, developers typically deploy multiple services on the same electronic device, and the device data generated by these services is usually stored in a third-party database. When a service on one electronic device needs to transfer data with services on other electronic devices, the corresponding device data can be retrieved from the third-party database. However, when services on the same electronic device need to transfer data, retrieving device data from a third-party database reduces data transmission efficiency. Therefore, there is an urgent need for a data processing method that can improve the efficiency of data transmission between services within the same electronic device. Summary of the Invention
[0003] This application provides a data processing method, apparatus, electronic device, and readable storage medium, which can improve the transmission efficiency of device data between services.
[0004] Firstly, a data processing method is provided for use in an electronic device, the method comprising:
[0005] When the first service in an electronic device sends out new device data, the new device data is stored in the local storage space of the electronic device.
[0006] When a second service in an electronic device issues a subscription request, if the target of the subscription request is the first service, the target device data of the subscription request is determined from the local storage space.
[0007] Provide target device data to the second service.
[0008] In this embodiment, the electronic device stores the new device data issued by the first service in its local storage space. This facilitates rapid access by other services within the electronic device and ensures that data transmission does not require leaving the node where the electronic device is currently located, thereby achieving high-performance data transmission and improving data processing efficiency. Furthermore, when the second service issues a subscription request, the electronic device can accurately match the target device data generated by the first service through the request object in the subscription request, avoiding data mistransmission and redundancy, thus improving the response speed for data acquisition.
[0009] In conjunction with the first aspect, in some possible implementations, the new device data is stored in the local storage space of the electronic device, including:
[0010] Determine whether a first subspace exists in at least one subspace; wherein, the subspace is a storage space pre-allocated from local storage space for the first service, and the first subspace is a subspace with a free location for storing new device data;
[0011] If a first subspace exists, the new device data is stored in the first subspace;
[0012] Alternatively, if a first subspace does not exist, a new subspace is allocated from the local storage space for the first service, and the new device data is stored in the new subspace.
[0013] In this embodiment, the electronic device can efficiently utilize existing storage space and avoid unnecessary space waste by determining whether there is free space in the subspace pre-allocated for the first service. When the existing subspace cannot meet the storage requirements, the electronic device can dynamically allocate new storage space to ensure continuous data storage capability and improve overall storage efficiency.
[0014] In conjunction with the first aspect, in some possible implementations, the target device data for the subscription request is determined from local storage space, including:
[0015] Based on the spatial index included in the subscription request, a second subspace is determined from at least one subspace pre-divided for the first service;
[0016] Based on the address index included in the subscription request, determine the storage address of the target device data in the second subspace;
[0017] Based on the storage address, the target device data is determined from the second subspace.
[0018] In this embodiment, by setting a spatial index, the electronic device can quickly narrow down the search range and directly locate the second subspace containing the target device data, avoiding traversing the entire storage system and improving the efficiency of data location. Furthermore, within the second subspace, the storage address of the target device data is further precisely located using an address index, making data location even more efficient.
[0019] In conjunction with the first aspect, in some possible implementations, if the target of the subscription request is the first service, the target device data for the subscription request is determined from the local storage space, including:
[0020] Retrieve the data identifiers included in the subscription request;
[0021] If the obtained data identifier is the same as the data identifier pre-configured for the device data generated for the first service, then the target device data is determined from the local storage space.
[0022] In this embodiment, only the second service holding the correct data identifier can access the device data of the first service, thereby avoiding unnecessary data leakage and mistransmission, and thus improving the accuracy and security of data transmission. Simultaneously, the data identifier also allows electronic devices to more conveniently manage data transmission sessions between various services.
[0023] In conjunction with the first aspect, in some possible implementations, new device data is received by a proxy service in the electronic device and stored in local storage space. The method also includes:
[0024] When the proxy service receives the first detection signal, it sends a first response signal to the first service; wherein the first detection signal is periodically sent from the first service to the proxy service.
[0025] If the first service does not receive the first response signal within the first preset time period, it caches the generated device data and sends the cached device data to the proxy service the next time it receives the first response signal.
[0026] In this embodiment, the first service periodically sends a first detection signal to monitor the connection status with the proxy service in real time. If no response is received within a preset time period, it indicates a potential connection problem. In this case, the first service caches the data and transmits it only after the connection is restored, thus avoiding the risk of data loss. Simultaneously, when network conditions are poor or the proxy service is temporarily unavailable, the first service does not continuously send data but caches it, reducing unnecessary network requests and lowering network congestion. Data transmission is then resumed once network conditions improve or the proxy service recovers, improving the efficiency of network resource utilization.
[0027] In conjunction with the first aspect, in some possible implementations, the method also includes:
[0028] When the proxy service receives the second detection signal, it sends a second response signal to the second service; wherein the second detection signal is periodically sent from the second service to the proxy service.
[0029] If the second service does not receive the second response signal within the second preset time period, it will suspend sending subscription requests and send subscription requests to the proxy service the next time it receives the second response signal.
[0030] In this embodiment, the second service periodically sends a second detection signal to monitor the connection status with the proxy service in real time. If no response is received within a preset time period, it indicates a potential problem with the proxy service. In this case, the second service will pause sending subscription requests and resume transmission once the connection is restored, thus avoiding the risk of lost subscription requests. When network conditions are poor or the proxy service is temporarily unavailable, the second service will not continuously resend subscription requests. This reduces unnecessary network requests and lowers network congestion. Subscription request transmission will resume once network conditions improve or the proxy service recovers, thereby improving the efficiency of network resource utilization.
[0031] In conjunction with the first aspect, in some possible implementations, the new device data is stored in the local storage space of the electronic device, including:
[0032] Determine whether the new device data was sent by the first service based on the electronic device's loopback address;
[0033] If the first service issues the data based on the loopback address, the new device data will be stored in local storage.
[0034] In this embodiment, by verifying whether data is sent based on a loopback address, it can be ensured that only specific data for the electronic device can be received and stored, thereby reducing the risk of data leakage. By determining whether new device data is sent by the first service based on a loopback address, the electronic device can filter out insecure data, reduce the burden of processing invalid data, and thus improve the response speed of the electronic device.
[0035] Secondly, a data processing apparatus is provided, the apparatus comprising:
[0036] The storage module is used to store new device data in the local storage space of the electronic device when the first service in the electronic device issues new device data.
[0037] The determination module is used to determine the target device data of the subscription request from the local storage space when the second service in the electronic device issues a subscription request and the request object of the subscription request is the first service.
[0038] A module is provided to provide target device data to the second service.
[0039] Thirdly, an electronic device is provided, including a memory for storing executable program code;
[0040] A processor is used to call and run executable program code from memory, causing the electronic device to perform the method in any possible implementation of the first aspect described above.
[0041] Fourthly, an executable program code product is provided, comprising: executable program code that, when run on a computer, causes the computer to perform the method in any possible implementation of the first aspect described above.
[0042] Fifthly, a readable storage medium is provided that stores executable program code, which, when run on a computer, causes the computer to perform the method in any possible implementation of the first aspect described above. Attached Figure Description
[0043] Figure 1 This is a flowchart of the steps of a data processing method provided in an embodiment of this application;
[0044] Figure 2 This is a flowchart of the steps of a data processing method provided in an embodiment of this application;
[0045] Figure 3 This is a flowchart of the steps of a data processing method provided in an embodiment of this application;
[0046] Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application;
[0047] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0048] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0049] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0050] Currently, to improve communication efficiency, developers often deploy multiple services on the same electronic device, and the device data generated by these services is typically stored in a third-party database. When a service on one electronic device needs to transfer data with services on other electronic devices, it can retrieve the corresponding device data from the third-party database. However, when services on the same electronic device need to transfer data, retrieving device data from a third-party database reduces data transmission efficiency.
[0051] To address the aforementioned technical problems, this application provides a data processing method that can be executed by an electronic device. When a first service within the electronic device sends new device data, the new device data is stored in the electronic device's local storage space. When a second service within the electronic device sends a subscription request, if the request object is the first service, the target device data to be subscribed to in the subscription request is determined from the local storage space, and the target device data is provided to the second service. In this way, device data can be stored in local storage space among services deployed on the same electronic device, ensuring that data transmission does not require leaving the node where the current electronic device is located, thereby achieving high-performance data transmission and improving the efficiency of data transmission and processing.
[0052] See Figure 1 , Figure 1 This is a flowchart illustrating the steps of a data processing method provided in an embodiment of this application. The execution subject of this method can be an electronic device, such as... Figure 1 As shown, the method may include the following steps.
[0053] S101, when the first service in the electronic device sends new device data, the new device data is stored in the local storage space of the electronic device.
[0054] Local storage space refers to the physical storage medium inside an electronic device used to store device data.
[0055] In electronic devices, multiple services typically run simultaneously, each responsible for a different function. The first service refers to a specific service or program module running on the electronic device. Device data refers to data generated or received by the first service; for example, in a vehicle, the device data of the first service could be the vehicle's current status obtained from the vehicle's speed sensor, or it could be data such as the vehicle's current fuel level, current interior temperature, and current door open / closed status obtained from the vehicle's electronic control unit.
[0056] In practical applications, electronic devices can pre-create a publish-subscriber (also known as a listener) to monitor in real time whether other services are sending device data. When the electronic device detects that the first service has sent new device data, it can store the new device data in the local storage space of the electronic device according to the preset storage method.
[0057] In one implementation, after creating a publish-subscriber, the electronic device listens in real time for other services to send device data. When it determines that a first service has sent new device data, the electronic device can receive the device data sent by the first service through a collector or a gRPC-Push interface, and store this device data in the form of files in the local file system. The file name can be determined according to preset storage rules. For example, the file name can be determined according to the offset of the first device data in the file, that is, the file name can be named in the form of 000000+offset.log. Alternatively, the file name can be based on the storage time of the device data.
[0058] For example, taking a vehicle as an example, during the vehicle's operation, assuming the first service is the signal acquisition service, after determining that the electronic device has successfully created a publish-subscriber, it monitors in real time whether various services inside the vehicle are sending new device data. When the electronic device determines that the signal acquisition service has sent a message at the current time of 10:00 that the vehicle's fuel level is 75 liters, it can create a file named with a timestamp and store the fuel level data 75 liters and the current time timestamp 10:00 together in the local file system.
[0059] In another implementation, after creating a publish-subscriber, the electronic device listens in real time for other services to send device data. When it determines that a first service has sent new device data, the electronic device can store this device data in the corresponding location in its local database. Using a database storage method allows for convenient data querying, updating, and deletion operations.
[0060] S102, when the second service in the electronic device issues a subscription request, if the request object of the subscription request is the first service, the target device data of the subscription request is determined from the local storage space.
[0061] S103, providing target device data to the second service.
[0062] The second service refers to a service within an electronic device that can receive and process device data from other services (such as the first service). Taking a vehicle as an example, the second service could be a display service within the in-vehicle system. For instance, if the first service sends fuel level data, the second service can obtain this data and, when the fuel level is below a preset threshold, alert the user on the central control screen while simultaneously recommending nearby gas stations. Another example is a control service within the vehicle. If the first service sends the interior temperature, the second service can obtain this temperature and, when it falls below a preset temperature threshold, alert the user on the central control screen while simultaneously controlling the vehicle's air conditioning heating system to activate.
[0063] A subscription request is a request sent by a second service to an electronic device, indicating that the second service wishes to receive device data for a specific service. A subscription request may include, but is not limited to, the request object, authentication information, and the request file name.
[0064] In this embodiment, the electronic device monitors various services within the electronic device in real time via a publisher-subscriber. When it determines that a second service in the electronic device has issued a subscription request, it determines whether the requested object in the subscription request is the first service. If the requested object is the first service, the electronic device can determine the storage location of the device data of the first service in its local storage space based on the subscription request, and determine the target device data to be subscribed to based on the storage location. Then, the electronic device sends the target device data to the second service.
[0065] Furthermore, after receiving the target device data, the second service performs corresponding data processing based on the target device data.
[0066] For example, taking a vehicle as an example, assume the first service is a signal acquisition service; the second service is a display service in the in-vehicle system. When the electronic device determines that the second service has issued a subscription request, it parses the subscription request and obtains that the requested object in the subscription request is the first service. If the electronic device determines that the requested object is the first service, it determines the storage location of the device data of the first service in its local storage space based on the request file name in the subscription request, and then determines the fuel level of the vehicle requesting the subscription based on the storage location. Afterwards, the electronic device sends the vehicle's fuel level to the second service.
[0067] Furthermore, after receiving the vehicle's fuel level, the second service compares the vehicle's fuel level with a preset fuel level threshold. If it determines that the fuel level is less than the preset fuel level threshold, the electronic device can remind the user on the central control screen and simultaneously push nearby gas stations to the user.
[0068] In this embodiment, when a first service in the electronic device sends new device data, the new device data is stored in the local storage space of the electronic device. Subsequently, when a second service in the electronic device sends a subscription request, if the request object is the first service, the target device data to be subscribed to in the subscription request is determined from the local storage space; and the target device data is provided to the second service. In this way, the electronic device stores the new device data sent by the first service in its local storage space, which facilitates rapid access by other services within the electronic device and ensures that data transmission does not need to leave the current node where the electronic device is located, thereby achieving high-performance data transmission and improving data processing efficiency. Furthermore, when the second service sends a subscription request, the electronic device can accurately match the target device data generated by the first service through the request object in the subscription request, avoiding data mistransmission and redundancy, thereby improving the response speed for data acquisition.
[0069] Optionally, storing new device data in the local storage space of the electronic device includes:
[0070] Determine whether a first subspace exists in at least one subspace; wherein, the subspace is a storage space pre-allocated from local storage space for the first service, and the first subspace is a subspace with a free location for storing new device data;
[0071] If a first subspace exists, the new device data is stored in the first subspace;
[0072] Alternatively, if a first subspace does not exist, a new subspace is allocated from the local storage space for the first service, and the new device data is stored in the new subspace.
[0073] In this embodiment, when the electronic device determines that the first service has sent new device data, it can determine the size of the device data. After determining the size, the electronic device can compare the size with the first subspace to determine whether there is a first subspace with a free location to store the new device data. If the size is less than or equal to the first subspace, it is determined that there is a first subspace. Then, the electronic device can convert the device data to be stored into a format of data length + data content, and store the new device data in the first subspace in the form of bytes.
[0074] If the data size is larger than the first subspace, it is determined that the first subspace does not exist. Then, the electronic device allocates a new subspace for the first service from the local storage space and stores the new device data in the new subspace.
[0075] Furthermore, each subspace corresponds to an index file. After the electronic device stores new device data in the first subspace, it can add the address index (also known as the offset) of the device data and the storage address corresponding to the address index to the end of the index file.
[0076] For example, taking a vehicle as an example, suppose the first service in an electronic device (e.g., the vehicle's fuel level monitoring system) issues new device data indicating that the vehicle's current fuel level is 75 liters, and its data size is 2 bytes. The electronic device compares this data size with a first subspace (e.g., 100 bytes in size), determines that the data size is smaller than the first subspace, and therefore determines that there is enough free space in the first subspace to store the new device data. Next, if there is no other data in the first subspace, the electronic device converts this device data into a "data length + data content" format and stores it in bytes at the beginning of the first subspace. After storage, the electronic device also appends a record to the end of the corresponding index file. Assuming the index file is initially empty, the electronic device adds the address index and corresponding storage address of the device data to the index file; the address index is "0000", and the corresponding storage address is "0000". If the newly generated data exceeds the capacity of the first subspace, the electronic device allocates a new subspace for the first service in local storage and repeats the above storage process.
[0077] As another example, if the first subspace already stores two pieces of device data, with sizes of 20 bytes and 30 bytes respectively, and a first service in the electronic device (e.g., a vehicle's fuel level monitoring system) issues a new piece of device data indicating that the vehicle's current fuel level is 75 liters, with a data size of 2 bytes, the electronic device compares this data size with the remaining space in the first subspace (50 bytes). It determines that the new data size is smaller than the first subspace, therefore there is sufficient free space in the first subspace to store the new device data. Thus, this device data is stored immediately following the previous two pieces of data, starting at a byte offset of 50. Subsequently, assuming the initial index file content is: address index: 0001, storage address: 0000; address index: 0002, storage address: 0020; the electronic device will append a record to the end of the corresponding index file, that is, the updated index file will be: address index: 0001, storage address: 0000; address index: 0002, storage address: 0020; address index: 0003, storage address: 0050.
[0078] In this embodiment, the electronic device determines whether a first subspace exists within at least one subspace. If a first subspace exists, new device data is stored in the first subspace. If a first subspace does not exist, a new subspace is allocated from local storage for the first service, and the new device data is stored in the new subspace. In this way, by determining whether there is free space in the pre-allocated subspace for the first service, the electronic device can efficiently utilize existing storage space and avoid unnecessary space waste. When the existing subspace cannot meet the storage requirements, the electronic device can dynamically allocate new storage space to ensure continuous data storage capability and improve overall storage efficiency.
[0079] Optionally, the target device data for the subscription request can be determined from local storage space, including:
[0080] Based on the spatial index included in the subscription request, a second subspace is determined from at least one subspace pre-divided for the first service;
[0081] Based on the address index included in the subscription request, determine the storage address of the target device data in the second subspace;
[0082] Based on the storage address, the target device data is determined from the second subspace.
[0083] Here, the spatial index refers to the index in which the target device data in the subscription request is located within a pre-divided subspace; the second subspace refers to a specific subspace among at least one subspace pre-divided for the first service, which contains the target device data requested by the subscription request. The address index refers to the index or identifier within the index file corresponding to the second subspace used to locate the target device data. The storage address refers to the specific storage location of the target device data within the second subspace.
[0084] In practical applications, electronic devices can pre-create an offset generator (also known as an offset unit) to determine in real time whether the offset of the device service has changed. If a change is detected, the offset is updated. Simultaneously, after the second service sends a subscription request, the electronic device can use the offset generator to determine the spatial index and address index that the second service needs to read.
[0085] In one implementation, the subscription request includes a spatial index and an address index. The electronic device can receive a subscription request from a second service via the gRPC-receive interface. After receiving the subscription request from the second service, it can determine the spatial index in the subscription request and determine a second subspace from at least one subspace pre-divided for the first service based on a binary search method and the spatial index. Then, the electronic device determines the storage address of the target device data in the second subspace based on the binary search method and the address index; and based on the storage address, it determines the target device data from the second subspace.
[0086] For example, taking a vehicle as an example, suppose an electronic device in the vehicle has multiple services, including a signal acquisition service (as the first service) and a data analysis service (as the second service). The signal acquisition service is responsible for collecting various vehicle sensor data, while the data analysis service needs to subscribe to specific vehicle data for analysis. When the second service needs the latest vehicle speed data, it sends a subscription request to the electronic device. This request contains spatial index 001 and address index 003. The electronic device uses a binary search algorithm to quickly locate the second subspace storing the vehicle speed data among multiple pre-divided subspaces based on spatial index 001. In the corresponding index file within the second subspace, the electronic device again uses binary search to determine address index 002 and the corresponding storage address as 50 bytes. Finally, the electronic device reads the target device data from the 50-byte address within the second subspace.
[0087] In another implementation, the subspace may include log files and index files. Log files store the actual device data, while index files store index addresses and the storage addresses of the corresponding device data. The naming of the log files for each subspace is consistent with that of the index files, and can be based on the index address of the data at the beginning of each index file. For example, the first index file might be named 000000+1.index; the first log file might be named 000000+1.log; assuming the first index file stores 50 data entries, the second index file might be named 000000+51.index; the second log file might be named 000000+51.log; and so on. When the second service reads data, it can start reading from the subspace with address index 1. After each read, the address index value is incremented by 1 and recorded. In the next read, the device data is read sequentially starting from the recorded address index.
[0088] For example, the subscription request may include an address index; after receiving a subscription request from the second service, the electronic device can determine which index file the index address is located in from at least one subspace pre-divided for the first service, based on a binary search and the address index. Then, the electronic device can determine the storage address of the target device data in the index file based on the binary search and the address index; and based on the storage address, determine the target device data from the log file.
[0089] In this embodiment, the electronic device determines a second subspace from at least one subspace pre-divided for the first service based on the spatial index in the subscription request; and determines the storage address of the target device data in the second subspace based on the address index in the subscription request. Based on the storage address, the target device data is then determined from the second subspace. Thus, by setting a spatial index, the electronic device can quickly narrow down the search range and directly locate the second subspace containing the target device data, avoiding traversing the entire storage system and improving the efficiency of data location. Furthermore, within the second subspace, the address index is used to further precisely locate the storage address of the target device data, making data location even more efficient.
[0090] Optionally, if the target of the subscription request is the first service, the target device data of the subscription request is determined from the local storage space, including:
[0091] Retrieve the data identifiers included in the subscription request;
[0092] If the obtained data identifier is the same as the data identifier pre-configured for the device data generated for the first service, then the target device data is determined from the local storage space.
[0093] Among them, the data identifier refers to the identifier used to identify a unique session between the first service and the second service, which can also be called a "topic".
[0094] In this embodiment, when the first service sends new device data, it pre-generates a data identifier. Simultaneously, when the second service wishes to transmit data with the first service, it also pre-generates a data identifier identical to that of the first service. After receiving a subscription request from the second service, the electronic device can obtain the data identifier from the subscription request and compare it with the data identifier configured in the device data generated by the first service. If the data identifier matches the data identifier generated by the first service, it indicates that the second service can obtain the device identification data from the first service; that is, the electronic device determines the target device data from its local storage space.
[0095] If the data identifier is inconsistent with the data identifier generated by the first service, it indicates that the second service and the first service cannot transmit data, that is, the second service cannot obtain the device data of the first service.
[0096] In this embodiment, the electronic device obtains a data identifier from the subscription request. If the obtained data identifier is a data identifier pre-configured for the device data generated for the first service, the target device data is determined from the local storage space. In this way, only the second service holding the correct data identifier can access the device data of the first service, thereby avoiding unnecessary data leakage and mistransmission, and thus improving the accuracy and security of data transmission. Simultaneously, the data identifier also allows the electronic device to more conveniently manage data transmission sessions between various services.
[0097] Optionally, the new device data is received by a proxy service in the electronic device and stored in local storage space. The method may also include the following steps:
[0098] When the proxy service receives the first detection signal, it sends a first response signal to the first service; wherein the first detection signal is periodically sent from the first service to the proxy service.
[0099] If the first service does not receive the first response signal within the first preset time period, it caches the generated device data and sends the cached device data to the proxy service the next time it receives the first response signal.
[0100] In this context, the proxy service refers to a program running on the electronic device that is responsible for receiving device data from the first service and storing it in local storage. Furthermore, the proxy service is also responsible for handling communication with the first service, including receiving a first detection signal and sending a first response signal accordingly.
[0101] The first detection signal refers to a specific type of signal (also known as a "heartbeat signal") that is periodically sent by the first service to the proxy service. The first detection signal is used to check whether the proxy service is online and available, so that the first service can determine whether it is safe to send data to the proxy service.
[0102] The first response signal refers to the reply signal sent by the proxy service to the first service after receiving the first detection signal from the first service. This signal indicates that the proxy service has successfully received the first detection signal and is currently online, capable of receiving device data from the first service.
[0103] In practical applications, before receiving detection signals, the proxy service in an electronic device can pre-create a heartbeat to receive detection signals sent by other services, so as to ensure that the proxy service knows in a timely manner whether other services are online, and that other services know in a timely manner whether the proxy service is online.
[0104] In this embodiment, after going online, the first service periodically sends a first detection signal to the proxy service in the electronic device. For example, in the first period, the first service sends a first detection signal to the proxy service. When the proxy service receives the first detection signal, if the proxy service is online, it sends a first response signal to the first service. If the first service receives the first response signal from the proxy service within a preset time period, it indicates that the first service can send device data to the proxy service. In the second period, the first service sends a first detection signal to the proxy service, but does not receive the first response signal from the proxy service within the first preset time period, indicating that the first service cannot send device data to the proxy service at this time, and the first service can cache the generated device data. In the third period, the first service receives the first response signal from the proxy service, at which time the first service can resend the cached device data to the proxy service. After receiving the device data, the proxy service stores the device data in the current storage space.
[0105] In this embodiment, when the proxy service receives the first detection signal, it sends a first response signal to the first service. If the first service does not receive the first response signal within a first preset time period, it caches the generated device data and sends the cached device data to the proxy service the next time it receives the first response signal. In this way, the first service can monitor the connection status with the proxy service in real time by periodically sending the first detection signal. If no response is received within the preset time period, it indicates a potential connection problem. In this case, the first service will cache the data and transmit it only after the connection is restored, thus avoiding the risk of data loss. Simultaneously, when network conditions are poor or the proxy service is temporarily unavailable, the first service will not continuously send data but will cache it, reducing unnecessary network requests and network congestion. Data transmission will only occur after network conditions improve or the proxy service recovers, improving the efficiency of network resource utilization.
[0106] Optionally, the method may further include the following steps:
[0107] When the proxy service receives the second detection signal, it sends a second response signal to the second service; wherein the second detection signal is periodically sent from the second service to the proxy service.
[0108] If the second service does not receive the second response signal within the second preset time period, it will suspend sending subscription requests and send subscription requests to the proxy service the next time it receives the second response signal.
[0109] The second detection signal refers to a specific type of signal periodically sent by the second service to the proxy service. Its main function is to check whether the proxy service is online and available, allowing the second service to determine if it is safe to send subscription requests to the proxy service. Similar to the first detection signal, the second detection signal is often referred to as a "heartbeat signal." The second response signal is the reply signal sent by the proxy service to the second service after receiving the second detection signal. This signal indicates that the proxy service has successfully received the second detection signal and is currently online, capable of receiving subscription requests from the second service. If the second service does not receive this response signal within a preset time, it considers the proxy service unavailable and takes appropriate measures, such as caching subscription requests and waiting for a later opportunity to resend them.
[0110] In this embodiment, after going online, the second service periodically sends a second detection signal to the proxy service in the electronic device. For example, in the first period, the second service sends a second detection signal to the proxy service. When the proxy service receives the second detection signal, if the proxy service is online, it sends a second response signal to the second service. If the second service receives the second response signal from the proxy service within a preset time period, it indicates that the second service can send a subscription request to the proxy service. In the second period, the second service sends a second detection signal to the proxy service, but does not receive the second response signal from the proxy service within the second preset time period, indicating that the second service cannot send a subscription request to the proxy service at this time, and the second service can cache the generated subscription request. In the third period, the second service receives the second response signal from the proxy service, at which time the second service can resend the cached subscription request to the proxy service. After receiving the subscription request, the proxy service determines the target device data of the subscription request from the local storage space and provides the target device data to the second service.
[0111] In this embodiment, when the proxy service receives the second detection signal, it sends a second response signal to the second service. If the second service does not receive the second response signal within a second preset time period, it suspends sending subscription requests and sends a subscription request to the proxy service the next time it receives the second response signal. In this way, the second service can monitor the connection status with the proxy service in real time by periodically sending the second detection signal. If no response is received within the preset time period, it indicates that there may be a problem with the proxy service. In this case, the second service will suspend sending subscription requests and resume transmission after the connection is restored, thereby avoiding the risk of lost subscription requests. When network conditions are poor or the proxy service is temporarily unavailable, the second service will not continuously resend subscription requests, which reduces unnecessary network requests and lowers network congestion. Subscription request transmission will resume once network conditions improve or the proxy service recovers, thereby improving the efficiency of network resource utilization.
[0112] Optionally, storing new device data in the local storage space of the electronic device includes:
[0113] Determine whether the new device data was sent by the first service based on the electronic device's loopback address;
[0114] If the first service issues the data based on the loopback address, the new device data will be stored in local storage.
[0115] The loopback address refers to the unique identifier of an electronic device or a specific network address.
[0116] In this embodiment, when the electronic device receives new device data from the first service, it determines whether the new device data was sent by the first service based on the electronic device's loopback address. If the device data was sent by the first service based on the loopback address, the electronic device considers the data to be secure and valid, and stores the new device data in its local storage space. If the device data was not sent by the first service based on the loopback address, the electronic device considers the data to be insecure or invalid, discards the new device data, and sends a response message to the first service indicating that the received device data is insecure or the verification failed.
[0117] In this embodiment, the electronic device determines whether new device data is sent by a first service based on the electronic device's loopback address. If it is sent by the first service based on the loopback address, the new device data is stored in local storage. By verifying whether data is sent based on the loopback address, it ensures that only data specific to the electronic device can be received and stored, thereby reducing the risk of data leakage. By determining whether new device data is sent by the first service based on the loopback address, the electronic device can filter out invalid or insecure data, reducing the processing burden on invalid data and thus improving the response speed of the electronic device.
[0118] Optionally, before the first service in the electronic device sends new device data, the first service may send a first registration request to the proxy service. When the proxy service receives the first registration request sent by the first service, it determines whether the identification information of the first service is used by other services. If not, the proxy service registers the first service and caches the identification information in a preset mapping table.
[0119] Correspondingly, before the second service in the electronic device issues a subscription request, the second service can send a second registration request to the proxy service. When the proxy service receives the second registration request from the second service, it determines whether the identification information generated by the second service is used by other services. If not, the proxy service registers the second service and caches the identification information in a preset mapping table.
[0120] See Figure 2 , Figure 2 This is a flowchart illustrating the steps of a data processing method provided in an embodiment of this application. Figure 2 As shown, the method may include the following steps.
[0121] S201, The first service sends the first registration request to the agent service.
[0122] The first registration request carries the identification information of the first service.
[0123] S202, after receiving the first registration request, the proxy service determines whether the identification information of the first service has been registered by other services. If it has been registered by other services, then proceed to step S203; otherwise, proceed to step S204.
[0124] S203, the agent service returned a message indicating that the first service registration failed.
[0125] S204, The proxy service registers with the first service and caches the identification information in a preset mapping table.
[0126] S205, after the first service successfully registers, the first service sends the first detection signal to the agent service.
[0127] S206, when the agent service receives the first detection signal, it sends a first response signal to the first service.
[0128] S207, the first service determines whether it receives the first response signal within the first preset time period. If the first response signal is received, then step S208 is executed; otherwise, step S209 is executed.
[0129] S208, sends device data to the agent service.
[0130] S209, cache the generated device data, and send the cached device data to the agent service the next time the first response signal is received.
[0131] S211, the second service sends a second registration request to the proxy service.
[0132] The second registration request carries the identification information of the second service.
[0133] S212 After receiving the second registration request, the proxy service determines whether the identification information of the second service has been registered by other services. If it has been registered by other services, then proceed to step S213; otherwise, proceed to step S214.
[0134] S213, the agent service returned a message indicating that the second service registration failed.
[0135] S214, the proxy service registers the second service and caches the identification information in a preset mapping table.
[0136] S215, after the second service successfully registers, the second service sends a second detection signal to the proxy service.
[0137] S216, when the agent service receives the second detection signal, it sends a second response signal to the first service.
[0138] S217, the second service determines whether it receives the second response signal within the second preset time period. If it receives the signal, it executes step S218; otherwise, it executes step S219.
[0139] S218, Send a subscription request to the proxy service.
[0140] S219, suspend sending subscription requests, and send a subscription request to the proxy service the next time a second response signal is received.
[0141] It should be noted that the execution order of the first and second services can vary depending on the actual application scenario, and there is no limitation on this.
[0142] See Figure 3 , Figure 3 This is a flowchart illustrating the steps of a data processing method provided in an embodiment of this application. Figure 3 As shown, the method may include the following steps.
[0143] S301, the first service sends new device data to the agent service.
[0144] S302, receives new device data sent by the first service.
[0145] S303, determine whether a first subspace exists in at least one subspace. If a first subspace exists, proceed to step S304; otherwise, proceed to step S305.
[0146] The subspace is a storage space pre-allocated from the local storage space for the first service, and the first subspace is a subspace with a free location for storing new device data.
[0147] S304 stores new device data in the first subspace.
[0148] For example, after receiving new device data from the first service, it can be determined whether the new device data was sent by the first service based on the loopback address of the electronic device; if it was sent by the first service based on the loopback address, the new device data is stored in the first subspace.
[0149] S305 allocates a new subspace from the local storage space for the first service, and stores the new device data in the new subspace.
[0150] S311, the second service sends a subscription request to the proxy service.
[0151] S312, receive a subscription request from the second service.
[0152] S313, based on the spatial index included in the subscription request, determine the second subspace from at least one subspace pre-divided for the first service.
[0153] S314, based on the address index included in the subscription request, determine the storage address of the target device data in the second subspace.
[0154] S315 determines the target device data from the second subspace based on the storage address.
[0155] S316 provides target device data to the second service.
[0156] It should be noted that the execution order of the first and second services can vary depending on the actual application scenario, and there is no limitation on this.
[0157] It should be noted that the implementation methods and technical effects of each step in the embodiments of this application can be referred to the relevant content in the above embodiments, and will not be repeated here.
[0158] See Figure 4 , Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. The data processing device can be disposed in an electronic device and may include: a storage module 401, a determination module 402 and a providing module 403.
[0159] Storage module 401 is used to store new device data in the local storage space of the electronic device when the first service in the electronic device issues new device data;
[0160] The determination module 402 is used to determine the target device data of the subscription request from the local storage space when the second service in the electronic device issues a subscription request and the request object of the subscription request is the first service.
[0161] Module 403 is provided for providing target device data to the second service.
[0162] Optionally, the storage module 401 is specifically used to determine whether a first subspace exists in at least one subspace; wherein, the subspace is a storage space pre-allocated from the local storage space for the first service, and the first subspace is a subspace with a free location for storing new device data; if the first subspace exists, the new device data is stored in the first subspace; or, if the first subspace does not exist, a new subspace is allocated from the local storage space for the first service, and the new device data is stored in the new subspace.
[0163] Optionally, the determining module 402 is specifically used to determine a second subspace from at least one subspace pre-divided for the first service based on the space index included in the subscription request; determine the storage address of the target device data in the second subspace based on the address index included in the subscription request; and determine the target device data from the second subspace based on the storage address.
[0164] Optionally, the determining module 402 is specifically used to obtain the data identifier included in the subscription request; if the obtained data identifier is a data identifier pre-configured for the device data generated for the first service, then the target device data is determined from the local storage space.
[0165] Optionally, the new device data is received by a proxy service in the electronic device and stored in local storage space. The data processing device may also include: a first sending module and a cache module.
[0166] The first sending module is used to send a first response signal to the first service when the proxy service receives the first detection signal; wherein the first detection signal is periodically sent from the first service to the proxy service;
[0167] The caching module is used to cache the generated device data when the first service does not receive the first response signal within a first preset time period, and to send the cached device data to the proxy service when the first response signal is received again.
[0168] Optionally, the data processing device may further include: a second transmitting module and a third transmitting module;
[0169] The second sending module is used to send a second response signal to the second service when the proxy service receives the second detection signal; wherein the second detection signal is periodically sent from the second service to the proxy service;
[0170] The third sending module is used to pause sending subscription requests when the second service does not receive the second response signal within a second preset time period, and to send subscription requests to the proxy service the next time the second response signal is received.
[0171] Optionally, the storage module 401 is specifically used to determine whether the new device data is sent by the first service based on the loopback address of the electronic device; if it is sent by the first service based on the loopback address, the new device data is stored in the local storage space.
[0172] The data processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0173] See Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0174] For example, such as Figure 5 As shown, the electronic device 500 includes a memory 501 and a processor 502. The memory 501 stores executable program code 5011, and the processor 502 is used to call and execute the executable program code 5011 to perform a data processing method.
[0175] Furthermore, this application also protects a vehicle that may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to perform a data processing method provided in this application.
[0176] This embodiment also provides a readable storage medium storing executable program code. When the executable program code is run on a computer, the computer performs the aforementioned method steps to implement a data processing method provided in the above embodiment.
[0177] This embodiment also provides an executable program code product. When the executable program code product is run on a computer, it causes the computer to perform the above-mentioned related steps to implement a data processing method provided in the above embodiment.
[0178] In this embodiment, the device, readable storage medium, executable program code product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0179] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0180] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0181] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data processing method, characterized in that, Applied to electronic devices, the method includes: When the first service in the electronic device sends new device data, the new device data is stored in the local storage space of the electronic device. The new device data is received by the proxy service in the electronic device and stored in the local storage space. When a second service in the electronic device issues a subscription request, if the target of the subscription request is the first service, the target device data of the subscription request is determined from the local storage space. Provide the target device data to the second service; When the proxy service receives the first detection signal, it sends a first response signal to the first service; wherein the first detection signal is periodically sent from the first service to the proxy service. If the first service does not receive the first response signal within a first preset time period, it caches the generated device data and sends the cached device data to the proxy service the next time it receives the first response signal. When the proxy service receives the second detection signal, it sends a second response signal to the second service; wherein the second detection signal is periodically sent from the second service to the proxy service. If the second service does not receive the second response signal within a second preset time period, it shall suspend sending the subscription request, and send the subscription request to the proxy service the next time it receives the second response signal.
2. The method according to claim 1, characterized in that, The step of storing the new device data in the local storage space of the electronic device includes: Determine whether a first subspace exists in at least one subspace; wherein, the subspace is a storage space pre-allocated from the local storage space for the first service, and the first subspace is the subspace with a free location for storing the new device data; If the first subspace exists, the new device data is stored in the first subspace; Alternatively, if the first subspace does not exist, a new subspace is allocated from the local storage space for the first service, and the new device data is stored in the new subspace.
3. The method according to claim 2, characterized in that, Determining the target device data for the subscription request from the local storage space includes: Based on the spatial index included in the subscription request, a second subspace is determined from at least one of the subspaces pre-divided for the first service; Based on the address index included in the subscription request, determine the storage address of the target device data in the second subspace; Based on the storage address, the target device data is determined from the second subspace.
4. The method according to claim 1, characterized in that, If the subscription request targets the first service, then determining the target device data for the subscription request from the local storage space includes: Obtain the data identifier included in the subscription request; If the obtained data identifier is a data identifier pre-configured for the device data generated for the first service, then the target device data is determined from the local storage space.
5. The method according to any one of claims 1-4, characterized in that, The step of storing the new device data in the local storage space of the electronic device includes: Determine whether the new device data was sent by the first service based on the electronic device's callback address; If the first service issues the data based on the loopback address, the new device data is stored in the local storage space.
6. A data processing apparatus, characterized in that, The device is disposed in an electronic device, the device comprising: A storage module is used to store new device data in the local storage space of the electronic device when a first service in the electronic device sends out new device data. The new device data is received by a proxy service in the electronic device and stored in the local storage space. The determining module is configured to, when a second service in the electronic device issues a subscription request, determine the target device data of the subscription request from the local storage space if the request object of the subscription request is the first service; A module is provided for providing the target device data to the second service; A first sending module is configured to send a first response signal to the first service when the proxy service receives a first detection signal; wherein the first detection signal is periodically sent from the first service to the proxy service; The caching module is used to cache the generated device data when the first service does not receive the first response signal within a first preset time period, and to send the cached device data to the proxy service the next time the first response signal is received; The second sending module is used to send a second response signal to the second service when the proxy service receives the second detection signal; wherein the second detection signal is periodically sent from the second service to the proxy service; The third sending module is used to pause sending the subscription request when the second service does not receive the second response signal within a second preset time period, and to send the subscription request to the proxy service the next time the second response signal is received.
7. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 5.
8. A readable storage medium, characterized in that, The readable storage medium stores executable program code, which, when executed, implements the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Communication method, device, equipment and medium
CN115914393A
Data calling method and device, computer equipment and storage medium
CN118051284A