EP-4742053-A1 - WRITING METHOD FOR DISTRIBUTED FILE SYSTEM, AND ELECTRONIC DEVICE
Abstract
The present application relates to the technical field of terminals, and discloses a writing method for a distributed file system, and an electronic device. The method is applied to a first electronic device and comprises: acquiring data request information of a target file sent by a second electronic device in communication connection with the first electronic device; determining a target address of first data content on the basis of a request identifier and a linked list array corresponding to the target file; determining a target linked list corresponding to the target address in the linked list array, and under the condition that there is second data content in a memory space of the target linked list, storing the second data content and the first data content into a storage node of the target linked list according to a preset storage rule; and writing data content stored in the linked lists of the linked list array into the target file in parallel.
Inventors
- ZHAO, Sijing
Assignees
- ZTE CORPORATION
Dates
- Publication Date
- 20260513
- Application Date
- 20240311
Claims (10)
- A writing method for a distributed file system applied to a first electronic device, comprising: Acquiring data request information for a target file sent by a second electronic device communicatively connected to the first electronic device, the data request information comprises a request identification and first data content; determining a destination address of the first data content based on the request identification and a linked list array corresponding to the target file; determining a target linked list corresponding to the destination address in the linked list array, and in a case where second data content exists in a memory space of the target linked list, storing the second data content and the first data content in storage nodes of the target linked list based on a preset storage rule, the target linked list comprises a plurality of storage nodes that are sequentially stored in the memory space which is continuous; and writing data content stored in each linked list of the linked list array to the target file in parallel, the data content comprises the first data content and the second data content.
- The method of claim 1, wherein acquiring the data request information for the target file sent by the second electronic device communicatively connected to the first electronic device comprises: receiving a data request packet sent by the second electronic device, the data request packet comprises protocol data and the data request information; and analyzing the data request packet based on the protocol data to obtain the data request information of the target file.
- The method of claim 1, wherein the request identification comprises a device identification and a data identification, and determining the destination address of the first data content based on the request identification and the linked list array corresponding to the target file comprises: determining a key of a hash table based on the device identification and the data identification; and determining the destination address of the first data content based on the key of the hash table and the linked list array corresponding to the target file.
- The method of claim 3, wherein determining the destination address of the first data content based on the key of the hash table and the linked list array corresponding to the target file comprises: acquiring a hash function corresponding to the linked list array; and determining the destination address of the first data content based on the hash function and the key of the hash table.
- The method of claim 1, wherein storing the second data content and the first data content in the storage nodes of the target linked list based on the preset storage rule comprises: acquiring a first storage node where the second data content is located; and storing the first data content on a second storage node of the target linked list, the second storage node is a next storage node immediately adjacent to the first storage node.
- The method of any one of claims 1 to 5, wherein after determining the target linked list corresponding to the destination address in the linked list array, and before writing the data content stored in each linked list of the linked list array to the target file in parallel, the method further comprises: in a case where the second data content does not exist in the memory space of the target linked list, storing the first data content in the memory space.
- A writing method for a distributed file system applied to a second electronic device, comprising: acquiring a request identification corresponding to the second electronic device and first data content corresponding to the write operation instruction of the user for the target file, in response to a write operation instruction initiated by a user for a target file in a first electronic device, the first electronic device and the second electronic device are communicatively connected to each other; and sending data request information for the target file to the first electronic device, the data request information comprises the request identification and the first data content.
- The method of claim 7, wherein sending the data request information of the target file to the first electronic device comprises: encapsulating the data request information into a data request packet based on protocol data for preset network communication; and sending the data request packet to the first electronic device, the data request packet comprises the protocol data and the data request information.
- An electronic device, comprising a display screen, a processor, and a storage device, wherein the storage device stores a program or an instruction executable on the processor, and when the program or the instruction is executed by the processor, the method of any one of claims 1 to 8 is implemented.
- A readable storage medium having stored therein a program or an instruction, wherein the program or the instruction runs on an electronic device, and when the program or the instruction is executed by a processor, the method of any one of claims 1 to 8 is implemented.
Description
CROSS REFERENCE TO RELATED APPLICATIONS The present disclosure claims the priority to Chinese Patent Application No. 202310975556.1 entitled "WRITING METHOD FOR DISTRIBUTED FILE SYSTEM, AND ELECTRONIC DEVICE" and filed with the CNIPA on August 3, 2023, entire contents of which are incorporated herein by reference. TECHNICAL FIELD Embodiments of the present disclosure relate to the field of terminal technology, and in particular, to a writing method for a distributed file system and an electronic device. BACKGROUND A situation that a plurality of terminals simultaneously accesses a certain file on a same terminal is usually involved in a multi-screen collaboration scenario. For example, there is an office file in a terminal A, and a terminal B and a terminal C need to write data to the file at the same time, which causes a problem of data access conflict. At present, in order to avoid the data access conflict, a system default access interception method is generally adopted, that is, when the terminal B accesses the file, the other terminals A and C are prohibited from accessing the file, but with such method, efficiency of collaborative data writing among the plurality of terminals is not high, and user experience is affected. SUMMARY The embodiments of the present disclosure provide a writing method for a distributed file system and an electronic device, so as to solve a problem of data access conflict in a scenario where a plurality of terminals access a same file collaboratively and improve efficiency of collaborative data writing among the plurality of terminals. In a first aspect, an embodiment of the present disclosure provides a writing method for a distributed file system applied to a first electronic device, including: acquiring data request information for a target file which is sent by a second electronic device communicatively connected to the first electronic device, the data request information includes a request identification and first data content; determining a destination address of the first data content based on the request identification and a linked list array corresponding to the target file; determining a target linked list corresponding to the destination address in the linked list array, and in a case where second data content exists in a memory space of the target linked list, storing the second data content and the first data content in storage nodes of the target linked list based on a preset storage rule, the target linked list includes a plurality of storage nodes that are sequentially stored in the memory space which is continuous; and writing data content stored in each linked list of the linked list array to the target file in parallel, the data content includes the first data content and the second data content. In a second aspect, an embodiment of the present disclosure provides a writing method for a distributed file system applied to a second electronic device, including: acquiring a request identification corresponding to the second electronic device and first data content corresponding to the write operation instruction of the user for the target file, in response to a write operation instruction initiated by a user for a target file in a first electronic device, the first electronic device and the second electronic device are communicatively connected to each other; and sending data request information for the target file to the first electronic device, the data request information includes the request identification and the first data content. In a third aspect, an embodiment of the present disclosure provides an electronic device, including a processor and a storage device, wherein the storage device stores a program or an instruction executable on the processor, and when the program or the instruction is executed by the processor, operations in the method described in the first aspect are implemented. In a fourth aspect, an embodiment of the present disclosure provides a readable storage medium having stored thereon a program or an instruction which, when executed by a processor, implement the operations of the method described in the first aspect. BRIEF DESCRIPTION OF DRAWINGS The drawings here are incorporated into the specification and constitute a part of the specification. The drawings illustrate the embodiments of the present disclosure, and are used to explain, together with the specification, the principle of the present disclosure. FIG. 1 is a schematic diagram illustrating a possible application scenario according to an embodiment of the present disclosure;FIG. 2 is a schematic flowchart illustrating a writing method for a distributed file system according to an embodiment of the present disclosure;FIG. 3 is a schematic diagram of a data structure of a data request packet according to an embodiment of the present disclosure;FIG. 4 is a schematic diagram of a data storage structure of a linked list array according to an embodiment of the present disclosu