Data writing method, terminal, system, electronic device and storage medium
By implementing shared storage space and mutual recognition mechanisms between terminals in the Internet of Things system, dynamically determine the data writing to the target terminal, solving the problem of short service life caused by high-frequency data writing and improving system stability.
Patent Information
- Application Number
- CN202210691678.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-17
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-06-17
AI Technical Summary
High-frequency data writing in IoT systems leads to a short service life of the terminal, affecting system stability.
By realizing shared storage space between terminals in the Internet of Things system, using mutual recognition mechanisms and testing mechanisms to build a shared storage space network, dynamically determine the data writing to the target terminal, and avoid the service life reduction caused by frequent writes.
It extends the service life of high-frequency data writing terminals and improves the stability of the entire Internet of Things system.
Smart Images

Figure CN115102971B_ABST
Abstract
Description
[Technical field]
[0001] The embodiments of the present application relate to the field of storage technology, and in particular to a data writing method, terminal, system, electronic device and storage medium. [Background technology]
[0002] An IoT system includes multiple terminals, and some of these terminals may have a high frequency of data writing. In the case that the storage space of the above terminals is limited, high-frequency data writing will result in a shorter service life of the above terminals, thereby affecting the stability of the entire IoT system. [Summary of the invention]
[0003] The embodiments of the present application provide a data writing method, terminal, system, electronic device and storage medium, which can extend the service life of terminals with a high writing frequency in an Internet of Things system, thereby improving the stability of the entire Internet of Things system.
[0004] In a first aspect, an embodiment of the present application provides a data writing method, which is applied to a first terminal, wherein the first terminal establishes a communication connection with multiple second terminals and shares their respective free storage spaces, and the number of data writing times in the first terminal is higher than the number of data writing times in the multiple second terminals, and the method includes:
[0005] The first terminal receives a write request from a third terminal, the write request including target data to be written into the first terminal and a target storage space size occupied by the target data;
[0006] When the number of data writes of the first terminal exceeds a set threshold, the first terminal determines a first target second terminal and a corresponding target storage address to store the target data based on the size of the target storage space;
[0007] The first terminal sends the target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
[0008] In the embodiment of the present application, the first terminal can be considered to share the free storage space with multiple second terminals, and the first terminal has a higher writing frequency than each second terminal, that is, the service life of the storage space in the first terminal decreases faster. Therefore, when the third terminal needs to write the target data to the first terminal, the first terminal can determine whether it has already written many times. If the first terminal determines that it has written many times, it determines a second terminal to store the target data and the target storage address corresponding to the second terminal from the shared storage space, and informs the third terminal of the target storage address, so that the third terminal can write the target data to the second terminal, that is, use a second terminal that shares the storage space with the first terminal to store the target data to be written to the first terminal, so as to avoid the rapid decline of the service life of the first terminal due to frequent writing, thereby improving the stability of the system where the first terminal is located.
[0009] Optionally, before receiving the write request from the third terminal, the method further includes:
[0010] The first terminal and the multiple second terminals construct a shared storage space network based on a mutual identification mechanism and a test mechanism. In the shared storage space network, the first terminal and the multiple second terminals share their own free storage space. The mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each second terminal among the multiple second terminals to join the shared storage space network is recognized by the first terminal and other second terminals. The first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has not joined any shared storage space network. The test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and each second terminal and between each second terminal exceed a set threshold.
[0011] In an embodiment of the present application, if the first terminal and multiple second terminals have not joined any shared storage space network, the first terminal and each second terminal can broadcast a request to join the shared storage space network, and after recognizing each other's request and ensuring good communication quality, the first terminal and each second terminal can more easily build a new shared storage space network.
[0012] Optionally, before receiving the write request from the third terminal, the method further includes:
[0013] The first terminal joins a shared storage space network that already has the multiple second terminals based on a mutual identification mechanism and a test mechanism. In the shared storage space network, the first terminal and the multiple second terminals all share their own free storage space. The mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each of the multiple second terminals to join the shared storage network is recognized by the first terminal. The first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has joined the shared storage space network. The test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and the multiple second terminals all exceed a set threshold.
[0014] In an embodiment of the present application, if multiple second terminals join a shared storage space network and the first terminal has not joined any shared storage space network, then the first terminal and each second terminal can broadcast a request to join the shared storage space network, and the request corresponding to the first terminal carries an identifier indicating that the first terminal has not joined any shared storage space network, and the request corresponding to each second terminal carries an identifier indicating that the second terminal has joined a shared storage space network. In this way, the first terminal and each second terminal can recognize each other's requests, and while ensuring good communication quality, the first terminal can more easily join the shared storage space network where multiple second terminals are located.
[0015] Optionally, the first terminal belongs to a first shared storage space network, and the first terminal is located at a physical center of the first shared storage space network, the multiple second terminals belong to a second shared storage space network, and the second target second terminal is located at a physical center of the second shared storage space network, and before receiving a write request from a third terminal, the method further includes:
[0016] When a terminal whose number of terminals between the first shared storage space network and the second shared storage space network exceeds a set threshold receives a request to join the shared storage space network broadcasted by a terminal in a shared storage space network other than the terminal itself, the first terminal and the second target second terminal merge the first shared storage space network and the second shared storage space network into a third shared storage space network based on a test mechanism, in which the first terminal and the multiple second terminals in the third shared storage space network share their respective free storage space, and the test mechanism is used for network parameter values that characterize the communication quality between the first terminal and the second target second terminal to exceed a set threshold.
[0017] In an embodiment of the present application, if a first terminal has joined a first shared storage space network, and multiple second terminals have joined a second shared storage space network, then when the terminals between the first shared storage space network and the second shared storage space network exceeding a set threshold receive a request to join the shared storage space network broadcasted by a terminal of a shared storage space network other than the terminal itself, and when the communication quality between the first terminal located at the physical center of the first shared storage space network and the second target second terminal located at the physical center of the second shared storage space network is good, the first shared storage space network and the second shared storage space network can be merged relatively easily, so that the first terminal and each second terminal are in the same shared storage space network.
[0018] Optionally, the method further includes:
[0019] The first terminal and the plurality of second terminals synchronize their respective free storage space sizes.
[0020] In the embodiment of the present application, the free storage space sizes of the first terminal and the plurality of second terminals located in the same shared storage space network can be synchronized.
[0021] Optionally, after the first terminal sends the target storage address to the third terminal, the method further includes:
[0022] The first terminal determines that the third terminal has completed sending the target data.
[0023] In the embodiment of the present application, since the target data belongs to the first terminal, the first terminal needs to determine that the third terminal has successfully sent the target data to avoid the first terminal repeatedly notifying the third terminal to send data.
[0024] Optionally, after the first terminal determines that the third terminal has completed sending the target data, the method further includes:
[0025] The first terminal determines that the first target second terminal has received the target data.
[0026] In the embodiment of the present application, since the target data belongs to the first terminal, the first terminal needs to determine that the first target second terminal has received the target data, thereby avoiding the first terminal notifying the third terminal to resend the data.
[0027] Optionally, after the first terminal determines that the first target second terminal has received the target data, the method further includes:
[0028] The first terminal synchronizes the remaining free storage space size of the first target second terminal and the attribution relationship of the target data to other second terminals among the plurality of second terminals except the first target second terminal.
[0029] In an embodiment of the present application, the first terminal can synchronize the remaining storage space size of the first target second terminal used to store the current target data and the ownership relationship of the target data stored in the first target second terminal to other terminals in the same shared storage space network, so that other terminals can be aware of changes in the shared storage space network.
[0030] In a second aspect, an embodiment of the present application provides a first terminal, wherein the first terminal establishes a communication connection with multiple second terminals and shares their respective free storage spaces, wherein the number of data writes in the first terminal is higher than the number of data writes in the multiple second terminals, and the first terminal includes:
[0031] a receiving unit, configured to receive a write request from a third terminal, wherein the write request includes target data to be written into the first terminal and a target storage space size occupied by the target data;
[0032] A determining unit, configured to determine a first target second terminal to store the target data and a corresponding target storage address based on the size of the target storage space when the number of data writes to the first terminal exceeds a set threshold;
[0033] The sending unit is configured to send the target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
[0034] Optionally, the first terminal includes:
[0035] A construction unit is used to control the first terminal and the multiple second terminals to construct a shared storage space network based on a mutual identification mechanism and a test mechanism, in which the first terminal and the multiple second terminals in the shared storage space network share their own free storage space, and the mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each second terminal in the multiple second terminals to join the shared storage space network is recognized by the first terminal and other second terminals, the first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has not joined any shared storage space network, and the test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and each second terminal and between each second terminal exceed a set threshold.
[0036] Optionally, the first terminal further includes:
[0037] A joining unit is used to control the first terminal to join a shared storage space network that already has the multiple second terminals based on a mutual identification mechanism and a test mechanism, wherein the first terminal and the multiple second terminals in the shared storage space network share their own free storage space, the mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each of the multiple second terminals to join the shared storage network is recognized by the first terminal, the first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has joined the shared storage space network, and the test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and the multiple second terminals exceed a set threshold.
[0038] Optionally, the first terminal belongs to a first shared storage space network, and the first terminal is located at a physical center of the first shared storage space network, the multiple second terminals belong to a second shared storage space network, and the second target second terminal is located at a physical center of the second shared storage space network, and the first terminal further includes:
[0039] A merging unit, when a terminal exceeding a set threshold between the first shared storage space network and the second shared storage space network receives a request to join the shared storage space network broadcasted by a terminal in a shared storage space network other than its own, is used to control the first terminal and the second target second terminal to merge the first shared storage space network and the second shared storage space network into a third shared storage space network based on a test mechanism, in which the first terminal and the multiple second terminals in the third shared storage space network all share their respective free storage space, and the test mechanism is used to ensure that the network parameter values characterizing the communication quality between the first terminal and the second target second terminal all exceed the set threshold.
[0040] Optionally, the first terminal further includes:
[0041] The synchronization unit is used to control the first terminal and the plurality of second terminals to synchronize the free storage space sizes of each terminal.
[0042] Optionally, the determining unit is further used to: determine that the third terminal has completed sending the target data.
[0043] Optionally, the determining unit is further used for: the first terminal determining that the first target second terminal has received the target data.
[0044] Optionally, the synchronization unit is further used for:
[0045] The first terminal is controlled to synchronize the remaining free storage space size of the first target second terminal and the attribution relationship of the target data to other second terminals among the plurality of second terminals except the first target second terminal.
[0046] In a third aspect, the present application provides a data writing system, the data writing system comprising: a first terminal, and a plurality of second terminals communicating with the first terminal, the first terminal and the plurality of second terminals sharing their respective free storage spaces, the number of data writing times in the first terminal being higher than the number of data writing times in the plurality of second terminals;
[0047] The first terminal is configured to receive a write request from a third terminal, the write request including target data to be written to the first terminal and a target storage space size occupied by the target data; when the number of data writes to the first terminal exceeds a set threshold, determine a first target second terminal to store the target data and a corresponding target storage address based on the target storage space size; and send the target storage address to the third terminal;
[0048] The first target second terminal is used to receive and store the target data sent by the third terminal based on the target storage address, and the target data is set to belong to the first terminal.
[0049] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the processor is configured to implement the steps of the method described in any embodiment of the first aspect when executing a computer program stored in the memory.
[0050] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method as described in any embodiment of the first aspect.
[0051] It should be understood that the second to fifth aspects of the embodiments of the present invention are consistent with the technical solutions of the first aspect of the embodiments of the present invention, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be described in detail.
Brief Description of the Drawings
[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 An architecture diagram of an Internet of Things system provided in an embodiment of the present application;
[0054] Figure 2 A flowchart of a data writing method provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of the structure of a first terminal provided in an embodiment of the present application;
[0056] Figure 4 An architectural diagram of a data writing system provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. [Specific implementation method]
[0058] In order to better understand the technical solution of this specification, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0059] It should be clear that the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0060] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit this specification. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0061] Currently, NAND flash memory is widely used in various terminals to store data written into the terminal. However, the characteristic of NAND flash memory is that once it is erased many times, it will cause bad blocks in the internal storage unit and become unusable. Then, when all NAND flash memory blocks become bad blocks, the terminal equipped with the NAND flash memory will also not work properly.
[0062] The inventor of the present application has found that in an Internet of Things system, there are usually multiple types of terminals. For example, in a smart home Internet of Things system, there are terminals such as routers, electric lights, stereos, televisions, and sweeping robots. The frequency of writing data in the above-mentioned different types of terminals is different. Therefore, when the storage space of the terminal itself is limited, the service life of different types of terminals is also different. For example, when the terminal storage space is limited, if the frequency of data writing is small, there is no need to frequently erase the original stored data, so the service life of the terminal decreases slowly, that is, the service life of the terminal is longer; on the contrary, if the frequency of data writing is greater, the original stored data needs to be frequently erased, resulting in a faster reduction in service life, that is, the service life of the terminal is shorter, which will affect the stability of the entire Internet of Things system.
[0063] In view of this, an embodiment of the present application provides a data writing method, in which a first terminal can be considered to share its own free storage space with multiple second terminals, and the first terminal has a higher writing frequency than each second terminal, that is, the service life of the storage space in the first terminal decreases faster. Therefore, when the third terminal needs to write the target data to the first terminal, the first terminal can determine whether it has already written many times. If the first terminal determines that it has written many times, it determines a second terminal to store the target data and the target storage address corresponding to the second terminal from the shared storage space, and informs the third terminal of the target storage address, so that the third terminal can write the target data to the second terminal, that is, use a second terminal that shares the storage space with the first terminal to store the target data to be written to the first terminal, so as to avoid the rapid decrease in the service life of the first terminal due to frequent writing, thereby improving the stability of the system where the first terminal is located.
[0064] For ease of understanding, an application scenario of the embodiment of the present application is first introduced. Figure 1 , is an architecture diagram of an Internet of Things system provided in an embodiment of the present application. Figure 1 It includes terminal A1, terminal A2, gateway A, terminal B, gateway B, terminal C, gateway C and local server. Among them, each terminal (terminal A, terminal B, terminal C) can be considered to be mainly used to collect data, such as temperature data, humidity data, pressure data, etc. There is no special restriction on the specific type of data that can be collected by each terminal. Gateway A is mainly used to forward data from terminal A1 and terminal A2 to the local server. Gateway B is mainly used to forward data from terminal B to the local server; gateway C is mainly used to forward data from terminal C to the local server. The local server is used to analyze and process the received data. It should be understood that Figure 1 The direction of the solid arrow shown in represents the direction of data transmission.
[0065] On this basis, a shared storage space network (indicated by dotted lines) can be formed between gateways A, B and C, that is, gateways A, B and C can share their respective free storage space so that other devices besides themselves can also use the shared storage space in the shared storage space network. For example, gateway A can use the free storage space shared by gateways B and C, gateway B can use the free storage space shared by gateways A and C, and gateway C can use the free storage space shared by gateways A and B.
[0066] The following is an introduction to the technical solution provided by the embodiment of the present application in conjunction with the accompanying drawings. Figure 1 For example, see the application scenario shown in Figure 2 The embodiment of the present invention provides a data writing method, which can be applied to a first terminal, where a communication connection is established with a plurality of second terminals, and the first terminal shares their respective free storage spaces. The process of the method is described as follows:
[0067] Step 101: A first terminal receives a write request from a third terminal, where the write request includes target data to be written into the first terminal and a target storage space size occupied by the target data.
[0068] The first terminal can be considered as a node in the IoT system that can store data. For example, please continue to refer to Figure 1 , the first terminal may be gateway A, gateway B or gateway C. This means that other terminals may send data to be stored to the first terminal for storage.
[0069] As a possible implementation, the first terminal may receive a write request from a third terminal, the write request including target data to be written to the first terminal and the target storage space size occupied by the target data. It should be understood that the third terminal may be considered as another terminal that does not share free storage space with the first terminal and the plurality of second terminals.
[0070] Step 102: When the number of data writes of the first terminal exceeds a set threshold, the first terminal determines a first target second terminal and a corresponding target storage address for storing target data based on the size of the target storage space.
[0071] In the embodiment of the present application, although the first terminal shares free storage space with multiple second terminals, the number of data writes to the first terminal and the multiple second terminals is different. For example, within a unit time, the number of data writes to the first terminal can be considered to be greater than that of the multiple second terminals sharing the free storage space with it. In other words, the service life of the first terminal decreases faster than that of the multiple second terminals. In order to extend the service life of the first terminal as much as possible, the data that needs to be written to the first terminal can be written to a second terminal. Prior to this, it is necessary to first determine which of the multiple second terminals that share the free storage space with the first terminal is responsible for storing the data that currently needs to be written to the first terminal.
[0072] As a possible implementation mode, after receiving a write request from a third terminal, the first terminal may determine whether its own data write times are large. If it is determined that its own data write times exceed a set threshold, that is, it is determined that the data write times are large, it indicates that the current first terminal may have a problem of rapidly decreasing service life. At this time, the first terminal may determine a first target second terminal from multiple second terminals based on the size of the target storage space occupied by the target data that currently needs to be written to itself, as well as a target storage address in the first target second terminal that can accommodate the above target data.
[0073] Step 103: The first terminal sends a target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
[0074] In an embodiment of the present application, after the first terminal determines a first target second terminal for indirectly storing the above-mentioned target data from multiple second terminals, the target storage address for storing the above-mentioned target data in the first target second terminal can be sent to the third terminal, so that the third terminal can store the target data stored in the first terminal in the first target second terminal, thereby extending the service life of the first terminal as much as possible.
[0075] As a possible implementation, the first terminal can send the target storage address in the first target second terminal to the third terminal. After receiving the target storage address, the third terminal can first set the target data to belong to the first terminal, for example, add identification information belonging to the first terminal to the target data, and then write the target data to the first target second terminal based on the above target storage address.
[0076] For example, see Figure 1, since gateway A needs to store the data of terminal A1 and terminal A2, while gateway B only needs to store the data of terminal B, and gateway C only needs to store the data of terminal C, it can be considered that the number of writes of data in gateway A is higher than the number of writes of gateway B and gateway C, that is, gateway A can be considered as the first terminal, and gateway B and gateway C can be considered as the second terminal. If gateway A currently receives a write request from terminal A1, and gateway A determines that its own write count is already high, then the data to be written to gateway A can be stored from the target gateway in gateway B and gateway C. For example, the target gateway can be grid B. At this time, gateway A can send the target storage address for storing the above data to be stored in gateway B to terminal A1. After receiving the target storage address in gateway B, terminal A1 sets the ownership of the data to be sent to gateway A to belong to gateway A, and sends the data to be sent to gateway A to gateway B based on the target storage address, thereby reducing the number of writes of gateway A and extending the service life of gateway A to a certain extent.
[0077] In the above embodiment, the reason why the first terminal and multiple second terminals can share their respective free storage spaces is that the first terminal and multiple second terminals are all in the same shared storage space network. The following is a detailed description of how the first terminal and multiple second terminals form a shared storage space network.
[0078] Case 1: The first terminal and the plurality of second terminals are not joined to any shared storage space network.
[0079] In an embodiment of the present application, after startup, the first terminal can self-check whether it needs to join a shared storage space network. For example, a corresponding flag bit can be set in the register of the first terminal, and the flag bit is used to identify whether the first terminal needs to join the shared storage space network. Exemplarily, when the above flag bit is binary 0, it indicates that the first terminal does not need to join the shared storage space network; when the above flag bit is binary 1, it indicates that the first terminal needs to join the shared storage space network. When the first terminal determines through self-check that it needs to join the shared storage space network, it can broadcast a first joining request to join the shared storage space network. The first joining request can be considered to carry an identifier indicating that the first terminal is not currently joined to any shared storage space network.
[0080] Similarly, each second terminal among multiple second terminals can also self-check whether it needs to join a shared storage space network. For example, a corresponding flag bit may be set in the register of each second terminal, and the flag bit is used to identify whether the second terminal needs to join the shared storage space network. Exemplarily, when the above flag bit is binary 0, it indicates that the first terminal does not need to join the shared storage space network; when the above flag bit is binary 1, it indicates that the first terminal needs to join the shared storage space network. When each second terminal determines through self-check that it needs to join the shared storage space network, it can broadcast a second joining request to join the shared storage space network. The second joining request can be considered to carry an identification indicating that each second terminal is not currently joined to any shared storage space network.
[0081] First, the first terminal and multiple second terminals can determine through a mutual identification mechanism that the other party needs to join the shared storage space network. For example, when the first joining request broadcast by the first terminal is recognized by multiple second terminals, and the second joining request of each second terminal is recognized by the first terminal and other second terminals (i.e., other second terminals among the multiple second terminals except itself), it indicates that the mutual identification mechanism has been passed; then, the first terminal and multiple second terminals need to further determine whether the storage space network can be shared through a test mechanism. For example, if the network parameter value representing the communication quality between the first terminal and each second terminal, and between two second terminals exceeds the set threshold, it indicates that the test mechanism has been passed. Then, after the first terminal and multiple second terminals pass the mutual identification mechanism and the test mechanism, they build a shared storage space network, in which the first terminal and multiple second terminals can share their respective free storage space.
[0082] Case 2: The first terminal has not joined any shared storage space network, and multiple second terminals have joined the shared storage space network.
[0083] In an embodiment of the present application, after startup, the first terminal can self-check whether it needs to join a shared storage space network. For example, a corresponding flag bit can be set in the register of the first terminal, and the flag bit is used to identify whether the first terminal needs to join the shared storage space network. Exemplarily, when the above flag bit is binary 0, it indicates that the first terminal does not need to join the shared storage space network; when the above flag bit is binary 1, it indicates that the first terminal needs to join the shared storage space network. When the first terminal determines through self-check that it needs to join the shared storage space network, it can broadcast a first joining request to join the shared storage space network. The first joining request can be considered to carry an identification that indicates that the first terminal is not currently in any shared storage space network. At this time, if multiple second terminals are already in a shared storage space network, then each second terminal among the multiple second terminals can also broadcast a second joining request to join the shared storage network. The second joining request carries an identification of the shared storage space network that the second terminal has joined.
[0084] First, the first terminal and multiple second terminals can determine through a mutual identification mechanism that the other party needs to join the shared storage space network. For example, when the first joining request broadcast by the first terminal is recognized by multiple second terminals, and the second joining request of each second terminal is recognized by the first terminal, it indicates that the mutual identification mechanism has been passed; then, the first terminal and multiple second terminals need to further determine whether they can share the storage space network through a test mechanism. For example, if the network parameter values that characterize the communication quality between the first terminal and each second terminal exceed the set threshold, it indicates that the test mechanism has been passed. Then, after the first terminal and multiple second terminals pass the mutual identification mechanism and the test mechanism, the first terminal can join the shared storage space network where the multiple second terminals are located, and the first terminal and multiple second terminals can share their respective free storage spaces in the shared storage space network.
[0085] Case 3: A first terminal joins a first shared storage space network, and multiple second terminals join a second shared storage space network.
[0086] In an embodiment of the present application, when a first terminal has joined a first shared storage space network, multiple second terminals have joined a second shared storage space network, and when the number of terminals between the first shared storage space network and the second shared storage space network exceeding a set threshold receives a request to join the shared storage space network broadcasted by a terminal in a shared storage space network other than its own, it indicates that a larger portion of the terminals in the first shared storage space network and the second shared storage space network satisfy the mutual identification mechanism.
[0087] On this basis, a test mechanism can be used to determine whether the first shared storage space network and the second shared storage space network can share storage space. For example, the communication quality of the first terminal located in the physical center area of the first shared storage space network and the second target second terminal located in the physical center of the second shared storage space network is tested. When the network parameter values characterizing the communication quality between the first terminal and the second target second terminal exceed the set threshold, it indicates that the test mechanism has been passed. Then the terminals exceeding the set threshold between the first shared storage space network and the second shared storage space network meet the mutual identification mechanism, and after the first terminal and the second target second terminal, the first terminal and the multiple second terminals pass the mutual identification mechanism and the test mechanism, the first shared storage space network and the second shared storage space network can be merged into a third shared storage space network, in which the first terminal and the multiple second terminals can share their respective free storage space.
[0088] In some embodiments, after a first terminal and multiple second terminals form a shared storage space network, the first terminal and multiple second terminals can share their own free storage space. When a terminal needs to apply for free storage space from the shared storage space network, it is necessary to know the specific size of the free storage space provided by each terminal, so as to apply for the corresponding storage space of the corresponding terminal according to the actual size of the data to be stored. Therefore, in the embodiment of the present application, after the shared storage space is formed, each terminal in the free storage space should know the size of the free storage space that can be provided to each other.
[0089] As a possible implementation, after the first terminal and the plurality of second terminals form a shared storage space network, the first terminal and the plurality of second terminals synchronize their respective free storage spaces. It should be understood that the free storage space here can be considered as part or all of the storage space currently used by each terminal, and no special limitation is made here.
[0090] In some embodiments, considering that the third terminal sends the target data to be sent to the first terminal to the first target second terminal, the first terminal cannot determine when the third terminal sends the target data, so the first terminal may repeatedly notify the third terminal to send the data. Therefore, in the embodiment of the present application, the first terminal can interact with the third terminal to determine that the third terminal has sent the target data, thereby avoiding triggering the first terminal to notify the third terminal to resend the target data.
[0091] In some embodiments, considering that the third terminal sends the target data to be sent to the first terminal to the first target second terminal, that is, the first terminal cannot determine whether the first target second terminal has received the above target data, then the first terminal may also notify the third terminal to resend. Therefore, in the embodiment of the present application, after receiving the target data from the third terminal, the first target second terminal can interact with the first terminal, so that the first terminal determines that the first target second terminal has received the above target data, thereby avoiding triggering the first terminal to notify the third terminal to resend the target data.
[0092] In some embodiments, after the third terminal sends the target data to the first target second terminal, the above target data will inevitably occupy part of the free storage space in the first target second terminal, that is, the original free storage space in the first target second terminal will become smaller, and the data stored in the first target second terminal originally belonged to the first terminal. Therefore, in order to enable other terminals in the shared storage space network to know the changes in the free storage space of the first target second terminal and the ownership of the stored data, in an embodiment of the present application, the first terminal can synchronize the remaining free storage space size of the first target second terminal and the ownership of the target data stored in the first target second terminal to other second terminals among multiple second terminals except the first target second terminal.
[0093] See also Figure 3 Based on the same inventive concept, an embodiment of the present application provides a first terminal, which establishes a communication connection with multiple second terminals and shares their respective free storage space. The number of data write times in the first terminal is higher than the number of data write times in the multiple second terminals. The first terminal includes: a receiving unit 201, a determining unit 202 and a sending unit 203.
[0094] A receiving unit 201 is used to receive a write request from a third terminal, where the write request includes target data to be written into the first terminal and a target storage space size occupied by the target data;
[0095] A determination unit 202, configured to determine a first target second terminal and a corresponding target storage address for storing target data based on a target storage space size when the number of data write times of the first terminal exceeds a set threshold;
[0096] The sending unit 203 is configured to send the target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
[0097] Optionally, the first terminal includes:
[0098] A construction unit is used to control a first terminal and multiple second terminals to construct a shared storage space network based on a mutual identification mechanism and a test mechanism, in which the first terminal and multiple second terminals in the shared storage space network share their own free storage space, and the mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each second terminal in the multiple second terminals to join the shared storage space network is recognized by the first terminal and other second terminals, the first joining request carries an identifier representing that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier representing that the second terminal has not joined any shared storage space network, and the test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and each second terminal and between any two second terminals exceed a set threshold.
[0099] Optionally, the first terminal further includes:
[0100] A joining unit is used to control a first terminal to join a shared storage space network having multiple second terminals based on a mutual identification mechanism and a test mechanism, wherein the first terminal and multiple second terminals in the shared storage space network share their own free storage space, the mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each of the multiple second terminals to join the shared storage network is recognized by the first terminal, the first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has joined the shared storage space network, and the test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and multiple second terminals exceed a set threshold.
[0101] Optionally, the first terminal belongs to a first shared storage space network, and the first terminal is located at a physical center of the first shared storage space network, the plurality of second terminals belong to a second shared storage space network, and the second target second terminal is located at a physical center of the second shared storage space network, and the first terminal further includes:
[0102] A merging unit, when a terminal exceeding a set threshold between a first shared storage space network and a second shared storage space network receives a request to join a shared storage space network broadcasted by a terminal in a shared storage space network other than its own, is used to control the first terminal and the second target second terminal to merge the first shared storage space network and the second shared storage space network into a third shared storage space network based on a test mechanism, in which the first terminal and multiple second terminals in the third shared storage space network all share their own free storage space, and the test mechanism is used to ensure that the network parameter values characterizing the communication quality between the first terminal and the second target second terminal all exceed the set threshold.
[0103] Optionally, the first terminal further includes:
[0104] The synchronization unit is used to control the first terminal and the plurality of second terminals to synchronize the free storage space sizes of each terminal.
[0105] Optionally, the determining unit 202 is further used to: determine that the third terminal has completed sending the target data.
[0106] Optionally, the determining unit 202 is further used to: determine that the first target second terminal has received the target data.
[0107] Optionally, the synchronization unit is also used to:
[0108] The first terminal is controlled to synchronize the remaining free storage space size of the first target second terminal and the attribution relationship of the target data to other second terminals except the first target second terminal among the plurality of second terminals.
[0109] See also Figure 4 , based on the same inventive concept, an embodiment of the present application provides a data writing system, the data writing system comprising: a first terminal, and a plurality of second terminals having communication connections with the first terminal, the first terminal and the plurality of second terminals sharing their respective free storage spaces, the number of data writing times in the first terminal being higher than the number of data writing times in the plurality of second terminals;
[0110] The first terminal is configured to receive a write request from a third terminal, the write request including target data to be written to the first terminal and the size of a target storage space occupied by the target data; when the number of data writes to the first terminal exceeds a set threshold, determine a first target second terminal and a corresponding target storage address for storing the target data based on the size of the target storage space; and send the target storage address to the third terminal;
[0111] The first target second terminal is used to receive and store target data sent by the third terminal based on the target storage address, and the target data is set to belong to the first terminal.
[0112] See also Figure 5 Based on the same inventive concept, an embodiment of the present application provides an electronic device, the electronic device includes at least one processor 301, the processor 301 is used to execute a computer program stored in a memory, and implement the embodiment of the present application as provided in Figure 2 The steps of the data writing method are shown.
[0113] Optionally, the processor 301 may specifically be a central processing unit, a specific ASIC, or one or more integrated circuits for controlling program execution.
[0114] Optionally, the electronic device may further include a memory 302 connected to the at least one processor 301, and the memory 302 may include a ROM, a RAM, and a disk memory. The memory 302 is used to store data required by the processor 301 when it is running, that is, it stores instructions that can be executed by the at least one processor 301. The at least one processor 301 executes the instructions stored in the memory 302 to execute the following steps: Figure 2 The method shown. The number of the memory 302 is one or more. The memory 302 is Figure 5 However, it should be noted that the memory 302 is not a mandatory functional module, so Figure 5 Shown by dotted lines.
[0115] The physical devices corresponding to the receiving unit 201, the determining unit 202 and the sending unit 203 can all be the aforementioned processor 301. The electronic device can be used to execute Figure 2 Therefore, for the functions that can be realized by each functional module in the electronic device, please refer to Figure 2 The corresponding description in the illustrated embodiment will not be repeated here.
[0116] The present application also provides a computer storage medium, wherein the computer storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer executes Figure 2 The method described.
[0117] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.
Claims
1. A data writing method, characterized in that: Applied to a first terminal, the first terminal has established a communication connection with a plurality of second terminals and shares their respective free storage spaces, the number of data writes in the first terminal is higher than the number of data writes in the plurality of second terminals, the method comprising: The first terminal receives a write request from a third terminal, the write request including target data to be written into the first terminal and a target storage space size occupied by the target data; When the number of data writes of the first terminal exceeds a set threshold, the first terminal determines a first target second terminal and a corresponding target storage address to store the target data based on the size of the target storage space; The first terminal sends the target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
2. The method according to claim 1, characterized in that Before receiving the write request from the third terminal, the method further includes: The first terminal and the multiple second terminals construct a shared storage space network based on a mutual identification mechanism and a test mechanism. In the shared storage space network, the first terminal and the multiple second terminals share their own free storage space. The mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each second terminal among the multiple second terminals to join the shared storage space network is recognized by the first terminal and other second terminals. The first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has not joined any shared storage space network. The test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and each second terminal and between each second terminal exceed a set threshold.
3. The method according to claim 1, characterized in that Before receiving the write request from the third terminal, the method further includes: The first terminal joins a shared storage space network that already has the multiple second terminals based on a mutual identification mechanism and a test mechanism. In the shared storage space network, the first terminal and the multiple second terminals all share their own free storage space. The mutual identification mechanism is used to indicate that a first joining request broadcast by the first terminal to join the shared storage space network is recognized by the multiple second terminals, and a second joining request of each of the multiple second terminals to join the shared storage network is recognized by the first terminal. The first joining request carries an identifier indicating that the first terminal has not joined any shared storage space network, and the second joining request carries an identifier indicating that the second terminal has joined the shared storage space network. The test mechanism is used to indicate that network parameter values representing communication quality between the first terminal and the multiple second terminals all exceed a set threshold.
4. The method according to claim 1, characterized in that: Before receiving the write request from the third terminal, the method further includes: When a terminal exceeding a set threshold in the first shared storage space network including the first terminal and the second shared storage space network including the multiple second terminals receives a request to join the shared storage space network broadcasted by a terminal in a shared storage space network other than the own, the first terminal and the second target second terminal merge the first shared storage space network and the second shared storage space network into a third shared storage space network based on a test mechanism, in which the first terminal and the multiple second terminals in the third shared storage space network share their respective free storage space, the first terminal is located at the physical center of the first shared storage space network, and the second target second terminal is located at the physical center of the second shared storage space network, and the test mechanism is used to indicate that the network parameter values characterizing the communication quality between the first terminal and the second target second terminal exceed the set threshold.
5. The method according to any one of claims 2 to 4, characterized in that: The method further comprises: The first terminal and the plurality of second terminals synchronize their respective free storage space sizes.
6. The method according to claim 5, characterized in that After the first terminal sends the target storage address to the third terminal, the method further includes: The first terminal determines that the third terminal has completed sending the target data.
7. The method according to claim 5, characterized in that After the first terminal determines that the third terminal has completed sending the target data, the method further includes: The first terminal determines that the first target second terminal has received the target data.
8. The method according to claim 7, characterized in that After the first terminal determines that the first target second terminal has received the target data, the method further includes: The first terminal synchronizes the remaining free storage space size of the first target second terminal and the attribution relationship of the target data to other second terminals among the plurality of second terminals except the first target second terminal.
9. A first terminal, characterized in that The first terminal establishes a communication connection with a plurality of second terminals and shares their respective free storage spaces, the number of data writes in the first terminal is higher than the number of data writes in the plurality of second terminals, and the first terminal includes: a receiving unit, configured to receive a write request from a third terminal, wherein the write request includes target data to be written into the first terminal and a target storage space size occupied by the target data; A determining unit, configured to determine a first target second terminal to store the target data and a corresponding target storage address based on the size of the target storage space when the number of data writes to the first terminal exceeds a set threshold; The sending unit is configured to send the target storage address to the third terminal, so that the third terminal sets the target data to belong to the first terminal, and writes the target data to the first target second terminal based on the target storage address.
10. A data writing system, characterized in that: The data writing system comprises: a first terminal, and a plurality of second terminals communicating with the first terminal, the first terminal and the plurality of second terminals sharing their own free storage space, and a data writing frequency in the first terminal being higher than a data writing frequency in the plurality of second terminals; The first terminal is configured to receive a write request from a third terminal, the write request including target data to be written to the first terminal and a target storage space size occupied by the target data; when the number of data writes to the first terminal exceeds a set threshold, determine a first target second terminal to store the target data and a corresponding target storage address based on the target storage space size; and send the target storage address to the third terminal; The first target second terminal is used to receive and store the target data sent by the third terminal based on the target storage address, and the target data is set to belong to the first terminal.
11. An electronic device, characterized in that: The electronic device comprises a plurality of processors and a memory connected to the plurality of processors, and the plurality of processors are configured to implement the steps of the method according to any one of claims 1 to 8 when executing a computer program stored in the memory.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Terminal, and method and device for processing multiple users of terminal
CN104573541A
Storage management system, management apparatus and method
CN105592123A
Distributed data sharing method and device, storage node card and computer equipment
CN113901015A
Data sharing method and device, terminal equipment and desktop cloud system
CN114003328A
Multi-cloud storage system, multi-cloud data read-write method and electronic equipment
CN114422538A
