Data processing method and device, electronic equipment and readable storage medium
By storing device data between services in the local storage space of electronic devices and directly providing data when needed, the problem of low data transmission efficiency between services within the same device is solved, and efficient and secure data transmission is achieved.
Patent Information
- Application Number
- CN202411928656.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-25
AI Technical Summary
When data transmission is performed between multiple services deployed on the same electronic device, obtaining device data from a third-party database will reduce the data transmission efficiency.
The new device data issued by the first service is stored in the local storage space of the electronic device, and the target device data is provided from the local storage space when the second service issues a subscription request.
By storing data locally, data transmission across nodes is avoided, data transmission efficiency and response speed are improved, and data transmission accuracy and security are enhanced.
Smart Images

Figure CN119766882A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a data processing method, device, electronic device and readable storage medium in the field of computer technology. Background Art
[0002] At present, researchers usually deploy multiple services on the same electronic device, and the device data generated by these services are usually stored in a third-party database. When the service on the electronic device needs to transmit data with services on other electronic devices, the corresponding device data can be obtained from the third-party database. However, when data needs to be transmitted between services on the same electronic device, obtaining device data from a third-party database will reduce the data transmission efficiency. Therefore, there is an urgent need for a data processing method that can improve the efficiency of device data transmission between services in the same electronic device. Summary of the invention
[0003] The present 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] In a first aspect, a data processing method is provided, which is applied to an electronic device, and the method includes:
[0005] 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;
[0006] When the second service in the electronic device issues a subscription request, if the request object of the subscription request is the first service, determining the target device data for subscription requested by the subscription request from the local storage space;
[0007] The target device data is provided to the second service.
[0008] In the embodiment of the present application, the electronic device stores the new device data sent by the first service in the local storage space, which is conducive to being quickly accessed by other services in the electronic device, ensuring that the device data does not need to jump out of the node where the current electronic device is located when transmitting, thereby achieving high-performance data transmission, and further improving the efficiency of data processing. 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 of obtaining data.
[0009] In conjunction with the first aspect, in some possible implementations, storing new device data in a local storage space of the electronic device includes:
[0010] Determine whether there is a first subspace in at least one subspace; wherein the subspace is a storage space pre-divided from the local storage space for the first service, and the first subspace is a subspace having a free position for storing new device data;
[0011] If the first subspace exists, storing new device data in the first subspace;
[0012] Alternatively, if the first subspace does not exist, a new subspace is divided from the local storage space for the first service, and the new device data is stored in the new subspace.
[0013] In the embodiment of the present application, the electronic device can efficiently utilize the existing storage space and avoid unnecessary waste of space by determining whether the subspace pre-divided for the first service has free space. When the existing subspace cannot meet the storage demand, the electronic device can dynamically allocate new storage space to ensure the continuous storage capacity of data and improve the overall storage efficiency.
[0014] In conjunction with the first aspect, in some possible implementations, determining target device data for a subscription request from a local storage space includes:
[0015] Based on the space index included in the subscription request, determine a second subspace from at least one subspace pre-divided for the first service;
[0016] Determine a storage address of the target device data in the second subspace based on the address index included in the subscription request;
[0017] Based on the storage address, target device data is determined from the second subspace.
[0018] In the embodiment of the present application, by setting the spatial index, the electronic device can quickly narrow 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 locating data. Furthermore, in the second subspace, the storage address of the target device data is further accurately located through the address index, making data location more efficient.
[0019] In combination with the first aspect, in some possible implementations, if the request object of the subscription request is the first service, determining the target device data for subscription requested by the subscription request from the local storage space includes:
[0020] Get the data identifier included in the subscription request;
[0021] If the acquired data identifier is a data identifier configured for device data generated in advance for the first service, the target device data is determined from the local storage space.
[0022] In the embodiment of the present application, only the second service with the correct data identifier can access the device data of the first service, thereby avoiding unnecessary data leakage and miscommunication, thereby improving the accuracy and security of data transmission. At the same time, the data identifier can also make it easier for the electronic device to manage the data transmission session between various services.
[0023] In conjunction with the first aspect, in some possible implementations, the new device data is received by a proxy service in the electronic device and stored in a local storage space, and the method further includes:
[0024] The proxy service sends a first response signal to the first service when receiving the first detection signal; wherein the first detection signal is periodically sent by the first service to the proxy service;
[0025] When 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 when it receives the first response signal next time.
[0026] In the embodiment of the present application, 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, it means that there may be a problem with the connection. At this time, the first service will cache the data and transmit it after the connection is restored, thereby avoiding the risk of data loss. At the same time, when the network condition is poor or the proxy service is temporarily unavailable, the first service will not send data all the time, but cache the data, which can reduce unnecessary network requests and reduce network congestion. Wait until the network condition improves or the proxy service is restored before transmitting data, thereby improving the efficiency of network resource utilization.
[0027] In combination with the first aspect, in some possible implementations, the method further includes:
[0028] The proxy service sends a second response signal to the second service when receiving the second detection signal; wherein the second detection signal is periodically sent by the second service to the proxy service;
[0029] When the second service does not receive the second response signal within the second preset time period, it suspends sending the subscription request, and sends the subscription request to the proxy service when it receives the second response signal next time.
[0030] In an embodiment of the present application, the second service can monitor the connection status with the proxy service in real time by periodically sending a second detection signal. If no response is received within a preset time, it means that there may be a problem with the proxy service. At this time, the second service will suspend the sending of the subscription request and transmit it after the connection is restored, thereby avoiding the risk of losing the subscription request. When the network condition is poor or the proxy service is temporarily unavailable, the second service will not keep resending the subscription request, which can reduce unnecessary network requests and reduce network congestion. The subscription request will be transmitted after the network condition improves or the proxy service is restored, thereby improving the efficiency of network resource utilization.
[0031] In conjunction with the first aspect, in some possible implementations, storing new device data in a local storage space of the electronic device includes:
[0032] determining whether new device data is sent by the first service based on a loopback address of the electronic device;
[0033] If sent by the first service based on the loopback address, the new device data is stored in the local storage space.
[0034] In the embodiment of the present application, by verifying whether the data is sent based on the 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 the new device data is sent by the first service based on the loopback address, the electronic device can filter out unsafe data, reduce the processing burden of invalid data, and thus improve the response speed of the electronic device.
[0035] In a second aspect, a data processing device is provided, the device comprising:
[0036] A storage module, configured to store the new device data in a local storage space of the electronic device when the first service in the electronic device sends new device data;
[0037] A determination module, configured to determine target device data for subscription from a local storage space when a second service in the electronic device issues a subscription request, if the request object of the subscription request is the first service;
[0038] A module is provided for providing target device data to a second service.
[0039] In a third aspect, an electronic device is provided, comprising a memory for storing executable program code;
[0040] The processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in any possible implementation manner of the first aspect above.
[0041] In a fourth aspect, an executable program code product is provided, the executable program code product comprising: an executable program code, when the executable program code is run on a computer, the computer executes the method in any possible implementation manner of the above-mentioned first aspect.
[0042] In a fifth aspect, a readable storage medium is provided, which stores an executable program code. When the executable program code runs on a computer, the computer executes the method in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a flowchart of a data processing method provided by an embodiment of the present application;
[0044] Figure 2 is a flowchart of a data processing method provided by an embodiment of the present application;
[0045] Figure 3 is a flowchart of a data processing method provided by an embodiment of the present application;
[0046] Figure 4 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0047] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0049] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying 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 the features.
[0050] At present, in order to improve communication efficiency, researchers usually deploy multiple services on the same electronic device, and the device data generated by these services are usually stored in a third-party database. When the service on the electronic device needs to transmit data to services on other electronic devices, the corresponding device data can be obtained from the third-party database. However, when data needs to be transmitted between services on the same electronic device, obtaining device data from a third-party database will reduce the data transmission efficiency.
[0051] In order to solve the above technical problems, an embodiment of the present application provides a data processing method, which can be executed by an electronic device. When the first service in the electronic device sends new device data, the electronic device stores the new device data in the local storage space of the electronic device; when the second service in the electronic device sends a subscription request, if the request object of the subscription request is the first service, the target device data subscribed by 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 device data can be stored in the local storage space between the services deployed on the same electronic device, ensuring that the device data does not need to jump out of the node where the current electronic device is located when transmitting, thereby achieving high-performance data transmission, and further improving the efficiency of data transmission and data processing.
[0052] See also Figure 1 , Figure 1 is a flowchart of a data processing method provided by an embodiment of the present application. The execution subject of the method may be an electronic device, such as Figure 1 As shown, the method may include the following steps.
[0053] S101: When a first service in an electronic device sends new device data, the new device data is stored in a local storage space of the electronic device.
[0054] The local storage space refers to the physical storage medium inside the electronic device for storing device data.
[0055] In electronic devices, there are usually multiple services running at the same time, and each service is responsible for different functions. Among them, 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, taking a vehicle as an example, the device data of the first service can be the current vehicle status of the vehicle obtained by the first service from the vehicle's speed sensor, or the current fuel level, current temperature inside the vehicle, current door switch status, etc. obtained from the vehicle's electronic control unit.
[0056] In actual applications, the electronic device can pre-create a publisher-subscriber (also called a listener) to monitor in real time whether other services send device data; when the electronic device monitors that the first service sends new device data, the new device data can be stored in the local storage space of the electronic device according to a preset storage method.
[0057] In one embodiment, after creating a publisher-subscriber, the electronic device monitors in real time whether other services send device data. When it is determined that the first service sends 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 the device data in the form of a file in the local file system. The naming of the file can be determined according to a preset storage rule. For example, the naming of the file 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. For another example, the file name can be named according to the storage time of the device data.
[0058] For example, taking a vehicle as an example, during the driving process of the vehicle, assuming that the first service is a signal collection service, after determining that the electronic device has successfully created a publisher-subscriber, real-time monitoring is performed to determine whether the various services inside the vehicle send new device data. When the electronic device determines that the signal collection service sends a signal at the current time 10:00 that the vehicle's oil volume is 75 liters, a file named with a timestamp can be created, and the oil volume data 75 liters and the current timestamp 10:00 can be stored together in the local file system.
[0059] In another embodiment, after creating a publisher-subscriber, the electronic device monitors in real time whether other services send device data. When it is determined that the first service sends new device data, the electronic device can store the device data in the corresponding location of the local database. The use of a database storage method can conveniently implement operations such as data query, update, and deletion.
[0060] S102: When the second service in the electronic device sends a subscription request, if the request object of the subscription request is the first service, determine the target device data for subscription of the subscription request from the local storage space.
[0061] S103: Provide target device data to the second service.
[0062] Among them, the second service refers to a service inside an electronic device that can receive and process device data from other services (such as the first service). Taking the vehicle as an example, the second service can be a display service in the vehicle system. For example, if the first service sends fuel volume data, the second service can obtain the fuel volume data sent by the first service, and when the fuel volume data is less than the preset fuel volume threshold, it reminds the user on the central control screen and pushes nearby gas stations to the user. For another example, the second service can be a control service in the vehicle. If the first service sends the in-car temperature, the second service can obtain the in-car temperature sent by the first service, and when the in-car temperature is less than the preset temperature threshold, it reminds the user on the central control screen and controls the air conditioning and heating system in the vehicle to turn on.
[0063] The subscription request refers to a request sent by the second service to the electronic device, which is used to indicate that the second service wishes to receive device data of a specific service. The subscription request may include, but is not limited to, a request object, identity authentication information, a request file name, and the like.
[0064] In this embodiment, the electronic device monitors various services in the electronic device in real time through the publisher and subscriber. When determining that the second service in the electronic device sends a subscription request, it determines whether the request object in the subscription request is the first service. If the request object is the first service, the electronic device can determine the storage location of the device data of the first service in the local storage space according to the subscription request, and determine the target device data requested for subscription according to the storage location. Afterwards, 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 according to the target device data.
[0066] For example, taking a vehicle as an example, assume that the first service is a signal acquisition service; the second service is a display service in the vehicle system. When the electronic device determines that the second service sends a subscription request, it parses the subscription request and obtains that the request object in the subscription request is the first service. When the electronic device determines that the request object is the first service, it determines the storage location of the device data of the first service in the local storage space according to the request file name in the subscription request, and determines the fuel level of the vehicle requested to be subscribed according to the storage location. Afterwards, the electronic device sends the fuel level of the vehicle 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. When it is determined that the fuel level data is less than the preset fuel level threshold, the electronic device can remind the user on the central control screen and push nearby gas stations to the user.
[0068] In an embodiment of the present application, 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. Afterwards, when the second service in the electronic device sends a subscription request, if the request object of the subscription request is the first service, the target device data to be subscribed by 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 the local storage space, which is conducive to being quickly accessed by other services in the electronic device, ensuring that the device data does not need to jump out of the node where the current electronic device is located when transmitting, thereby achieving high-performance data transmission, and further improving the efficiency of data processing. 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 of obtaining data.
[0069] Optionally, storing the new device data in a local storage space of the electronic device includes:
[0070] Determine whether there is a first subspace in at least one subspace; wherein the subspace is a storage space pre-divided from the local storage space for the first service, and the first subspace is a subspace having a free position for storing new device data;
[0071] If the first subspace exists, storing new device data in the first subspace;
[0072] Alternatively, if the first subspace does not exist, a new subspace is divided 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 sends new device data, it can determine the data size of the device data; after determining the data size, the electronic device can compare the data size with the first subspace to determine whether there is a first subspace in the subspace with a free position to store the new device data; if the data size is less than or equal to the first subspace, it is determined that there is a first word space, and then the electronic device can convert the device data to be stored into the 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. Afterwards, the electronic device divides a new subspace for the first service from the local storage space and stores 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 an address index (also called an offset) of the device data and a storage address corresponding to the address index to the end of the index file.
[0076] For example, taking a vehicle as an example, it is assumed that the first service in the electronic device (for example, the fuel monitoring system of the vehicle) sends a new device data, which indicates that the current fuel volume of the vehicle is 75 liters, and its data size is 2 bytes. The electronic device compares the data size with the first subspace (for example, the size is 100 bytes), and determines that the data size is smaller than the first subspace, so it is determined that there are enough free positions to store the new device data in the first subspace. Next, if there is no other data in the first subspace, the electronic device will convert this device data into the format of "data length + data content" and store it in the form of bytes at the starting position of the first subspace. After the storage is completed, the electronic device will also append a record at the end of the corresponding index file. Assuming that the index file is initially empty, the electronic device will add the address index and the corresponding storage address of the device data in the index file, then the address index is "0000" and the corresponding storage address is "0000". If the newly generated data volume exceeds the capacity of the first subspace, the electronic device will allocate a new subspace for the first service in the local storage space and repeat the above storage process.
[0077] In another exemplary embodiment, if two pieces of device data are already stored in the first subspace, and the sizes of the device data are 20 bytes and 30 bytes respectively, at this time, if the first service in the electronic device (for example, the fuel level monitoring system of the vehicle) sends a new piece of device data, the device data indicates that the current fuel level of the vehicle is 75 liters, and its data size is 2 bytes. The electronic device compares the data size with the remaining space of the first subspace (the size is 50 bytes), and 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. Therefore, the device data is stored in the position immediately after the first two pieces of data, that is, starting from byte offset 50. Afterwards, assuming that 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 is address index: 0001, storage address: 0000; address index: 0002, storage address: 0020; address index: 0003, storage address: 0050.
[0078] In an embodiment of the present application, the electronic device determines whether there is a first subspace in at least one subspace; if there is a first subspace, new device data is stored in the first subspace; if there is no first subspace, a new subspace is divided from the local storage space for the first service, and the new device data is stored in the new subspace. In this way, the electronic device can efficiently utilize the existing storage space and avoid unnecessary waste of space by determining whether the subspace pre-divided for the first service has free space. When the existing subspace cannot meet the storage requirements, the electronic device can dynamically allocate new storage space to ensure the continuous storage capacity of data and improve the overall storage efficiency.
[0079] Optionally, determining the target device data for the subscription request from the local storage space includes:
[0080] Based on the space index included in the subscription request, determine a second subspace from at least one subspace pre-divided for the first service;
[0081] Determine a storage address of the target device data in the second subspace based on the address index included in the subscription request;
[0082] Based on the storage address, target device data is determined from the second subspace.
[0083] The spatial index refers to the index of the pre-divided subspace in which the target device data in the subscription request is located; the second subspace refers to a specific subspace in 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 used to locate the target device data in the index file corresponding to the second subspace. The storage address refers to the specific storage location of the target device data in the second subspace.
[0084] In actual applications, the electronic device can pre-create an offsetter (also called an offsetter) to determine in real time whether the offset of the device service has changed. If it is determined that the offset of the device service has changed, the offset is updated. At the same time, after the second service sends a subscription request, the electronic device can determine the spatial index and address index that the second service currently needs to read through the offsetter.
[0085] In one embodiment, the subscription request includes a spatial index and an address index; the electronic device can receive the subscription request sent by the second service through the grpc-receive interface, and after receiving the subscription request sent by the second service, the spatial index in the subscription request can be determined, and the second subspace can be determined from at least one subspace pre-divided for the first service according to the binary method and the spatial index. Afterwards, the electronic device determines the storage address of the target device data in the second subspace according to the binary method and the address index; and determines the target device data from the second subspace based on the storage address.
[0086] Exemplarily, taking a vehicle as an example, assume that an electronic device in the vehicle has multiple services, including a signal acquisition service (as a first service) and a data analysis service (as a 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, a subscription request is issued to the electronic device. This request contains a spatial index 001 and an address index 003. The electronic device uses a binary search algorithm to quickly locate the second subspace storing vehicle speed data in multiple pre-divided subspaces according to the spatial index 001. In the corresponding index file inside the second subspace, the electronic device uses binary search again to determine that the address index 002 and the storage address corresponding to the address index are 50 bytes. Finally, the electronic device reads the target device data from 50 bytes inside the second subspace.
[0087] In another embodiment, the subspace may include a log file and an index file. The log file is used to store actual device data, and the index file is used to store index addresses and storage addresses of device data corresponding to the index addresses. At the same time, the naming of the log file corresponding to each subspace is consistent with the naming of the index file, and can be named according to the index address of the data at the starting position of each index file. For example, the first index file is named 000000+1.index; the first log file is named 000000+1.log; assuming that 50 data are stored in the first index file, the second index file is named 000000+51.index; the second log file is named 000000+51.log; and so on. When the second service reads data, it can start reading from the subspace with an address index of 1. After each reading, the address index value is increased by 1 and recorded. The device data is read sequentially from the recorded address index at the next reading.
[0088] Exemplarily, the subscription request may include an address index; after receiving the subscription request from the second service, the electronic device may determine in which index file the index address is located from at least one subspace pre-divided for the first service based on the binary search method and the address index. Afterwards, the electronic device may determine the storage address of the target device data in the index file based on the binary search method and the address index; and determine the target device data from the log file based on the storage address.
[0089] In an embodiment of the present application, the electronic device determines the 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 determined from the second subspace. In this way, by setting the spatial index, the electronic device can quickly narrow 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 locating data. Furthermore, within the second subspace, the storage address of the target device data is further accurately located through the address index, making data positioning more efficient.
[0090] Optionally, if the request object of the subscription request is the first service, determining the target device data for subscription requested by the subscription request from the local storage space includes:
[0091] Get the data identifier included in the subscription request;
[0092] If the acquired data identifier is a data identifier configured for device data generated in advance for the first service, the target device data is determined from the local storage space.
[0093] The data identifier refers to an identifier used to identify a unique session between the first service and the second service, which may also be referred to as a "topic".
[0094] In this embodiment, when the first service sends new device data, the first service will pre-generate a data identifier. At the same time, when the second service wants to transmit data with the first service, the second service will also pre-generate a data identifier that is the same as the first service. After receiving the subscription request from the second service, the electronic device can obtain the data identifier in the subscription request; and compare the data identifier with the data identifier of the device data configuration generated by the first service. If the data identifier is consistent with the data identifier generated by the first service, it indicates that the second service can obtain the device identification data of the first service, that is, the electronic device determines the target device data from the local storage space.
[0095] If the data identifier is inconsistent with the data identifier generated by the first service, it indicates that data cannot be transmitted between the second service and the first service, that is, the second service cannot obtain the device data of the first service.
[0096] In an embodiment of the present application, the electronic device obtains the data identifier in the subscription request; if the obtained data identifier is a data identifier configured for the device data generated in advance 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 miscommunication, and further improving the accuracy and security of data transmission. At the same time, the data identifier can also make it easier for the electronic device to manage the data transmission sessions between various services.
[0097] Optionally, the new device data is received by the proxy service in the electronic device and stored in the local storage space. The method may further include the following steps:
[0098] The proxy service sends a first response signal to the first service when receiving the first detection signal; wherein the first detection signal is periodically sent by the first service to the proxy service;
[0099] When 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 when it receives the first response signal next time.
[0100] The proxy service refers to a program running on an electronic device, which is responsible for receiving device data from the first service and storing it in a local storage space. In addition, the proxy service is also responsible for processing communications 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 called a "heartbeat signal") periodically sent by the first service to the proxy service. The first detection signal can be 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 a reply signal sent by the proxy service to the first service after receiving the first detection signal from the first service. The signal indicates that the proxy service has successfully received the first detection signal and is currently online and can receive device data from the first service.
[0103] In actual applications, before receiving the detection signal, the proxy service in the electronic device can pre-create a heartbeat to receive the detection signals sent by other services to ensure that the proxy service is aware of whether other services are online in a timely manner, and enable other services to know whether the proxy service is online in a timely manner.
[0104] In this embodiment, after the first service goes online, it periodically sends a first detection signal to the proxy service in the electronic device. For example, in the first cycle, 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 sent by the proxy service within a preset time, it indicates that the first service can send device data to the proxy service. In the second cycle, the first service sends a first detection signal to the proxy service, but does not receive the first response signal sent by the proxy service within the first preset time, 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 cycle, the first service receives the first response signal sent by the proxy service, and 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 this storage space.
[0105] In an embodiment of the present application, 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 the first preset time period, the generated device data is cached, and the cached device data is sent to the proxy service when the first response signal is received next time. 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 means that there may be a problem with the connection. At this time, the first service will cache the data and transmit it after the connection is restored, thereby avoiding the risk of data loss. At the same time, when the network condition is poor or the proxy service is temporarily unavailable, the first service will not send data all the time, but cache the data, which can reduce unnecessary network requests, reduce network congestion, and wait until the network conditions improve or the proxy service is restored before transmitting data, thereby improving the efficiency of network resource utilization.
[0106] Optionally, the method may further include the following steps:
[0107] The proxy service sends a second response signal to the second service when receiving the second detection signal; wherein the second detection signal is periodically sent by the second service to the proxy service;
[0108] When the second service does not receive the second response signal within the second preset time period, it suspends sending the subscription request, and sends the subscription request to the proxy service when it receives the second response signal next time.
[0109] Among them, the second detection signal refers to a specific type of signal periodically sent by the second service to the proxy service. The main function of this signal is to check whether the proxy service is online and available, so that the second service can determine whether it is safe to send a subscription request to the proxy service. Similar to the first detection signal, the second detection signal is also commonly referred to as a "heartbeat signal". The second response signal refers to the reply signal sent by the proxy service to the second service after receiving the second detection signal from the second service. This signal indicates that the proxy service has successfully received the second detection signal and is currently online and can receive subscription requests from the second service. If the second service does not receive this response signal within a preset time, it will consider the proxy service unavailable and take corresponding measures, such as caching the subscription request and waiting for the next opportunity to resend it.
[0110] In this embodiment, after the second service goes online, it periodically sends a second detection signal to the proxy service in the electronic device. For example, in the first cycle, 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 sent by the proxy service within the preset time, it indicates that the second service can send a subscription request to the proxy service. In the second cycle, the second service sends a second detection signal to the proxy service, but does not receive the second response signal sent by the proxy service within the second preset time, 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 cycle, the second service receives the second response signal sent by the proxy service, and 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 subscribed by the subscription request from the local storage space, and provides the target device data to the second service.
[0111] In an embodiment of the present application, when the proxy service receives the second detection signal, it sends a second response signal to the second service; when the second service does not receive the second response signal within the second preset time, it suspends sending the subscription request, and sends the 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, it means that there may be a problem with the proxy service. At this time, the second service will suspend the sending of the subscription request and transmit it after the connection is restored, thereby avoiding the risk of losing the subscription request. When the network condition is poor or the proxy service is temporarily unavailable, the second service will not keep resending the subscription request, which can reduce unnecessary network requests and reduce network congestion. The subscription request will be transmitted after the network condition improves or the proxy service is restored, thereby improving the efficiency of network resource utilization.
[0112] Optionally, storing the new device data in a local storage space of the electronic device includes:
[0113] determining whether new device data is sent by the first service based on a loopback address of the electronic device;
[0114] If sent by the first service based on the loopback address, the new device data is stored in the local storage space.
[0115] The loopback address refers to a unique identifier of an electronic device or a specific network address.
[0116] In this embodiment, when the electronic device receives new device data sent by the first service, it determines whether the new device data is sent by the first service based on the loopback address of the electronic device. If the device data is sent by the first service based on the loopback address, the electronic device will consider the data to be safe and valid, and store the new device data in the local storage space. If the device data is not sent by the first service based on the loopback address, the electronic device will consider the data to be unsafe or invalid, and discard the new device data, and send a response message to the first service, indicating that the received device data is unsafe or verification fails.
[0117] In the embodiment of the present application, the electronic device determines 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. In this way, by verifying whether the data is sent based on the 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 the new device data is sent by the first service based on the loopback address, the electronic device can filter out invalid or unsafe data, reduce the processing burden of invalid data, and thus improve 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 sends 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 sent by 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 also Figure 2 , Figure 2 This is a flow chart of the steps of a data processing method provided by an embodiment of the present application. Figure 2 As shown, the method may include the following steps.
[0121] S201: A first service sends a first registration request to a proxy service.
[0122] The first registration request carries 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 so, step S203 is executed; otherwise, step S204 is executed.
[0124] S203: The proxy service returns that the first service registration has failed.
[0125] S204: The proxy service registers the first service and caches the identification information in a preset mapping table.
[0126] S205: After the first service is successfully registered, the first service sends a first detection signal to the proxy service.
[0127] S206: When receiving the first detection signal, the proxy service sends a first response signal to the first service.
[0128] S207, the first service determines whether a first response signal is received within a first preset time period, if the first response signal is received, execute step S208; otherwise, execute step S209.
[0129] S208, sending device data to the proxy service.
[0130] S209, cache the generated device data, and send the cached device data to the proxy service when the first response signal is received next time.
[0131] S211, the second service sends a second registration request to the proxy service.
[0132] The second registration request carries 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 so, execute step S213; otherwise, execute step S214.
[0134] S213: The proxy service returns that the second service registration has 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 is successfully registered, the second service sends a second detection signal to the proxy service.
[0137] S216: When receiving the second detection signal, the proxy service sends a second response signal to the first service.
[0138] S217, the second service determines whether a second response signal is received within a second preset time period, if received, execute step S218; otherwise, execute step S219.
[0139] S218, sending a subscription request to the proxy service.
[0140] S219, suspend sending the subscription request, and send the subscription request to the proxy service when receiving the second response signal next time.
[0141] It should be noted that the execution order of the first service and the second service may be changed according to the actual application scenario and is not limited thereto.
[0142] See also Figure 3 , Figure 3 This is a flow chart of the steps of a data processing method provided by an embodiment of the present application. Figure 3 As shown, the method may include the following steps.
[0143] S301, the first service sends new device data to the proxy service.
[0144] S302: Receive new device data sent by the first service.
[0145] S303, determining whether there is a first subspace in at least one subspace, if there is a first subspace, executing step S304; otherwise, executing step S305.
[0146] The subspace is a storage space pre-divided from the local storage space for the first service, and the first subspace is a subspace with a free position for storing new device data.
[0147] S304: Store new device data in the first subspace.
[0148] Exemplarily, after receiving new device data sent by the first service, it can be determined whether the new device data is sent by the first service based on the loopback address of the electronic device; if sent by the first service based on the loopback address, the new device data is stored in the first subspace.
[0149] S305: divide a new subspace from the local storage space for the first service, and store 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 sent by the second service.
[0152] S313: 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.
[0153] S314: Determine the storage address of the target device data in the second subspace based on the address index included in the subscription request.
[0154] S315 , determining target device data from the second subspace based on the storage address.
[0155] S316, providing the target device data to the second service.
[0156] It should be noted that the execution order of the first service and the second service may be changed according to the actual application scenario and is not limited thereto.
[0157] It should be noted that the achievable methods and technical effects of each step in the embodiments of the present application can refer to the relevant contents in the above embodiments and will not be repeated here.
[0158] See also Figure 4 , Figure 4 It is a structural diagram of a data processing device provided in an embodiment of the present application. The data processing device can be set in an electronic device and can include: a storage module 401, a determination module 402 and a providing module 403.
[0159] The storage module 401 is used to store the new device data in the local storage space of the electronic device when the first service in the electronic device sends new device data;
[0160] The determination module 402 is used to determine the target device data for subscription request from the local storage space when the second service in the electronic device sends a subscription request, if the request object of the subscription request is the first service;
[0161] The providing module 403 is used to provide the target device data to the second service.
[0162] Optionally, the storage module 401 is specifically used to determine whether there is a first subspace 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 position 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 determination module 402 is specifically used to determine the 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 determination module 402 is specifically configured to obtain a data identifier included in the subscription request; if the obtained data identifier is a data identifier configured for device data generated in advance for the first service, 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 a local storage space, and the data processing apparatus may further include: a first sending module and a caching module;
[0166] A first sending module, configured for the proxy service 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 by the first service to the proxy service;
[0167] The cache module is used to cache the generated device data when the first service does not receive the first response signal within the first preset time period, and send the cached device data to the proxy service when the first response signal is received next time.
[0168] Optionally, the data processing device may further include: a second sending module and a third sending module;
[0169] A second sending module, configured for the proxy service 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 by the second service to the proxy service;
[0170] The third sending module is used to suspend sending the subscription request when the second service does not receive the second response signal within the second preset time period, and send the subscription request to the proxy service when the second response signal is received next time.
[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 embodiments, and its implementation principles and technical effects are similar, which will not be repeated here.
[0173] See also Figure 5 , Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0174] For example, Figure 5 As shown, the electronic device 500 includes: a memory 501 and a processor 502, wherein the memory 501 stores an 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] In addition, an embodiment of the present application also protects a vehicle, which may include a memory and a processor, wherein the memory stores an executable program code, and the processor is used to call and execute the executable program code to execute a data processing method provided by an embodiment of the present application.
[0176] This embodiment also provides a readable storage medium, in which executable program code is stored. When the executable program code runs on a computer, the computer executes the above-mentioned related method steps to implement a data processing method provided by the above-mentioned embodiment.
[0177] This embodiment also provides an executable program code product. When the executable program code product runs on a computer, the computer is enabled to execute the above-mentioned related steps to implement a data processing method provided by the above embodiment.
[0178] Among them, the device, readable storage medium, executable program code product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0179] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned 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 the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0181] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data processing method, characterized in that: Applied to electronic equipment, the method comprises: When the first service in the electronic device sends new device data, storing the new device data in a local storage space of the electronic device; When the second service in the electronic device issues a subscription request, if the request object of the subscription request is the first service, determining the target device data for subscription requested by the subscription request from the local storage space; The target device data is provided to the second service.
2. The method according to claim 1, characterized in that The storing the new device data in the local storage space of the electronic device includes: Determine whether there is a first subspace in at least one subspace; wherein the subspace is a storage space pre-divided from the local storage space for the first service, and the first subspace is the subspace having a free position for storing the new device data; If the first subspace exists, storing the new device data in the first subspace; Alternatively, if the first subspace does not exist, a new subspace is divided 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 The determining, from the local storage space, target device data for subscription by the subscription request includes: Determine, based on the space index included in the subscription request, a second subspace from at least one of the subspaces pre-divided for the first service; Determine, based on the address index included in the subscription request, a storage address of the target device data in the second subspace; The target device data is determined from the second subspace based on the storage address.
4. The method according to claim 1, characterized in that: If the request object of the subscription request is the first service, determining the target device data for subscription requested by the subscription request from the local storage space includes: Obtaining a data identifier included in the subscription request; If the acquired data identifier is a data identifier configured in advance for device data generated for the first service, the target device data is determined from the local storage space.
5. The method according to claim 1, characterized in that The new device data is received by the proxy service in the electronic device and stored in the local storage space, and the method further includes: The proxy service sends a first response signal to the first service when receiving the first detection signal; wherein the first detection signal is periodically sent by the first service to the proxy service; When 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 when it receives the first response signal next time.
6. The method according to claim 5, characterized in that The method further comprises: The proxy service sends a second response signal to the second service when receiving the second detection signal; wherein the second detection signal is periodically sent by the second service to the proxy service; When the second service does not receive the second response signal within a second preset time period, it suspends sending the subscription request, and sends the subscription request to the proxy service when it receives the second response signal next time.
7. The method according to any one of claims 1 to 6, characterized in that The storing the new device data in the local storage space of the electronic device includes: determining whether the new device data is sent by the first service based on a loopback address of the electronic device; If sent by the first service based on the loopback address, the new device data is stored in the local storage space.
8. A data processing device, characterized in that: The device comprises: A storage module, configured to store new device data in a local storage space of the electronic device when the first service in the electronic device sends new device data; a determination module, configured to determine, when a second service in the electronic device issues a subscription request, target device data for which the subscription request is requested from the local storage space if the request object of the subscription request is the first service; A providing module is used to provide the target device data to the second service.
9. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores executable program codes, and when the executable program codes are executed, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Communication method, device, equipment and medium
CN115914393A
Data caching method and device, electronic equipment and computer readable storage medium
CN117493394A
Data calling method and device, computer equipment and storage medium
CN118051284A
Mutations with immediate feedback
US10891282B1
File access method and system, electronic device, and machine-readable storage medium
WO2024230779A1