WO2022068596A1 - Metadata management method, and electronic device - Google Patents

Metadata management method, and electronic device Download PDF

Info

Publication number
WO2022068596A1
WO2022068596A1 PCT/CN2021/118646 CN2021118646W WO2022068596A1 WO 2022068596 A1 WO2022068596 A1 WO 2022068596A1 CN 2021118646 W CN2021118646 W CN 2021118646W WO 2022068596 A1 WO2022068596 A1 WO 2022068596A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
file
directory
local file
metadata
Prior art date
Application number
PCT/CN2021/118646
Other languages
French (fr)
Chinese (zh)
Inventor
李志鹏
娄松
冒晶晶
韦龙平
张智伟
易见
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202011377326.8A external-priority patent/CN114328377A/en
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022068596A1 publication Critical patent/WO2022068596A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • G06F16/137Hash-based
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files

Definitions

  • the first directory of the first local file system contains a second local file
  • the second local file may include metadata information of other files in the first directory.
  • the second electronic device can obtain the second local file and cache it in the first directory in the second local file system, so that the second local file can be stored in the second local file system.
  • the first local file is displayed in the first directory in the system. In this way, the metadata information of each file in each directory in the local file system is directly stored in the directory, and does not need to be stored in the central node of the distributed file system.
  • an embodiment of the present application provides a computer program product containing instructions, when the computer program product is executed on a first electronic device, the first electronic device is made to execute any one of the second aspect and the second aspect. possible implementations of the method described.
  • the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: stop mounting the first electronic device in the distributed file system After the second local file system is installed, the second local file cached in the first directory in the second local file system is deleted.
  • the device identifier may be a device name, a MAC address, etc., which are not limited here.
  • the first directory of the distributed file system may also be mounted with the first directory of other electronic devices, such as a third electronic device.
  • the first electronic device may also obtain the bloom filter bit array of the third electronic device.
  • the first electronic device reads the data in the third file from the second electronic device through the distributed file system, and will generate the radix tree of the third file in the local memory.
  • the cache of the fifth data on the radix tree of the third file in the local memory can be directly cleared, that is, only one need to be cleared.
  • the data of the size of the memory page does not need to clear the entire third file, which improves the efficiency of maintaining data consistency in the distributed file system and reduces the consumption of network resources.
  • Fig. 39 is a pseudo-code schematic diagram in the embodiment of the present application.
  • Figure 42 is a schematic diagram of an exemplary scenario for data access
  • FIG. 60 is a schematic block diagram of another exemplary software structure of the electronic device of the embodiment.
  • the metadata information of a file includes metadata describing the file.
  • the metadata describing the file contained in the metadata information of the file may also be different.
  • FIG. 1 is an exemplary schematic diagram of metadata information of a file in an embodiment of the present application.
  • its metadata information may include: file name: document 1.txt, document type: text document, and file size, Metadata such as modification time and so on.
  • its metadata information can include file name, document type, file size, modification time and other metadata information of other types of files.
  • file-specific metadata of the picture type such as shooting time, resolution, bit depth, width, and height.
  • the file name of the metadata file may carry an identifier of an electronic device to distinguish metadata files from different electronic devices.
  • the identifier of the directory can also be carried in the file name of the metadata file to distinguish metadata files in different directories, or the file name of the metadata file does not carry the identifier of the directory, and the path of the metadata file is used.
  • Different directories, etc. are not limited here.
  • FIG. 4 it is an exemplary schematic diagram of a metadata file being updated due to file modification in an embodiment of the present application.
  • (a) of FIG. 4 shows a user interface 410 of the electronic device 1 .
  • the user interface 410 is a user interface after the user opens the file 1 in the root directory of the electronic device 1 . If the user modifies the content of file 1, and as shown in (b) of FIG. 4, at 2020/02/02 02:02, the user clicks the save control in the user interface 410, and the modification to file 1 is saved. Then, the electronic device 1 will also update the metadata information of the file 1 stored in the metadata file 1 accordingly. Exemplarily, as shown in (c) in FIG.
  • the update content can include: the modification time has been updated to 2020/02/02 02:02.
  • other content updates may also be included, such as file size update, character number update, etc., which are not limited here.
  • FIG. 5 it is an exemplary schematic diagram of metadata file update caused by file deletion in an embodiment of the present application.
  • (a) of FIG. 5 shows an exemplary user interface 210 of the electronic device.
  • the user interface 210 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 1 .
  • a directory A and a file 1 are stored in the root directory of the file system, and a metadata file 1 that stores metadata information of all other files in the root directory.
  • the user interface 210 can be updated as shown in (b) of FIG. 5 .
  • the electronic device 1 will correspondingly update the metadata file 1 under the root directory, and delete the metadata information of the file 1 from the metadata file 1 .
  • (c) of FIG. 5 if the identifier of the file 1 is used to query the metadata information of the file 1 from the metadata file 1 at this time, the metadata information of the file 1 cannot be queried.
  • the files recorded in the metadata files obtained from other electronic devices are displayed in the directory, which may specifically be display link files of the files recorded in the metadata files. It can also be a real file showing the file recorded in the metadata file, which is not limited here. If the displayed link file is different from the real file that stores the actual data of the file in this electronic device, the link file is generated according to the metadata information of the file recorded in the metadata file, and does not contain the actual data of the file. The display effect of the linked file may be the same as or different from that of the real file, which is not limited here.
  • the electronic device receives the request for accessing the linked file, the request can be converted into a request for accessing real files in other electronic devices corresponding to the linked file. If a real file is displayed, after obtaining the metadata file from other electronic devices, the electronic device can obtain and display the corresponding real file from other electronic devices according to the metadata information of the file recorded in the metadata file.
  • an inode structure of the file to be displayed will be generated in the memory of the electronic device.
  • the inode structure corresponding to the file in the memory will store the electronic device identifier of the source of the metadata file. In this way, when the electronic device receives a request to access the file, the electronic device can determine that the file actually comes from a file in an electronic device according to the identifier of the electronic device in the inode structure corresponding to the file in the memory.
  • the user interface 720 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 2 .
  • Directory A, file 5, file 6 and metadata file 2-1 are stored in the root directory of the file system, and the metadata file 2-1 records the metadata information of directory A, file 1, file 5 and file 6 , the file name of the metadata file contains the identifier of the electronic device 2: 2.
  • the USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • Non-volatile memory may include magnetic disk storage devices, flash memory.
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
  • the gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 .
  • the angular velocity of electronic device 100 about three axes ie, x, y, and z axes
  • the gyro sensor 180B can be used for image stabilization.
  • the gyro sensor 180B detects the shaking angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse motion to achieve anti-shake.
  • the gyro sensor 180B can also be used for navigation and somatosensory game scenarios.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the electronic device A modifies and saves the file A under the directory A;
  • step S1704 is specifically and exemplarily described by taking the electronic device A that determines whether there is an online electronic device that requests to acquire the metadata file A through the stored read record as an example:
  • the electronic device A may store it in another way.
  • Table 4 it is another schematic example of the read record of the electronic device A in the embodiment of the present application.
  • the electronic device A pushes the metadata file A to the electronic device that requests to obtain the metadata file A and is online in the distributed file system;
  • FIG. 19 it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
  • the following describes the metadata management method in the embodiment of the present application by taking the process of electronic device A in the distributed file system accessing directory A of the file system mounted by the distributed file system in electronic device A as an example.
  • the electronic device A determines that there is no valid metadata file cached in the directory A of the electronic device B under the directory A of the electronic device A, the electronic device A can obtain the metadata files that are not effectively cached in the directory A of the electronic device B. Data file B.
  • the electronic device B records the correspondence between the identification of the electronic device A and the read metadata file B in the read record of the electronic device B;
  • the electronic device A may perform the following steps to cache the metadata file C:
  • the electronic device A caches the metadata file C under the directory A of the electronic device A.
  • the electronic device A When the electronic device A determines that the electronic device B is not online, it can feed back prompt information, and the prompt information can be used to indicate that the electronic device B is not online and the file B cannot be accessed.
  • the electronic device A may determine that the valid metadata file B under the directory A of the electronic device B is cached in the directory A of the electronic device A, and may execute step S2107.
  • the metadata file B under the directory A of the electronic device B and the metadata file C under the directory A of the electronic device C are cached under the directory A of the electronic device A, and the metadata file C under the directory A of the electronic device C is cached.
  • these files in other devices displayed are generated based on the metadata information in the metadata file, and are linked files without actual data.
  • steps S2101 to S2104 may be performed, or steps S2101 to S2104 may not be performed, which is not limited here.
  • the user can modify and save the file B cached in the directory A of the electronic device A, and the file B can be updated to the file B1.
  • Electronic device A may send the updated file B1 to electronic device B, indicating that file B has been updated to file B1.
  • the electronic device A After receiving the metadata file B1, the electronic device A updates the metadata file B under the directory A of the electronic device A to the metadata file B1.
  • the name file on one of the electronic devices can be returned (for example, the name file on the electronic device with the smallest device number), or the name file can be returned.
  • This name file on all electronic devices is not limited here.
  • the central node For an existing distributed file system with a central node, the central node maintains the metadata information of all files in the distributed file system.
  • the connected electronic device When an electronic device accesses the distributed file system with a central node, the connected electronic device synchronizes the metadata information of the files under its own paths to the central node, and the central node will check whether it is compatible with the distributed file system. Files with the same name exist in each path in the file system, so as to ensure that files with the same name do not appear in the same path.
  • FIG. 28 is a schematic structural diagram of a bloom filter bit array in an embodiment of the present application.
  • the bloom filter includes an 8-bit bit array and 3 hash functions as an example. At this time, the value of each bit is initialized to 0.
  • the metadata server as the central node identifies files with the same name in each directory, thereby ensuring that no files with the same name exist in the same directory.
  • this method cannot be used to identify files with the same name.
  • the electronic device A in the distributed file system needs to display all files under the directory A as an example, and the method for identifying files with the same name in the embodiment of the present application is described in detail:
  • electronic device X other online electronic devices other than electronic device A in the distributed file system are referred to as electronic device X.
  • the electronic device A After the electronic device A receives the request to display all the files in the directory A in the distributed file system, it can send the electronic device X to obtain the file names of all the local files in the directory A in the electronic device X and the Bloom filter bit of the electronic device X Array of requests.
  • the electronic device X calculates the Bloom filter bit array of the electronic device X according to the file names of all local files under the directory A in the electronic device X;
  • the electronic device A determines whether a file with the same name may exist under the directory A in each electronic device according to the Bloom filter bit array of each electronic device;
  • the electronic device A can perform step S3207;
  • the electronic device A respectively judges whether the number of digits that are 1 at the same position in the Bloom filter bit array of each electronic device is less than K;
  • FIG. 34 is a schematic diagram of an exemplary scenario for determining whether a file with the same name may exist in this embodiment of the present application.
  • Electronic device A obtains the Bloom filter bit arrays of the other two online electronic devices in the distributed file system: electronic device B and electronic device C.
  • the bloom filter bit array of electronic device A is denoted as BA
  • the bloom filter bit array of electronic device B is denoted as BB
  • the bloom filter bit array of electronic device C is denoted as BC.
  • Electronic device A compares BA and BB, and when the number of 1 bits at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine that electronic device A and electronic device B are not in directory A. A file with the same name may exist; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that a file with the same name may exist in the directory A of the electronic device A and the electronic device B.
  • Electronic device A compares BA and BC. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device A and electronic device C are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that there may be files with the same name in the directory A of the electronic device A and the electronic device C.
  • Electronic device A obtains the Bloom filter bit arrays of the other three online electronic devices in the distributed file system: electronic device B, electronic device C, and electronic device D.
  • the bloom filter bit array of electronic device A is denoted as BA
  • the bloom filter bit array of electronic device B is denoted as BB
  • the bloom filter bit array of electronic device C is denoted as BC
  • the The bloom filter bit array of electronic device D is denoted as BD.
  • step S3607 When it is determined that it is less than K, step S3607 can be performed;
  • step S3608 may be performed.
  • the second line indicates that the subsequent loop operation is performed for each file y under the path in the electronic device j.
  • the electronic device A determines that the file with the same name in the directory A may exist in two electronic devices with the same name, and renames the file with the same name;
  • the electronic device A After the electronic device A determines that it is impossible for a file with the same name to exist under the directory A in each electronic device, the electronic device A can display all the files under the directory A in the distributed file system.
  • the current data pre-reading technology will pre-read more fixed multiple memory pages after reading the requested data. Then set a read-ahead flag on the last fixed value memory page. When the pre-reading flag is accessed, the next pre-reading can be triggered.
  • Virtual memory is an important milestone in the history of operating system development. The use of virtual memory prevents the program from directly dealing with physical memory, and abstracts the cache, main memory and disk so that the program can break through the size limit of physical memory. Of course, the program is still subject to the size limit of virtual memory.
  • the memory address seen in the program is the virtual memory address, and the program's read and write to the virtual memory address will be mapped to the actual physical memory. This mapping is called translation.
  • This translation work is done by the memory management unit (MMU).
  • MMU memory management unit
  • the MMU receives the virtual address sent by the CPU, translates it into a physical address and sends it to the memory.
  • the memory reads or writes according to the physical address. Enter relevant data.
  • FIG. 41 is an exemplary schematic diagram of memory paging management in an embodiment of the present application.
  • the paging mechanism can split data into memory page sizes and allocate contiguous addresses in the virtual address space. These memory pages with contiguous addresses in the virtual address space can be fragmented and allocated to unallocated pages in the physical address space.
  • the electronic device A can buffer and display Y11 to Y15. After the user turns the pages, the electronic device A needs to display the next part of the data of the file A, and the corresponding memory pages are Y16-Y20. Then, the electronic device A needs to request the electronic device B to access Y16-Y20 again to display the next part of the file A again.
  • FIG. 43 is a schematic diagram of an exemplary scenario for performing data pre-reading.
  • the size of the read ahead window is N.
  • both electronic device A and electronic device B are mobile terminals and use a wireless mobile network. Influenced by factors such as the number of base stations arranged around by the mobile network service provider used by electronic equipment A and electronic equipment B, the number of users using wireless mobile networks around, the distance from the base station and other factors, electronic equipment A and electronic equipment will be affected.
  • the network latency between B varies dynamically.
  • the network bandwidth between electronic device A and electronic device B is 500 bits/s.
  • an electronic device that exceeds the preset capability value may be referred to as a first capability device, such as a mobile phone, computer, etc.; an electronic device that does not exceed the preset capability value may be referred to as a second capability device, such as a watch, router, etc.
  • the preset capability value may include parameters such as the number and frequency of cpu cores, memory size, etc., which are not limited here.
  • a pre-read flag is set.
  • the electronic device A reads the memory page with the pre-reading flag, the electronic device A triggers the next pre-reading of the file A. It is understandable that the next pre-reading will also be processed according to the default pre-reading window size of 10 and the default position of the pre-reading flag bit -5.
  • the size of the pre-reading window determined by the electronic device A is different: more memory pages can be pre-read when the network environment is poor, and fewer memory pages can be pre-read when the network environment is good. While reducing the power consumption of the electronic device A, it is ensured that the electronic device A can pre-read a suitable number of memory pages each time.
  • the data pre-reading module is configured to execute the data pre-reading method in this embodiment of the present application when the electronic device 100 accesses files of other electronic devices in the distributed file system.
  • Both the electronic device A or the electronic device B in the embodiment of the present application may adopt the software and hardware structure of the foregoing exemplary electronic device 100, which is not limited here.
  • Pre-reading stage According to (1) the pre-reading window size determined in real time in the pre-reading window size determination stage, and (2) the number and position of the pre-reading flag bits to be set determined in the pre-reading flag bit determination stage , pre-read data from the peer electronic device and set the pre-read flag.
  • the pre-reading window size determination stage can be continuously and repeatedly executed, and the pre-reading window size is updated in real time.
  • the application A in the electronic device A can access the file F in the electronic device B that is in the same distributed file system as the electronic device A.
  • electronic device A When electronic device A accesses file F in electronic device B, it can first query the metadata information of file F from the unique metadata server in the distributed file system, and then access file F to electronic device B according to the metadata information of file F. ; You can also query the metadata information of the file F cached in the electronic device, and access the file F to the electronic device B according to the metadata information of the file F, which is not limited here.
  • step S5002 may be executed.
  • the electronic device A may send a request to the electronic device B periodically, and use the duration of receiving the response returned by the electronic device B as the network round-trip delay with the electronic device B.
  • the size of the read-ahead window may be calculated according to the network round-trip delay and network bandwidth.
  • the electronic device A can perform step S5102;
  • the electronic device A may determine that a pre-read flag needs to be set in each pre-read memory page.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A metadata management method, and an electronic device. The method comprises: a first electronic device comprising a first local file and a second local file in a first directory in a first local file system, wherein the second local file comprises metadata information of the first local file; when a second electronic device receives a request to access the first directory, the second electronic device sending, to the first electronic device, a request that a distributed file system acquires the second local file; the first electronic device sending the second local file to the second electronic device; the second electronic device caching the second local file into the first directory in a second local file system, and displaying the first local file in the first directory in the second local file system. The stability of using a distributed file system is improved.

Description

元数据管理方法和电子设备Metadata management method and electronic device
本申请要求于2020年9月30日提交中国专利局、申请号为202011062903.4、申请名称为“元数据管理方法和电子设备”的中国专利申请的优先权;以及于2020年9月30日提交中国专利局、申请号为202011063023.9、申请名称为“一种数据预读方法和电子设备”的中国专利申请的优先权;以及于2020年9月30日提交中国专利局、申请号为202011062887.9、申请名称为“一种同名文件识别方法和电子设备”的中国专利申请的优先权;以及于2020年9月30日提交中国专利局、申请号为202011066342.5、申请名称为“保持数据一致性的方法和电子设备”的中国专利申请的优先权;以及于2020年11月30日提交中国专利局、申请号为202011377326.8、申请名称为“元数据管理方法和电子设备”的中国专利申请的优先权;以上专利申请的全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202011062903.4 and the application title "Metadata Management Method and Electronic Device" filed with the China Patent Office on September 30, 2020; and filed in China on September 30, 2020 Patent Office, application No. 202011063023.9, application title: "A data pre-reading method and electronic device" The priority of the Chinese patent application; The priority of the Chinese patent application for "a method and electronic device for document identification of the same name"; and the application number 202011066342.5 filed with the Chinese Patent Office on September 30, 2020, and the application title is "Method and Electronic Device for Maintaining Data Consistency" and the priority of the Chinese patent application filed on November 30, 2020 with the application number 202011377326.8 and the application title of "Metadata Management Method and Electronic Equipment"; the above patents The entire contents of the application are incorporated herein by reference.
技术领域technical field
本申请涉及终端及通信技术领域,尤其涉及元数据管理方法和电子设备。The present application relates to the technical field of terminals and communications, and in particular, to a metadata management method and an electronic device.
背景技术Background technique
随着网络通信技术的蓬勃发展,万物互联已悄然进入大众生活。万物互联的基石为不同设备之间的数据可相互访问,而分布式文件系统正是提供不同设备数据视角一致的一种技术。With the vigorous development of network communication technology, the Internet of Everything has quietly entered public life. The cornerstone of the Internet of Everything is that data between different devices can access each other, and the distributed file system is a technology that provides a consistent data perspective for different devices.
现有分布式文件系统通常包含元数据服务器和数据服务器。当用户访问文件数据时,需要先访问元数据服务器获取文件的基本信息和数据索引信息,再访问数据服务器获取文件数据。Existing distributed file systems typically contain metadata servers and data servers. When users access file data, they need to access the metadata server to obtain the basic information and data index information of the file, and then access the data server to obtain the file data.
然而,这种分布式文件系统的实现过程中,以元数据服务器作为分布式文件系统的中心节点,需要保证元数据服务器时刻在线提供元数据查询更新服务。当元数据服务器下线时,该分布式文件系统的服务不可用。而当前的分布式文件系统可能需要由多个随时都能下线的电子设备组成,若采用该现有的分布式文件系统,当作为中心节点的电子设备下线后,该分布式文件系统无法再对系统中的元数据信息进行管理,从而导致该分布式文件系统无法稳定使用。However, in the implementation process of this distributed file system, the metadata server is used as the central node of the distributed file system, and it is necessary to ensure that the metadata server is always online to provide metadata query and update services. When the metadata server goes offline, the distributed file system's services are unavailable. The current distributed file system may need to be composed of multiple electronic devices that can be offline at any time. If the existing distributed file system is used, when the electronic device serving as the central node is offline, the distributed file system cannot be used. Then, the metadata information in the system is managed, so that the distributed file system cannot be used stably.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了元数据管理方法和电子设备,用于在无中心节点的情况下实现分布式文件系统的元数据管理,提升使用分布式文件系统的稳定性。Embodiments of the present application provide a metadata management method and electronic device, which are used to implement metadata management of a distributed file system without a central node, and improve the stability of using the distributed file system.
第一方面,本申请提供了一种元数据管理方法,包括:第一电子设备在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,所述第二本地文件中包括所述第一本地文件的元数据信息;当第二电子设备接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,所述第二电子设备向所述第一电子设备发送分布式文件系统获取所述第二本地文件的请求;所述第一电子设备向所述第二电子设备发送所述第二本地文件;所述第二电子设备将所述第二本地文件缓存到第二本地文件系统中的第一目录中,并根据所述第二本地文件,在所述第二本地文件系统中的第一目录中显示所述第一本地文件。In a first aspect, the present application provides a metadata management method, including: a first electronic device includes a first local file and a second local file in a first directory in a first local file system of the first electronic device, so The second local file includes metadata information of the first local file; when the second electronic device receives a request to access the first directory in the second local file system of the second electronic device, the second electronic device The device sends a request for the distributed file system to obtain the second local file to the first electronic device; the first electronic device sends the second local file to the second electronic device; the second electronic device Cache the second local file in the first directory in the second local file system, and display the first local file in the first directory in the second local file system according to the second local file document.
上述实施例中,第一本地文件系统的第一目录下包含有第二本地文件,该第二本地文件 中可以包括该第一目录下其他文件的元数据信息。当需要访问第二本地文件系统中的第一目录时,第二电子设备可以获取该第二本地文件,并缓存在该第二本地文件系统中的第一目录中,从而在该第二本地文件系统中的第一目录中显示该第一本地文件。这样将本地文件系统中每个目录中各文件的元数据信息直接保存在该目录下,而不需要保存在分布式文件系统的中心节点中。一方面可以便捷的根据需求将包含元数据信息的本地文件发送给其他电子设备,构成无中心节点的分布式文件系统,不再因为中心节点下线而导致整个分布式文件系统不可用,提升了使用分布式文件系统的稳定性。另一方面在本地文件系统中管理元数据信息,根据需求在分布式文件系统中传输和共享,使得本地文件系统中的文件可以便捷的在分布式文件系统被使用。In the above embodiment, the first directory of the first local file system contains a second local file, and the second local file may include metadata information of other files in the first directory. When the first directory in the second local file system needs to be accessed, the second electronic device can obtain the second local file and cache it in the first directory in the second local file system, so that the second local file can be stored in the second local file system. The first local file is displayed in the first directory in the system. In this way, the metadata information of each file in each directory in the local file system is directly stored in the directory, and does not need to be stored in the central node of the distributed file system. On the one hand, local files containing metadata information can be easily sent to other electronic devices according to requirements, forming a distributed file system without a central node, and the entire distributed file system is no longer unavailable due to the offline of the central node. Stability using a distributed file system. On the other hand, metadata information is managed in the local file system, and transmitted and shared in the distributed file system according to requirements, so that the files in the local file system can be conveniently used in the distributed file system.
第二方面,本申请提供了一种元数据管理方法,包括:第一电子设备在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,该第二本地文件中包括第一本地文件的元数据信息;当该第一电子设备接收到第二电子设备发送的分布式文件系统获取该第二本地文件的请求时,该第一电子设备向该第二电子设备发送该第二本地文件,使得在第二电子设备的第二本地文件系统中的第一目录中显示该第一本地文件。In a second aspect, the present application provides a metadata management method, comprising: the first electronic device includes a first local file and a second local file in a first directory in a first local file system of the first electronic device, the The second local file includes metadata information of the first local file; when the first electronic device receives the request sent by the second electronic device for the distributed file system to obtain the second local file, the first electronic device sends the The second electronic device sends the second local file, so that the first local file is displayed in the first directory in the second local file system of the second electronic device.
上述实施例中,将本地文件系统中每个目录中各文件的元数据信息直接保存在该目录下,而不需要保存在分布式文件系统的中心节点中,根据需求发送给其他电子设备,使得其他电子设备在相应目录中显示该目录中的文件。一方面可以便捷的根据需求将包含元数据信息的本地文件发送给其他电子设备,构成无中心节点的分布式文件系统,不再因为中心节点下线而导致整个分布式文件系统不可用,提升了使用分布式文件系统的稳定性。另一方面在本地文件系统中管理元数据信息,根据需求在在分布式文件系统中传输和共享,使得本地文件系统中的文件可以便捷的在分布式文件系统被使用。In the above-mentioned embodiment, the metadata information of each file in each directory in the local file system is directly stored in the directory, and does not need to be stored in the central node of the distributed file system, and is sent to other electronic devices according to requirements, so that Other electronic devices display the files in that directory in the corresponding directory. On the one hand, local files containing metadata information can be easily sent to other electronic devices according to requirements, forming a distributed file system without a central node, and the entire distributed file system is no longer unavailable due to the offline of the central node. Stability using a distributed file system. On the other hand, metadata information is managed in the local file system, and transmitted and shared in the distributed file system according to the requirements, so that the files in the local file system can be conveniently used in the distributed file system.
结合第二方面的一些实施例,在一些实施例中,该元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。With reference to some embodiments of the second aspect, in some embodiments, the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
结合第二方面的一些实施例,在一些实施例中,该方法还包括:当该第一电子设备在该第一本地文件系统中的第一目录中增加第三本地文件时,该第一电子设备在该第二本地文件中增加第三本地文件的元数据信息。With reference to some embodiments of the second aspect, in some embodiments, the method further includes: when the first electronic device adds a third local file in the first directory in the first local file system, the first electronic device The device adds metadata information of the third local file to the second local file.
上述实施例中,随着一个目录中文件的增加,会在包含该目录中文件的元数据信息的第二本地文件中增加相应文件的元数据信息,保持该第二本地文件中记录的文件的元数据信息的全面性。In the above embodiment, along with the increase of files in a directory, the metadata information of the corresponding file will be added to the second local file containing the metadata information of the files in the directory, and the data of the files recorded in the second local file will be maintained. Comprehensiveness of metadata information.
结合第二方面的一些实施例,在一些实施例中,该方法还包括:当该第一电子设备删除该第一本地文件时,该第一电子设备在该第二本地文件中删除该第一本地文件的元数据信息。With reference to some embodiments of the second aspect, in some embodiments, the method further includes: when the first electronic device deletes the first local file, the first electronic device deletes the first local file in the second local file Metadata information for local files.
上述实施例中,当删除一个目录中的本地文件时,会在包含该目录中文件的元数据信息的第二本地文件中删除相应文件的元数据信息,保持该第二本地文件中记录的文件的元数据信息是最新的。In the above embodiment, when deleting a local file in a directory, the metadata information of the corresponding file will be deleted in the second local file containing the metadata information of the file in the directory, and the file recorded in the second local file will be kept. The metadata information is up to date.
结合第二方面的一些实施例,在一些实施例中,该方法还包括:当该第一电子设备修改该第一本地文件时,该第一电子设备根据对该第一本地文件的修改,在该第二本地文件中更新该第一本地文件的元数据信息。With reference to some embodiments of the second aspect, in some embodiments, the method further includes: when the first electronic device modifies the first local file, the first electronic device, according to the modification of the first local file, The metadata information of the first local file is updated in the second local file.
上述实施例中,当修改一个目录中的本地文件时,会在包含该目录中文件的元数据信息的第二本地文件中修改相应文件的元数据信息,保持该第二本地文件中记录的文件的元数据信息是最新的。In the above embodiment, when modifying a local file in a directory, the metadata information of the corresponding file will be modified in the second local file containing the metadata information of the file in the directory, and the file recorded in the second local file will be kept. The metadata information is up to date.
结合第二方面的一些实施例,在一些实施例中,该第一目录为第二目录中的一个目录;该方法还包括:该第一电子设备接收该第二电子设备发送的分布式文件系统获取该第一本地文件系统中的第二目录中第四本地文件的请求;该第四本地文件中包括该第一本地文件系统中的第一目录的元数据信息;该第一电子设备发送该第四本地文件给该第二电子设备;该第一电子设备接收该第二电子设备发送的分布式文件系统获取该第一本地文件系统中的第一目录中的该第二本地文件的请求;该第一电子设备发送该第二本地文件给该第二电子设备;该第二本地文件中包括该第一本地文件系统中的第一目录中的第五本地文件的元数据信息;该第一电子设备接收该第二电子设备对该第五本地文件的访问。With reference to some embodiments of the second aspect, in some embodiments, the first directory is a directory in the second directory; the method further includes: receiving, by the first electronic device, a distributed file system sent by the second electronic device A request for obtaining a fourth local file in the second directory in the first local file system; the fourth local file includes metadata information of the first directory in the first local file system; the first electronic device sends the The fourth local file is given to the second electronic device; the first electronic device receives a request sent by the second electronic device for the distributed file system to obtain the second local file in the first directory in the first local file system; The first electronic device sends the second local file to the second electronic device; the second local file includes metadata information of the fifth local file in the first directory in the first local file system; the first local file The electronic device receives the access of the second electronic device to the fifth local file.
上述实施例中,在第二电子设备需要访问多层目录下的一个文件时,可以从该文件的路径的最上层目录开始,依次获取其他电子设备中在该目录下的元数据文件,确定是否存在该文件的路径的下一级目录,直到找到该文件。In the above embodiment, when the second electronic device needs to access a file in a multi-layer directory, it can start from the top-level directory of the path of the file, and sequentially obtain the metadata files in the directory in other electronic devices to determine whether The directory one level below the path where the file exists until the file is found.
结合第二方面的一些实施例,在一些实施例中,该第一目录为第二目录中的一个目录;该方法还包括:该第一电子设备接收该第二电子设备发送的第五本地文件的路径;该第五本地文件为该第一本地文件系统中的第一目录中的一个文件;当该第一电子设备确定该第一本地文件系统中的第一目录下存在该第五本地文件时,该第一电子设备向该第二电子设备发送该第二本地文件;该第二本地文件中包括该第五本地文件的元数据信息;该第一电子设备接收该第二电子设备对该第五本地文件的访问。With reference to some embodiments of the second aspect, in some embodiments, the first directory is a directory in the second directory; the method further includes: receiving, by the first electronic device, a fifth local file sent by the second electronic device path; the fifth local file is a file in the first directory in the first local file system; when the first electronic device determines that the fifth local file exists in the first directory in the first local file system , the first electronic device sends the second local file to the second electronic device; the second local file includes metadata information of the fifth local file; the first electronic device receives the second electronic device for the Fifth local file access.
上述实施例中,在第二电子设备需要访问多层目录下的一个文件时,可以直接将该文件的路径发送给其他电子设备,例如第一电子设备。在第一电子设备确定第一本地文件系统中该路径下存在该文件时,可以返回包含有该文件的元数据信息的第二本地文件给该第二电子设备,使得第二电子设备可以访问该文件。In the above embodiment, when the second electronic device needs to access a file in a multi-layer directory, the path of the file can be directly sent to other electronic devices, such as the first electronic device. When the first electronic device determines that the file exists under the path in the first local file system, it can return a second local file containing metadata information of the file to the second electronic device, so that the second electronic device can access the file document.
结合第二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备接收该第二电子设备发送的更新后的第一本地文件;该第一电子设备根据更新后的第一本地文件,更新该第二本地文件;更新后的第二本地文件中包括更新后的第一本地文件的元数据信息。With reference to some embodiments of the second aspect, in some embodiments, the method further includes: receiving, by the first electronic device, an updated first local file sent by the second electronic device; For the first local file, the second local file is updated; the updated second local file includes metadata information of the updated first local file.
上述实施例中,第一电子设备可以接受其他电子设备发送的更新后的本地文件,并根据更新后的本地文件,更新相应目录下的元数据文件中的元数据信息。In the above embodiment, the first electronic device can accept the updated local files sent by other electronic devices, and update the metadata information in the metadata files in the corresponding directory according to the updated local files.
结合第二方面的一些实施例,在一些实施例中,该第一电子设备中包括第一读取记录,该第一读取记录中包括该第二电子设备向该第一电子设备请求获取包括元数据信息的本地文件的记录。With reference to some embodiments of the second aspect, in some embodiments, the first electronic device includes a first read record, and the first read record includes that the second electronic device requests the first electronic device to obtain information including: A record of the metadata information for the local file.
结合第二方面的一些实施例,在一些实施例中,该方法还包括:当该第一电子设备发送该第二本地文件给该第二电子设备,且该第一电子设备更新该第二本地文件后,该第一电子设备将更新后的第二本地文件发送给该第二电子设备。With reference to some embodiments of the second aspect, in some embodiments, the method further includes: when the first electronic device sends the second local file to the second electronic device, and the first electronic device updates the second local file After the file is created, the first electronic device sends the updated second local file to the second electronic device.
上述实施例中,第一电子设备可以将包含有第一目录下文件的元数据信息的第二本地文件,在更新后再次发送给读取了该第二本地文件的第二电子设备,使得第二电子设备中的第二本地文件也保持为最新。In the above embodiment, the first electronic device can send the second local file containing the metadata information of the file in the first directory to the second electronic device that has read the second local file after updating, so that the second local file is updated. The second local file in the second electronic device is also kept up to date.
第三方面,本申请提供了一种元数据管理方法,包括:当第二电子设备接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,该第二电子设备向第一电子设备发送分布式文件系统获取第二本地文件的请求;该第二本地文件中包括第一电子设备的第一本地文件系统中的第一目录中第一本地文件的元数据信息;该第二电子设备接收该第一电子设备发送的该第二本地文件,并缓存到该第二本地文件系统中的第一目录中;该第二电子设备根 据该第二本地文件,在该第二本地文件系统中的第一目录中显示该第一本地文件。In a third aspect, the present application provides a method for managing metadata, comprising: when a second electronic device receives a request to access a first directory in a second local file system of the second electronic device, the second electronic device sends a request to the second electronic device. The first electronic device sends a request for the distributed file system to obtain the second local file; the second local file includes metadata information of the first local file in the first directory in the first local file system of the first electronic device; the The second electronic device receives the second local file sent by the first electronic device, and caches it in the first directory in the second local file system; the second electronic device stores the file in the second local file according to the second local file The first local file is displayed in the first directory in the local file system.
上述实施例中,将本地文件系统中每个目录中各文件的元数据信息直接保存在该目录下,而不需要保存在分布式文件系统的中心节点中。当访问某个目录时,可以根据需求获取其他电子设备中相应目录中的元数据文件,从而在本电子设备的本地文件系统的该目录中显示其他电子设备的本地文件系统中相应目录中的文件。一方面可以便捷的根据需求获取其他电子设备中包含元数据信息的本地文件,构成无中心节点的分布式文件系统,不再因为中心节点下线而导致整个分布式文件系统不可用,提升了使用分布式文件系统的稳定性。另一方面在本地文件系统中管理元数据信息,根据需求在分布式文件系统中传输和共享,使得本地文件系统中的文件可以便捷的在分布式文件系统被使用。In the above embodiment, the metadata information of each file in each directory in the local file system is directly stored in the directory, and does not need to be stored in the central node of the distributed file system. When accessing a certain directory, the metadata files in the corresponding directory in other electronic devices can be obtained as required, so that the files in the corresponding directory in the local file system of other electronic devices are displayed in the directory in the local file system of this electronic device . On the one hand, local files containing metadata information in other electronic devices can be easily obtained according to requirements, forming a distributed file system without a central node. The entire distributed file system is no longer unavailable due to the offline of the central node, which improves the use of Stability of distributed file systems. On the other hand, metadata information is managed in the local file system, and transmitted and shared in the distributed file system according to requirements, so that the files in the local file system can be conveniently used in the distributed file system.
结合第三方面的一些实施例,在一些实施例中,该元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。With reference to some embodiments of the third aspect, in some embodiments, the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
结合第三方面的一些实施例,在一些实施例中,该第一目录为第二目录中的一个目录;该方法还包括:当该第二电子设备接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,该第二电子设备向该第一电子设备发送分布式文件系统获取该第一本地文件系统中的第二目录中第四本地文件的请求;该第四本地文件中包括该第一目录的元数据信息;当该第二电子设备确定接收到的该第四本地文件中包含该第一目录的元数据信息时,该第二电子设备向该第一电子设备发送分布式文件系统获取该第一本地文件系统中的第一目录中第二本地文件的请求;该第二电子设备根据接收到的该第二本地文件,访问该第五本地文件;该第二本地文件中包括该第五本地文件的元数据信息。With reference to some embodiments of the third aspect, in some embodiments, the first directory is a directory in the second directory; the method further includes: when the second electronic device receives access to the second directory in the distributed file system When a request for a fifth local file in the first directory in the ; The fourth local file includes the metadata information of the first directory; when the second electronic device determines that the received fourth local file contains the metadata information of the first directory, the second electronic device sends The first electronic device sends a request for the distributed file system to obtain a second local file in the first directory in the first local file system; the second electronic device accesses the fifth local file according to the received second local file file; the second local file includes metadata information of the fifth local file.
结合第三方面的一些实施例,在一些实施例中,该第一目录为第二目录中的一个目录;该方法还包括:当该第二电子设备接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,该第二电子设备向该第一电子设备发送第五本地文件的路径;该第五本地文件为该第一本地文件系统中的第一目录中的一个文件;当该第二电子设备接收到该第一电子设备发送的该第二本地文件时,该第二电子设备根据该第二本地文件,访问该第五本地文件。With reference to some embodiments of the third aspect, in some embodiments, the first directory is a directory in the second directory; the method further includes: when the second electronic device receives access to the second directory in the distributed file system The second electronic device sends the path of the fifth local file to the first electronic device when the request for the fifth local file in the first directory in the a file in the directory; when the second electronic device receives the second local file sent by the first electronic device, the second electronic device accesses the fifth local file according to the second local file.
结合第三方面的一些实施例,在一些实施例中,该方法还包括:该第二电子设备在该第二本地文件系统中的第一目录中缓存该第一本地文件;该第二电子设备更新该第一本地文件,将更新后的第一本地文件发送给该第一电子设备。With reference to some embodiments of the third aspect, in some embodiments, the method further includes: the second electronic device caches the first local file in a first directory in the second local file system; the second electronic device The first local file is updated, and the updated first local file is sent to the first electronic device.
结合第三方面的一些实施例,在一些实施例中,该方法还包括:当该第二电子设备接收该第一电子设备发送的第二本地文件后,该第二电子设备接收该第一电子设备发送的更新后的第二本地文件;该第二电子设备根据该更新后的第二本地文件,在该第二本地文件系统中的第一目录中,显示该第一本地文件系统中的第一目录中的更新后的文件。With reference to some embodiments of the third aspect, in some embodiments, the method further includes: after the second electronic device receives the second local file sent by the first electronic device, the second electronic device receives the first electronic device The updated second local file sent by the device; the second electronic device displays the first directory in the first local file system in the first directory in the second local file system according to the updated second local file The updated files in a directory.
结合第三方面的一些实施例,在一些实施例中,该方法还包括:在该分布式文件系统停止挂载该第二本地文件系统后,该第二电子设备删除在该第二本地文件系统中的第一目录中缓存的第二本地文件。With reference to some embodiments of the third aspect, in some embodiments, the method further includes: after the distributed file system stops mounting the second local file system, the second electronic device deletes the file in the second local file system The second local file cached in the first directory.
上述实施例中,在分布式文件系统停止挂载该第二本地文件系统后,第二电子设备可以删除各目录中缓存的其他电子设备的元数据文件,从而保障缓存的其他电子设备的元数据文件是最新的。In the above embodiment, after the distributed file system stops mounting the second local file system, the second electronic device can delete the metadata files of other electronic devices cached in each directory, thereby ensuring the cached metadata of other electronic devices. Documentation is up to date.
第四方面,本申请实施例提供了一种第一电子设备,该第一电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码, 该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该第一电子设备执行:在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,该第二本地文件中包括第一本地文件的元数据信息;当接收到第二电子设备发送的分布式文件系统获取该第二本地文件的请求时,向该第二电子设备发送该第二本地文件,使得在第二电子设备的第二本地文件系统中的第一目录中显示该第一本地文件。In a fourth aspect, an embodiment of the present application provides a first electronic device, where the first electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used for storing computer program code comprising computer instructions invoked by the one or more processors to cause the first electronic device to execute: including in a first directory in a first local file system of the first electronic device The first local file and the second local file, where the second local file includes metadata information of the first local file; when receiving a request sent by the second electronic device for the distributed file system to obtain the second local file, send the request to the The second electronic device sends the second local file, so that the first local file is displayed in the first directory in the second local file system of the second electronic device.
结合第四方面的一些实施例,在一些实施例中,该元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。With reference to some embodiments of the fourth aspect, in some embodiments, the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当在该第一本地文件系统中的第一目录中增加第三本地文件时,在该第二本地文件中增加第三本地文件的元数据信息。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when the first file in the first local file system When a third local file is added to a directory, metadata information of the third local file is added to the second local file.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当删除该第一本地文件时,在该第二本地文件中删除该第一本地文件的元数据信息。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when the first local file is deleted, in the The metadata information of the first local file is deleted from the second local file.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当修改该第一本地文件时,根据对该第一本地文件的修改,在该第二本地文件中更新该第一本地文件的元数据信息。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when modifying the first local file, according to the The modification of the first local file updates the metadata information of the first local file in the second local file.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收该第二电子设备发送的分布式文件系统获取该第一本地文件系统中的第二目录中第四本地文件的请求;该第四本地文件中包括该第一本地文件系统中的第一目录的元数据信息;发送该第四本地文件给该第二电子设备;接收该第二电子设备发送的分布式文件系统获取该第一本地文件系统中的第一目录中的该第二本地文件的请求;发送该第二本地文件给该第二电子设备;该第二本地文件中包括该第一本地文件系统中的第一目录中的第五本地文件的元数据信息;接收该第二电子设备对该第五本地文件的访问。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive a distributed file sent by the second electronic device The system obtains a request for a fourth local file in the second directory in the first local file system; the fourth local file includes metadata information of the first directory in the first local file system; sends the fourth local file to the second electronic device; receiving a request sent by the second electronic device for the distributed file system to obtain the second local file in the first directory in the first local file system; sending the second local file to the first local file system two electronic devices; the second local file includes metadata information of the fifth local file in the first directory in the first local file system; and the access to the fifth local file by the second electronic device is received.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收该第二电子设备发送的第五本地文件的路径;该第五本地文件为该第一本地文件系统中的第一目录中的一个文件;当确定该第一本地文件系统中的第一目录下存在该第五本地文件时,向该第二电子设备发送该第二本地文件;该第二本地文件中包括该第五本地文件的元数据信息;接收该第二电子设备对该第五本地文件的访问。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive a fifth local message sent by the second electronic device The path of the file; the fifth local file is a file in the first directory in the first local file system; when it is determined that the fifth local file exists in the first directory in the first local file system, to the The second electronic device sends the second local file; the second local file includes metadata information of the fifth local file; and receives the access of the second electronic device to the fifth local file.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收该第二电子设备发送的更新后的第一本地文件;根据更新后的第一本地文件,更新该第二本地文件;更新后的第二本地文件中包括更新后的第一本地文件的元数据信息。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive the updated data sent by the second electronic device The first local file; the second local file is updated according to the updated first local file; the updated second local file includes metadata information of the updated first local file.
结合第四方面的一些实施例,在一些实施例中,该第一电子设备中包括第一读取记录,该第一读取记录中包括该第二电子设备向该第一电子设备请求获取包括元数据信息的本地文件的记录。With reference to some embodiments of the fourth aspect, in some embodiments, the first electronic device includes a first read record, and the first read record includes that the second electronic device requests the first electronic device to obtain information including: A record of the metadata information for the local file.
结合第四方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当发送该第二本地文件给该第二电子设备,且更新该第二本地文件后,将更新后的第二本地文件发送给该第二电子设备。With reference to some embodiments of the fourth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when sending the second local file to the second The electronic device, and after updating the second local file, sends the updated second local file to the second electronic device.
第五方面,本申请实施例提供了一种芯片系统,该芯片系统应用于第一电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该第一电子设备执行如第二方面以及第二方面中任一可能的实现方式描述的方法。In a fifth aspect, an embodiment of the present application provides a chip system, the chip system is applied to a first electronic device, the chip system includes one or more processors, and the processors are configured to invoke computer instructions to make the first electronic device A method as described in the second aspect and any possible implementation of the second aspect is performed.
第六方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在第一电子设备上运行时,使得上述第一电子设备执行如第二方面以及第二方面中任一可能的实现方式描述的方法。In a sixth aspect, an embodiment of the present application provides a computer program product containing instructions, when the computer program product is executed on a first electronic device, the first electronic device is made to execute any one of the second aspect and the second aspect. possible implementations of the method described.
第七方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在第一电子设备上运行时,使得上述第一电子设备执行如第二方面以及第二方面中任一可能的实现方式描述的方法。In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, when the above-mentioned instructions are executed on a first electronic device, the above-mentioned first electronic device is made to execute any one of the second aspect and the second aspect possible implementations of the method described.
可以理解地,上述第四方面提供的电子设备、第五方面提供的芯片系统、第六方面提供的计算机程序产品和第七方面提供的计算机存储介质均用于执行本申请实施例第二方面以及第二方面中任一可能的实现方式所提供的元数据管理方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。It can be understood that the electronic device provided in the fourth aspect, the chip system provided in the fifth aspect, the computer program product provided in the sixth aspect, and the computer storage medium provided in the seventh aspect are all used to execute the second aspect and The metadata management method provided by any possible implementation manner of the second aspect. Therefore, for the beneficial effects that can be achieved, reference may be made to the beneficial effects in the corresponding method, which will not be repeated here.
第八方面,本申请实施例提供了一种第二电子设备,该第二电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该第二电子设备执行:当接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,向第一电子设备发送分布式文件系统获取第二本地文件的请求;该第二本地文件中包括第一电子设备的第一本地文件系统中的第一目录中第一本地文件的元数据信息;接收该第一电子设备发送的该第二本地文件,并缓存到该第二本地文件系统中的第一目录中;根据该第二本地文件,在该第二本地文件系统中的第一目录中显示该第一本地文件。In an eighth aspect, an embodiment of the present application provides a second electronic device, where the second electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used for storing computer program code comprising computer instructions invoked by the one or more processors to cause the second electronic device to execute: upon receiving access to a first file in a second local file system of the second electronic device When requesting a directory, a request for obtaining a second local file from the distributed file system is sent to the first electronic device; the second local file includes the first local file in the first directory in the first local file system of the first electronic device metadata information; receive the second local file sent by the first electronic device, and cache it in the first directory in the second local file system; according to the second local file, in the second local file system The first local file is displayed in the first directory of the .
结合第八方面的一些实施例,在一些实施例中,该元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。With reference to some embodiments of the eighth aspect, in some embodiments, the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
结合第八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第二电子设备执行:当接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,向该第一电子设备发送分布式文件系统获取该第一本地文件系统中的第二目录中第四本地文件的请求;该第四本地文件中包括该第一目录的元数据信息;当确定接收到的该第四本地文件中包含该第一目录的元数据信息时,向该第一电子设备发送分布式文件系统获取该第一本地文件系统中的第一目录中第二本地文件的请求;根据接收到的该第二本地文件,访问该第五本地文件;该第二本地文件中包括该第五本地文件的元数据信息。With reference to some embodiments of the eighth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: when receiving access to the second electronic device in the distributed file system When the request for the fifth local file in the first directory in the directory is sent, a request for the distributed file system to obtain the fourth local file in the second directory in the first local file system is sent to the first electronic device; The local file includes metadata information of the first directory; when it is determined that the received fourth local file contains metadata information of the first directory, send a distributed file system to the first electronic device to obtain the first directory A request for a second local file in the first directory in the local file system; accessing the fifth local file according to the received second local file; the second local file including metadata information of the fifth local file.
结合第八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第二电子设备执行:当接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,向该第一电子设备发送第五本地文件的路径;该第五本地文件为该第一本地文件系统中的第一目录中的一个文件;当接收到该第一电子设备发送的该第二本地文件时,根据该第二本地文件,访问该第五本地文件。With reference to some embodiments of the eighth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: when receiving access to the second electronic device in the distributed file system When requesting the fifth local file in the first directory in the directory, send the path of the fifth local file to the first electronic device; the fifth local file is one of the first directories in the first local file system file; when receiving the second local file sent by the first electronic device, access the fifth local file according to the second local file.
结合第八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第二电子设备执行:在该第二本地文件系统中的第一目录中缓存该第一本地文件;更新该第一本地文件,将更新后的第一本地文件发送给该第一电子设备。With reference to some embodiments of the eighth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: the first in the second local file system The first local file is cached in the directory; the first local file is updated, and the updated first local file is sent to the first electronic device.
结合第八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计 算机指令以使得该第二电子设备执行:当接收该第一电子设备发送的第二本地文件后,接收该第一电子设备发送的更新后的第二本地文件;根据该更新后的第二本地文件,在该第二本地文件系统中的第一目录中,显示该第一本地文件系统中的第一目录中的更新后的文件。With reference to some embodiments of the eighth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: when receiving the second data sent by the first electronic device After the local file, receive the updated second local file sent by the first electronic device; according to the updated second local file, display the first local file in the first directory in the second local file system The updated file in the first directory in the system.
结合第八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第二电子设备执行:在该分布式文件系统停止挂载该第二本地文件系统后,删除在该第二本地文件系统中的第一目录中缓存的第二本地文件。With reference to some embodiments of the eighth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the second electronic device to execute: stop mounting the first electronic device in the distributed file system After the second local file system is installed, the second local file cached in the first directory in the second local file system is deleted.
第九方面,本申请实施例提供了一种芯片系统,该芯片系统应用于第二电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该第二电子设备执行如第三方面以及第三方面中任一可能的实现方式描述的方法。In a ninth aspect, an embodiment of the present application provides a chip system, the chip system is applied to a second electronic device, the chip system includes one or more processors, and the processors are configured to invoke computer instructions to make the second electronic device A method as described in the third aspect and any possible implementation of the third aspect is performed.
第十方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在第二电子设备上运行时,使得上述第二电子设备执行如第三方面以及第三方面中任一可能的实现方式描述的方法。In a tenth aspect, an embodiment of the present application provides a computer program product including instructions, when the computer program product is run on a second electronic device, the second electronic device is made to execute any one of the third aspect and the third aspect. possible implementations of the method described.
第十一方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在第二电子设备上运行时,使得上述第二电子设备执行如第三方面以及第三方面中任一可能的实现方式描述的方法。In an eleventh aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, when the above-mentioned instructions are executed on a second electronic device, the above-mentioned second electronic device is made to perform any one of the third aspect and the third aspect. A possible implementation of the method described.
可以理解地,上述第八方面提供的电子设备、第九方面提供的芯片系统、第十方面提供的计算机程序产品和第十一方面提供的计算机存储介质均用于执行本申请实施例第三方面以及第三方面中任一可能的实现方式所提供的元数据管理方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。Understandably, the electronic device provided in the eighth aspect, the chip system provided in the ninth aspect, the computer program product provided in the tenth aspect, and the computer storage medium provided in the eleventh aspect are all used to execute the third aspect of the embodiments of the present application. and the metadata management method provided by any possible implementation manner of the third aspect. Therefore, for the beneficial effects that can be achieved, reference may be made to the beneficial effects in the corresponding method, which will not be repeated here.
本申请实施例还提供了一种同名文件识别方法和电子设备,用于在无中心节点的分布式文件系统中,快速的确定各电子设备的一个路径下是否存在同名文件。Embodiments of the present application further provide a method and electronic device for identifying a file with the same name, which are used to quickly determine whether a file with the same name exists in a path of each electronic device in a distributed file system without a central node.
第十二方面,本申请提供了一种同名文件识别方法,包括:第一电子设备响应于显示分布式文件系统中第一目录下文件的请求,根据第一电子设备的布隆过滤器位数组和第二电子设备的布隆过滤器位数组,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否不存在同名文件;当确定不存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息,该第一目录下的文件信息包括该第一电子设备中第一目录下的本地文件的文件信息和该第二电子设备中第一目录下的本地文件的文件信息。In a twelfth aspect, the present application provides a method for identifying a file with the same name, comprising: a first electronic device, in response to a request for displaying a file in a first directory in a distributed file system, according to a Bloom filter bit array of the first electronic device and the Bloom filter bit array of the second electronic device, determine whether there is no file with the same name under the first directory in the first electronic device and under the first directory in the second electronic device; when it is determined that the file with the same name does not exist, the The first electronic device displays file information in the first directory in the distributed file system, and the file information in the first directory includes the file information of the local files in the first directory in the first electronic device and the second electronic device. File information of local files in the first directory.
在上述实施例中,根据各电子设备的布隆过滤器位数组对分布式文件系统中多个电子设备中同目录下存在同名文件的可能性进行整体判断,再根据整体判断的结果进行后续处理。由于各电子设备中同目录下存在同名文件的情况并不是非常多,因此,在大多数情况下都能直接通过该整体判断快速得到两个目录之间没有同名文件的识别结果。即使整体判断出有些目录间可能有同名文件,不能直接得到最终识别结果,也能显著的缩小进行同名文件识别的范围。极大的降低了进行同名文件识别时的处理时长,减少了进行同名文件识别时消耗的资源。In the above embodiment, an overall judgment is made on the possibility that a file with the same name exists in the same directory in multiple electronic devices in the distributed file system according to the Bloom filter bit array of each electronic device, and then follow-up processing is carried out according to the result of the overall judgment . Since there are not very many files with the same name in the same directory in each electronic device, in most cases, the identification result that there is no file with the same name between the two directories can be quickly obtained directly through the overall judgment. Even if it is judged as a whole that some directories may have files with the same name, the final recognition result cannot be directly obtained, and the scope of file recognition with the same name can be significantly narrowed. This greatly reduces the processing time when identifying files with the same name, and reduces the resources consumed when identifying files with the same name.
结合第十二方面的一些实施例,在一些实施例中,该方法还包括:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下可能存在同名文件时,该第一电子设备确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否存在同名文件;当确定存在同名文件时,对同名文件重命名,直到该第一电子设备中第一目录下和该第二电子设备中 第一目录下不存在同名文件。With reference to some embodiments of the twelfth aspect, in some embodiments, the method further includes: when it is determined that a file with the same name may exist in the first directory in the first electronic device and in the first directory in the second electronic device, The first electronic device determines whether a file with the same name exists in the first directory in the first electronic device and in the first directory in the second electronic device; when it is determined that a file with the same name exists, rename the file with the same name until the first electronic device There is no file with the same name in the first directory in the device and in the first directory in the second electronic device.
可选的,对同名文件重命名可以为:在显示同名文件时,在同名文件的文件名中添加存储该文件的设备的设备标识。Optionally, renaming the file with the same name may be: when the file with the same name is displayed, the device identifier of the device storing the file is added to the file name of the file with the same name.
可选的,设备标识可以为设备名称、MAC地址等等,此处不作限定。Optionally, the device identifier may be a device name, a MAC address, etc., which are not limited here.
在上述实施例中,当确定两个目录中可能存在同名文件时,第一电子设备可以找出其中的同名文件并重命名,直到两个目录中不存在同名文件再显示。由于只需要比较可能存在同名文件的目录,极大的降低了同名文件识别的处理时长,减少了进行同名文件识别时消耗的资源。In the above embodiment, when it is determined that a file with the same name may exist in the two directories, the first electronic device can find the file with the same name and rename it, and display it until the file with the same name does not exist in the two directories. Since it is only necessary to compare directories in which files with the same name may exist, the processing time for identifying files with the same name is greatly reduced, and the resources consumed when identifying files with the same name is reduced.
结合第十二方面的一些实施例,在一些实施例中,该第一电子设备确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否存在同名文件,具体包括:该第一电子设备将该第一电子设备中第一目录下每个本地文件的文件名,分别与该第二电子设备中第一目录下每个文件的文件名比较,确定是否存在同名文件。With reference to some embodiments of the twelfth aspect, in some embodiments, the first electronic device determines whether a file with the same name exists in the first directory in the first electronic device and in the first directory in the second electronic device, specifically including : The first electronic device compares the file name of each local file in the first directory in the first electronic device with the file name of each file in the first directory in the second electronic device to determine whether there is a file with the same name .
在上述实施例中,在确定两个目录中可能存在同名文件,需要确定其中是否存在同名文件时,第一电子设备可以对两个目录中的文件分别进行两两比较,找出其中存在的同名文件,或确定两个目录中不存在同名文件。In the above embodiment, when it is determined that there may be files with the same name in two directories, and it is necessary to determine whether there is a file with the same name, the first electronic device can compare the files in the two directories in pairs to find out the files with the same name in them. file, or determine that a file with the same name does not exist in both directories.
结合第十二方面的一些实施例,在一些实施例中,该第一电子设备确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否存在同名文件,具体包括:该第一电子设备根据该第一电子设备的布隆过滤器位数组,分别确定第二电子设备中第一目录下的每个文件是否在第一电子设备中第一目录下可能存在同名文件;当确定第二电子设备中第一目录下的一个文件在第一电子设备中第一目录下可能存在同名文件时,将该文件与该第一电子设备中第一目录下每个文件的文件名分别比较,确定是否存在同名文件。With reference to some embodiments of the twelfth aspect, in some embodiments, the first electronic device determines whether a file with the same name exists in the first directory in the first electronic device and in the first directory in the second electronic device, specifically including : The first electronic device determines, according to the Bloom filter bit array of the first electronic device, whether each file in the first directory in the second electronic device may have a file with the same name in the first directory in the first electronic device When it is determined that a file under the first directory in the second electronic device may have a file of the same name under the first directory in the first electronic device, this file and the file of each file in the first directory in the first electronic device The names are compared to determine whether there is a file with the same name.
在上述实施例中,在确定两个目录中可能存在同名文件,需要确定其中是否存在同名文件时,第一电子设备可以根据第一电子设备的布隆过滤器位数组,分别确定第二电子设备中第一目录下每个文件是否可能在该第一电子设备的第一目录下可能存在同名文件。只有在可能存在时,才将该文件的文件名与该第一电子设备的第一目录下的每个文件的文件名进行比较。否则,可以直接确定该文件在该第一电子设备的第一目录下不存在同名文件,不需要分别去与该第一电子设备的第一目录下的每个文件的文件名进行比较。由于不存在同名文件的文件占大多数,在各电子设备的第一目录下文件较多时,可以极大的减少确定其中同名文件的时间。In the above embodiment, when it is determined that a file with the same name may exist in two directories, and it is necessary to determine whether a file with the same name exists, the first electronic device may determine the second electronic device according to the bloom filter bit array of the first electronic device. Whether each file in the first directory may exist in the first directory of the first electronic device with the same name. The filename of the file is compared with the filename of each file under the first directory of the first electronic device only if possible. Otherwise, it can be directly determined that the file does not exist in the first directory of the first electronic device with the same name, and there is no need to compare it with the file name of each file in the first directory of the first electronic device. Since most files do not have files with the same name, when there are many files in the first directory of each electronic device, the time for determining the files with the same name can be greatly reduced.
结合第十二方面的一些实施例,在一些实施例中,该文件信息包括:文件名和/或文件图标。With reference to some embodiments of the twelfth aspect, in some embodiments, the file information includes: a file name and/or a file icon.
可选的,在一些实施例中,该文件信息还可以包括文件的实际数据。Optionally, in some embodiments, the file information may also include actual data of the file.
结合第十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备根据该第一电子设备中第一目录下本地文件的文件名,计算第一电子设备的布隆过滤器位数组;该第一电子设备获取第二电子设备的布隆过滤器位数组;该第二电子设备的布隆过滤器位数组是根据该第二电子设备中第一目录下本地文件的文件名计算得到。With reference to some embodiments of the twelfth aspect, in some embodiments, the method further includes: the first electronic device calculates the distribution of the first electronic device according to the file name of the local file in the first directory in the first electronic device Bloom filter bit array; the first electronic device obtains the Bloom filter bit array of the second electronic device; the Bloom filter bit array of the second electronic device is based on the local file in the first directory in the second electronic device The filename is calculated.
可以理解的是,第一电子设备和第二电子设备中都包含有布隆过滤器,且两个电子设备 中的布隆过滤器的参数相同,即包含有相同的K个哈希函数,以及位数相同的N个位数的布隆过滤器位数组。K和N的具体值可以根据实际情况设定,此处不作作限定。It can be understood that both the first electronic device and the second electronic device include bloom filters, and the parameters of the bloom filters in the two electronic devices are the same, that is, they include the same K hash functions, and A Bloom filter bit array of N digits with the same number of digits. The specific values of K and N can be set according to actual conditions, which are not limited here.
在上述实施例中,第一电子设备可以先得到第一电子设备的布隆过滤器位数组和第二电子设备的布隆过滤器位数组。该第一电子设备的布隆过滤器位数组由该第一电子设备根据第一电子设备中第一目录下本地文件的文件名计算得到。In the above embodiment, the first electronic device may first obtain the bloom filter bit array of the first electronic device and the bloom filter bit array of the second electronic device. The bloom filter bit array of the first electronic device is calculated by the first electronic device according to the file name of the local file in the first directory in the first electronic device.
该第二电子设备的布隆过滤器位数组为根据第二电子设备中第一目录下本地文件的文件名计算得到,但是第一电子设备获取第二电子设备的布隆过滤器位数组的过程可以有多种不同的方式:The bloom filter bit array of the second electronic device is calculated according to the file name of the local file in the first directory in the second electronic device, but the process of acquiring the bloom filter bit array of the second electronic device by the first electronic device There are many different ways:
可选的,在一些实施例中,该第一电子设备获取第二电子设备的布隆过滤器位数组,具体包括:该第一电子设备向该第二电子设备发送获取该第二电子设备的布隆过滤器位数组的请求,其中携带有第一目录的标识;该第一电子设备接收该第二电子设备发送的该第二电子设备的布隆过滤器位数组。Optionally, in some embodiments, the first electronic device obtains the bloom filter bit array of the second electronic device, which specifically includes: the first electronic device sends the second electronic device to obtain the data of the second electronic device. A request for a bloom filter bit array, which carries the identifier of the first directory; the first electronic device receives the bloom filter bit array of the second electronic device sent by the second electronic device.
在上述实施例中,该第二电子设备的布隆过滤器位数组是第二电子设备自己根据第二电子设备中第一目录下本地文件的文件名计算得到的。第二电子设备计算得到该当第二电子设备的布隆过滤器位数组后,基于该第一电子设备发送的请求,可以将该第二电子设备的布隆过滤器位数组发送给该第一电子设备。In the above embodiment, the bloom filter bit array of the second electronic device is calculated by the second electronic device itself according to the file name of the local file in the first directory in the second electronic device. After the second electronic device calculates and obtains the bloom filter bit array of the second electronic device, based on the request sent by the first electronic device, the bloom filter bit array of the second electronic device can be sent to the first electronic device equipment.
可选的,在一些实施例中,该第一电子设备获取第二电子设备的布隆过滤器位数组,具体包括:该第一电子设备获取该第二电子设备中第一目录下本地文件的文件名;该第一电子设备根据该第二电子设备中第一目录下本地文件的文件名,计算得到该第二电子设备的布隆过滤器位数组。Optionally, in some embodiments, acquiring the Bloom filter bit array of the second electronic device by the first electronic device specifically includes: the first electronic device acquiring the data of the local file in the first directory in the second electronic device. File name; the first electronic device calculates the Bloom filter bit array of the second electronic device according to the file name of the local file in the first directory in the second electronic device.
在上述实施例中,第一电子设备可以先获取第二电子设备中第一目录下本地文件的文件名,然后由该第一电子设备自己计算出该第二电子设备的布隆过滤器位数组。In the above embodiment, the first electronic device can first obtain the file name of the local file in the first directory in the second electronic device, and then the first electronic device can calculate the bloom filter bit array of the second electronic device by itself .
在实际应用中,该第一电子设备获取第二电子设备中第一目录下本地文件的文件名也可以有多种不同的方式:In practical applications, the first electronic device may obtain the file name of the local file in the first directory in the second electronic device in many different ways:
可选的,在一些实施例中,该第一电子设备获取该第二电子设备中第一目录下本地文件的文件名,具体包括:该第一电子设备向该第二电子设备发送获取该第二电子设备中第一目录下本地文件的文件名的请求;该第一电子设备接收该第二电子设备发送的第二电子设备中第一目录下本地文件的文件名。Optionally, in some embodiments, the first electronic device obtains the file name of the local file in the first directory in the second electronic device, which specifically includes: the first electronic device sends the second electronic device to obtain the first electronic device. A request for the file name of the local file in the first directory in the second electronic device; the first electronic device receives the file name of the local file in the first directory in the second electronic device sent by the second electronic device.
在上述实施例中,第一电子设备可以通过向第二电子设备发送请求来获取第二电子设备中第一目录下本地文件的文件名。In the above embodiment, the first electronic device may acquire the file name of the local file in the first directory in the second electronic device by sending a request to the second electronic device.
可选的,在一些实施例这种,该第一电子设备获取该第二电子设备中第一目录下本地文件的文件名,具体包括:该第一电子设备根据存储的第二电子设备中第一目录下本地文件的元数据信息,获取到该第二电子设备中第一目录下本地文件的文件名。Optionally, in some embodiments, the first electronic device obtains the file name of the local file in the first directory in the second electronic device, which specifically includes: the first electronic device according to the stored second electronic device. The metadata information of a local file in a directory is obtained, and the file name of the local file in the first directory in the second electronic device is obtained.
在上述实施例中,由于该第一电子设备的第一目录与该第二电子设备的第一目录都被挂载在分布式文件系统中,因此,该第一电子设备中可以存储有该第二电子设备的第一目录下本地文件的元数据信息,该元数据信息中可以包括文件名。该第一电子设备可以根据存储的第二电子设备的第二目录下本地文件的元数据信息,获取到该第二电子设备中第一目录下本 地文件的文件名,不需要临时去向第二电子设备请求获取该第二电子设备中第一目录下本地文件的文件名。In the above embodiment, since the first directory of the first electronic device and the first directory of the second electronic device are both mounted in the distributed file system, the first electronic device may store the first directory The metadata information of the local file in the first directory of the second electronic device, the metadata information may include the file name. The first electronic device can obtain the file name of the local file in the first directory in the second electronic device according to the stored metadata information of the local file in the second directory of the second electronic device, without temporarily going to the second electronic device The device requests to obtain the file name of the local file in the first directory in the second electronic device.
结合第十二方面的一些实施例,在一些实施例中,该第一电子设备根据该第一电子设备中第一目录下本地文件的文件名,计算第一电子设备的布隆过滤器位数组,具体包括:该第一电子设备使用第一电子设备的布隆过滤器中的K个哈希函数,计算该第一电子设备中第一目录下每个本地文件的文件名的哈希值;将该每个本地文件的文件名的哈希值映射到该第一电子设备的布隆过滤器中包含有的N个位数的位数组中,得到该第一电子设备的布隆过滤器位数组;其中K为正整数,N为大于K的正整数。With reference to some embodiments of the twelfth aspect, in some embodiments, the first electronic device calculates the bloom filter bit array of the first electronic device according to the file name of the local file in the first directory in the first electronic device , specifically comprising: the first electronic device uses K hash functions in the Bloom filter of the first electronic device to calculate the hash value of the file name of each local file in the first directory in the first electronic device; mapping the hash value of the file name of each local file to the bit array of N digits included in the bloom filter of the first electronic device to obtain the bloom filter bits of the first electronic device Array; where K is a positive integer and N is a positive integer greater than K.
结合第十二方面的一些实施例,在一些实施例中,该第二电子设备的布隆过滤器位数组是根据第二电子设备的布隆过滤器中的该K个哈希函数,计算该第二电子设备中第一目录下每个本地文件的文件名的哈希值,将该每个本地文件的文件名的哈希值映射到该第二电子设备的布隆过滤器中包含有的N个位数的位数组中得到的。With reference to some embodiments of the twelfth aspect, in some embodiments, the bloom filter bit array of the second electronic device is calculated according to the K hash functions in the bloom filter of the second electronic device. The hash value of the file name of each local file in the first directory in the second electronic device, and the hash value of the file name of each local file is mapped to the hash value included in the Bloom filter of the second electronic device obtained from a bit array of N digits.
结合第十二方面的一些实施例,在一些实施例中,该根据第一电子设备的布隆过滤器位数组和第二电子设备的布隆过滤器位数组,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否可能存在同名文件,具体包括:该第一电子设备确定该第一电子设备的布隆过滤器位数组和该第二电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K,该K为该第一电子设备的布隆过滤器和该第二电子设备的布隆过滤器中哈希函数的数目;当确定小于该K时,该第一电子设备确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件;当确定不小于该K时,该第一电子设备确定该第一电子设备中第一目录下和该第二电子设备中第一目录下可能存在同名文件。With reference to some embodiments of the twelfth aspect, in some embodiments, the first electronic device is determined according to the bloom filter bit array of the first electronic device and the bloom filter bit array of the second electronic device. Whether a file with the same name may exist in a directory and a first directory in the second electronic device specifically includes: the first electronic device determines the Bloom filter bit array of the first electronic device and the Bloom filter of the second electronic device. Whether the number of digits that are 1 at the same position in the filter bit array at the same time is less than K, where K is the number of hash functions in the Bloom filter of the first electronic device and the Bloom filter of the second electronic device; when it is determined When it is less than the K, the first electronic device determines that there is no file with the same name in the first directory in the first electronic device and in the first directory in the second electronic device; when it is determined not less than the K, the first electronic device It is determined that a file with the same name may exist in the first directory in the first electronic device and in the first directory in the second electronic device.
在上述实施例中,通过整体比对第一电子设备的布隆过滤器位数组和第二电子设备的布隆过滤器位数组,即可以判断第一电子设备中第一目录下与第二电子设备中第一目录下是否可能存在同名文件。在有多个目录需要比对判断时,可以直接确定其中的部分目录与另外部分目录不存在同名文件,而不需要分别对目录中的每个文件进行两两比对,极大的降低了同名文件识别的处理时长,减少了进行同名文件识别时消耗的资源。In the above embodiment, by comparing the Bloom filter bit array of the first electronic device and the Bloom filter bit array of the second electronic device as a whole, it can be determined that the first directory in the first electronic device is the same as the second electronic device. Check whether a file with the same name may exist in the first directory of the device. When there are multiple directories that need to be compared and judged, it can be directly determined that some of the directories and other directories do not have files with the same name, and it is not necessary to perform a pairwise comparison of each file in the directory, which greatly reduces the number of files with the same name. The processing time of file identification reduces the resources consumed when identifying files with the same name.
结合第十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备获取第三电子设备的布隆过滤器位数组;该第三电子设备的布隆过滤器位数组是根据该第三电子设备中第一目录下本地文件的文件名计算得到。With reference to some embodiments of the twelfth aspect, in some embodiments, the method further includes: acquiring, by the first electronic device, an array of bloom filter bits of a third electronic device; The array is calculated according to the file names of the local files in the first directory in the third electronic device.
在上述实施例中,分布式文件系统的第一目录还可以挂载有其他电子设备的第一目录,例如第三电子设备。第一电子设备还可以获取该第三电子设备的布隆过滤器位数组。In the above embodiment, the first directory of the distributed file system may also be mounted with the first directory of other electronic devices, such as a third electronic device. The first electronic device may also obtain the bloom filter bit array of the third electronic device.
结合第十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备根据该第一电子设备的布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第一电子设备中第一目录下和该第三电子设备中第一目录下是否可能存在同名文件;该第一电子设备根据该第二电子设备的布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第二电子设备中第一目录下和该第三电子设备中第一目录下是否可能存在同名文件;该当确定不存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息,具 体包括:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件,且该第一电子设备中第一目录下和该第三电子设备中第一目录下不存在同名文件,且该第二电子设备中第一目录下和该第三电子设备中第一目录下不存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息;其中包括该第一电子设备中第一目录下的本地文件的文件信息、该第二电子设备中第一目录下的本地文件的文件信息和该第三电子设备中第一目录下的本地文件的文件信息。With reference to some embodiments of the twelfth aspect, in some embodiments, the method further includes: the first electronic device according to the bloom filter bit array of the first electronic device and the bloom filter of the third electronic device A bit array to determine whether a file with the same name may exist in the first directory in the first electronic device and in the first directory in the third electronic device; the first electronic device is based on the Bloom filter bit array of the second electronic device and The bloom filter bit array of the third electronic device determines whether a file with the same name may exist in the first directory in the second electronic device and in the first directory in the third electronic device; when it is determined that a file with the same name does not exist, the The first electronic device displays file information under the first directory in the distributed file system, specifically including: when it is determined that there is no file with the same name in the first directory in the first electronic device and in the first directory in the second electronic device, And there is no file with the same name in the first directory in the first electronic device and in the first directory in the third electronic device, and there is no file in the first directory in the second electronic device and in the first directory in the third electronic device. When a file with the same name exists, the first electronic device displays the file information in the first directory in the distributed file system; which includes the file information of the local file in the first directory in the first electronic device, and the file information in the second electronic device. The file information of the local file under the first directory and the file information of the local file under the first directory in the third electronic device.
在上述实施例中,第一电子设备可以将第一电子设备的布隆过滤器位数组、第二电子设备的布隆过滤器位数组和第三电子设备的布隆过滤器位数组分别两两比较,在确定各电子设备中第一目录下都不存在同名文件时,再显示分布式文件系统这种该第一目录下的文件信息。In the above-mentioned embodiment, the first electronic device may separate the bloom filter bit array of the first electronic device, the bloom filter bit array of the second electronic device, and the bloom filter bit array of the third electronic device into two By comparison, when it is determined that there is no file with the same name in the first directory in each electronic device, the file information in the first directory, such as the distributed file system, is displayed again.
结合第十二方面的一些实施例,在一些实施例中,该方法还包括:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件时,该第一电子设备对该第一电子设备的布隆过滤器位数组和该第二电子设备的布隆过滤器位数组进行逻辑或操作,得到逻辑或布隆过滤器位数组;该第一电子设备根据该逻辑或布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第一电子设备和该第二电子设备中是否至少有一个的第一目录下与该第三电子设备的第一目录下可能存在同名文件;该当确定不存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息,具体包括:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件,且确定该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息;其中包括该第一电子设备中第一目录下的本地文件的文件信息、该第二电子设备中第一目录下的本地文件的文件信息和该第三电子设备中第一目录下的本地文件的文件信息。With reference to some embodiments of the twelfth aspect, in some embodiments, the method further includes: when it is determined that a file with the same name does not exist in the first directory in the first electronic device and in the first directory in the second electronic device, The first electronic device performs a logical OR operation on the bloom filter bit array of the first electronic device and the bloom filter bit array of the second electronic device to obtain a logical OR bloom filter bit array; the first electronic device The device determines whether at least one of the first electronic device and the second electronic device has a first directory with the third electronic device according to the logical OR Bloom filter bit array and the Bloom filter bit array of the third electronic device. There may be a file with the same name in the first directory of the three electronic devices; when it is determined that the file with the same name does not exist, the first electronic device displays the file information under the first directory in the distributed file system, which specifically includes: when it is determined that the first electronic device does not exist There is no file with the same name in the first directory in the device and in the first directory in the second electronic device, and it is determined that there is no file with the same name in the first directory in the first electronic device and the second electronic device. When a file with the same name exists in a directory, the first electronic device displays the file information in the first directory in the distributed file system; which includes the file information of the local file in the first directory in the first electronic device, the second The file information of the local file under the first directory in the electronic device and the file information of the local file under the first directory in the third electronic device.
在上述实施例中,第一电子设备可以将确定不存在同名文件的电子设备的布隆过滤器位数组进行逻辑或操作,得到逻辑或布隆过滤器位数组,再整体与第三电子设备的布隆过滤器位数组进行比较。进一步降低了同名文件识别的处理时长。In the above-mentioned embodiment, the first electronic device may perform a logical OR operation on the Bloom filter bit array of the electronic device that determines that there is no file with the same name, to obtain a logical OR Bloom filter bit array, and then the whole with the third electronic device's bit array. Bloom filter bit arrays to compare. The processing time for identifying files with the same name is further reduced.
结合第十二方面的一些实施例,在一些实施例中,该第一电子设备根据该逻辑或布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第一电子设备和该第二电子设备中是否至少有一个的第一目录下与该第三电子设备的第一目录下可能存在同名文件,具体包括:该第一电子设备确定该逻辑或布隆过滤器位数组和该第三电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K,该K为该第一电子设备的布隆过滤器、该第二电子设备的布隆过滤器和该第三电子设备的布隆过滤器中哈希函数的数目;当确定小于该K时,该第一电子设备确定该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件;当确定不小于该K时,该第一电子设备确定该第一电子设备和该第二电子设备中至少有一个的第一目录下可能与该第三电子设备的第一目录下存在同名文件,确定并重命名其中的同名文件,直到该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件。With reference to some embodiments of the twelfth aspect, in some embodiments, the first electronic device determines the first electronic device according to the logical OR Bloom filter bit array and the Bloom filter bit array of the third electronic device Whether there may exist a file with the same name in the first directory of at least one of the device and the second electronic device as in the first directory of the third electronic device, specifically including: the first electronic device determines the logical OR Bloom filter bit Whether the number of digits in the array and the Bloom filter bit array of the third electronic device that are at the same position at the same time is 1 is less than K, where K is the Bloom filter of the first electronic device and the Bloom filter of the second electronic device The number of hash functions in the Bloom filter of the device and the third electronic device; when it is determined to be less than the K, the first electronic device determines that the first electronic device and the second electronic device do not have one in the first directory A file with the same name exists in the first directory of the third electronic device; when it is determined that it is not less than the K, the first electronic device determines that at least one of the first electronic device and the second electronic device may be in the first directory. There is a file with the same name in the first directory of the third electronic device, determine and rename the file with the same name, until there is no one in the first directory of the first electronic device and the second electronic device that has the same name as the third electronic device. A file with the same name exists in a directory.
第十三方面,本申请实施例提供了一种第一电子设备,该第一电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该第 一电子设备执行:响应于显示分布式文件系统中第一目录下文件的请求,根据该第一电子设备的布隆过滤器位数组和该第二电子设备的布隆过滤器位数组,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否不存在同名文件;当确定不存在同名文件时,该第一电子设备显示分布式文件系统中该第一目录下的文件信息,该第一目录下的文件信息包括该第一电子设备中第一目录下的本地文件的文件信息和该第二电子设备中第一目录下的本地文件的文件信息。In a thirteenth aspect, an embodiment of the present application provides a first electronic device, where the first electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used for storing computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the first electronic device to execute: in response to a request to display a file in a first directory in the distributed file system, according to The bloom filter bit array of the first electronic device and the bloom filter bit array of the second electronic device determine whether the first directory in the first electronic device and the first directory in the second electronic device are different A file with the same name exists; when it is determined that a file with the same name does not exist, the first electronic device displays the file information under the first directory in the distributed file system, and the file information under the first directory includes the first directory in the first electronic device. The file information of the local file under the second electronic device and the file information of the local file under the first directory in the second electronic device.
在上述实施例中,根据各电子设备的布隆过滤器位数组对分布式文件系统中多个电子设备中同目录下存在同名文件的可能性进行整体判断,再根据整体判断的结果进行后续处理。由于各电子设备中同目录下存在同名文件的情况并不是非常多,因此,在大多数情况下都能直接通过该整体判断快速得到两个目录之间没有同名文件的识别结果。即使整体判断出有些目录间可能有同名文件,不能直接得到最终识别结果,也能显著的缩小进行同名文件识别的范围。极大的降低了进行同名文件识别时的处理时长,减少了进行同名文件识别时消耗的资源。In the above embodiment, an overall judgment is made on the possibility that a file with the same name exists in the same directory in multiple electronic devices in the distributed file system according to the Bloom filter bit array of each electronic device, and then follow-up processing is carried out according to the result of the overall judgment . Since there are not very many files with the same name in the same directory in each electronic device, in most cases, the identification result that there is no file with the same name between the two directories can be quickly obtained directly through the overall judgment. Even if it is judged as a whole that some directories may have files with the same name, the final recognition result cannot be directly obtained, and the scope of file recognition with the same name can be significantly narrowed. This greatly reduces the processing time when identifying files with the same name, and reduces the resources consumed when identifying files with the same name.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下可能存在同名文件时,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下是否存在同名文件;当确定存在同名文件时,对同名文件重命名,直到该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when it is determined that the first electronic device in the first electronic device When a file with the same name may exist under the directory and under the first directory in the second electronic device, determine whether there is a file with the same name under the first directory in the first electronic device and under the first directory in the second electronic device; when it is determined that there is a file with the same name When the file is created, the file with the same name is renamed until the file with the same name does not exist in the first directory in the first electronic device and in the first directory in the second electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:将该第一电子设备中第一目录下每个本地文件的文件名,分别与该第二电子设备中第一目录下每个文件的文件名比较,确定是否存在同名文件。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: the first directory in the first electronic device The file name of each local file in the second electronic device is compared with the file name of each file in the first directory in the second electronic device to determine whether there is a file with the same name.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:根据该第一电子设备的布隆过滤器位数组,分别确定第二电子设备中第一目录下的每个文件是否在第一电子设备中第一目录下可能存在同名文件;当确定第二电子设备中第一目录下的一个文件在第一电子设备中第一目录下可能存在同名文件时,将该文件与该第一电子设备中第一目录下每个文件的文件名分别比较,确定是否存在同名文件。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to perform: Bloom filtering according to the first electronic device bit array, respectively determine whether each file in the first directory in the second electronic device may have a file with the same name in the first directory in the first electronic device; when it is determined that a file in the first directory in the second electronic device is in When a file with the same name may exist in the first directory in the first electronic device, the file is compared with the file name of each file in the first directory in the first electronic device to determine whether there is a file with the same name.
结合第十三方面的一些实施例,在一些实施例中,该文件信息包括:文件名和/或文件图标。With reference to some embodiments of the thirteenth aspect, in some embodiments, the file information includes: a file name and/or a file icon.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:根据该第一电子设备中第一目录下本地文件的文件名,计算第一电子设备的布隆过滤器位数组;获取第二电子设备的布隆过滤器位数组;该第二电子设备的布隆过滤器位数组是根据该第二电子设备中第一目录下本地文件的文件名计算得到。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: according to the first directory in the first electronic device Under the file name of the local file, calculate the bloom filter bit array of the first electronic device; obtain the bloom filter bit array of the second electronic device; the bloom filter bit array of the second electronic device is based on the second electronic device. The file name of the local file in the first directory in the electronic device is calculated and obtained.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:向该第二电子设备发送获取该第二电子设备的布隆过滤器位数组的请求,其中携带有第一目录的标识;接收该第二电子设备发送的该第二电子设备的布隆过滤器位数组。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: send to the second electronic device to obtain the first electronic device. The request for the bloom filter bit array of the second electronic device, which carries the identifier of the first directory; and the bloom filter bit array of the second electronic device sent by the second electronic device is received.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:获取该第二电子设备中第一目录下本地文件的文件名;根据该第二电子设备中第一目录下本地文件的文件名,计算得到该第二电子设备的布隆过滤器位数组。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: obtain a first directory in the second electronic device The file name of the local file in the second electronic device; according to the file name of the local file in the first directory in the second electronic device, the Bloom filter bit array of the second electronic device is obtained by calculation.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:向该第二电子设备发送获取该第二电子设备中第一目录下本地文件的文件名的请求;接收该第二电子设备发送的第二电子设备中第一目录下本地文件的文件名。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: send to the second electronic device to obtain the first electronic device. 2. A request for the file name of the local file in the first directory in the electronic device; and receiving the file name of the local file in the first directory in the second electronic device sent by the second electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:根据存储的第二电子设备中第一目录下本地文件的元数据信息,获取到该第二电子设备中第一目录下本地文件的文件名。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: according to the stored first in the second electronic device The metadata information of the local file in the directory is obtained, and the file name of the local file in the first directory in the second electronic device is obtained.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:使用第一电子设备的布隆过滤器中的K个哈希函数,计算该第一电子设备中第一目录下每个本地文件的文件名的哈希值;将该每个本地文件的文件名的哈希值映射到该第一电子设备的布隆过滤器中包含有的N个位数的位数组中,得到该第一电子设备的布隆过滤器位数组;其中K为正整数,N为大于K的正整数。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: use a Bloom filter of the first electronic device K hash functions in the first electronic device, calculate the hash value of the file name of each local file under the first directory in the first electronic device; map the hash value of the file name of each local file to the first electronic device From the bit array of N digits included in the bloom filter of the device, the bloom filter bit array of the first electronic device is obtained; wherein K is a positive integer, and N is a positive integer greater than K.
结合第十三方面的一些实施例,在一些实施例中,该第二电子设备的布隆过滤器位数组是根据第二电子设备的布隆过滤器中的该K个哈希函数,计算该第二电子设备中第一目录下每个本地文件的文件名的哈希值,将该每个本地文件的文件名的哈希值映射到该第二电子设备的布隆过滤器中包含有的N个位数的位数组中得到的。With reference to some embodiments of the thirteenth aspect, in some embodiments, the bloom filter bit array of the second electronic device is calculated according to the K hash functions in the bloom filter of the second electronic device. The hash value of the file name of each local file in the first directory in the second electronic device, and the hash value of the file name of each local file is mapped to the hash value included in the Bloom filter of the second electronic device obtained from a bit array of N digits.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:确定该第一电子设备的布隆过滤器位数组和该第二电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K,该K为该第一电子设备的布隆过滤器和该第二电子设备的布隆过滤器中哈希函数的数目;当确定小于该K时,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件;当确定不小于该K时,确定该第一电子设备中第一目录下和该第二电子设备中第一目录下可能存在同名文件。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to perform: determine Bloom filtering of the first electronic device Whether the number of bits that are 1 at the same position in the filter bit array and the bloom filter bit array of the second electronic device at the same time is less than K, where K is the bloom filter of the first electronic device and the cloth of the second electronic device. The number of hash functions in the rumble filter; when it is determined that it is less than the K, it is determined that there is no file with the same name in the first directory in the first electronic device and in the first directory in the second electronic device; when it is determined that it is not less than the K When it is determined that a file with the same name may exist in the first directory in the first electronic device and in the first directory in the second electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:获取第三电子设备的布隆过滤器位数组;该第三电子设备的布隆过滤器位数组是根据该第三电子设备中第一目录下本地文件的文件名计算得 到。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: acquiring a Bloom filter of the third electronic device Bit array; the Bloom filter bit array of the third electronic device is calculated according to the file name of the local file in the first directory in the third electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:根据该第一电子设备的布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第一电子设备中第一目录下和该第三电子设备中第一目录下是否可能存在同名文件;根据该第二电子设备的布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第二电子设备中第一目录下和该第三电子设备中第一目录下是否可能存在同名文件;该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件,且该第一电子设备中第一目录下和该第三电子设备中第一目录下不存在同名文件,且该第二电子设备中第一目录下和该第三电子设备中第一目录下不存在同名文件时,显示分布式文件系统中该第一目录下的文件信息;其中包括该第一电子设备中第一目录下的本地文件的文件信息、该第二电子设备中第一目录下的本地文件的文件信息和该第三电子设备中第一目录下的本地文件的文件信息。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to perform: Bloom filtering according to the first electronic device The device bit array and the Bloom filter bit array of the third electronic device are used to determine whether a file with the same name may exist in the first directory in the first electronic device and in the first directory in the third electronic device; according to the second electronic device The Bloom filter bit array of the device and the Bloom filter bit array of the third electronic device determine whether a file with the same name may exist in the first directory in the second electronic device and in the first directory in the third electronic device; The one or more processors are specifically configured to invoke the computer instruction to cause the first electronic device to execute: when it is determined that the first directory in the first electronic device and the first directory in the second electronic device do not have the same name file, and there is no file with the same name in the first directory in the first electronic device and in the first directory in the third electronic device, and the first directory in the second electronic device and the third electronic device in the first directory When the file with the same name does not exist under the same name, the file information under the first directory in the distributed file system is displayed; which includes the file information of the local file under the first directory in the first electronic device, the first directory in the second electronic device. The file information of the local file under the third electronic device and the file information of the local file under the first directory in the third electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件时,对该第一电子设备的布隆过滤器位数组和该第二电子设备的布隆过滤器位数组进行逻辑或操作,得到逻辑或布隆过滤器位数组;根据该逻辑或布隆过滤器位数组和该第三电子设备的布隆过滤器位数组,确定该第一电子设备和该第二电子设备中是否至少有一个的第一目录下与该第三电子设备的第一目录下可能存在同名文件;该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:当确定该第一电子设备中第一目录下和该第二电子设备中第一目录下不存在同名文件,且确定该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件时,显示分布式文件系统中该第一目录下的文件信息;其中包括该第一电子设备中第一目录下的本地文件的文件信息、该第二电子设备中第一目录下的本地文件的文件信息和该第三电子设备中第一目录下的本地文件的文件信息。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when it is determined that the first electronic device in the first electronic device When the file with the same name does not exist under the directory and the first directory in the second electronic device, perform a logical OR operation on the Bloom filter bit array of the first electronic device and the Bloom filter bit array of the second electronic device, Obtaining a logical OR bloom filter bit array; according to the logical OR bloom filter bit array and the bloom filter bit array of the third electronic device, determine whether the first electronic device and the second electronic device have at least one A file with the same name may exist under the first directory of the third electronic device and the first directory of the third electronic device; the one or more processors are specifically used to invoke the computer instruction to cause the first electronic device to execute: when the first electronic device is determined to There is no file with the same name in the first directory in an electronic device and in the first directory in the second electronic device, and it is determined that there is no file with the third electronic device in the first directory in the first electronic device and the second electronic device. When there is a file with the same name in the first directory of the distributed file system, the file information under the first directory in the distributed file system is displayed; including the file information of the local file in the first directory in the first electronic device, the file information in the second electronic device The file information of the local file under the first directory and the file information of the local file under the first directory in the third electronic device.
结合第十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:确定该逻辑或布隆过滤器位数组和该第三电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K,该K为该第一电子设备的布隆过滤器、该第二电子设备的布隆过滤器和该第三电子设备的布隆过滤器中哈希函数的数目;当确定小于该K时,确定该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件;当确定不小于该K时,确定该第一电子设备和该第二电子设备中至少有一个的第一目录下可能与该第三电子设备的第一目录下存在同名文件,确定并重命名其中的同名文件,直到该第一电子设备和该第二电子设备中第一目录下没有一个与该第三电子设备的第一目录下存在同名文件。With reference to some embodiments of the thirteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: determine the logical or bloom filter bit array Whether the number of digits that are at the same position as 1 in the bloom filter bit array of the third electronic device is less than K, where K is the bloom filter of the first electronic device and the bloom filter of the second electronic device and the number of hash functions in the Bloom filter of the third electronic device; when it is determined to be less than the K, it is determined that none of the first electronic device and the second electronic device under the first directory is related to the third electronic device There is a file with the same name in the first directory of If a file with the same name exists, determine and rename the file with the same name, until there is no file with the same name in the first directory of the first electronic device and the second electronic device and a file with the same name in the first directory of the third electronic device.
第十四方面,本申请实施例提供了一种芯片系统,该芯片系统应用于第一电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该第一电子设备执行如第十二方面以及第十二方面中任一可能的实现方式描述的方法。In a fourteenth aspect, an embodiment of the present application provides a chip system, the chip system is applied to a first electronic device, the chip system includes one or more processors, and the processors are configured to invoke computer instructions to make the first electronic device The device performs the method described in the twelfth aspect and any possible implementation manner of the twelfth aspect.
第十五方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在第一电子设备上运行时,使得上述第一电子设备执行如第十二方面以及第十二方面中任一可能的实现方式描述的方法。A fifteenth aspect, an embodiment of the present application provides a computer program product including instructions, when the computer program product is executed on a first electronic device, the first electronic device is made to perform the twelfth and twelfth aspects The method described in any of the possible implementations.
第十六方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在第一电子设备上运行时,使得上述第一电子设备执行如第十二方面以及第十二方面中任一可能的实现方式描述的方法。In a sixteenth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, when the above-mentioned instructions are executed on a first electronic device, the above-mentioned first electronic device is made to execute the twelfth aspect and the twelfth aspect The method described in any of the possible implementations.
可以理解地,上述第十三方面提供的第一电子设备、第十四方面提供的芯片系统、第十五方面提供的计算机程序产品和第十六方面提供的计算机存储介质均用于执行本申请实施例所提供的同名文件识别方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。It can be understood that the first electronic device provided in the thirteenth aspect, the chip system provided in the fourteenth aspect, the computer program product provided in the fifteenth aspect, and the computer storage medium provided in the sixteenth aspect are all used to execute the present application. The method for identifying files with the same name provided by the embodiment. Therefore, for the beneficial effects that can be achieved, reference may be made to the beneficial effects in the corresponding method, which will not be repeated here.
本申请实施例还提供了一种数据预读方法和电子设备,用于提升分布式文件系统中电子设备的预读性能。Embodiments of the present application further provide a data pre-reading method and electronic device, which are used to improve the pre-reading performance of the electronic device in the distributed file system.
第十七方面,本申请提供了一种数据预读方法,包括:第一电子设备从第二电子设备上获取第一文件中第一数值的文件页,在该文件页中的第N个文件页中设置预读标志位;该N由第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备类型确定;该第一应用为该第一电子设备中访问该第二电子设备上第一文件的应用;当该第一应用访问到设置该预读标志位的文件页时,该第一电子设备从该第二电子设备上获取第一文件中第二数值的文件页;该第二数值由该第一电子设备与该第二电子设备之间的网络延迟和网络带宽确定。In a seventeenth aspect, the present application provides a data pre-reading method, comprising: a first electronic device acquiring a file page of a first value in a first file from a second electronic device, and the Nth file in the file page is The pre-reading flag is set in the page; the N is determined by the file type of the first file, and/or the application type of the first application, and/or the device type of the second electronic device; the first application is the first electronic device an application that accesses the first file on the second electronic device; when the first application accesses the file page where the pre-read flag is set, the first electronic device obtains the first file from the second electronic device A two-valued file page; the second value is determined by the network delay and network bandwidth between the first electronic device and the second electronic device.
本申请实施例中,第一电子设备可以根据网络环境适应性的确定预读窗口大小,根据需要访问的第一文件的文件类型、和/或访问第一文件的第一应用的应用类型和/或第二电子设备的设备类型,适应性的设置不同数目和位置的预读标志位,可以使得第一电子设备更大可能的在访问完已读取的数据之前接收到从第二电子设备读取的新的数据,且不需要存储过多的预读数据,在极大的提升了分布式文件系统中电子设备的预读性能的同时,消耗了较少的网络和存储资源。In this embodiment of the present application, the first electronic device may adaptively determine the size of the pre-reading window according to the network environment, according to the file type of the first file to be accessed, and/or the application type of the first application accessing the first file and/or Or the device type of the second electronic device, adaptively setting different numbers and positions of pre-read flags, can make the first electronic device more likely to receive read data from the second electronic device before accessing the read data. The new data is retrieved, and there is no need to store too much pre-reading data, which greatly improves the pre-reading performance of electronic devices in the distributed file system and consumes less network and storage resources.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备从该第二电子设备上获取第一文件中第二数值的文件页的步骤之前,该方法还包括:该第一电子设备监测与该第二电子设备间的网络往返延迟;该第一电子设备确定与该第二电子设备间的网络带宽;该第一电子设备根据与该第二电子设备之间的网络往返延迟和网络带宽,确定当前预读窗口大小为该第二数值。With reference to some embodiments of the seventeenth aspect, in some embodiments, before the first electronic device acquires the file page of the second value in the first file from the second electronic device, the method further includes: the first electronic device. An electronic device monitors the network round-trip delay with the second electronic device; the first electronic device determines the network bandwidth with the second electronic device; the first electronic device determines the network round-trip delay with the second electronic device Delay and network bandwidth, determine the current pre-reading window size as the second value.
上述实施例中,第一电子设备可以根据与第二电子设备之间的网络往返延迟和网络带宽,动态的确定当前预读窗口大小,提升了分布式文件系统中电子设备的预读性能。In the above embodiment, the first electronic device can dynamically determine the current pre-reading window size according to the network round-trip delay and network bandwidth with the second electronic device, which improves the pre-reading performance of the electronic device in the distributed file system.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备根据与该第二电子设备之间的网络往返延迟和网络带宽,确定预读窗口大小为该第二数值,具体包括:该第一电子设备将网络往返延迟与网络带宽的乘积,再除以一个内存页大小得到的值,作为该第二数值。With reference to some embodiments of the seventeenth aspect, in some embodiments, the first electronic device determines the pre-reading window size to be the second value according to the network round-trip delay and network bandwidth between the first electronic device and the second electronic device, specifically The method includes: the first electronic device uses the product of the network round-trip delay and the network bandwidth, and then divides the value obtained by the size of a memory page as the second value.
上述实施例中,预读窗口的大小与内存页大小相关,使得计算出的预读窗口大小更符合实际需求。In the above embodiment, the size of the pre-reading window is related to the size of the memory page, so that the calculated pre-reading window size is more in line with actual requirements.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备确定与该第二电子设备间的网络带宽,具体包括:该第一电子设备根据该第一电子设备接收到的网络信号强度和/或该第一电子设备使用的网络频段,估算出与该第二电子设备间的网络带宽。With reference to some embodiments of the seventeenth aspect, in some embodiments, determining the network bandwidth between the first electronic device and the second electronic device specifically includes: the first electronic device according to the data received by the first electronic device. The network bandwidth with the second electronic device is estimated from the network signal strength and/or the network frequency band used by the first electronic device.
上述实施例中,在无法直接获取到与该第二电子设备间的网络带宽时,可以估算出该第二电子设备间的网络带宽,从而实时计算出预读窗口大小,提高了计算预读窗口大小过程对不同网络环境的适应性。In the above embodiment, when the network bandwidth with the second electronic device cannot be directly obtained, the network bandwidth between the second electronic device can be estimated, thereby calculating the size of the pre-reading window in real time, and improving the calculation of the pre-reading window. The adaptability of large and small processes to different network environments.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备监测与该第二电子设备间的网络往返延迟,具体包括:该第一电子设备实时获取与该第二电子设备之间的TCP链接的往返时延RTT参数值,作为与该第二电子设备间的网络往返延迟。With reference to some embodiments of the seventeenth aspect, in some embodiments, monitoring the network round-trip delay between the first electronic device and the second electronic device specifically includes: the first electronic device obtains a real-time connection between the first electronic device and the second electronic device The round-trip delay RTT parameter value of the TCP link between the two is used as the network round-trip delay with the second electronic device.
上述实施例中,将TCP链接的RTT参数值作为与该第二电子设备间的网络往返延迟,提升了获取网络往返延迟的效率。In the above embodiment, the RTT parameter value of the TCP link is used as the network round-trip delay with the second electronic device, which improves the efficiency of obtaining the network round-trip delay.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备从第二电子设备上获取第一文件中第一数值的文件页,在该文件页中的第N个文件页中设置预读标志位,具体包括:该第一电子设备从第二电子设备上获取第一文件中第一数值的文件页;该第一电子设备确定该第一文件的文件类型是否为视频文件;当确定该第一文件的文件类型为视频文件时,该第一电子设备在该第一数值的文件页中的多个文件页中设置预读标志位。With reference to some embodiments of the seventeenth aspect, in some embodiments, the first electronic device acquires, from the second electronic device, the file page of the first value in the first file, the Nth file page in the file page Setting the pre-reading flag bit in , specifically includes: the first electronic device obtains the file page of the first value in the first file from the second electronic device; the first electronic device determines whether the file type of the first file is a video file ; When it is determined that the file type of the first file is a video file, the first electronic device sets a pre-reading flag in a plurality of file pages in the file pages of the first value.
上述实施例中,在第一文件的文件类型为视频文件时,在预读的文件页中的多个文件页中设置预读标志位,这样即使用户跳看视频,也不会跳过在该多个文件页中设置的预读标志位,使得第一电子设备在访问其他电子设备中的视频文件时更加流畅。In the above embodiment, when the file type of the first file is a video file, the pre-reading flag is set in a plurality of file pages in the pre-reading file page, so that even if the user skips the video, it will not be skipped in the pre-reading file page. The pre-reading flag bits set in the multiple file pages make the first electronic device more fluent when accessing video files in other electronic devices.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备确定该第一文件的文件类型是否为视频文件,具体包括:该第一电子设备确定该第一文件的扩展名是否为视频文件的扩展名;当确定该第一文件的扩展名为视频文件的扩展名时,该第一电子设备确定该第一文件的文件类型为视频文件;当确定该第一文件的扩展名不是视频文件的扩展名时,该第一电子设备确定该第一文件的文件类型不是视频文件。With reference to some embodiments of the seventeenth aspect, in some embodiments, the first electronic device determining whether the file type of the first file is a video file specifically includes: the first electronic device determining the extension of the first file Whether it is the extension of the video file; when determining that the extension of the first file is the extension of the video file, the first electronic device determines that the file type of the first file is a video file; when determining the extension of the first file When the name is not the extension of the video file, the first electronic device determines that the file type of the first file is not a video file.
上述实施例中,通过文件的扩展名确定文件的文件类型,提高了电子设备确定文件的文件类型的效率。In the above embodiment, the file type of the file is determined by the extension of the file, which improves the efficiency of the electronic device in determining the file type of the file.
结合第十七方面的一些实施例,在一些实施例中,该方法还包括:当确定该第一文件的文件类型不是视频文件时,该第一电子设备确定该第一应用的应用类型是否为前台应用;当确定该第一应用的应用类型不是前台应用时,该第一电子设备在该第一数值的文件页中的第N1个文件页中设置预读标志位;该第N1个文件页在该第一数值的文件页中的位置为第一位置,该N1大于该第一数值的1/2。With reference to some embodiments of the seventeenth aspect, in some embodiments, the method further includes: when it is determined that the file type of the first file is not a video file, the first electronic device determines whether the application type of the first application is A foreground application; when it is determined that the application type of the first application is not a foreground application, the first electronic device sets a pre-reading flag in the N1 th file page in the file page of the first value; the N1 th file page The position in the file page of the first value is the first position, and the N1 is greater than 1/2 of the first value.
上述实施例中,在第一文件的文件类型不是视频文件,且访问该第一文件的第一应用不是前台应用时,可以将预读标志位设置在读取的第一数值的文件页中的后半部分的文件页中,可以较晚的触发进行下一次预读,降低非必要应用对网络资源的占用。In the above embodiment, when the file type of the first file is not a video file, and the first application accessing the first file is not a foreground application, the pre-reading flag bit can be set in the file page of the read first value. In the second half of the file page, the next pre-reading can be triggered later to reduce the occupation of network resources by non-essential applications.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备确定该第一应用的应用类型是否为前台应用,具体包括:该第一电子设备确定该第一应用的进程中是否包含前台应用标识;当确定该第一应用的进程中包含该前台应用标识时,该第一电子设备确定该第一应用的应用类型为前台应用;当确定该第一应用的进程中不包含该前台应用标识时,该第一电子设备确定该第一应用的应用类型不是前台应用。With reference to some embodiments of the seventeenth aspect, in some embodiments, determining by the first electronic device whether the application type of the first application is a foreground application specifically includes: determining, by the first electronic device, that the first application is in the process of Whether the foreground application identifier is included; when it is determined that the foreground application identifier is included in the process of the first application, the first electronic device determines that the application type of the first application is a foreground application; when it is determined that the process of the first application does not include the foreground application identifier When the foreground application is identified, the first electronic device determines that the application type of the first application is not a foreground application.
上述实施例中,可以通过第一应用的进程中是否包含前台应用标识来快速确定第一应用的应用类型,提高了确定第一应用的应用类型的效率。In the above embodiment, the application type of the first application can be quickly determined by whether the process of the first application contains the foreground application identifier, which improves the efficiency of determining the application type of the first application.
结合第十七方面的一些实施例,在一些实施例中,该方法还包括:当确定该第一应用的应用类型是前台应用时,该第一电子设备确定该第二电子设备的设备类型是否为第一能力设备;该第一能力设备为能力超出预设能力值的电子设备;当确定该第一电子设备的设备类型是第一能力设备时,该第一电子设备在该第一数值的文件页中的第N2个文件页中设置预读标志位;该第N2个文件页在该第一数值的文件页中的位置为第二位置,该第二位置在该第一位置之前;当确定该第一电子设备的设备类型不是第一能力设备时,该第一电子设备在该第一数值的文件页中的第N3个文件页中设置预读标志位;该第N3个文件页在该第一数值的文件页中的位置为第三位置,该第三位置在该第二位置之前,该N3小于该第一数值的1/2。With reference to some embodiments of the seventeenth aspect, in some embodiments, the method further includes: when it is determined that the application type of the first application is a foreground application, the first electronic device determines whether the device type of the second electronic device is is the first capability device; the first capability device is an electronic device whose capability exceeds the preset capability value; when it is determined that the device type of the first electronic device is the first capability device, the first electronic device is within the range of the first value. The pre-reading flag is set in the N2th file page in the file page; the position of the N2th file page in the file page of the first value is the second position, and the second position is before the first position; when When it is determined that the device type of the first electronic device is not the first capability device, the first electronic device sets the pre-read flag bit in the N3 th file page in the file pages of the first value; the N3 th file page is in the The position in the file page of the first value is a third position, the third position is before the second position, and the N3 is less than 1/2 of the first value.
上述实施例中,当访问第一文件的第一应用的应用类型是前台应用,且第一电子设备的设备类型不是第一能力设备时,可以将预读标志位设置在读取的第一数值的文件页中的前半部分的文件页中,使得能更早的触发下一次数据预读,以保障前台应用对数据访问的及时性。In the above embodiment, when the application type of the first application accessing the first file is a foreground application, and the device type of the first electronic device is not the first capability device, the pre-reading flag bit can be set at the read first value. In the first half of the file page, the next data pre-reading can be triggered earlier to ensure the timeliness of data access by the foreground application.
结合第十七方面的一些实施例,在一些实施例中,该预设能力值包括CPU的频率为第一预设频率,和/或内存大小为第一容量。With reference to some embodiments of the seventeenth aspect, in some embodiments, the preset capability value includes that the frequency of the CPU is the first preset frequency, and/or the memory size is the first capacity.
结合第十七方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备确定计算出预读窗口大小为该第二数值时的网络往返延迟与当前网络往返延迟的差值是否达到预设变化阈值;当确定达到预设变化阈值时,该第一电子设备根据该当前网络往返延迟和当前网络带宽,确定当前预读窗口大小为第三数值,该第三数值与该第二数值不同。With reference to some embodiments of the seventeenth aspect, in some embodiments, the method further includes: the first electronic device determines the difference between the network round-trip delay and the current network round-trip delay when the pre-reading window size is the second value. Whether the value reaches the preset change threshold; when it is determined that the preset change threshold is reached, the first electronic device determines the current pre-reading window size to be a third value according to the current network round-trip delay and the current network bandwidth, and the third value is the same as the The second value is different.
上述实施例中,如果网络往返延迟发送较大变化,第一电子设备可以实时更新预读窗口大小,使得即使网络环境剧烈变化,第一电子设备也能够流畅的访问第一文件。In the above embodiment, if the network round-trip delay is greatly changed, the first electronic device can update the pre-reading window size in real time, so that even if the network environment changes drastically, the first electronic device can smoothly access the first file.
结合第十七方面的一些实施例,在一些实施例中,该第一电子设备根据该当前网络往返延迟和当前网络带宽,确定当前预读窗口大小为第三数值的步骤之后,该方法还包括:当该第一应用访问到该第二数值的文件页中设置预读标志位的文件页时,该第一电子设备从该第二电子设备上获取第一文件中第三数值的文件页。With reference to some embodiments of the seventeenth aspect, in some embodiments, after the first electronic device determines that the current pre-reading window size is a third value according to the current network round-trip delay and the current network bandwidth, the method further includes : When the first application accesses the file page with the pre-read flag set in the file page of the second value, the first electronic device obtains the file page of the third value in the first file from the second electronic device.
第十八方面,本申请实施例提供了一种第一电子设备,该第一电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该第一电子设备执行:从第二电子设备上获取第一文件中第一数值的文件页,在该文件页中的第N个文件页中设置预读标志位;该N由第一文件的文件类型,和/或第一应用的应用类型,和 /或第二电子设备的设备类型确定;该第一应用为该第一电子设备中访问该第二电子设备上第一文件的应用;当该第一应用访问到设置该预读标志位的文件页时,从该第二电子设备上获取第一文件中第二数值的文件页;该第二数值由该第一电子设备与该第二电子设备之间的网络延迟和网络带宽确定。In an eighteenth aspect, an embodiment of the present application provides a first electronic device, where the first electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used for Stores computer program code, the computer program code including computer instructions that the one or more processors invoke to cause the first electronic device to perform: obtain a file page of the first value in the first file from the second electronic device , set the read-ahead flag in the Nth file page in the file page; the N is determined by the file type of the first file, and/or the application type of the first application, and/or the device type of the second electronic device ; This first application is the application that accesses the first file on the second electronic device in the first electronic device; When the first application accesses the file page that sets the pre-reading flag bit, from the second electronic device A file page of a second value in the first file is obtained; the second value is determined by the network delay and network bandwidth between the first electronic device and the second electronic device.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:监测与该第二电子设备间的网络往返延迟;确定与该第二电子设备间的网络带宽;根据与该第二电子设备之间的网络往返延迟和网络带宽,确定当前预读窗口大小为该第二数值。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to perform: monitor the network with the second electronic device round-trip delay; determine the network bandwidth with the second electronic device; determine the current pre-reading window size as the second value according to the network round-trip delay and network bandwidth with the second electronic device.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:将网络往返延迟与网络带宽的乘积,再除以一个内存页大小得到的值,作为该第二数值。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to perform: multiply the network round-trip delay by the network bandwidth, The value obtained by dividing by a memory page size is used as the second value.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:根据该第一电子设备接收到的网络信号强度和/或该第一电子设备使用的网络频段,估算出与该第二电子设备间的网络带宽。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: according to the network received by the first electronic device The signal strength and/or the network frequency band used by the first electronic device is used to estimate the network bandwidth with the second electronic device.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:实时获取与该第二电子设备之间的TCP链接的往返时延RTT参数值,作为与该第二电子设备间的网络往返延迟。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: real-time acquisition between the computer and the second electronic device The round-trip delay RTT parameter value of the TCP link is used as the network round-trip delay with the second electronic device.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:从第二电子设备上获取第一文件中第一数值的文件页;确定该第一文件的文件类型是否为视频文件;当确定该第一文件的文件类型为视频文件时,在该第一数值的文件页中的多个文件页中设置预读标志位。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: obtain the first file from the second electronic device The file page of the first numerical value in the file; determine whether the file type of the first file is a video file; when it is determined that the file type of the first file is a video file, in the multiple file pages in the file page of the first numerical value Set the read-ahead flag.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:确定该第一文件的扩展名是否为视频文件的扩展名;当确定该第一文件的扩展名为视频文件的扩展名时,确定该第一文件的文件类型为视频文件;当确定该第一文件的扩展名不是视频文件的扩展名时,确定该第一文件的文件类型不是视频文件。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instruction to cause the first electronic device to execute: determine whether the extension of the first file is The extension of the video file; When determining that the extension of the first file is the extension of the video file, determine that the file type of the first file is a video file; When determining that the extension of the first file is not the extension of the video file When it is determined that the file type of the first file is not a video file.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当确定该第一文件的文件类型不是视频文件时,确定该第一应用的应用类型是否为前台应用;当确定该第一应用的应用类型不是前台应用时,在该第一数值的文件页中的第N1个文件页中设置预读标志位;该第N1个文件页在该第一数值的文件页中的位置为第一位置,该N1大于该第一数值的1/2。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when it is determined that the file type of the first file is not When it is a video file, determine whether the application type of the first application is a foreground application; when it is determined that the application type of the first application is not a foreground application, set pre-reading in the N1th file page in the file page of the first value Flag bit; the position of the N1 th file page in the file page of the first numerical value is the first position, and the N1 is greater than 1/2 of the first numerical value.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:确定该第一应用的进程中是否包含前台应用标识;当确定该第一应用的进程中包含该前台应用标识时,确定该第一应用的应用类型为前台应用;当确定该第一应用的进程中不包含该前台应用标识时,确定该第一应用的应用类型不是前台应用。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: determine whether the process of the first application includes The foreground application identifier; when it is determined that the process of the first application contains the foreground application identifier, it is determined that the application type of the first application is a foreground application; when it is determined that the process of the first application does not contain the foreground application identifier, it is determined The application type of the first application is not a foreground application.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当确定该第一应用的应用类型是前台应用时,确定该第二电子设备的设备类型是否为第一能力设备;该第一能力设备为能力超出预设能力值的电子设备;当确定该第一电子设备的设备类型是第一能力设备时,在该第一数值的文件页中的第N2个文件页中设置预读标志位;该第N2个文件页在该第一数值的文件页中的位置为第 二位置,该第二位置在该第一位置之前;当确定该第一电子设备的设备类型不是第一能力设备时,在该第一数值的文件页中的第N3个文件页中设置预读标志位;该第N3个文件页在该第一数值的文件页中的位置为第三位置,该第三位置在该第二位置之前,该N3小于该第一数值的1/2。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when it is determined that the application type of the first application is In the foreground application, it is determined whether the device type of the second electronic device is the first capability device; the first capability device is an electronic device whose capability exceeds the preset capability value; when it is determined that the device type of the first electronic device is the first capability device, set the pre-reading flag bit in the N2th file page in the file page of the first value; the position of the N2th file page in the file page of the first value is the second position, the second The position is before the first position; when it is determined that the device type of the first electronic device is not the first capability device, the pre-reading flag is set in the N3 th file page in the file page of the first value; the N3 th file page is set. The position of each file page in the file page of the first value is a third position, the third position is before the second position, and the N3 is less than 1/2 of the first value.
结合第十八方面的一些实施例,在一些实施例中,该预设能力值包括CPU的频率为第一预设频率,和/或内存大小为第一容量。With reference to some embodiments of the eighteenth aspect, in some embodiments, the preset capability value includes that the frequency of the CPU is the first preset frequency, and/or the memory size is the first capacity.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:确定计算出预读窗口大小为该第二数值时的网络往返延迟与当前网络往返延迟的差值是否达到预设变化阈值;当确定达到预设变化阈值时,根据该当前网络往返延迟和当前网络带宽,确定当前预读窗口大小为第三数值,该第三数值与该第二数值不同。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instruction to cause the first electronic device to execute: determine and calculate the pre-reading window size as the first Whether the difference between the network round-trip delay at the binary value and the current network round-trip delay reaches the preset change threshold; when it is determined that the preset change threshold is reached, according to the current network round-trip delay and the current network bandwidth, determine the current pre-reading window size as the first Three numerical values, the third numerical value is different from the second numerical value.
结合第十八方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:当该第一应用访问到该第二数值的文件页中设置预读标志位的文件页时,从该第二电子设备上获取第一文件中第三数值的文件页。With reference to some embodiments of the eighteenth aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: when the first application accesses the second When the file page with the pre-reading flag is set in the file page of the numerical value, the file page of the third numerical value in the first file is obtained from the second electronic device.
第十九方面,本申请实施例提供了一种芯片系统,该芯片系统应用于第一电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该第一电子设备执行如第十七方面以及第十七方面中任一可能的实现方式描述的方法。In a nineteenth aspect, an embodiment of the present application provides a chip system, where the chip system is applied to a first electronic device, the chip system includes one or more processors, and the processors are configured to invoke computer instructions to make the first electronic device The device performs the method as described in the seventeenth aspect and any possible implementation manner of the seventeenth aspect.
第二十方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在第一电子设备上运行时,使得上述第一电子设备执行如第十七方面以及第十七方面中任一可能的实现方式描述的方法。In a twentieth aspect, an embodiment of the present application provides a computer program product containing instructions, when the computer program product is run on a first electronic device, the first electronic device is made to perform the seventeenth and seventeenth aspects The method described in any of the possible implementations.
第二十一方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在第一电子设备上运行时,使得上述第一电子设备执行如第十七方面以及第十七方面中任一可能的实现方式描述的方法。In a twenty-first aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, when the above-mentioned instructions are executed on a first electronic device, the above-mentioned first electronic device is made to perform the operations of the seventeenth aspect and the seventeenth aspect A method described in any possible implementation of the aspect.
可以理解地,上述第十八方面提供的第一电子设备、第十九方面提供的芯片系统、第二十方面提供的计算机程序产品和第二十一方面提供的计算机存储介质均用于执行本申请实施例所提供的数据预读方法方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。It can be understood that the first electronic device provided in the eighteenth aspect, the chip system provided in the nineteenth aspect, the computer program product provided in the twentieth aspect, and the computer storage medium provided in the twenty-first aspect are all used to execute the present invention. The data pre-reading method provided by the application embodiment is provided. Therefore, for the beneficial effects that can be achieved, reference may be made to the beneficial effects in the corresponding method, which will not be repeated here.
本申请实施例还提供了保持数据一致性的方法和电子设备,用于在分布式文件系统中保持数据一致性时,提升数据访问的速度,减少网络资源的消耗。The embodiments of the present application also provide a method and an electronic device for maintaining data consistency, which are used to improve the speed of data access and reduce the consumption of network resources when maintaining data consistency in a distributed file system.
第二十二方面,本申请提供了一种保持数据一致性的方法,包括:第一电子设备接收第二电子设备发送的将该第一电子设备中第一文件的第一数据修改为第二数据的请求;该第一数据为该第一文件的N个内存页大小的数据中偏移量为X的数据,该N和该X为正整数,该X不大于该N;该第一电子设备将本地内存中第一文件的基数树中的该第一数据修改为该第二数据;该第一电子设备将本地非易失性存储器中存储的第一文件中的该第一数据修改为该第二数据。In a twenty-second aspect, the present application provides a method for maintaining data consistency, comprising: a first electronic device receiving a message sent by a second electronic device and modifying the first data of the first file in the first electronic device to the second A request for data; the first data is the data with an offset of X in the data of the size of N memory pages of the first file, the N and the X are positive integers, and the X is not greater than the N; the first electronic The device modifies the first data in the radix tree of the first file in the local memory to the second data; the first electronic device modifies the first data in the first file stored in the local non-volatile memory to the second data.
可以理解的是,该第一文件存储在第一电子设备的本地非易失性存储器中。第二电子设备通过分布式文件系统读取该第一电子设备中存储的该第一文件时,第一电子设备会将该第一文件缓存到自己的本地内存中生成第一文件的基数树。第二电子设备读取到该第一文件后,也会在第二电子设备自己的本地内存中生成该第一文件的基数树。当第二电子设备将自己的 本地内存中第一文件的基数树中的第一数据修改为第二数据后,会向第一电子设备发送将该第一电子设备中第一文件的第一数据修改为第二数据的请求,以保持分布式文件系统中的数据一致性。第一电子设备接收到该修改请求后,不需要将本地内存中第一文件的基数树全部删除或无效。只需要将其中内存页大小的第一数据修改为第二数据,然后,相应的将本地非易失性存储中存储的第一文件中的该第一数据修改为该第二数据即可。避免了各电子设备重新加载修改后的第一文件的基数树,使得在分布式文件系统中保持数据一致性时,数据访问的速度得到极大提升,减少了网络资源的消耗。It can be understood that the first file is stored in the local non-volatile memory of the first electronic device. When the second electronic device reads the first file stored in the first electronic device through the distributed file system, the first electronic device caches the first file in its own local memory to generate a radix tree of the first file. After the second electronic device reads the first file, it also generates a radix tree of the first file in its own local memory of the second electronic device. After the second electronic device modifies the first data in the radix tree of the first file in its local memory to the second data, it will send the first data of the first file in the first electronic device to the first electronic device A request for modification of the second data to maintain data consistency in the distributed file system. After receiving the modification request, the first electronic device does not need to delete or invalidate all the radix trees of the first file in the local memory. It is only necessary to modify the first data of the memory page size into the second data, and then correspondingly modify the first data in the first file stored in the local non-volatile storage to the second data. It avoids each electronic device from reloading the modified radix tree of the first file, so that when data consistency is maintained in the distributed file system, the speed of data access is greatly improved, and the consumption of network resources is reduced.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备将本地内存中第一文件的基数树中的该第一数据修改为该第二数据的步骤之后,该方法还包括:该第一电子设备确定第三电子设备还读取过该第一数据;该第一电子设备向该第三电子设备发送标记该第一数据无效的通知,使得该第三电子设备清除本地内存中第一文件的基数树上第一数据的缓存。With reference to some embodiments of the twenty-second aspect, in some embodiments, after the first electronic device modifies the first data in the radix tree of the first file in the local memory to the second data, the method It also includes: the first electronic device determines that the third electronic device has also read the first data; the first electronic device sends a notification marking the first data invalid to the third electronic device, so that the third electronic device clears A cache of the first data on the radix tree of the first file in local memory.
在上述实施例中,第一电子设备修改第一数据为第二数据后,还会确定分布式文件系统中是否有其他电子设备读取过该第一数据。当确定还有第三电子设备通过分布式文件系统读取过该第一数据时,可以向第三电子设备发送标记该第一数据无效的通知,使得该第三电子设备清除本地内存中第一文件的基数树上第一数据的缓存。这样第三电子设备仅仅需要无效该第一文件的基数树上的一个内存页,而不需要无效该第一文件的整个基数树,也不需要重新加载修改后的整个第一文件的基数树,极大的减少了网络资源的消耗。In the above embodiment, after the first electronic device modifies the first data to the second data, it also determines whether other electronic devices in the distributed file system have read the first data. When it is determined that there is still a third electronic device that has read the first data through the distributed file system, a notification marking the invalidation of the first data may be sent to the third electronic device, so that the third electronic device clears the first data in the local memory A cache of the first data on the file's radix tree. In this way, the third electronic device only needs to invalidate one memory page on the radix tree of the first file, but does not need to invalidate the entire radix tree of the first file, and does not need to reload the modified radix tree of the entire first file, Greatly reduces the consumption of network resources.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备确定第三电子设备还读取过该第一数据,具体包括:该第一电子设备根据本地数据读取记录,确定该第三电子设备还读取过该第一数据;该本地数据读取记录用于记录其他电子设备读取该第一电子设备中文件的数据的对应关系。With reference to some embodiments of the twenty-second aspect, in some embodiments, the first electronic device determines that the third electronic device has also read the first data, which specifically includes: the first electronic device reads records according to local data , it is determined that the third electronic device has also read the first data; the local data reading record is used to record the correspondence between other electronic devices reading the data of the file in the first electronic device.
在上述实施例中,第一电子设备可以根据本地数据读取记录确定分布式文件系统中还读取过该第一数据的电子设备,提升了确定过程的准确性。In the above embodiment, the first electronic device can determine the electronic device in the distributed file system that has also read the first data according to the local data reading record, which improves the accuracy of the determination process.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备向该第三电子设备发送标记该第一数据无效的通知的步骤之后,该方法还包括:该第一电子设备删除第三电子设备对第一数据的读取记录。With reference to some embodiments of the twenty-second aspect, in some embodiments, after the step of the first electronic device sending a notification marking the first data invalid to the third electronic device, the method further includes: the first electronic device The device deletes the read record of the first data by the third electronic device.
在上述实施例中,第一电子设备向第三电子设备发送标记第一数据无效的通知后,可以删除第三电子设备对第一数据的读取记录,保障了记录的其他电子设备对第一电子设备中文件的数据的读取记录的实时性。In the above-mentioned embodiment, after the first electronic device sends a notification that the first data is invalid to the third electronic device, the record of reading the first data by the third electronic device can be deleted, so as to ensure that other electronic devices recorded have no effect on the first data. The real-time performance of the reading record of the data of the file in the electronic device.
结合第二十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备修改本地内存中第二文件的基数树中的第三数据为第四数据;该第二文件为该第二电子设备中的文件;该第三数据为该第二文件的M个内存页大小的数据中偏移量为Y的数据,该M和该Y为正整数,该Y不大于该M;在预设延迟时长后,该第一电子设备向该第二电子设备发送将该第二电子设备中第二文件的第三数据修改为第四数据的请求。With reference to some embodiments of the twenty-second aspect, in some embodiments, the method further includes: the first electronic device modifies, by the first electronic device, the third data in the radix tree of the second file in the local memory to be fourth data; the second The file is the file in the second electronic device; the third data is the data whose offset is Y in the M memory page size data of the second file, the M and the Y are positive integers, and the Y is not greater than The M; after a preset delay time, the first electronic device sends a request to the second electronic device to modify the third data of the second file in the second electronic device to the fourth data.
在上述实施例中,第一电子设备修改从分布式文件系统读取的第二电子设备中第二文件的第三数据为第四数据后,可以向第二电子设备发送修改请求,请求将第二电子设备中的第三数据修改为第四数据,以保持分布式文件系统中的数据一致性。且只需要将第三数据修改为第四数据,而不需要删除整个第二文件后再重新加载,提升了分布式文件系统中保持数据一致性的效率,减少了网络资源的消耗。In the above embodiment, after the first electronic device modifies the third data of the second file in the second electronic device read from the distributed file system to the fourth data, it can send a modification request to the second electronic device, requesting The third data in the second electronic device is modified to the fourth data to maintain data consistency in the distributed file system. In addition, only the third data needs to be modified to the fourth data, and the entire second file does not need to be deleted and then reloaded, which improves the efficiency of maintaining data consistency in the distributed file system and reduces the consumption of network resources.
结合第二十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备接 收第二电子设备发送的标记第五数据无效的通知;该第五数据为第二电子设备中第三文件中的数据;该第一电子设备清除本地内存中第三文件的基数树上第五数据的缓存。With reference to some embodiments of the twenty-second aspect, in some embodiments, the method further includes: receiving, by the first electronic device, a notification sent by the second electronic device indicating that the fifth data is invalid; the fifth data is the second electronic device data in the third file in the device; the first electronic device clears the cache of the fifth data on the radix tree of the third file in the local memory.
在上述实施例中,第一电子设备通过分布式文件系统从第二电子设备读取第三文件中的数据,并将在本地内存中生成第三文件的基数树。在接收到第二电子设备发送的标记第三文件中内存页大小的第五数据无效的通知时,可以直接清除本地内存中第三文件的基数树上第五数据的缓存,即只需要清除一个内存页大小的数据,而不需要清除整个第三文件,提升了分布式文件系统中保持数据一致性的效率,减少了网络资源的消耗。In the above embodiment, the first electronic device reads the data in the third file from the second electronic device through the distributed file system, and will generate the radix tree of the third file in the local memory. When receiving the notification sent by the second electronic device that the fifth data marking the size of the memory page in the third file is invalid, the cache of the fifth data on the radix tree of the third file in the local memory can be directly cleared, that is, only one need to be cleared The data of the size of the memory page does not need to clear the entire third file, which improves the efficiency of maintaining data consistency in the distributed file system and reduces the consumption of network resources.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备清除本地内存中第三文件的基数树上第五数据的缓存,具体包括:该第一电子设备将本地内存中第三文件的基数树上第五数据所在的内存页标记为脏。With reference to some embodiments of the twenty-second aspect, in some embodiments, the first electronic device clears the cache of the fifth data on the radix tree of the third file in the local memory, specifically including: the first electronic device stores the local memory The memory page where the fifth data in the radix tree of the third file is located is marked as dirty.
在上述实施例中,第一电子设备清除本地内存中第五数据的缓存时,只需要将第五数据所在的内存页标记为脏,来表示该内存页中的数据无效即可,提升了清除缓存的效率。In the above embodiment, when the first electronic device clears the cache of the fifth data in the local memory, it only needs to mark the memory page where the fifth data is located as dirty to indicate that the data in the memory page is invalid, which improves the clearing process. cache efficiency.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备接收第二电子设备发送的将该第一电子设备中第一文件的第一数据修改为第二数据的请求的步骤之前,该方法还包括:该第一电子设备接收该第二电子设备发送的读第一文件的第一数据的第一请求;该第一电子设备将该第一数据从本地非易失性存储器读取到本地内存中第一文件的基数树中缓存;该第一电子设备返回第一响应给该第二电子设备,该第一响应中包含该第一数据。With reference to some embodiments of the twenty-second aspect, in some embodiments, the first electronic device receives a request sent by the second electronic device to modify the first data of the first file in the first electronic device to the second data Before the step of , the method further includes: the first electronic device receives a first request to read the first data of the first file sent by the second electronic device; the first electronic device converts the first data from a local nonvolatile The first electronic device returns a first response to the second electronic device, and the first response includes the first data.
在上述实施例中,第一电子设备能接收到分布式文件系统中其他电子设备读取本地非易失性存储器中存储的文件中内存页大小的数据的请求。在接收到请求时,可以先将本地非易失性存储器中存储的文件的数据缓存到本地内存中,生成该文件的基数树,再返回携带有请求访问的数据的响应给该其他电子设备。细化了文件访问的粒度,提升了访问分布式文件系统中文件的数据的访问效率。In the above embodiment, the first electronic device can receive a request from other electronic devices in the distributed file system to read data of the size of a memory page in the file stored in the local non-volatile memory. When a request is received, the data of the file stored in the local non-volatile memory can be cached in the local memory to generate a radix tree of the file, and then a response carrying the requested data is returned to the other electronic device. The granularity of file access is refined, and the data access efficiency of files in the distributed file system is improved.
结合第二十二方面的一些实施例,在一些实施例中,该第一电子设备将该第一数据从本地非易失性存储器读取到本地内存中第一文件的基数树中缓存的步骤之后,该方法还包括:该第一电子设备在本地数据读取记录中记录该第二电子设备与该第一数据的对应关系;该本地数据读取记录用于记录其他电子设备读取该第一电子设备中文件的数据的对应关系。With reference to some embodiments of the twenty-second aspect, in some embodiments, the first electronic device reads the first data from the local non-volatile memory to the step of caching in the radix tree of the first file in the local memory Afterwards, the method further includes: the first electronic device records the correspondence between the second electronic device and the first data in a local data reading record; the local data reading record is used to record other electronic devices reading the first data A corresponding relationship of data in a file in an electronic device.
结合第二十二方面的一些实施例,在一些实施例中,该第一请求中包括读指令的命令编号、该第二电子设备的设备标识、第一文件的路径以及该第一数据在第一文件中的偏移量;该第一响应中还包含与该第一请求中相同的读指令的命令编号,用于表示该第一响应是对该第一请求的响应。With reference to some embodiments of the twenty-second aspect, in some embodiments, the first request includes the command number of the read instruction, the device identifier of the second electronic device, the path of the first file, and the first data in the first request. An offset in a file; the first response also includes the same command number of the read command as in the first request, which is used to indicate that the first response is a response to the first request.
结合第二十二方面的一些实施例,在一些实施例中,该方法还包括:该第一电子设备接收到访问第二电子设备中第四文件的第六数据的请求;该第六数据为该第四文件的H个内存页大小的数据中偏移量为K的数据,该H和该K为正整数,该K不大于该H;该第一电子设备在本地内存中查找第四文件的基数树中是否已经缓存了该第六数据;当确定还未缓存该第六数据时,该第一电子设备向该第二电子设备发送读该第二电子设备中第四文件的第六数据的第二请求;当确定已经缓存该第六数据时,该第一电子设备从本地内存中第四文件的基数树中读取该第六数据。With reference to some embodiments of the twenty-second aspect, in some embodiments, the method further includes: the first electronic device receives a request to access sixth data of the fourth file in the second electronic device; the sixth data is In the data of the size of H memory pages of the fourth file, the offset is K, the H and the K are positive integers, and the K is not greater than the H; the first electronic device searches the local memory for the fourth file whether the sixth data has been cached in the radix tree of the second request; when it is determined that the sixth data has been cached, the first electronic device reads the sixth data from the radix tree of the fourth file in the local memory.
在上述实施例中,第一电子设备接收到通过分布式文件系统访问其他电子设备的文件中的数据的请求时,可以先查找本地内存中该文件的基数树中是否有缓存请求的数据。如果有缓存,则可以直接从缓存的该文件的基数树中返回请求的数据。没有缓存时,才通过分布式文件系统向目标电子设备发送读取数据的请求,提升了分布式文件系统中访问数据的效率。In the above embodiment, when the first electronic device receives a request to access data in files of other electronic devices through the distributed file system, it may first check whether there is cached requested data in the radix tree of the file in the local memory. If there is a cache, the requested data can be returned directly from the cached radix tree for that file. When there is no cache, a request for reading data is sent to the target electronic device through the distributed file system, which improves the efficiency of data access in the distributed file system.
第二十三方面,本申请实施例提供了一种第一电子设备,该第一电子设备包括:一个或多个处理器和存储器;该存储器包括本地内存和本地非易失性存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该第一电子设备执行:接收第二电子设备发送的将该第一电子设备中第一文件的第一数据修改为第二数据的请求;该第一数据为该第一文件的N个内存页大小的数据中偏移量为X的数据,该N和该X为正整数,该X不大于该N;将该本地内存中第一文件的基数树中的该第一数据修改为该第二数据;将该本地非易失性存储器中存储的第一文件中的该第一数据修改为该第二数据。In a twenty-third aspect, an embodiment of the present application provides a first electronic device, the first electronic device includes: one or more processors and a memory; the memory includes a local memory and a local non-volatile memory; the memory coupled to the one or more processors, the memory for storing computer program code comprising computer instructions that the one or more processors invoke to cause the first electronic device to perform: receive a second A request sent by the electronic device to modify the first data of the first file in the first electronic device to the second data; the first data is the offset of X in the data of the size of N memory pages of the first file data, the N and X are positive integers, and the X is not greater than the N; the first data in the radix tree of the first file in the local memory is modified to the second data; the local non-volatile memory The first data stored in the first file is modified to the second data.
上述实施例中,该第一文件存储在第一电子设备的本地非易失性存储器中。第二电子设备通过分布式文件系统读取该第一电子设备中存储的该第一文件时,第一电子设备会将该第一文件缓存到自己的本地内存中生成第一文件的基数树。第二电子设备读取到该第一文件后,也会在第二电子设备自己的本地内存中生成该第一文件的基数树。当第二电子设备将自己的本地内存中第一文件的基数树中的第一数据修改为第二数据后,会向第一电子设备发送将该第一电子设备中第一文件的第一数据修改为第二数据的请求,以保持分布式文件系统中的数据一致性。第一电子设备接收到该修改请求后,不需要将本地内存中第一文件的基数树全部删除或无效。只需要将其中内存页大小的第一数据修改为第二数据,然后,相应的将本地非易失性存储中存储的第一文件中的该第一数据修改为该第二数据即可。避免了各电子设备重新加载修改后的第一文件的基数树,使得在分布式文件系统中保持数据一致性时,数据访问的速度得到极大提升,减少了网络资源的消耗。In the above embodiment, the first file is stored in the local non-volatile memory of the first electronic device. When the second electronic device reads the first file stored in the first electronic device through the distributed file system, the first electronic device caches the first file in its own local memory to generate a radix tree of the first file. After the second electronic device reads the first file, it also generates a radix tree of the first file in its own local memory of the second electronic device. After the second electronic device modifies the first data in the radix tree of the first file in its local memory to the second data, it will send the first data of the first file in the first electronic device to the first electronic device A request for modification of the second data to maintain data consistency in the distributed file system. After receiving the modification request, the first electronic device does not need to delete or invalidate all the radix trees of the first file in the local memory. It is only necessary to modify the first data of the memory page size into the second data, and then correspondingly modify the first data in the first file stored in the local non-volatile storage to the second data. It avoids each electronic device from reloading the modified radix tree of the first file, so that when data consistency is maintained in the distributed file system, the speed of data access is greatly improved, and the consumption of network resources is reduced.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:确定第三电子设备还读取过该第一数据;向该第三电子设备发送标记该第一数据无效的通知,使得该第三电子设备清除本地内存中第一文件的基数树上第一数据的缓存。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: determine that the third electronic device has also read the first data; sending a notification marking the invalidity of the first data to the third electronic device, so that the third electronic device clears the cache of the first data on the radix tree of the first file in the local memory.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调用该计算机指令以使得该第一电子设备执行:根据本地数据读取记录,确定该第三电子设备还读取过该第一数据;该本地数据读取记录用于记录其他电子设备读取该第一电子设备中文件的数据的对应关系。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: read records according to local data, and determine the The third electronic device has also read the first data; the local data reading record is used to record the correspondence between other electronic devices reading the data of the file in the first electronic device.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:删除第三电子设备对第一数据的读取记录。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: delete the third electronic device for the first data read records.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:修改本地内存中第二文件的基数树中的第三数据为第四数据;该第二文件为该第二电子设备中的文件;该第三数据为该第二文件的M个内存页大小的数据中偏移量为Y的数据,该M和该Y为正整数,该Y不大于该M;在预设延迟时长后,向该第二电子设备发送将该第二电子设备中第二文件的第三数据修改为第四数据的请求。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instruction to cause the first electronic device to execute: modify the cardinality of the second file in the local memory The third data in the tree is the fourth data; the second file is the file in the second electronic device; the third data is the data whose offset is Y in the M memory page size data of the second file , the M and the Y are positive integers, and the Y is not greater than the M; after the preset delay time, the third data of the second file in the second electronic device is sent to the second electronic device to modify the fourth data request.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收第二电子设备发送的标记第五数据无效的通知;该第五数据为第二电子设备中第三文件中的数据;清除本地内存中第三文件的基数树上第五数据的缓存。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive the marked first electronic device sent by the second electronic device 5. Notification of invalid data; the fifth data is the data in the third file in the second electronic device; clear the cache of the fifth data on the radix tree of the third file in the local memory.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,具体用于调 用该计算机指令以使得该第一电子设备执行:将本地内存中第三文件的基数树上第五数据所在的内存页标记为脏。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are specifically configured to invoke the computer instructions to cause the first electronic device to execute: convert the radix of the third file in the local memory The memory page where the fifth data in the tree resides is marked as dirty.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收该第二电子设备发送的读第一文件的第一数据的第一请求;将该第一数据从该本地非易失性存储器读取到本地内存中第一文件的基数树中缓存;返回第一响应给该第二电子设备,该第一响应中包含该第一数据。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive the read data sent by the second electronic device The first request for the first data of the first file; the first data is read from the local non-volatile memory into the radix tree of the first file in the local memory and cached; the first response is returned to the second electronic device , the first response includes the first data.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:在本地数据读取记录中记录该第二电子设备与该第一数据的对应关系;该本地数据读取记录用于记录其他电子设备读取该第一电子设备中文件的数据的对应关系。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: record the local data read record The corresponding relationship between the second electronic device and the first data; the local data reading record is used to record the corresponding relationship between other electronic devices reading the data of the file in the first electronic device.
结合第二十三方面的一些实施例,在一些实施例中,该第一请求中包括读指令的命令编号、该第二电子设备的设备标识、第一文件的路径以及该第一数据在第一文件中的偏移量;该第一响应中还包含与该第一请求中相同的读指令的命令编号,用于表示该第一响应是对该第一请求的响应。With reference to some embodiments of the twenty-third aspect, in some embodiments, the first request includes the command number of the read instruction, the device identifier of the second electronic device, the path of the first file, and the first data in the first request. An offset in a file; the first response also includes the same command number of the read command as in the first request, which is used to indicate that the first response is a response to the first request.
结合第二十三方面的一些实施例,在一些实施例中,该一个或多个处理器,还用于调用该计算机指令以使得该第一电子设备执行:接收访问第二电子设备中第四文件的第六数据的请求;该第六数据为该第四文件的H个内存页大小的数据中偏移量为K的数据,该H和该K为正整数,该K不大于该H;在本地内存中查找第四文件的基数树中是否已经缓存了该第六数据;当确定还未缓存该第六数据时,向该第二电子设备发送读该第二电子设备中第四文件的第六数据的第二请求;当确定已经缓存该第六数据时,从本地内存中第四文件的基数树中读取该第六数据。With reference to some embodiments of the twenty-third aspect, in some embodiments, the one or more processors are further configured to invoke the computer instructions to cause the first electronic device to execute: receive access to a fourth in the second electronic device A request for the sixth data of the file; the sixth data is the data whose offset is K in the H memory page size data of the fourth file, the H and the K are positive integers, and the K is not greater than the H; Find out in the local memory whether the sixth data has been cached in the radix tree of the fourth file; when it is determined that the sixth data has not been cached, send to the second electronic device a reading of the fourth file in the second electronic device A second request for sixth data; when it is determined that the sixth data has been cached, the sixth data is read from the radix tree of the fourth file in the local memory.
第二十四方面,本申请实施例提供了一种芯片系统,该芯片系统应用于第一电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该第一电子设备执行如第二十二方面以及第二十二方面中任一可能的实现方式描述的方法。In a twenty-fourth aspect, an embodiment of the present application provides a chip system, where the chip system is applied to a first electronic device, the chip system includes one or more processors, and the processors are configured to invoke computer instructions to make the first electronic device The electronic device performs the method described in the twenty-second aspect and any possible implementation manner of the twenty-second aspect.
第二十五方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在第一电子设备上运行时,使得上述第一电子设备执行如第二十二方面以及第二十二方面中任一可能的实现方式描述的方法。In a twenty-fifth aspect, an embodiment of the present application provides a computer program product containing instructions, when the computer program product is executed on a first electronic device, the first electronic device is made to perform the operations of the twenty-second aspect and the second The method described in any possible implementation manner of the twelve aspects.
第二十六方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在第一电子设备上运行时,使得上述第一电子设备执行如第二十二方面以及第二十二方面中任一可能的实现方式描述的方法。In a twenty-sixth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, when the above-mentioned instructions are executed on a first electronic device, the above-mentioned first electronic device is made to perform the operations of the twenty-second aspect and the second The method described in any possible implementation manner of the twelve aspects.
可以理解地,上述第二十三方面提供的第一电子设备、第二十四方面提供的芯片系统、第二十五方面提供的计算机程序产品和第二十六方面提供的计算机存储介质均用于执行本申请实施例所提供的保持数据一致性的方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。Understandably, the first electronic device provided in the twenty-third aspect, the chip system provided in the twenty-fourth aspect, the computer program product provided in the twenty-fifth aspect, and the computer storage medium provided in the twenty-sixth aspect all use For implementing the method for maintaining data consistency provided by the embodiments of the present application. Therefore, for the beneficial effects that can be achieved, reference may be made to the beneficial effects in the corresponding method, which will not be repeated here.
附图说明Description of drawings
图1是本申请实施例中文件的元数据信息的一个示例性示意图;1 is an exemplary schematic diagram of metadata information of a file in an embodiment of the present application;
图2是本申请实施例中元数据文件在文件系统中分布的一个示例性示意图;2 is an exemplary schematic diagram of the distribution of metadata files in a file system in an embodiment of the present application;
图3是本申请实施例中从元数据文件中得到元数据信息的一个示例性示意图;3 is an exemplary schematic diagram of obtaining metadata information from a metadata file in an embodiment of the present application;
图4是本申请实施例中文件修改引起元数据文件更新的一个示例性示意图;4 is an exemplary schematic diagram of a metadata file update caused by file modification in an embodiment of the present application;
图5是本申请实施例中文件删除引起元数据文件更新的一个示例性示意图;5 is an exemplary schematic diagram of a metadata file update caused by file deletion in an embodiment of the present application;
图6是本申请实施例中文件增加引起元数据文件更新的一个示例性示意图;FIG. 6 is an exemplary schematic diagram of metadata file update caused by file addition in an embodiment of the present application;
图7是本申请实施例中一组示例性用户界面示意图;FIG. 7 is a schematic diagram of a group of exemplary user interfaces in an embodiment of the present application;
图8是本申请实施例中电子设备内存中一个示例性状态示意图;FIG. 8 is a schematic diagram of an exemplary state in the memory of the electronic device in the embodiment of the present application;
图9是本申请实施例中从其他电子设备获取元数据文件后目录树的示例性示意图;9 is an exemplary schematic diagram of a directory tree after obtaining metadata files from other electronic devices in an embodiment of the present application;
图10是现有技术中分布式文件系统一个示例性场景示意图;10 is a schematic diagram of an exemplary scenario of a distributed file system in the prior art;
图11是现有技术中修改分布式文件系统中文件的一个示例性信令交互图;11 is an exemplary signaling interaction diagram for modifying files in a distributed file system in the prior art;
图12是本申请实施例中无中心分布式文件系统的一个示例性场景示意图;12 is a schematic diagram of an exemplary scenario of a centerless distributed file system in an embodiment of the present application;
图13是本申请实施例提供的电子设备100的示例性结构示意图;FIG. 13 is a schematic diagram of an exemplary structure of an electronic device 100 provided by an embodiment of the present application;
图14是本申请实施例提供的电子设备100的一个示例性软件结构框图;FIG. 14 is an exemplary software structural block diagram of the electronic device 100 provided by the embodiment of the present application;
图15是本申请实施例中元数据管理方法一个信令交互示意图;15 is a schematic diagram of a signaling interaction of the metadata management method in the embodiment of the present application;
图16是本申请实施例中另一组示例性用户界面示意图;FIG. 16 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图17是本申请实施例中元数据管理方法另一个信令交互示意图;FIG. 17 is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application;
图18是本申请实施例中另一组示例性用户界面示意图;FIG. 18 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图19是本申请实施例中元数据管理方法另一个信令交互示意图;19 is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application;
图20是本申请实施例中另一组示例性用户界面示意图;FIG. 20 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图21是本申请实施例中元数据管理方法另一个信令交互示意图;21 is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application;
图22是本申请实施例中另一组示例性用户界面示意图;FIG. 22 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图23是本申请实施例中元数据管理方法另一个信令交互示意图;23 is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application;
图24是本申请实施例中另一组示例性用户界面示意图;FIG. 24 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图25是本申请实施例中元数据管理方法另一个信令交互示意图;25 is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application;
图26是本申请实施例中另一组示例性用户界面示意图;FIG. 26 is a schematic diagram of another group of exemplary user interfaces in the embodiment of the present application;
图27是本申请实施例中一组用户界面示意图;27 is a schematic diagram of a group of user interfaces in an embodiment of the present application;
图28是本申请实施例中布隆过滤器位数组的一组状态示意图;Figure 28 is a group of state schematic diagrams of the Bloom filter bit array in the embodiment of the present application;
图29是本申请实施例中将两个电子设备的布隆过滤器位数组进行比对的一个示例性场景示意图;29 is a schematic diagram of an exemplary scenario in which the Bloom filter bit arrays of two electronic devices are compared in an embodiment of the present application;
图30是本申请实施例中另一组用户界面示意图;30 is a schematic diagram of another group of user interfaces in the embodiment of the present application;
图31是本申请实施例提供的电子设备100的另一个示例性软件结构示意框图;FIG. 31 is a schematic block diagram of another exemplary software structure of the electronic device 100 provided by the embodiment of the present application;
图32是本申请实施例中同名文件识别方法的一个信令交互示意图;32 is a schematic diagram of a signaling interaction of a method for identifying a file with the same name in the embodiment of the present application;
图33是本申请实施例中判断是否可能存在同名文件的一个流程示意图;33 is a schematic flow chart of judging whether there may be a file with the same name in the embodiment of the present application;
图34是本申请实施例中判断是否可能存在同名文件的一个示例性场景示意图;34 is a schematic diagram of an exemplary scenario for judging whether a file with the same name may exist in an embodiment of the present application;
图35是本申请实施例中判断是否可能存在同名文件的另一个示例性场景示意图;35 is a schematic diagram of another exemplary scenario for judging whether a file with the same name may exist in an embodiment of the present application;
图36是本申请实施例中判断是否可能存在同名文件的另一个流程示意图;Figure 36 is another schematic flowchart of judging whether there may be a file with the same name in the embodiment of the present application;
图37是本申请实施例中对布隆过滤器位数组进行逻辑或操作的一个示例性示意图;37 is an exemplary schematic diagram of performing a logical OR operation on a Bloom filter bit array in an embodiment of the present application;
图38是本申请实施例中使用逻辑或操作判断是否可能存在同名文件的一个示例性场景示意图;38 is a schematic diagram of an exemplary scenario in which a logical OR operation is used to determine whether a file with the same name may exist in an embodiment of the present application;
图39是本申请实施例中一个伪代码示意图;Fig. 39 is a pseudo-code schematic diagram in the embodiment of the present application;
图40是本申请实施例中应用程序、虚拟内存和物理内存的一个关系示意图;FIG. 40 is a schematic diagram of a relationship between an application program, virtual memory, and physical memory in an embodiment of the present application;
图41是本申请实施例中内存分页管理的一个示例性示意图;FIG. 41 is an exemplary schematic diagram of memory paging management in an embodiment of the present application;
图42是进行数据访问的一个示例性场景示意图;Figure 42 is a schematic diagram of an exemplary scenario for data access;
图43是进行数据预读的一个示例性场景示意图;Figure 43 is a schematic diagram of an exemplary scenario for data pre-reading;
图44是本申请实施例中预读标志位一个示例性场景示意图;44 is a schematic diagram of an exemplary scenario of pre-reading flag bits in the embodiment of the present application;
图45是本申请实施例中根据不同设备类型设置不同预读标志位的一个示例性示意图;45 is an exemplary schematic diagram of setting different pre-reading flag bits according to different device types in the embodiment of the present application;
图46是现有技术中进行数据预读的一个示例性信令交互示意图;46 is a schematic diagram of an exemplary signaling interaction for data pre-reading in the prior art;
图47是现有技术中数据预读的内存页一个示例性状态示意图;FIG. 47 is a schematic diagram of an exemplary state of a memory page for data pre-reading in the prior art;
图48是本申请实施例中数据预读的一个示例性场景示意图;FIG. 48 is a schematic diagram of an exemplary scenario of data pre-reading in an embodiment of the present application;
图49是本申请实施例提供的电子设备100的另一个示例性软件结构示意框图;FIG. 49 is a schematic block diagram of another exemplary software structure of the electronic device 100 provided by the embodiment of the present application;
图50是本申请实施例中预读窗口大小确定阶段的一个信令交互示意图;50 is a schematic diagram of signaling interaction in the pre-reading window size determination stage in the embodiment of the present application;
图51是本申请实施例中预读标志位确定阶段的一个流程示意图;51 is a schematic flowchart of the pre-reading flag determination stage in the embodiment of the present application;
图52是本申请实施例中预读标志位的不同位置的一个示例性示意图;Fig. 52 is an exemplary schematic diagram of different positions of the pre-read flag bit in the embodiment of the present application;
图53是本申请实施例中预读阶段的一个信令交互示意图;53 is a schematic diagram of signaling interaction in the pre-reading stage in the embodiment of the present application;
图54是本申请实施例中文件F在内存中的基数树的一个示例性示意图;54 is an exemplary schematic diagram of the radix tree of file F in memory in the embodiment of the present application;
图55是现有技术中保持数据一致性的方法的一个示例性场景示意图;55 is a schematic diagram of an exemplary scenario of a method for maintaining data consistency in the prior art;
图56是本申请实施例中保持数据一致性的方法的一个示例性场景示意图;56 is a schematic diagram of an exemplary scenario of a method for maintaining data consistency in an embodiment of the present application;
图57是本申请实施例提供的电子设备100的一个示例性软件结构框图;FIG. 57 is an exemplary software structural block diagram of the electronic device 100 provided by the embodiment of the present application;
图58是本申请实施例中保存数据一致性的方法一个信令交互示意图;58 is a schematic diagram of signaling interaction of a method for preserving data consistency in an embodiment of the present application;
图59是本申请实施例提供的示例性电子设备200的一个结构示意图;FIG. 59 is a schematic structural diagram of an exemplary electronic device 200 provided by an embodiment of the present application;
图60实施例的电子设备的另一个示例性软件结构示意框图。FIG. 60 is a schematic block diagram of another exemplary software structure of the electronic device of the embodiment.
具体实施方式Detailed ways
本申请以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括复数表达形式,除非其上下文中明确地有相反指示。还应当理解,本申请中使用的术语“和/或”是指并包含一个或多个所列出项目的任何或所有可能组合。The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations of the present application. As used in the specification of this application and the appended claims, the singular expressions "a," "an," "the," "above," "the," and "the" are intended to also Plural expressions are included unless the context clearly dictates otherwise. It will also be understood that, as used in this application, the term "and/or" refers to and includes any and all possible combinations of one or more of the listed items.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。Hereinafter, the terms "first" and "second" are only used for descriptive purposes, and should not be construed as implying or implying relative importance or implying the number of indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, the "multiple" The meaning is two or more.
本申请实施例提供了元数据管理方法、同名文件识别方法、数据预读方法、保持数据一致性的方法和电子设备。The embodiments of the present application provide a method for managing metadata, a method for identifying a file with the same name, a method for pre-reading data, a method for maintaining data consistency, and an electronic device.
本申请实施例中的元数据管理方法能在无中心节点的情况下实现分布式文件系统的元数据管理,提升了电子设备使用分布式文件系统的稳定性。The metadata management method in the embodiment of the present application can realize the metadata management of the distributed file system without a central node, and improve the stability of the electronic device using the distributed file system.
在该无中心节点的分布式文件系统中,电子设备使用了元数据管理方法得到其他电子设备中某个路径下的元数据文件后,可以根据该元数据文件在该路径下显示其他电子设备中该路径下的文件,例如可以在电子设备A中路径:根目录/目录A下显示电子设备B中路径:根目录/目录A中的文件。In the distributed file system without a central node, after the electronic device uses the metadata management method to obtain the metadata file under a certain path in other electronic devices, it can display other electronic devices under the path according to the metadata file. For the files under the path, for example, the path: root directory/directory A in the electronic device A may display the files in the path: root directory/directory A of the electronic device B.
为了使得一个路径下显示的各文件的文件名唯一,就需要使得分布式文件系统中各电子设备能对相同路径下是否存在同名文件进行识别。在识别确定不存在同名文件时可以直接显 示其他电子设备中该相同路径下的文件,在识别确定存在同名文件时,则需要对同名文件重命名。而本申请实施例中的同名文件识别方法则能在无中心节点的分布式文件系统中,快速的确定各电子设备的一个路径下是否存在同名文件,降低进行同名文件识别时的处理时长。In order to make the file names of each file displayed under one path unique, it is necessary to enable each electronic device in the distributed file system to identify whether a file with the same name exists under the same path. When it is determined that a file with the same name does not exist, the file under the same path in other electronic devices can be displayed directly. When it is determined that a file with the same name exists, the file with the same name needs to be renamed. The method for identifying a file with the same name in the embodiment of the present application can quickly determine whether a file with the same name exists in a path of each electronic device in a distributed file system without a central node, thereby reducing the processing time when identifying a file with the same name.
电子设备中显示有其他电子设备中的文件后,可以读取该其他电子设备中的文件,为加快不同电子设备间进行数据读取的速度,可以采用数据预读技术。而在无中心节点的分布式文件系统中,各电子设备间的网络环境经常处于动态变化中,且各电子设备的性能也各有不同。在一个电子设备对另一个电子设备进行数据预读时,经常会由于网络环境的变化或设备性能的差异而导致预读效果较差。而本申请实施例中提供的数据预读方法,能提升分布式文件系统中电子设备的预读性能。After the electronic device displays the files in other electronic devices, the files in the other electronic devices can be read. In order to speed up the data reading speed between different electronic devices, data pre-reading technology can be used. On the other hand, in a distributed file system without a central node, the network environment among various electronic devices is often in dynamic change, and the performance of each electronic device is also different. When one electronic device performs data pre-reading on another electronic device, the pre-reading effect is often poor due to changes in the network environment or differences in device performance. However, the data pre-reading method provided in the embodiment of the present application can improve the pre-reading performance of the electronic device in the distributed file system.
电子设备在读取了另一个电子设备中的文件后,可能会对该文件进行修改,为了使其他电子设备在读取该文件时得到最新的文件,就需要在分布式文件系统中保持数据的一致性。而本申请实施例中提供的保持数据一致性的方法,能在分布式文件系统中保持数据一致性时,提升数据访问的速度,减少网络资源的消耗。After an electronic device reads a file in another electronic device, it may modify the file. In order for other electronic devices to get the latest file when reading the file, it is necessary to keep the data in the distributed file system. consistency. However, the method for maintaining data consistency provided in the embodiments of the present application can improve the speed of data access and reduce the consumption of network resources when maintaining data consistency in a distributed file system.
下面结合具体场景,分别对上述各方法进行详细描述:The above methods are described in detail below in combination with specific scenarios:
一、元数据管理方法:1. Metadata management method:
为了便于理解,下面先对本申请实施例涉及元数据管理方法的相关术语及概念进行介绍。For ease of understanding, the following first introduces related terms and concepts related to the metadata management method in the embodiments of the present application.
(1)元数据信息;(1) Metadata information;
元数据(Metadata)被定义为:描述数据的数据,是对数据及信息资源的描述性信息。Metadata is defined as: data describing data, which is descriptive information for data and information resources.
元数据是描述其它数据的数据,或者说是用于提供某种资源的有关信息的结构数据。其使用目的在于:识别资源;评价资源;追踪资源在使用过程中的变化;实现简单高效地管理大量网络化数据;实现信息资源的有效发现、查找、一体化组织和对使用资源的有效管理等。Metadata is data that describes other data, or structured data that provides information about a resource. The purpose of its use is to: identify resources; evaluate resources; track the changes of resources in the process of use; realize simple and efficient management of large amounts of networked data; realize effective discovery, search, integrated organization of information resources, and effective management of used resources .
本申请实施例中,一个文件的元数据信息中包含有描述该文件的元数据。根据文件类型的不同,该文件的元数据信息中包含的描述该文件的元数据也可以不同。In this embodiment of the present application, the metadata information of a file includes metadata describing the file. According to different file types, the metadata describing the file contained in the metadata information of the file may also be different.
一般的,一个文件的元数据信息中包含的该文件的元数据可以包括:文件名、文件类型、文件大小、修改时间、访问权限等。Generally, the metadata of a file contained in the metadata information of a file may include: file name, file type, file size, modification time, access authority, and the like.
不同类型的文件的元数据信息中可以包含有不同的元数据。对于一些特定格式的文件,该文件的元数据信息中还可以包含更多的特定的元数据。The metadata information of different types of files may contain different metadata. For some files of a specific format, the metadata information of the file may also contain more specific metadata.
图1为本申请实施例中文件的元数据信息的一个示例性示意图。如图1中的(a)所示,对于一个文本文档类型的文件:文档1.txt,其元数据信息中可以包含:文件名:文档1.txt、文档类型:文本文档、以及文件大小、修改时间等等元数据。如图1中的(b)所示,对于一个图片文件:图片2.txt,其元数据信息中除了可以包含文件名、文档类型、文件大小、修改时间等这些其他类型的文件的元数据信息中一般都包含的元数据外,还可以包含有拍摄时间、分辨率、位深度、宽度、高度等该图片类型的文件特定的元数据。如图1中的(c)所示,对于一个音频文件:歌曲3.mp3,其元数据信息中除了可以包含文件名、文档类型、文件大小、修改时间等这些其他类型的文件的元数据信息中一般都包含的元数据外,还可以包含有唱片集、流派、时长、比特率等该音频类型的文件特定的元数据。FIG. 1 is an exemplary schematic diagram of metadata information of a file in an embodiment of the present application. As shown in (a) of Figure 1, for a file of text document type: document 1.txt, its metadata information may include: file name: document 1.txt, document type: text document, and file size, Metadata such as modification time and so on. As shown in (b) in Figure 1, for a picture file: picture 2.txt, its metadata information can include file name, document type, file size, modification time and other metadata information of other types of files. In addition to the metadata generally contained in the file, it can also contain file-specific metadata of the picture type, such as shooting time, resolution, bit depth, width, and height. As shown in (c) in Figure 1, for an audio file: song 3.mp3, its metadata information can include file name, document type, file size, modification time and other metadata information of other types of files. In addition to the metadata generally contained in the audio file, it can also contain file-specific metadata of the audio type, such as album, genre, duration, bit rate, etc.
(2)元数据文件;(2) Metadata files;
2.1、元数据文件的分布结构:2.1. Distribution structure of metadata files:
本申请实施例中,一个电子设备中被分布式文件系统挂载的文件系统内每个目录下会维 护有一个元数据文件,该元数据文件中会存储有该目录下所有其他文件的元数据信息。In the embodiment of the present application, a metadata file is maintained under each directory in a file system mounted by a distributed file system in an electronic device, and the metadata file is stored in the metadata file of all other files in the directory information.
可选的,该元数据文件为数据库形式的文件,例如为F2FS(flash friendly file system)文件系统中存储目录项数据的格式的文件、表格格式的文件等,此处不作限定。根据该元数据文件所在目录中一个其他文件的标识信息,例如文件名、唯一标识号等,可以从该元数据文件中获取到该其他文件的元数据信息。Optionally, the metadata file is a file in the form of a database, for example, a file in a format for storing directory entry data in an F2FS (flash friendly file system) file system, a file in a table format, etc., which is not limited here. According to the identification information of another file in the directory where the metadata file is located, such as file name, unique identification number, etc., the metadata information of the other file can be obtained from the metadata file.
本申请实施例中,该元数据文件的文件名中可以携带有电子设备的标识用以区分来源于不同电子设备的元数据文件。可选的,还可以在元数据文件的文件名中携带目录的标识用于区分不同目录中的元数据文件,或元数据文件的文件名中不携带目录的标识,而通过元数据文件的路径区分不同的目录等,此处不作限定。In this embodiment of the present application, the file name of the metadata file may carry an identifier of an electronic device to distinguish metadata files from different electronic devices. Optionally, the identifier of the directory can also be carried in the file name of the metadata file to distinguish metadata files in different directories, or the file name of the metadata file does not carry the identifier of the directory, and the path of the metadata file is used. Different directories, etc., are not limited here.
可选的,该元数据文件可以对用户不可见。Optionally, the metadata file may be invisible to the user.
图2为本申请实施例中元数据文件在文件系统中分布的一个示例性示意图。图2中的(a)示出了电子设备一个示例性用户界面210。该用户界面210为电子设备1中一个被分布式文件系统挂载的文件系统的根目录的用户界面。该文件系统的根目录下保存有目录A和文件1,以及保存了该根目录下所有其他文件的元数据信息的元数据文件1。响应于用户打开目录A的操作,该电子设备1可以显示如图2中的(b)所示的用户界面220。该用户界面220为该电子设备1中根目录下目录A的用户界面。该文件系统的目录A下保存有文件2和文件3,以及保存了该目录A下所有其他文件的元数据信息的元数据文件2。FIG. 2 is an exemplary schematic diagram of distribution of metadata files in a file system in an embodiment of the present application. FIG. 2(a) shows an exemplary user interface 210 of the electronic device. The user interface 210 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 1 . A directory A and a file 1 are stored in the root directory of the file system, and a metadata file 1 that stores metadata information of all other files in the root directory. In response to the user's operation of opening the directory A, the electronic device 1 may display a user interface 220 as shown in (b) of FIG. 2 . The user interface 220 is the user interface of the directory A under the root directory in the electronic device 1 . The file 2 and the file 3 are stored under the directory A of the file system, and the metadata file 2 that stores the metadata information of all other files under the directory A is stored.
在本申请实施例中的附图中,以短虚线表示元数据文件可以对用户不可见,也可以可见,此处不作限定。例如图2中的(a)所示的元数据文件1和图2中的(b)所示的元数据文件2。在其他实施例中也可以采用这种方式表示,后续不再赘述。In the drawings in the embodiments of the present application, a short dashed line indicates that the metadata file may be invisible or visible to the user, which is not limited here. For example, the metadata file 1 shown in (a) in FIG. 2 and the metadata file 2 shown in (b) in FIG. 2 . In other embodiments, it can also be expressed in this manner, which will not be described in detail in the following.
如图2中(c)所示,为图2中的(a)和(b)所示的电子设备1中被分布式文件系统挂载的文件系统的树形图。可见,根目录下保存了目录A、文件1和元数据文件1,该元数据文件1中保存了目录A、文件1的元数据信息。该目录A下保存了文件2、文件3和元数据文件2,该元数据文件2中保存了文件2、文件3的元数据信息。As shown in (c) of FIG. 2 , it is a tree diagram of the file system mounted by the distributed file system in the electronic device 1 shown in (a) and (b) of FIG. 2 . It can be seen that a directory A, a file 1 and a metadata file 1 are stored in the root directory, and the metadata file 1 stores the metadata information of the directory A and the file 1. The directory A stores file 2, file 3, and metadata file 2, and the metadata file 2 stores metadata information of file 2 and file 3.
可以理解的是,在文件系统中,一个上级目录(例如根目录)的下级目录(例如目录A)也被作为一个文件,也有相应的元数据信息存储在该上级目录下的元数据文件(例如元数据文件1)中。It can be understood that, in the file system, a subordinate directory (such as directory A) of a superordinate directory (such as the root directory) is also regarded as a file, and there are also metadata files (such as Metadata file 1).
可选的,在一个电子设备中可以有很多个文件系统,可以只有被分布式文件系统挂载的文件系统才会在每个目录下维护有一个存储有该目录下所有其他文件的元数据信息的元数据文件。此处不作限定。Optionally, there can be many file systems in an electronic device, and only the file system mounted by the distributed file system can maintain a metadata information stored in each directory that stores all other files in the directory. metadata file. There is no limitation here.
2.2、元数据文件的使用和更新:2.2. Use and update of metadata files:
下面结合图2所示的示例性的元数据文件的分布结构,对元数据文件的使用和更新进行示例性的说明。The use and update of the metadata file are exemplarily described below in conjunction with the exemplary distribution structure of the metadata file shown in FIG. 2 .
如图3所示,为本申请实施例中从元数据文件中得到元数据信息的一个示例性示意图。由于元数据文件1中存储了根目录下所有其他文件的元数据信息,其中包括文件1的元数据信息。因此,根据文件1的标识,例如文件1的文件名,可以从该元数据文件1中查询得到该文件1的元数据信息。As shown in FIG. 3 , it is an exemplary schematic diagram of obtaining metadata information from a metadata file in an embodiment of the present application. Because the metadata file 1 stores the metadata information of all other files in the root directory, including the metadata information of the file 1. Therefore, according to the identifier of the file 1, such as the file name of the file 1, the metadata information of the file 1 can be obtained by querying the metadata file 1.
可以理解的是,虽然文件的元数据信息中可能没有文件的路径,但由于元数据文件记录了元数据信息的文件与该元数据文件在同一个目录下,因此,电子设备在得到文件的元数据信息后,根据该文件的元数据信息在该元数据文件所在的目录下检索,就可以定位到该文件。It can be understood that, although the metadata information of the file may not contain the path of the file, since the file in which the metadata information is recorded in the metadata file is in the same directory as the metadata file, the electronic device obtains the metadata of the file when the file is obtained. After the data information is retrieved according to the metadata information of the file in the directory where the metadata file is located, the file can be located.
如图4所示,为本申请实施例中文件修改引起元数据文件更新的一个示例性示意图。图4中的(a)示出了电子设备1的一个用户界面410。该用户界面410为用户打开电子设备1的根目录下的文件1后的用户界面。若用户修改了文件1的内容,并如图4中的(b)所示,在2020/02/02 02:02时点击了该用户界面410中的保存控件,保存了对文件1的修改。则电子设备1也会相应的更新元数据文件1中保存的文件1的元数据信息。示例性的,如图4中的(c)所示,若此时使用文件1的标识再次从元数据文件1中查询文件1的元数据信息,会发现文件1的元数据信息已经进行了更新,更新内容可以包括:修改时间已经更新为了2020/02/02 02:02。根据文件1的元数据信息中包含的内容不同,还可以包含有其他内容的更新,例如文件大小的更新,字符数的更新等等,此处不作限定。As shown in FIG. 4 , it is an exemplary schematic diagram of a metadata file being updated due to file modification in an embodiment of the present application. (a) of FIG. 4 shows a user interface 410 of the electronic device 1 . The user interface 410 is a user interface after the user opens the file 1 in the root directory of the electronic device 1 . If the user modifies the content of file 1, and as shown in (b) of FIG. 4, at 2020/02/02 02:02, the user clicks the save control in the user interface 410, and the modification to file 1 is saved. Then, the electronic device 1 will also update the metadata information of the file 1 stored in the metadata file 1 accordingly. Exemplarily, as shown in (c) in FIG. 4 , if the metadata of file 1 is queried from metadata file 1 again by using the identifier of file 1, it will be found that the metadata information of file 1 has been updated. , the update content can include: the modification time has been updated to 2020/02/02 02:02. Depending on the content contained in the metadata information of file 1, other content updates may also be included, such as file size update, character number update, etc., which are not limited here.
如图5所示,为本申请实施例中文件删除引起元数据文件更新的一个示例性示意图。图5中的(a)示出了电子设备一个示例性用户界面210。该用户界面210为电子设备1中一个被分布式文件系统挂载的文件系统的根目录的用户界面。该文件系统的根目录下保存有目录A和文件1,以及保存了该根目录下所有其他文件的元数据信息的元数据文件1。若用户操作删除了该根目录下的文件1,则该用户界面210可以更新为如图5中的(b)所示。电子设备1会相应的更新该根目录下的元数据文件1,从该元数据文件1中删除文件1的元数据信息。如图5中的(c)所示,若此时,再使用文件1的标识从元数据文件1中查询文件1的元数据信息,会无法查询到文件1的元数据信息。As shown in FIG. 5 , it is an exemplary schematic diagram of metadata file update caused by file deletion in an embodiment of the present application. (a) of FIG. 5 shows an exemplary user interface 210 of the electronic device. The user interface 210 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 1 . A directory A and a file 1 are stored in the root directory of the file system, and a metadata file 1 that stores metadata information of all other files in the root directory. If the user operation deletes the file 1 in the root directory, the user interface 210 can be updated as shown in (b) of FIG. 5 . The electronic device 1 will correspondingly update the metadata file 1 under the root directory, and delete the metadata information of the file 1 from the metadata file 1 . As shown in (c) of FIG. 5 , if the identifier of the file 1 is used to query the metadata information of the file 1 from the metadata file 1 at this time, the metadata information of the file 1 cannot be queried.
如图6所示,为本申请实施例中文件增加引起元数据文件更新的一个示例性示意图。图6中的(a)示出了电子设备一个示例性用户界面210。该用户界面210为电子设备1中一个被分布式文件系统挂载的文件系统的根目录的用户界面。该文件系统的根目录下保存有目录A和文件1,以及保存了该根目录下所有其他文件的元数据信息的元数据文件1。若用户操作在该根目录下增加了一个新的文件4,这该用户界面210可以更新为如图6中的(b)所示。电子设备1会相应的更新该根目录下的元数据文件1,在该元数据文件1中增加文件4的元数据信息。如图6中的(c)所示,此时,使用文件4的标识可以从元数据文件1中查询到文件4的元数据信息。As shown in FIG. 6 , it is an exemplary schematic diagram of updating the metadata file caused by the file addition in the embodiment of the present application. (a) of FIG. 6 shows an exemplary user interface 210 of the electronic device. The user interface 210 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 1 . A directory A and a file 1 are stored in the root directory of the file system, and a metadata file 1 that stores metadata information of all other files in the root directory. If the user operates to add a new file 4 under the root directory, the user interface 210 can be updated as shown in (b) of FIG. 6 . The electronic device 1 will correspondingly update the metadata file 1 under the root directory, and add the metadata information of the file 4 to the metadata file 1 . As shown in (c) of FIG. 6 , at this time, the metadata information of the file 4 can be queried from the metadata file 1 by using the identifier of the file 4 .
2.3、元数据文件的同步效果:2.3. Synchronization effect of metadata files:
本申请实施例中,一个电子设备可以获取分布式文件系统中其他电子设备中相同目录下的元数据文件,并存储在本电子设备中该目录下。然后可以在本电子设备中该目录下显示从其他电子设备获取到的元数据文件中记录的文件。In this embodiment of the present application, an electronic device may acquire metadata files in the same directory in other electronic devices in the distributed file system, and store them in the directory in the electronic device. Then, the files recorded in the metadata files obtained from other electronic devices can be displayed under the directory in the electronic device.
可以理解的是,由于分布式文件系统的目的是使得不同电子设备数据视角一致,因此,各电子设备中被同一分布式文件系统挂载的文件系统一般具有相同或近似的目录结构。且即使目录结构有不同,在获取到其他电子设备该目录下的元数据文件并在本电子设备中显示获取到的元数据文件中记录的文件后,也会得到相同的目录结构。It can be understood that, since the purpose of the distributed file system is to make the data perspectives of different electronic devices consistent, the file systems mounted by the same distributed file system in each electronic device generally have the same or similar directory structure. And even if the directory structure is different, the same directory structure will be obtained after acquiring the metadata files in the directory of other electronic devices and displaying the files recorded in the acquired metadata files in the electronic device.
可以理解的是,元数据文件中记录的文件,表示元数据文件中记录了元数据信息的文件。例如,若元数据文件1中记录了文件1的元数据信息,则可以理解为元数据文件1中记录了文件1。It can be understood that the files recorded in the metadata file represent files in which metadata information is recorded in the metadata file. For example, if metadata information of file 1 is recorded in metadata file 1, it can be understood that file 1 is recorded in metadata file 1.
可选的,在该目录下显示从其他电子设备获取到的元数据文件中记录的文件,具体可以为显示元数据文件中记录的文件的链接文件。也可以为显示元数据文件中记录的文件的真实文件,此处不作限定。若显示的是链接文件,区别于在本电子设备中存储有文件的实际数据的真实文件,链接文件根据元数据文件中记录的文件的元数据信息生成,不包含文件的实际 数据。该链接文件的显示效果可以与真实文件的显示效果相同,也可以不同,此处不作限定。电子设备接收到访问链接文件的请求时,可以将该请求转换为访问该链接文件对应的其他电子设备中的真实文件的请求。若显示的是真实文件,电子设备在从其他电子设备获取到元数据文件后,可以根据元数据文件中记录的文件的元数据信息,从其他电子设备获取到相应的真实文件并显示。Optionally, the files recorded in the metadata files obtained from other electronic devices are displayed in the directory, which may specifically be display link files of the files recorded in the metadata files. It can also be a real file showing the file recorded in the metadata file, which is not limited here. If the displayed link file is different from the real file that stores the actual data of the file in this electronic device, the link file is generated according to the metadata information of the file recorded in the metadata file, and does not contain the actual data of the file. The display effect of the linked file may be the same as or different from that of the real file, which is not limited here. When the electronic device receives the request for accessing the linked file, the request can be converted into a request for accessing real files in other electronic devices corresponding to the linked file. If a real file is displayed, after obtaining the metadata file from other electronic devices, the electronic device can obtain and display the corresponding real file from other electronic devices according to the metadata information of the file recorded in the metadata file.
可以理解的是,在根据从其他电子设备获取到的元数据文件中的元数据信息显示文件的过程中,会在电子设备的内存中生成需要显示的文件的索引节点(inode)结构体。根据获取一个文件的元数据信息所在的元数据文件的不同,在电子设备中显示该文件时,该文件在内存中对应的inode结构体中会保存有元数据文件来源的电子设备标识。这样,在电子设备接收到访问该文件的请求时,电子设备根据内存中该文件对应的inode结构体中电子设备的标识,就可以确定该文件实际是来源于来个电子设备中的文件。It can be understood that in the process of displaying the file according to the metadata information in the metadata file obtained from other electronic devices, an inode structure of the file to be displayed will be generated in the memory of the electronic device. Depending on the metadata file where the metadata information of a file is obtained, when the file is displayed on the electronic device, the inode structure corresponding to the file in the memory will store the electronic device identifier of the source of the metadata file. In this way, when the electronic device receives a request to access the file, the electronic device can determine that the file actually comes from a file in an electronic device according to the identifier of the electronic device in the inode structure corresponding to the file in the memory.
需要说明的是,本申请实施例中,将下级目录作为一种目录类型的文件,与该下级目录在同一上级目录下的元数据文件中也记录有该下级目录的元数据信息。但是,在对目录类型的文件的是否相同的判断上,只要该目录类型的文件的路径相同,且元数据信息中文件名相同,就确认其为同一个目录类型的文件。在一个目录有多个元数据文件时,不会对该多个元数据文件中记录的相同的目录类型的文件进行重复显示。对其他类型的文件,可以使用这种处理方式,也可以不使用这种处理方式,此处不作限定。It should be noted that, in the embodiment of the present application, the lower-level directory is regarded as a directory type file, and the metadata file of the lower-level directory and the lower-level directory in the same upper-level directory also records the metadata information of the lower-level directory. However, in judging whether the files of the directory type are the same, as long as the paths of the files of the directory type are the same and the file names in the metadata information are the same, it is confirmed that they are files of the same directory type. When a directory has multiple metadata files, the files of the same directory type recorded in the multiple metadata files will not be displayed repeatedly. For other types of files, this processing method may or may not be used, which is not limited here.
图7示出了本申请实施例中从其他电子设备获取元数据文件后一组示例性用户界面示意图。FIG. 7 shows a schematic diagram of a group of exemplary user interfaces after the metadata files are acquired from other electronic devices in the embodiment of the present application.
图7中的(a)示出了用户界面710。该用户界面710为电子设备1中一个被分布式文件系统挂载的文件系统的根目录的用户界面。该文件系统的根目录下保存有目录A、文件1和元数据文件1-1,该元数据文件1-1中记录了目录A和文件1的元数据信息。该元数据文件1-1中的文件名中包含有电子设备1的标识:1。(a) in FIG. 7 shows a user interface 710 . The user interface 710 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 1 . A directory A, a file 1 and a metadata file 1-1 are stored in the root directory of the file system, and the metadata file 1-1 records the metadata information of the directory A and the file 1. The file name in the metadata file 1-1 contains the identifier of the electronic device 1: 1.
图7中的(b)示出了用户界面720。该用户界面720为电子设备2中一个被分布式文件系统挂载的文件系统的根目录的用户界面。该文件系统的根目录下保存有目录A、文件5、文件6和元数据文件2-1,该元数据文件2-1中记录了目录A、文件1、文件5和文件6的元数据信息,该元数据文件的文件名中包含有电子设备2的标识:2。(b) of FIG. 7 shows the user interface 720 . The user interface 720 is a user interface of the root directory of a file system mounted by the distributed file system in the electronic device 2 . Directory A, file 5, file 6 and metadata file 2-1 are stored in the root directory of the file system, and the metadata file 2-1 records the metadata information of directory A, file 1, file 5 and file 6 , the file name of the metadata file contains the identifier of the electronic device 2: 2.
如图7中的(c)所示,电子设备1可以获取电子设备2的根目录下的元数据文件2-1,并保存在电子设备1的根目录下。As shown in (c) of FIG. 7 , the electronic device 1 can acquire the metadata file 2 - 1 in the root directory of the electronic device 2 and save it in the root directory of the electronic device 1 .
如图7中的(d)所示,电子设备1可以根据元数据文件2-1中记录的文件的元数据信息,显示该元数据文件2-1中记录的文件。由于元数据文件2-1中记录的目录A的元数据信息中,电子设备2中目录A的文件名,与电子设备1的根目录下目录A的文件名相同,因此,电子设备1确认元数据文件2-1中记录的目录A与电子设备1中根目录下的目录A为同一个目录文件,不再重复显示。电子设备1在根目录下显示出元数据文件2-1中记录的电子设备2的根目录下的其他文件:文件5和文件6。As shown in (d) of FIG. 7 , the electronic device 1 can display the file recorded in the metadata file 2-1 according to the metadata information of the file recorded in the metadata file 2-1. Since in the metadata information of the directory A recorded in the metadata file 2-1, the file name of the directory A in the electronic device 2 is the same as the file name of the directory A in the root directory of the electronic device 1, therefore, the electronic device 1 confirms the metadata The directory A recorded in the data file 2-1 and the directory A under the root directory in the electronic device 1 are the same directory file, and will not be displayed repeatedly. The electronic device 1 displays other files under the root directory of the electronic device 2 recorded in the metadata file 2-1: file 5 and file 6 under the root directory.
结合图7中的(d),图8为本申请实施例中电子设备根据元数据文件显示其他电子设备中的文件时内存中一个示例性状态示意图。电子设备1在根目录中根据元数据文件2-1中记录的元数据信息显示文件5和文件6的过程中,会在电子设备1的内存中分别生成文件5的inode结构体和文件6的inode结构体。由于文件5和文件6为根据元数据文件2-1生成,而元数据文件2-1来源于电子设备2,因此,在该文件5的inode结构体和文件6的inode结构体中会分别保存有电子设备2的标识。在电子设备1接收到对文件5访问请求时,根据内核 中文件5的inode结构体中电子设备2的标识,电子设备1就可以确定该文件5是分布式文件系统中电子设备2中的文件。从而可以根据文件5的元数据信息,确定文件5的索引路径,按照该索引路径访问电子设备2中的文件5。With reference to (d) in FIG. 7 , FIG. 8 is a schematic diagram of an exemplary state in the memory when the electronic device displays files in other electronic devices according to the metadata file in the embodiment of the present application. When the electronic device 1 displays the file 5 and the file 6 in the root directory according to the metadata information recorded in the metadata file 2-1, the inode structure of the file 5 and the inode structure of the file 6 are respectively generated in the memory of the electronic device 1. inode structure. Since the file 5 and the file 6 are generated according to the metadata file 2-1, and the metadata file 2-1 is derived from the electronic device 2, the inode structure of the file 5 and the inode structure of the file 6 will be saved separately. There is an electronic device 2 logo. When the electronic device 1 receives the access request to the file 5, according to the identifier of the electronic device 2 in the inode structure of the file 5 in the kernel, the electronic device 1 can determine that the file 5 is a file in the electronic device 2 in the distributed file system . Therefore, the index path of the file 5 can be determined according to the metadata information of the file 5, and the file 5 in the electronic device 2 can be accessed according to the index path.
结合图7所示的用户界面示意图,图9为本申请实施例中从其他电子设备获取元数据文件后目录树的示例性示意图。With reference to the schematic diagram of the user interface shown in FIG. 7 , FIG. 9 is an exemplary schematic diagram of a directory tree after obtaining metadata files from other electronic devices in an embodiment of the present application.
如图9中的(a)所示,为电子设备1中被分布式文件系统挂载的文件系统的目录树。其中,根目录下包含有目录A、文件1和元数据文件1-1。该元数据文件1-1的文件名中包含有电子设备1的标识:1。元数据文件1-1中保存有目录A、文件1的元数据信息。目录A中包含文件7和元数据文件1-A,元数据文件1-A中保存有文件7的元数据信息。该元数据文件1-A的文件名中包含有电子设备1的标识:1。As shown in (a) of FIG. 9 , it is the directory tree of the file system mounted by the distributed file system in the electronic device 1 . The root directory includes directory A, file 1 and metadata file 1-1. The file name of the metadata file 1-1 contains the identifier of the electronic device 1: 1. The metadata file 1-1 stores the metadata information of the directory A and the file 1. Directory A includes file 7 and metadata file 1-A, and metadata file 1-A stores metadata information of file 7. The file name of the metadata file 1-A contains the identifier of the electronic device 1: 1.
如图9中的(b)所示,为电子设备2中被分布式文件系统挂载的文件系统的目录树。其中,根目录下包含有目录A、文件5、文件6和元数据文件2-1。该元数据文件2-1的文件名中包含有电子设备2的标识:2。元数据文件2-1中保存有目录A、文件5、文件6的元数据信息。目录A中包含文件8和元数据文件2-A,元数据文件2-A中保存有文件7的元数据信息。该元数据文件2-A的文件名中包含有电子设备2的标识:2。As shown in (b) of FIG. 9 , it is the directory tree of the file system mounted by the distributed file system in the electronic device 2 . The root directory includes directory A, file 5, file 6 and metadata file 2-1. The file name of the metadata file 2-1 contains the identifier: 2 of the electronic device 2 . The metadata file 2-1 stores metadata information of the directory A, the file 5, and the file 6. Directory A includes file 8 and metadata file 2-A, and metadata file 2-A stores metadata information of file 7. The file name of the metadata file 2-A contains the identifier of the electronic device 2: 2.
如图9中的(c)所示,为电子设备1中被分布式文件系统挂载的文件系统拉取电子设备2的元数据文件2-1存储到根目录后的目录树。其中,根目录下包含有目录A、文件1、文件5、文件6、元数据文件1-1、元数据文件2-1。As shown in (c) of FIG. 9 , the metadata file 2-1 of the electronic device 2 is pulled for the file system mounted by the distributed file system in the electronic device 1 and stored in the directory tree after the root directory. The root directory includes directory A, file 1, file 5, file 6, metadata file 1-1, and metadata file 2-1.
其中,文件5和文件6中可以不包含实际数据,但文件5和文件6在内存中对应的inode结构体中有电子设备2的标识,因此访问该根目录下文件5或文件6的请求会转换为访问电子设备2的根目录下的文件5或文件6的请求。Among them, file 5 and file 6 may not contain actual data, but the inode structure corresponding to file 5 and file 6 in the memory has the identifier of electronic device 2, so the request to access file 5 or file 6 in the root directory will It is converted into a request to access file 5 or file 6 in the root directory of the electronic device 2 .
该元数据文件1-1的文件名中包含有电子设备1的标识:1,且该元数据文件1-1中保存有目录A、文件1的元数据信息。该目录A中包含文件7和元数据文件1-A,元数据文件1-A中保存有文件7的元数据信息。该元数据文件1-A的文件名中包含有电子设备1的标识:1。The file name of the metadata file 1-1 includes the identifier of the electronic device 1: 1, and the metadata file 1-1 stores the metadata information of the directory A and the file 1. The directory A includes a file 7 and a metadata file 1-A, and the metadata file 1-A stores metadata information of the file 7. The file name of the metadata file 1-A contains the identifier of the electronic device 1: 1.
该元数据文件2-1的文件名中包含有电子设备2的标识:2。元数据文件2-1中保存有目录A、文件5、文件6的元数据信息。The file name of the metadata file 2-1 contains the identifier: 2 of the electronic device 2 . The metadata file 2-1 stores metadata information of the directory A, the file 5, and the file 6.
图10为现有技术中分布式文件系统一个示例性场景示意图。现有技术中分布式文件系统通常由一个元数据服务器和若干个数据服务器组成,元数据服务器作为中心节点,存储元数据信息,而数据服务器管理存储分布式文件系统中文件的实际数据。当用户访问文件数据时,需要先访问作为中心节点的元数据服务器获取文件的基本信息和数据索引信息,再根据基本信息和数据索引信息访问数据服务器获取文件数据。如图10所示,设备A、设备B和设备C都需要通过分布式文件系统中作为中心节点的元数据服务器才能访问数据服务器中的文件。FIG. 10 is a schematic diagram of an exemplary scenario of a distributed file system in the prior art. In the prior art, a distributed file system usually consists of a metadata server and several data servers. The metadata server acts as a central node to store metadata information, and the data server manages and stores the actual data of files in the distributed file system. When users access file data, they need to first access the metadata server as the central node to obtain the basic information and data index information of the file, and then access the data server to obtain file data according to the basic information and data index information. As shown in Figure 10, device A, device B, and device C all need to access the files in the data server through the metadata server serving as the central node in the distributed file system.
具体的,结合图10所示的场景示意图,图11为现有技术中修改分布式文件系统中文件的一个示例性信令交互图。若设备A需要访问并修改分布式文件系统中的文件A,则设备A需要先向元数据服务器查询文件A的元数据信息。元数据服务器向设备A返回文件A的元数据信息。设备A再根据文件A的元数据信息中文件A的地址从数据服务器访问并修改文件A。然后数据服务器可以保存文件A的最新信息,并在元数据服务器中更新文件A的元数据信息。Specifically, with reference to the schematic diagram of the scenario shown in FIG. 10 , FIG. 11 is an exemplary signaling interaction diagram for modifying a file in a distributed file system in the prior art. If device A needs to access and modify file A in the distributed file system, device A needs to query the metadata server for metadata information of file A first. The metadata server returns the metadata information of file A to device A. Device A then accesses and modifies file A from the data server according to the address of file A in the metadata information of file A. Then the data server can save the latest information of file A, and update the metadata information of file A in the metadata server.
可见,现有技术的分布式文件系统中,元数据服务器作为分布式文件系统的中心节点, 需要保证时刻在线提供元数据查询更新服务。当元数据服务器下线时,分布式文件系统的服务就不可用。It can be seen that, in the distributed file system of the prior art, the metadata server, as the central node of the distributed file system, needs to ensure that the metadata query and update service is provided online at all times. When the metadata server goes offline, the services of the distributed file system are unavailable.
而本申请实施例提供的元数据管理方法,在由多个电子设备组成无中心的分布式文件系统中实现分布式文件系统的元数据管理,不会因为某个电子设备下线而导致分布式文件系统不可用,提升了使用分布式文件系统的稳定性。However, the metadata management method provided by the embodiment of the present application realizes the metadata management of the distributed file system in the non-central distributed file system composed of a plurality of electronic devices, and will not cause distributed problems due to the offline of a certain electronic device. The file system is unavailable, improving the stability of using a distributed file system.
图12为本申请实施例中无中心分布式文件系统的一个示例性场景示意图。设备A、设备B、设备C、设备D、设备E等电子设备组成无中心的分布式文件系统。该无中心分布式文件系统中的各电子设备可以直接管理其他电子设备中文件的元数据信息,从而不需要通过中心节点,即可直接显示或访问其他电子设备中的文件。例如,文件A存储在设备A中,文件B存储在设备B中,文件C存储在设备C中,但分布式文件系统中的所有在线设备都可以直接显示或访问这些文件。该无中心分布式文件系统中任一个电子设备下线,都不影响其他电子设备继续正常使用该无中心分布式文件系统的服务。FIG. 12 is a schematic diagram of an exemplary scenario of a centerless distributed file system in an embodiment of the present application. Device A, device B, device C, device D, device E and other electronic devices form a non-central distributed file system. Each electronic device in the centerless distributed file system can directly manage metadata information of files in other electronic devices, so that files in other electronic devices can be directly displayed or accessed without going through a central node. For example, file A is stored in device A, file B is stored in device B, and file C is stored in device C, but all online devices in the distributed file system can directly display or access these files. The offline of any electronic device in the centerless distributed file system will not affect the continued normal use of the services of the centerless distributed file system by other electronic devices.
下面首先介绍本申请实施例提供的示例性电子设备100。The following first introduces the exemplary electronic device 100 provided by the embodiments of the present application.
图13是本申请实施例提供的电子设备100的结构示意图。FIG. 13 is a schematic structural diagram of an electronic device 100 provided by an embodiment of the present application.
下面以电子设备100为例对实施例进行具体说明。应该理解的是,电子设备100可以具有比图中所示的更多的或者更少的部件,可以组合两个或多个的部件,或者可以具有不同的部件配置。图中所示出的各种部件可以在包括一个或多个信号处理和/或专用集成电路在内的硬件、软件、或硬件和软件的组合中实现。The embodiment will be described in detail below by taking the electronic device 100 as an example. It should be understood that the electronic device 100 may have more or fewer components than those shown in the figures, may combine two or more components, or may have different component configurations. The various components shown in the figures may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
电子设备100可以包括:处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2. Mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194 and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU) Wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the electronic device 100 . The controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数 据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may contain multiple sets of I2C buses. The processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces. For example, the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 110 may contain multiple sets of I2S buses. The processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 . In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus used for asynchronous communication. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is typically used to connect the processor 110 with the wireless communication module 160 . For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 . MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc. In some embodiments, the processor 110 communicates with the camera 193 through a CSI interface, so as to realize the photographing function of the electronic device 100 . The processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface may be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like. The GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
SIM接口可以被用于与SIM卡接口195通信,实现传送数据到SIM卡或读取SIM卡中数据的功能。The SIM interface can be used to communicate with the SIM card interface 195 to realize the function of transferring data to the SIM card or reading data in the SIM card.
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不 构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。The charging management module 140 is used to receive charging input from the charger. The charger may be a wireless charger or a wired charger.
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 . The power management module 141 receives input from the battery 142 and/or the charging management module 140 and supplies power to the processor 110 , the internal memory 121 , the external memory, the display screen 194 , the camera 193 , and the wireless communication module 160 .
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。 Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Wherein, the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and passed to the application processor. The application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 . In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellites Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared technology (IR). The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2 .
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括 全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include global positioning system (global positioning system, GPS), global navigation satellite system (global navigation satellite system, GLONASS), Beidou navigation satellite system (beidou navigation satellite system, BDS), quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light). emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on. In some embodiments, the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193 . For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin tone. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193 .
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object is projected through the lens to generate an optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。A digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process the input information, and can continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5 SDRAM)等;Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronization Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as the fifth generation DDR SDRAM is generally called DDR5 SDRAM), etc.;
非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。Non-volatile memory may include magnetic disk storage devices, flash memory.
快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universal flash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle, and can include single-level memory cell (SLC), multi-level memory cell (multi-level memory cell, SLC) according to the level of storage cell potential. cell, MLC), triple-level cell (TLC), quad-level cell (QLC), etc., according to the storage specification can include universal flash storage (English: universal flash storage, UFS) , embedded multimedia memory card (embedded multi media Card, eMMC) and so on.
随机存取存储器可以由处理器110直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (eg, machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.
非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器110直接进行读写。The non-volatile memory can also store executable programs and store data of user and application programs, etc., and can be loaded into the random access memory in advance for the processor 110 to directly read and write.
外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备100的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。The external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device 100 . The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video, etc. files in external non-volatile memory.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。Speaker 170A, also referred to as a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also referred to as "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be answered by placing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。The microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone jack 170D is used to connect wired earphones. The earphone interface 170D can be the USB interface 130, or can be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触 摸操作作用于短消息应用图标时,执行新建短消息的指令。The pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor 180A may be provided on the display screen 194 . There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, and the like. The capacitive pressure sensor may be comprised of at least two parallel plates of conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities may correspond to different operation instructions. For example, when a touch operation whose intensity is less than the first pressure threshold acts on the short message application icon, the instruction for viewing the short message is executed. When a touch operation whose intensity is greater than or equal to the first pressure threshold acts on the short message application icon, the instruction to create a new short message is executed.
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 . In some embodiments, the angular velocity of electronic device 100 about three axes (ie, x, y, and z axes) may be determined by gyro sensor 180B. The gyro sensor 180B can be used for image stabilization. Exemplarily, when the shutter is pressed, the gyro sensor 180B detects the shaking angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse motion to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenarios.
气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D. In some embodiments, when the electronic device 100 is a flip machine, the electronic device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D. Further, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, characteristics such as automatic unlocking of the flip cover are set.
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。Distance sensor 180F for measuring distance. The electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes. The light emitting diodes may be infrared light emitting diodes. The electronic device 100 emits infrared light to the outside through the light emitting diode. Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100 . When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100 . The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. Proximity light sensor 180G can also be used in holster mode, pocket mode automatically unlocks and locks the screen.
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。The ambient light sensor 180L is used to sense ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket, so as to prevent accidental touch.
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, accessing application locks, taking pictures with fingerprints, answering incoming calls with fingerprints, and the like.
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。The temperature sensor 180J is used to detect the temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by the low temperature. In some other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Touch sensor 180K, also called "touch panel". The touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”. The touch sensor 180K is used to detect a touch operation on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to touch operations may be provided through display screen 194 . In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the location where the display screen 194 is located.
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电 子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. The motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 . Different application scenarios (for example: time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。The SIM card interface 195 is used to connect a SIM card. The SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 . The electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
本申请实施例中,内部存储器121中存储的文件可以显示在被分布式文件系统挂载的文件系统中。电子设备100能通过移动通信模块150或无线通信模块160获取组成分布式文件系统的其他设备中的元数据文件并保存在内部存储器121中。处理器110通过调用内部存储器121中存储的计算机指令可以使得电子设备100执行本申请实施例中的元数据管理方法。In this embodiment of the present application, the files stored in the internal storage 121 may be displayed in the file system mounted by the distributed file system. The electronic device 100 can acquire metadata files in other devices constituting the distributed file system through the mobile communication module 150 or the wireless communication module 160 and save them in the internal memory 121 . The processor 110 can cause the electronic device 100 to execute the metadata management method in the embodiment of the present application by invoking the computer instructions stored in the internal memory 121 .
图14是本申请实施例的电子设备100的软件结构框图。FIG. 14 is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present application.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将系统分为四层,从上至下分别为应用程序层,应用程序框架层,运行时(Runtime)和系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers, which are, from top to bottom, an application layer, an application framework layer, a runtime (Runtime) and a system library, and a kernel layer.
应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.
如图14所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序(也可以称为应用)。As shown in FIG. 14 , the application package may include applications (also referred to as applications) such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
本申请实施例中,该应用程序层还可以包含有元数据管理模块,该元数据管理模块可用于执行本申请实施例中的元数据管理方法。In the embodiment of the present application, the application layer may further include a metadata management module, and the metadata management module may be used to execute the metadata management method in the embodiment of the present application.
可选的,本申请实施例中,该应用程序层还可以包含有在线确定模块,该在线确定模块可用于实时确定分布式文件系统中其他电子设备的在线状态。该在线确定模块可以提供读取接口给本申请实施例中的元数据管理模块。该元数据管理模块通过该在线确定模块的读取接口,可以实时确定分布式文件系统中其他电子设备的在线状态。Optionally, in this embodiment of the present application, the application layer may further include an online determination module, and the online determination module may be used to determine the online status of other electronic devices in the distributed file system in real time. The online determination module may provide a read interface to the metadata management module in this embodiment of the present application. The metadata management module can determine the online status of other electronic devices in the distributed file system in real time through the read interface of the online determination module.
该在线确定模块确定分布式文件系统中其他电子设备的在线状态的方式可以有很多,例如周期性的发送向其他电子设备发送心跳检测信号,能检测到心跳检测信号的响应信号时确定其他电子设备在线,当连续多次检测不到心跳检测信号的响应信号时确定其他电子设备已下线;再如,当接收到其他电子设备发送的上线通知后确定其他电子设备在线,当接收到其他电子设备发送的下线通知后确定其他电子设备已下线等等,还可以有其他的确定方式,此处不作限定。The online determination module can determine the online status of other electronic devices in the distributed file system in many ways, such as periodically sending a heartbeat detection signal to other electronic devices, and determining other electronic devices when a response signal of the heartbeat detection signal can be detected. Online, when the response signal of the heartbeat detection signal is not detected for many times in a row, it is determined that other electronic devices are offline; for another example, after receiving the online notification sent by other electronic devices, it is determined that other electronic devices are online, and when receiving other electronic devices, it is determined that other electronic devices are online. After the offline notification is sent, it is determined that other electronic devices have been offline, and so on. There may also be other determination methods, which are not limited here.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图14所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理 器,资源管理器,通知管理器等。As shown in Figure 14, the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。A window manager is used to manage window programs. The window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make these data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications. A display interface can consist of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide the communication function of the electronic device 100 . For example, the management of call status (including connecting, hanging up, etc.).
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话界面形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications from applications running in the background, and can also display notifications on the screen in the form of a dialog interface. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
运行时(Runtime)包括核心库和虚拟机。Runtime负责系统的调度和管理。Runtime (Runtime) includes core libraries and virtual machines. Runtime is responsible for the scheduling and management of the system.
核心库包含两部分:一部分是编程语言(例如,jave语言)需要调用的功能函数,另一部分是系统的核心库。The core library consists of two parts: one part is the function functions that the programming language (for example, jave language) needs to call, and the other part is the core library of the system.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的编程文件(例如,jave文件)执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in virtual machines. The virtual machine executes application layer and application framework layer programming files (eg, jave files) as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),二维图形引擎(例如:SGL)等。A system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了二维(2-Dimensional,2D)和三维(3-Dimensional,3D)图层的融合。The Surface Manager is used to manage the display subsystem and provides a fusion of two-dimensional (2-Dimensional, 2D) and three-dimensional (3-Dimensional, 3D) layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现3D图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
2D图形引擎是2D绘图的绘图引擎。2D graphics engine is a drawing engine for 2D drawing.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动,虚拟卡驱动。The kernel layer is the layer between hardware and software. The kernel layer contains at least display drivers, camera drivers, audio drivers, sensor drivers, and virtual card drivers.
下面结合上述示例性电子设备100的软硬件结构,对本申请实施例中方法进行具体描述:The method in the embodiment of the present application will be described in detail below with reference to the software and hardware structure of the above-mentioned exemplary electronic device 100:
下面以电子设备A、电子设备B和电子设备C组成无中心分布式文件系统为例,结合不同的场景,分别对本申请实施例中的元数据管理方法进行描述。可以理解的是,该无中心分布式文件系统可以由更多或更少的电子设备组成,此处不作限定。在后续描述中,为简化描述,该无中心分布式文件系统可以被简称为分布式文件系统。The following describes the metadata management method in the embodiment of the present application by taking an example that electronic device A, electronic device B, and electronic device C form a non-central distributed file system, and combining different scenarios. It can be understood that, the centerless distributed file system may be composed of more or less electronic devices, which is not limited here. In the subsequent description, to simplify the description, the centerless distributed file system may be simply referred to as a distributed file system.
本申请实施例中,组成分布式文件系统的设备群组,可以为在同一个网络账号下的电子设备,可以为在同一个局域网络下的电子设备,可以为具有相同特定标识的电子设备,还可 以为这些情况的组合等等,具体可以根据实际情况设定,此处不作限定。In the embodiment of the present application, the device group forming the distributed file system may be electronic devices under the same network account, may be electronic devices under the same local area network, may be electronic devices with the same specific identifier, It can also be a combination of these situations, etc., which can be specifically set according to the actual situation, which is not limited here.
下面按照(1)方法执行基础、(2)访问或修改本电子设备中的文件、(3)缓存其他电子设备的元数据文件、(4)访问其他电子设备中的文件、(5)修改缓存的其他电子设备中的文件、(6)电子设备下线后和下线前的元数据文件清理这几个场景,结合不同场景下电子设备间的信令交互图,分别对本申请实施例中的元数据管理方法进行描述。The following is based on (1) method execution, (2) accessing or modifying files in this electronic device, (3) caching metadata files of other electronic devices, (4) accessing files in other electronic devices, (5) modifying the cache The files in other electronic devices, (6) the metadata file cleaning after the electronic device goes offline and before it goes offline, combined with the signaling interaction diagrams between electronic devices in different scenarios, respectively. Metadata management methods are described.
可以理解的是,下面以在具体场景中电子设备A、电子设备B和电子设备C执行的步骤来描述本申请实施例中的元数据管理方法,因此不同的电子设备可能执行不同的步骤。但在分布式文件系统中的所有电子设备均可以具有执行下述任意步骤的能力,此处不作限定。It can be understood that the metadata management method in this embodiment of the present application is described below with steps performed by electronic device A, electronic device B, and electronic device C in specific scenarios, so different electronic devices may perform different steps. However, all electronic devices in the distributed file system may have the ability to execute any of the following steps, which is not limited here.
(1)方法执行基础:(1) Method execution basis:
如图15所示,为本申请实施例中元数据管理方法一个信令交互示意图。As shown in FIG. 15 , it is a schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
S1501、在本电子设备中被分布式文件系统挂载的文件系统中,每个目录下维护一个元数据文件,该元数据文件保存该目录下所有其他文件的元数据信息。S1501. In the file system mounted by the distributed file system in the electronic device, a metadata file is maintained in each directory, and the metadata file stores metadata information of all other files in the directory.
对元数据文件的具体分布结构,可参阅上述术语介绍中(2)元数据文件中的2.1、元数据文件的分布结构中的描述,此处不再赘述。For the specific distribution structure of the metadata file, reference may be made to the description in 2.1 and the distribution structure of the metadata file in (2) Metadata File in the above term introduction, which will not be repeated here.
在由电子设备A、电子设备B和电子设备C组成无中心分布式文件系统中,电子设备A、电子设备B和电子设备C可以分别在自己的电子设备中被该无中心分布式文件系统挂载的文件系统中的每个目录下维护一个元数据文件,该元数据文件保存该目录下所有其他文件的元数据信息。In a centerless distributed file system composed of electronic device A, electronic device B, and electronic device C, electronic device A, electronic device B, and electronic device C can be linked by the centerless distributed file system in their own electronic devices respectively. A metadata file is maintained under each directory in the downloaded file system, and the metadata file saves the metadata information of all other files in the directory.
对元数据信息的描述,可参阅上述术语介绍中(1)元数据信息中的描述,此处不再赘述。For the description of the metadata information, reference may be made to the description in (1) Metadata Information in the above term introduction, which will not be repeated here.
示例性的,如图16所示,为本申请实施例中一组用户界面示意图。电子设备A、电子设备B和电子设备C组成分布式文件系统。Exemplarily, as shown in FIG. 16 , it is a schematic diagram of a group of user interfaces in this embodiment of the present application. Electronic device A, electronic device B, and electronic device C form a distributed file system.
如图16中的(a)所示,为电子设备A中被分布式文件系统挂载的文件系统中根目录下目录A的用户界面1610。该电子设备A的目录A下保存有文件A,并维护有一个元数据文件A。该元数据文件A中保存有该文件A的元数据信息。As shown in (a) of FIG. 16 , it is the user interface 1610 of the directory A under the root directory in the file system mounted by the distributed file system in the electronic device A. A file A is stored in the directory A of the electronic device A, and a metadata file A is maintained. In the metadata file A, metadata information of the file A is stored.
如图16中的(b)所示,为电子设备B中被分布式文件系统挂载的文件系统中根目录下目录A的用户界面1620。该电子设备B的目录A下保存有文件B,并维护有一个元数据文件B。该元数据文件B中保存有该文件B的元数据信息。As shown in (b) of FIG. 16 , it is the user interface 1620 of the directory A under the root directory in the file system mounted by the distributed file system in the electronic device B. A file B is stored in the directory A of the electronic device B, and a metadata file B is maintained. In the metadata file B, metadata information of the file B is stored.
如图16中的(c)所示,为电子设备C中被分布式文件系统挂载的文件系统中根目录下目录A的用户界面1630。该电子设备C的目录A下保存有文件C1和文件C2,并维护有一个元数据文件C。该元数据文件C中保存有文件C1和文件C2的元数据信息。As shown in (c) of FIG. 16 , it is the user interface 1630 of the directory A under the root directory in the file system mounted by the distributed file system in the electronic device C. A file C1 and a file C2 are stored in the directory A of the electronic device C, and a metadata file C is maintained. The metadata file C stores metadata information of the file C1 and the file C2.
可以理解的是,该电子设备A、电子设备B和电子设备C的其他目录中也都分别维护有一个元数据文件,用以保存该目录下所有其他文件的元数据信息。It can be understood that each of the other directories of the electronic device A, the electronic device B, and the electronic device C also maintains a metadata file respectively, which is used to save the metadata information of all other files in the directory.
(2)访问或修改本电子设备中的文件:(2) To access or modify files in this electronic device:
如图17所示,为本申请实施例中元数据管理方法另一个信令交互示意图。As shown in FIG. 17 , it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
下面以分布式文件系统中的电子设备A访问或修改该电子设备A中被分布式文件系统挂载的文件系统的目录A中的文件A的过程为例,对本申请实施例中的元数据管理方法进行说明。The following takes the process of accessing or modifying the file A in the directory A of the file system mounted by the distributed file system in the electronic device A in the distributed file system as an example to describe the metadata management in the embodiment of the present application. method is explained.
可以理解的是,在执行如图17所示的步骤之前,分布式文件系统中的电子设备均已执行过上述步骤S1501。因此,电子设备A在该目录A下维护有一个元数据文件A,该元数据文 件A中存储了电子设备A的目录A下其他所有文件的元数据信息。It can be understood that, before executing the steps shown in FIG. 17 , the electronic devices in the distributed file system have all executed the above-mentioned step S1501 . Therefore, the electronic device A maintains a metadata file A under the directory A, and the metadata file A stores the metadata information of all other files under the directory A of the electronic device A.
S1701、电子设备A访问目录A下的文件A;S1701, the electronic device A accesses the file A under the directory A;
电子设备A可以直接访问自己电子设备中目录A下的文件A,不需要先读取文件A的元数据信息。The electronic device A can directly access the file A under the directory A in its own electronic device, and does not need to read the metadata information of the file A first.
S1702、电子设备A修改目录A下的文件A并保存;S1702, the electronic device A modifies and saves the file A under the directory A;
电子设备A访问文件A时,也可以直接修改该文件A并保存。When the electronic device A accesses the file A, the file A can also be directly modified and saved.
S1703、电子设备A在目录A下的元数据文件A中更新文件A的元数据信息;S1703, the electronic device A updates the metadata information of the file A in the metadata file A under the directory A;
在电子设备A修改文件A并保存后,电子设备A会在该文件A所在的目录A下的元数据文件A中更新该文件A的元数据信息。具体可以参阅对上述术语介绍(2)元数据文件中图4所示的文件修改引起的元数据文件更新的描述,此处不再赘述。After the electronic device A modifies and saves the file A, the electronic device A will update the metadata information of the file A in the metadata file A under the directory A where the file A is located. For details, please refer to the description of the metadata file update caused by the file modification shown in FIG. 4 in the above term introduction (2) Metadata file, which will not be repeated here.
S1704、电子设备A确定分布式文件系统中是否存在请求获取了元数据文件A且在线的电子设备;S1704, the electronic device A determines whether there is an online electronic device requesting to obtain the metadata file A in the distributed file system;
在电子设备A更新了元数据文件A之后,电子设备A会确认分布式文件系统中是否存在请求获取了该元数据文件A且在线的电子设备。After the electronic device A updates the metadata file A, the electronic device A will confirm whether there is an online electronic device requesting to obtain the metadata file A in the distributed file system.
可选的,电子设备A还可以通过向分布式文件系统中其他电子设备发送查询请求确定其是否已请求获取了该元数据文件A。Optionally, the electronic device A may also determine whether it has requested to acquire the metadata file A by sending a query request to other electronic devices in the distributed file system.
可选的,分布式文件系统中的各电子设备都可以分别存储一个读取记录,该读取记录中可以记录分布式文件系统中其他各电子设备的标识、各电子设备当前是否在线,以及各电子设备请求了本电子设备中哪些元数据文件的对应关系。其中,电子设备的标识用于在分布式文件系统中唯一标识一个电子设备,例如可以为电子设备的设备号、设备名称、国际移动设备识别码(international mobile equipment identity,IMEI)等任一项或其组合,此处不作限定。Optionally, each electronic device in the distributed file system can store a read record, and the read record can record the identifiers of other electronic devices in the distributed file system, whether each electronic device is currently online, and each electronic device. The electronic device requests the corresponding relationship of which metadata files in the electronic device. Wherein, the identifier of the electronic device is used to uniquely identify an electronic device in the distributed file system. The combination thereof is not limited here.
可以理解的是,电子设备A还可以通过其他方式确认分布式文件系统中是否存在请求获取了该元数据文件A且在线的电子设备,此处不作限定。It can be understood that, the electronic device A can also confirm whether there is an online electronic device in the distributed file system that requests to obtain the metadata file A by other means, which is not limited here.
当电子设备A确定分布式文件系统中存在请求获取了元数据文件A且在线的电子设备时,电子设备A可以执行步骤S1705;When the electronic device A determines that there is an online electronic device requesting to obtain the metadata file A in the distributed file system, the electronic device A may perform step S1705;
当电子设备A确定分布式文件系统中存在请求获取了元数据文件A且不在线的电子设备时,电子设备A可以执行步骤S1706;When the electronic device A determines that there is an electronic device in the distributed file system that requests to obtain the metadata file A and is not online, the electronic device A may perform step S1706;
当电子设备A确定分布式文件系统中不存在请求获取了元数据文件A的电子设备时,电子设备A可以执行步骤S1707。When the electronic device A determines that there is no electronic device requesting to obtain the metadata file A in the distributed file system, the electronic device A may perform step S1707.
下面以电子设备A通过存储的读取记录确定是否存在请求获取了该元数据文件A且在线的电子设备为例,对步骤S1704进行具体的示例性描述:Hereinafter, step S1704 is specifically and exemplarily described by taking the electronic device A that determines whether there is an online electronic device that requests to acquire the metadata file A through the stored read record as an example:
如下表1所示,为本申请实施例中电子设备A中的读取记录的一个示意性示例:As shown in Table 1 below, it is a schematic example of the read record in the electronic device A in the embodiment of the application:
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备BElectronic equipment B 在线online   
电子设备CElectronic equipment C 在线online 元数据文件Ametadata file A
表1Table 1
可以理解的是,除了可以为表格形式外,该读取记录还可以为其他形式,例如数组、数据库等等,此处不作限定。It can be understood that, in addition to being in the form of a table, the read record can also be in other forms, such as an array, a database, etc., which is not limited here.
电子设备A可以通过查询该读取记录,确定分布式文件系统是否存在请求获取了元数据文件A且在线的电子设备:The electronic device A can query the read record to determine whether there is an online electronic device that requests to obtain the metadata file A in the distributed file system:
示例性的,若电子设备A中的读取记录为表1所示,则电子设备A可以确定存在请求获取了元数据文件A且在线的电子设备C,电子设备A可以执行步骤S1705;Exemplarily, if the read record in the electronic device A is shown in Table 1, the electronic device A may determine that there is an online electronic device C that has requested to obtain the metadata file A, and the electronic device A may execute step S1705;
如下表2所示,为本申请实施例中电子设备A中的读取记录的另一个示意性示例:As shown in Table 2 below, it is another schematic example of the read record in the electronic device A in the embodiment of the application:
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备BElectronic equipment B 不在线not online 元数据文件Ametadata file A
电子设备CElectronic equipment C 在线online   
表2Table 2
示例性的,若电子设备A中的读取记录为如表2所示,则电子设备A可以确定存在请求获取了元数据文件A且不在线的电子设备B,电子设备A可以执行步骤S1706;Exemplarily, if the read record in the electronic device A is as shown in Table 2, then the electronic device A may determine that there is an electronic device B that requests to obtain the metadata file A and is not online, and the electronic device A may execute step S1706;
如下表3所示,为本申请实施例中电子设备A的读取记录的另一个示意性示例:As shown in Table 3 below, it is another schematic example of the reading record of the electronic device A in the embodiment of the application:
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备BElectronic equipment B 不在线not online   
电子设备CElectronic equipment C 在线online   
表3table 3
示例性的,若电子设备A中的读取记录为如表3所示,则电子设备A可以确定不存在请求获取了元数据文件A的电子设备,电子设备A可以执行步骤S1707。Exemplarily, if the read record in the electronic device A is as shown in Table 3, the electronic device A may determine that there is no electronic device requesting to obtain the metadata file A, and the electronic device A may execute step S1707.
可选的,在另一些实施例中,若设备群组中一个电子设备没有请求获取电子设备A中的元数据文件时,电子设备A的读取记录中可以不存在该电子设备对应的条目。Optionally, in other embodiments, if an electronic device in the device group does not request to obtain the metadata file in electronic device A, the entry corresponding to the electronic device may not exist in the read record of electronic device A.
示例性的,对于上述表1所示的读取记录,电子设备A中可以以另一种方式存储。如下表4所示,为本申请实施例中电子设备A的读取记录的另一个示意性示例。Exemplarily, for the read records shown in Table 1 above, the electronic device A may store it in another way. As shown in Table 4 below, it is another schematic example of the read record of the electronic device A in the embodiment of the present application.
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备CElectronic equipment C 在线online 元数据文件Ametadata file A
表4Table 4
相应的,上述表2或表3所示的读取记录中也可以不存在没有读取电子设备A中元数据文件的电子设备对应的条目,此处不再赘述。Correspondingly, in the read records shown in Table 2 or Table 3, there may be no entries corresponding to the electronic devices that have not read the metadata files in the electronic device A, which will not be repeated here.
S1705、电子设备A推送元数据文件A给该分布式文件系统中请求获取了元数据文件A且在线的电子设备;S1705, the electronic device A pushes the metadata file A to the electronic device that requests to obtain the metadata file A and is online in the distributed file system;
在电子设备A更新元数据文件A后,当电子设备A确定分布式文件系统中存在请求获取了元数据文件A且在线的电子设备时,该电子设备A可以推送元数据文件A给该请求获取了元数据文件A且在线的电子设备,使得该电子设备更新获取的元数据文件A。After the electronic device A updates the metadata file A, when the electronic device A determines that there is an online electronic device in the distributed file system that requests to obtain the metadata file A, the electronic device A can push the metadata file A to the request to obtain The electronic device that has obtained the metadata file A and is online, so that the electronic device updates the obtained metadata file A.
示例性的,若电子设备A通过上表1所示的读取记录,确定存在请求获取了元数据文件A且在线的电子设备C,则电子设备A可以推送元数据文件A给该电子设备C。Exemplarily, if electronic device A determines through the reading records shown in Table 1 above that there is an electronic device C that requests to obtain metadata file A and is online, then electronic device A can push metadata file A to the electronic device C. .
S1706、电子设备A删除读取记录中请求获取了元数据文件A但不在线的电子设备读取元数据文件A的记录;S1706, the electronic device A deletes the record of requesting to obtain the metadata file A but is not online to read the metadata file A in the read record;
在电子设备A更新元数据文件A后,当电子设备A确定分布式文件系统中存在请求获取了元数据文件A且不在线的电子设备时,该电子设备A可以删除读取记录中该获取了元数据文件A但不在线的电子设备读取元数据文件A的记录。After the electronic device A updates the metadata file A, when the electronic device A determines that there is an electronic device in the distributed file system that requests to obtain the metadata file A and is not online, the electronic device A can delete the obtained data in the read record. Metadata file A but not online electronic device reads the records of metadata file A.
示例性的,若电子设备A通过上表2所示的读取记录,确定存在请求获取了元数据文件 A但不在线的电子设备B,则电子设备A可以删除读取记录中电子设备B读取元数据文件A的记录。Exemplarily, if electronic device A determines through the reading records shown in Table 2 above that there is an electronic device B that requests to obtain metadata file A but is not online, then electronic device A can delete the reading records of electronic device B. Take the records of metadata file A.
可以理解的是,电子设备A删除读取记录中电子设备B读取元数据文件A的记录可以有多种方式:It can be understood that there may be multiple ways for electronic device A to delete the record of electronic device B reading metadata file A in the read record:
示例性的,如下表5所示,为本申请实施例中电子设备A将表2所示的读取记录中电子设备B读取元数据文件A的记录删除后的一个示意性示例:Exemplarily, as shown in Table 5 below, it is a schematic example after the electronic device A in the reading records shown in Table 2 deletes the record of reading the metadata file A by the electronic device A in the embodiment of the present application:
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备BElectronic equipment B 不在线not online   
电子设备CElectronic equipment C 在线online   
表5table 5
示例性的,在一些实施例中,若电子设备A的读取记录中其他电子设备没有已请求读取的元数据文件,则电子设备A可以将该电子设备在读取记录中的整个条目直接删除。此处不作限定。Exemplarily, in some embodiments, if other electronic devices in the read record of electronic device A do not have metadata files that have been requested to be read, then electronic device A may directly access the entire entry of the electronic device in the read record. delete. There is no limitation here.
S1707、电子设备A等待执行新的指令。S1707, the electronic device A waits for a new instruction to be executed.
在电子设备A更新元数据文件A后,当电子设备A确定分布式文件系统中不存在请求获取了元数据文件A的电子设备时,该电子设备A可以不执行任何操作,等待执行新的指令。After the electronic device A updates the metadata file A, when the electronic device A determines that there is no electronic device requesting to obtain the metadata file A in the distributed file system, the electronic device A may not perform any operation and wait for a new instruction to be executed .
示例性的,若电子设备A通过上表3所示的读取记录,确定不存在请求获取了元数据文件A的电子设备,则电子设备A可以不执行任何操作,等待执行新的指令。Exemplarily, if the electronic device A determines that there is no electronic device requesting to obtain the metadata file A through the reading records shown in Table 3 above, the electronic device A may not perform any operation and wait for a new instruction to be executed.
可选的,若电子设备A会直接将没有请求读取元数据文件的电子设备在读取记录中的整个条目直接删除,则电子设备可以在确定读取记录中没有数据时,确定分布式文件系统中不存在请求获取了元数据文件A的电子设备。进而可以不执行任何操作,等待执行新的指令。Optionally, if the electronic device A directly deletes the entire entry in the read record of the electronic device that does not request to read the metadata file, the electronic device can determine the distributed file when determining that there is no data in the read record. There is no electronic device requesting to obtain the metadata file A in the system. In turn, you can do nothing and wait for a new instruction to be executed.
示例性的,结合图16所示的用户界面,如图18所示,为本申请实施例中一组用户界面示意图。Exemplarily, with reference to the user interface shown in FIG. 16 , as shown in FIG. 18 , it is a schematic diagram of a group of user interfaces in this embodiment of the present application.
如图18中(a)所示,在电子设备A的用户界面1610中,用户对电子设备A的目录A中文件A进行了修改并保存,该文件A更新为文件A1。元数据文件A更新其中记录的文件A的元数据信息,该元数据文件A更新为元数据文件A1。As shown in FIG. 18( a ), in the user interface 1610 of the electronic device A, the user modifies and saves the file A in the directory A of the electronic device A, and the file A is updated to the file A1. The metadata file A is updated with the metadata information of the file A recorded therein, and the metadata file A is updated to the metadata file A1.
在电子设备A更新元数据文件A为元数据文件A1后,电子设备A通过读取记录确定此前电子设备C请求获取过电子设备A的元数据文件A。如图18中的(b)所示,电子设备C获取过元数据文件A,在电子设备C的目录A下缓存了该元数据文件A。并显示出该元数据文件A中记录的文件A。则,电子设备A向电子设备C推送元数据文件A1,指示元数据文件A已更新为了元数据文件A1;After the electronic device A updates the metadata file A to the metadata file A1, the electronic device A determines by reading the records that the electronic device C has requested to obtain the metadata file A of the electronic device A before. As shown in (b) of FIG. 18 , the electronic device C has acquired the metadata file A, and the metadata file A is cached under the directory A of the electronic device C. And the file A recorded in the metadata file A is displayed. Then, electronic device A pushes metadata file A1 to electronic device C, indicating that metadata file A has been updated to metadata file A1;
根据元数据文件显示出的文件可以为真实文件,也可以为链接文件,此处不作限定。The file displayed according to the metadata file may be a real file or a linked file, which is not limited here.
在本申请实施例中的附图中,以长虚线来表示根据元数据文件显示出的文件可以为真实文件,也可以为链接文件,此处不作限定。例如图18中的(b)所示的文件A。在其他实施例中也可以采用这种方式表示,后续不再赘述。In the drawings in the embodiments of the present application, a long dashed line indicates that the file displayed according to the metadata file may be a real file or a linked file, which is not limited here. For example, file A shown in (b) of FIG. 18 . In other embodiments, it can also be expressed in this manner, which will not be described in detail in the following.
如图18中的(c)所示,电子设备C接收到该元数据文件A1后,更新在目录A下缓存的元数据文件A为元数据文件A1,并相应的更新显示的元数据文件A1中记录的文件A为更新后的文件A1。As shown in (c) of FIG. 18 , after receiving the metadata file A1, the electronic device C updates the metadata file A cached in the directory A to the metadata file A1, and correspondingly updates the displayed metadata file A1 The file A recorded in is the updated file A1.
(3)缓存其他电子设备的元数据文件:(3) Cache metadata files of other electronic devices:
如图19所示,为本申请实施例中元数据管理方法另一个信令交互示意图。As shown in FIG. 19 , it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
下面以分布式文件系统中的电子设备A访问电子设备A中被分布式文件系统挂载的文件系统的目录A的过程为例,对本申请实施例中的元数据管理方法进行说明。The following describes the metadata management method in the embodiment of the present application by taking the process of electronic device A in the distributed file system accessing directory A of the file system mounted by the distributed file system in electronic device A as an example.
可以理解的是,在执行如图19所示的步骤之前,分布式文件系统中的电子设备均已执行过上述步骤S1501。因此,电子设备A在该目录A下维护有一个元数据文件A,该元数据文件A中存储了该电子设备A的目录A下其他所有文件的元数据信息。电子设备B在电子设备B的目录A下维护有一个元数据文件B,该元数据文件B中存储了该电子设备B的目录A下其他所有文件的元数据信息。电子设备C在电子设备C的目录A下维护有一个元数据文件C,该元数据文件C中存储了该电子设备C的目录A下其他所有文件的元数据信息。It can be understood that, before executing the steps shown in FIG. 19 , the electronic devices in the distributed file system have all executed the above-mentioned step S1501 . Therefore, the electronic device A maintains a metadata file A under the directory A, and the metadata file A stores the metadata information of all other files in the directory A of the electronic device A. The electronic device B maintains a metadata file B under the directory A of the electronic device B, and the metadata file B stores metadata information of all other files in the directory A of the electronic device B. The electronic device C maintains a metadata file C under the directory A of the electronic device C, and the metadata file C stores the metadata information of all other files under the directory A of the electronic device C.
S1901、电子设备A接收到访问电子设备A中目录A的请求;S1901, electronic device A receives a request for accessing directory A in electronic device A;
电子设备A可以接收访问电子设备A中被分布式文件系统挂载的文件系统中目录A的请求。The electronic device A may receive a request to access the directory A in the file system mounted by the distributed file system in the electronic device A.
可选的,访问目录A的请求可以为打开目录A的请求,也可以为访问目录A中某文件的请求,此处不作限定。Optionally, the request to access the directory A may be a request to open the directory A, or may be a request to access a file in the directory A, which is not limited here.
可以理解的是,上述步骤S1701中访问目录A下的文件A,也是一种访问目录A的请求,因此,电子设备A在执行步骤S1701后,执行步骤S1702~S1706的同时,也可以执行步骤S1902~S1904,此处不作限定。It can be understood that, accessing the file A under the directory A in the above step S1701 is also a request to access the directory A. Therefore, after performing the step S1701, the electronic device A can also perform the step S1902 while performing the steps S1702-S1706. ~S1904, which is not limited here.
S1902、电子设备A确定本地是否缓存了分布式文件系统中所有其他在线电子设备的目录A下有效的元数据文件;S1902, the electronic device A determines whether the valid metadata files under the directory A of all other online electronic devices in the distributed file system are cached locally;
电子设备A在接收到访问电子设备A中目录A的请求后,电子设备A可以确定该电子设备中被分布式文件系统挂载的文件系统的目录A中是否缓存有所有其他在线电子设备的目录A下有效的元数据文件。After the electronic device A receives the request to access the directory A in the electronic device A, the electronic device A can determine whether the directory A of the file system mounted by the distributed file system in the electronic device has the directories of all other online electronic devices cached A valid metadata file under A.
具体的,这个确定过程可以分为3个步骤:Specifically, this determination process can be divided into three steps:
1、电子设备A确定分布式文件系统中当前的在线电子设备;1. Electronic device A determines the current online electronic device in the distributed file system;
可选的,电子设备A可以通过在线确定模块确定分布式文件系统中当前的在线电子设备。Optionally, the electronic device A may determine the current online electronic device in the distributed file system through the online determination module.
示例性的,电子设备A可以确定分布式文件系统中的电子设备B、电子设备C都在线。Exemplarily, electronic device A may determine that electronic device B and electronic device C in the distributed file system are both online.
2、电子设备A确定目录A下是否缓存有这些在线电子设备的目录A下的元数据文件;2. The electronic device A determines whether the metadata files in the directory A of the online electronic devices are cached in the directory A;
由于每个电子设备维护的元数据文件的文件名中携带有本电子设备的标识,因此,电子设备A可以确定目录A下是否缓存有这些在线电子设备的目录A下的元数据文件。Since the file name of the metadata file maintained by each electronic device carries the identity of the electronic device, electronic device A can determine whether the metadata files in directory A of these online electronic devices are cached in directory A.
示例性的,若电子设备B的目录A下维护的元数据文件为元数据文件B,电子设备C的目录A下维护的元数据文件为元数据文件C。则电子设备A可以确定电子设备A的目录A下是否缓存有该元数据文件B和元数据文件C。若电子设备A确定电子设备A的目录A下没有缓存元数据文件B,则电子设备A可以确定没有缓存电子设备B的目录A下有效的元数据文件。若电子设备A确定电子设备A的目录A下没有缓存元数据文件C,则电子设备A可以确定没有缓存电子设备C的目录A下有效的元数据文件。Exemplarily, if the metadata file maintained under directory A of electronic device B is metadata file B, the metadata file maintained under directory A of electronic device C is metadata file C. Then the electronic device A can determine whether the metadata file B and the metadata file C are cached in the directory A of the electronic device A. If the electronic device A determines that the metadata file B is not cached in the directory A of the electronic device A, the electronic device A may determine that the valid metadata file in the directory A of the electronic device B is not cached. If the electronic device A determines that the metadata file C is not cached in the directory A of the electronic device A, the electronic device A may determine that the valid metadata file in the directory A of the electronic device C is not cached.
3、电子设备A确定缓存的元数据文件是否有效;3. The electronic device A determines whether the cached metadata file is valid;
缓存的元数据文件可以有有效期。当缓存的元数据文件的缓存时长不超出预设有效时长时,电子设备A可以确定该元数据文件有效。当缓存的元数据文件的缓存时长超出预设有效时长时,电子设备A可以确定该元数据文件无效。Cached metadata files can have an expiration date. When the cache duration of the cached metadata file does not exceed the preset valid duration, the electronic device A may determine that the metadata file is valid. When the cache duration of the cached metadata file exceeds the preset valid duration, the electronic device A may determine that the metadata file is invalid.
示例性的,若预设有效时长为5分钟。若电子设备A确定目录A下缓存有元数据文件B和元数据文件C,元数据文件B的缓存时长不超出5分钟,但是元数据文件C的缓存时长超出了5分钟。则电子设备A可以确定缓存了电子设备B的目录A下有效的元数据文件,但是没有缓存电子设备C的目录A下有效的元数据文件。Exemplarily, if the preset effective time period is 5 minutes. If the electronic device A determines that the metadata file B and the metadata file C are cached in the directory A, the cache time of the metadata file B does not exceed 5 minutes, but the cache time of the metadata file C exceeds 5 minutes. Then the electronic device A may determine that the valid metadata files under the directory A of the electronic device B are cached, but the valid metadata files under the directory A of the electronic device C are not cached.
当电子设备A确定电子设备A的目录A下没有缓存分布式文件系统中所有其他在线电子设备的目录A下有效的元数据文件时,电子设备A可以执行步骤S1903;When the electronic device A determines that the directory A of the electronic device A does not cache valid metadata files in the directory A of all other online electronic devices in the distributed file system, the electronic device A can perform step S1903;
当电子设备A确定电子设备A的目录A下已经缓存有分布式文件系统中所有其他在线电子设备的目录A下有效的元数据文件时,电子设备A可以执行步骤S1904。When the electronic device A determines that the directory A of the electronic device A has cached valid metadata files under the directory A of all other online electronic devices in the distributed file system, the electronic device A may execute step S1904.
S1903、电子设备A获取分布式文件系统中所有其他在线电子设备的目录A下没有被有效缓存的元数据文件;S1903, the electronic device A obtains the metadata files that are not effectively cached under the directory A of all other online electronic devices in the distributed file system;
在电子设备A确定电子设备A的目录A下没有缓存分布式文件系统中所有其他在线电子设备的目录A下有效的元数据文件时,电子设备A可以获取分布式文件系统中所有其他在线电子设备的目录A下没有被有效缓存的元数据文件。When the electronic device A determines that the directory A of the electronic device A does not cache the valid metadata files in the directory A of all other online electronic devices in the distributed file system, the electronic device A can obtain all other online electronic devices in the distributed file system. There are no effectively cached metadata files in directory A.
示例性的,若电子设备A确定电子设备A的目录A下没有缓存电子设备B的目录A下有效的元数据文件,则电子设备A可以获取电子设备B的目录A下没有被有效缓存的元数据文件B。Exemplarily, if the electronic device A determines that there is no valid metadata file cached in the directory A of the electronic device B under the directory A of the electronic device A, the electronic device A can obtain the metadata files that are not effectively cached in the directory A of the electronic device B. Data file B.
具体的,电子设备A可以执行如下步骤缓存该元数据文件B:Specifically, the electronic device A may perform the following steps to cache the metadata file B:
·S19031、电子设备A向电子设备B发送获取电子设备B的目录A的元数据文件B的请求;S19031, electronic device A sends a request to electronic device B to obtain metadata file B of directory A of electronic device B;
当电子设备A确定电子设备A的目录A下没有缓存电子设备B的目录A下有效的元数据文件时,电子设备A可以向电子设备B发送获取电子设备B的目录A下的元数据文件B的请求。When electronic device A determines that there is no valid metadata file under directory A of electronic device B cached in directory A of electronic device A, electronic device A may send to electronic device B to obtain the metadata file B under directory A of electronic device B request.
·S19032、电子设备B在电子设备B的读取记录中记录电子设备A的标识和读取元数据文件B的对应关系;S19032, the electronic device B records the correspondence between the identification of the electronic device A and the read metadata file B in the read record of the electronic device B;
电子设备B在接收到电子设备A发送的获取电子设备B的目录A下的元数据文件B的请求后,可以在电子设备B的读取记录中记录电子设备A的标识和读取元数据文件B的对应关系。After receiving the request from the electronic device A to obtain the metadata file B under the directory A of the electronic device B, the electronic device B can record the identification of the electronic device A and read the metadata file in the reading record of the electronic device B. Correspondence of B.
如下表6所示,为本申请实施例中电子设备B的读取记录的一个示意性示例:As shown in Table 6 below, it is a schematic example of the reading record of the electronic device B in the embodiment of the application:
电子设备标识Electronic Equipment Identification 在线状态online status 已请求读取的元数据文件Metadata file requested to read
电子设备AElectronic equipment A 在线online 元数据文件Bmetadata file B
表6Table 6
·S19033、电子设备B向电子设备A推送元数据文件B;S19033, electronic device B pushes metadata file B to electronic device A;
电子设备B更新读取记录后,可以向电子设备A推送电子设备A请求的电子设备B的目录A下的元数据文件B。After the electronic device B updates the read record, it can push the metadata file B under the directory A of the electronic device B requested by the electronic device A to the electronic device A.
·S19034、电子设备A在电子设备A的目录A下缓存该元数据文件B。· S19034, the electronic device A caches the metadata file B under the directory A of the electronic device A.
电子设备A在接收到电子设备B推送的电子设备B的目录A下的元数据文件B后,可以在电子设备A的目录A下缓存该元数据文件B。After receiving the metadata file B under the directory A of the electronic device B pushed by the electronic device B, the electronic device A may cache the metadata file B under the directory A of the electronic device A.
示例性的,若电子设备A确定电子设备A的目录A下没有缓存电子设备C的目录A下 有效的元数据文件,则电子设备A可以获取电子设备C的目录A下没有被有效缓存的元数据文件C。Exemplarily, if electronic device A determines that there is no valid metadata file cached under directory A of electronic device C under directory A of electronic device A, then electronic device A can obtain metadata files that are not cached effectively under directory A of electronic device C. Data file C.
具体的,电子设备A可以执行如下步骤缓存该元数据文件C:Specifically, the electronic device A may perform the following steps to cache the metadata file C:
·S19035、电子设备A向电子设备C发送获取电子设备C的目录A的元数据文件C的请求;S19035, the electronic device A sends a request to the electronic device C to obtain the metadata file C of the directory A of the electronic device C;
·S19036、电子设备C在电子设备C的读取记录中记录电子设备A的标识和读取元数据文件C的对应关系;S19036, the electronic device C records the correspondence between the identification of the electronic device A and the read metadata file C in the read record of the electronic device C;
·S19037、电子设备C向电子设备A推送元数据文件C;S19037, electronic device C pushes metadata file C to electronic device A;
·S19038、电子设备A在电子设备A的目录A下缓存该元数据文件C。· S19038, the electronic device A caches the metadata file C under the directory A of the electronic device A.
步骤S19035~S19038与步骤S19031~S19034类似,可参考对步骤S19031~S19034的描述,此处不再赘述。Steps S19035-S19038 are similar to steps S19031-S19034, and the description of steps S19031-S19034 can be referred to, and details are not repeated here.
S1904、电子设备A显示分布式文件系统中所有在线电子设备的目录A下元数据文件中记录的文件。S1904, the electronic device A displays the files recorded in the metadata files under the directory A of all online electronic devices in the distributed file system.
在确定电子设备A的目录A下已经缓存有分布式文件系统中所有其他在线电子设备的目录A下有效的元数据文件后,或在获取了分布式文件系统中所有其他在线电子设备的目录A下没有被有效缓存的元数据文件后,电子设备A可以显示分布式文件系统中所有在线电子设备的目录A下元数据文件中记录的文件。After determining that the directory A of the electronic device A has cached the valid metadata files in the directory A of all other online electronic devices in the distributed file system, or after obtaining the directory A of all other online electronic devices in the distributed file system After downloading the metadata files that have not been effectively cached, the electronic device A can display the files recorded in the metadata files under the directory A of all online electronic devices in the distributed file system.
示例性的,电子设备A的目录A下已经缓存有电子设备B的目录A下的元数据文件B,以及电子设备C的目录A下的元数据文件C。由于元数据文件B中记录有电子设备B的目录A下所有其他文件的元数据信息,元数据文件C中记录有电子设备C的目录A下所有其他文件的元数据信息。因此,电子设备A的目录A中除了可以显示电子设备的目录A中已有的文件,还可以根据该元数据文件B和元数据文件C,显示出电子设备B的目录A中的文件,以及电子设备C的目录A中的文件。Exemplarily, the metadata file B under the directory A of the electronic device B and the metadata file C under the directory A of the electronic device C have been cached under the directory A of the electronic device A. Since the metadata file B records the metadata information of all other files under the directory A of the electronic device B, the metadata file C records the metadata information of all other files under the directory A of the electronic device C. Therefore, in addition to displaying the existing files in the directory A of the electronic device A, the directory A of the electronic device A can also display the files in the directory A of the electronic device B according to the metadata file B and the metadata file C, and A file in directory A of electronic device C.
对于电子设备A根据元数据文件B和元数据文件C显示出相应文件的过程,可以参考上述术语介绍(2)元数据文件中的2.3、元数据文件的同步效果中的描述,此处不再赘述。For the process that the electronic device A displays the corresponding files according to the metadata file B and the metadata file C, you can refer to the description in 2.3, the synchronization effect of the metadata file in the above term introduction (2) metadata file, which is not repeated here. Repeat.
示例性的,结合图16所示的用户界面,如图20所示,为本申请实施例中一个用户界面示意图。电子设备A接收到访问目录A或目录A中文件的请求后,可以缓存分布式文件系统中电子设备B的目录A下的元数据文件B,以及电子设备C的目录A下的元数据文件C到该电子设备A的目录A下。Exemplarily, with reference to the user interface shown in FIG. 16 , as shown in FIG. 20 , which is a schematic diagram of a user interface in this embodiment of the present application. After electronic device A receives a request to access directory A or a file in directory A, it can cache metadata file B under directory A of electronic device B and metadata file C under directory A of electronic device C in the distributed file system to the directory A of the electronic device A.
在一些实施例中,可以在显示该电子设备A的目录A的用户界面1610中显示该元数据文件B中记录的文件B,以及该元数据文件C中记录的文件C1和文件C2。可以理解的是,根据元数据文件显示的文件可以为不包含实际数据的链接文件。In some embodiments, the file B recorded in the metadata file B, and the files C1 and C2 recorded in the metadata file C may be displayed in the user interface 1610 displaying the directory A of the electronic device A. It can be understood that the files displayed according to the metadata files may be linked files that do not contain actual data.
在一些实施例中,在电子设备A的目录A下缓存了元数据文件B或元数据文件C后,可以不显示该元数据文件B或元数据文件C中记录的文件。可以在接收到对元数据文件B或元数据文件C中记录的文件的访问请求后,再显示相应的文件。In some embodiments, after the metadata file B or the metadata file C is cached under the directory A of the electronic device A, the file recorded in the metadata file B or the metadata file C may not be displayed. The corresponding file may be displayed after an access request to the file recorded in the metadata file B or the metadata file C is received.
(4)访问其他电子设备中的文件:(4) Access files in other electronic devices:
下面以分布式文件系统中的电子设备A访问电子设备B的目录A下的文件B的过程为例,对本申请实施例中的元数据管理方法进行说明。The following describes the metadata management method in the embodiment of the present application by taking the process of accessing the file B under the directory A of the electronic device B by the electronic device A in the distributed file system as an example.
可以理解的是,在执行如图21所示的步骤之前,分布式文件系统中的电子设备均已执行过上述步骤S1501。因此,电子设备A在该目录A下维护有一个元数据文件A,该元数据文件A中存储了该电子设备A的目录A下其他所有文件的元数据信息。电子设备B在电子设备B的目录A下维护有一个元数据文件B,该元数据文件B中存储了该电子设备B的目录A下其他所有文件的元数据信息。It can be understood that, before executing the steps shown in FIG. 21 , the electronic devices in the distributed file system have all executed the above-mentioned step S1501 . Therefore, the electronic device A maintains a metadata file A under the directory A, and the metadata file A stores the metadata information of all other files in the directory A of the electronic device A. The electronic device B maintains a metadata file B under the directory A of the electronic device B, and the metadata file B stores metadata information of all other files in the directory A of the electronic device B.
可选的,电子设备A在执行如图21所示的步骤之前,可以已经执行过步骤S1901~S1904,也可以没有执行过步骤S1901~S1904,此处不作限定。Optionally, before the electronic device A performs the steps shown in FIG. 21 , steps S1901 to S1904 may be performed, or steps S1901 to S1904 may not be performed, which is not limited here.
如图21所示,为本申请实施例中元数据管理方法另一个信令交互示意图。As shown in FIG. 21 , it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
S2101、电子设备A接收到访问电子设备B的目录A下文件B的请求;S2101, electronic device A receives a request to access file B under directory A of electronic device B;
示例性的,电子设备A可以接收到电子设备A中的应用程序发出的访问请求,该访问请求可以指定访问路径为电子设备B的目录A下文件B的路径,用以访问电子设备B的目录A下文件B。Exemplarily, electronic device A may receive an access request sent by an application program in electronic device A, and the access request may specify that the access path is the path of file B under directory A of electronic device B to access the directory of electronic device B. A under file B.
示例性的,电子设备A的目录A下可以缓存有电子设备B的目录A下的元数据文件B,显示有电子设备B的目录A下的全部文件。电子设备A可以响应于用户点击该电子设备A的目录A下显示的电子设备B的目录A下文件B的操作,接收到访问电子设备B的目录A下文件B的请求。Exemplarily, the metadata file B under the directory A of the electronic device B may be cached under the directory A of the electronic device A, and all files under the directory A of the electronic device B are displayed. The electronic device A may receive a request to access the file B in the directory A of the electronic device B in response to the user clicking on the file B in the directory A of the electronic device B displayed under the directory A of the electronic device A.
可以理解的是,电子设备A还可以通过其他方式接收到访问电子设备B的目录A下文件B的请求,此处不作限定。It can be understood that the electronic device A may also receive a request for accessing the file B under the directory A of the electronic device B in other ways, which is not limited here.
S2102、电子设备A确定电子设备A的目录A下是否缓存了有效的电子设备B的目录A下的元数据文件B;S2102, the electronic device A determines whether a valid metadata file B under the directory A of the electronic device B is cached under the directory A of the electronic device A;
在接收到访问电子设备B的目录A下文件B的请求后,电子设备A可以确定电子设备A的目录A下是否缓存了有效的电子设备B的目录A下的元数据文件B;After receiving the request to access the file B under the directory A of the electronic device B, the electronic device A can determine whether the metadata file B under the directory A of the electronic device B is cached under the directory A of the electronic device A;
具体的,这个确定过程可以分为3个步骤:Specifically, this determination process can be divided into three steps:
1、电子设备A确定分布式文件系统中该电子设备B是否在线;1. The electronic device A determines whether the electronic device B in the distributed file system is online;
可选的,电子设备A可以通过在线确定模块确定分布式文件系统中当前的在线电子设备。Optionally, the electronic device A may determine the current online electronic device in the distributed file system through the online determination module.
当电子设备A确定电子设备B在线时,可以继续执行该确定过程的后续步骤。When electronic device A determines that electronic device B is online, subsequent steps of the determination process may be continued.
当电子设备A确定电子设备B不在线时,可以反馈提示信息,该提示信息可用于表示电子设备B不在线,文件B无法访问。When the electronic device A determines that the electronic device B is not online, it can feed back prompt information, and the prompt information can be used to indicate that the electronic device B is not online and the file B cannot be accessed.
2、电子设备A确定电子设备A的目录A下是否缓存有电子设备B的目录A下的元数据文件;2. The electronic device A determines whether the metadata file in the directory A of the electronic device B is cached in the directory A of the electronic device A;
当电子设备A确定电子设备B在线时,电子设备A可以确定电子设备A的目录A下是否缓存有电子设备B的目录A下的元数据文件B。When the electronic device A determines that the electronic device B is online, the electronic device A may determine whether the metadata file B under the directory A of the electronic device B is cached under the directory A of the electronic device A.
当电子设备A确定电子设备A的目录A下中没有缓存电子设备B的目录A下的元数据文件B时,电子设备A可以执行步骤S2103;When the electronic device A determines that the metadata file B under the directory A of the electronic device B is not cached in the directory A of the electronic device A, the electronic device A may perform step S2103;
当电子设备A确定电子设备A的目录A下中缓存有电子设备B的目录A下的元数据文件B时,电子设备A可以继续执行该确定过程的后续步骤。When the electronic device A determines that the metadata file B under the directory A of the electronic device B is cached in the directory A of the electronic device A, the electronic device A may continue to perform the subsequent steps of the determination process.
3、电子设备A确定缓存的元数据文件B是否有效;3. The electronic device A determines whether the cached metadata file B is valid;
缓存的元数据文件可以有有效期。当缓存的元数据文件的缓存时长不超出预设有效时长时,电子设备A可以确定该元数据文件有效。当缓存的元数据文件的缓存时长超出预设有效时长时,电子设备A可以确定该元数据文件无效。Cached metadata files can have an expiration date. When the cache duration of the cached metadata file does not exceed the preset valid duration, the electronic device A may determine that the metadata file is valid. When the cache duration of the cached metadata file exceeds the preset valid duration, the electronic device A may determine that the metadata file is invalid.
示例性的,若预设有效时长为5分钟。若电子设备A确定目录A下缓存有元数据文件B,元数据文件B的缓存时长不超出5分钟,则电子设备A可以确定缓存的元数据文件B有效。若电子设备确定目录A下缓存有元数据文件B,元数据文件B的缓存时长超出5分钟,则电子设备A可以确定缓存的元数据文件B无效。Exemplarily, if the preset effective time period is 5 minutes. If the electronic device A determines that the metadata file B is cached in the directory A, and the cache duration of the metadata file B does not exceed 5 minutes, the electronic device A may determine that the cached metadata file B is valid. If the electronic device determines that the metadata file B is cached in the directory A, and the cache time of the metadata file B exceeds 5 minutes, the electronic device A may determine that the cached metadata file B is invalid.
当电子设备A确定缓存的元数据文件B有效时,电子设备A可以确定电子设备A的目录A下缓存了有效的电子设备B的目录A下的元数据文件B,可以执行步骤S2107。When the electronic device A determines that the cached metadata file B is valid, the electronic device A may determine that the valid metadata file B under the directory A of the electronic device B is cached in the directory A of the electronic device A, and may execute step S2107.
当电子设备A确定缓存的元数据文件B无效时,电子设备A可以确定电子设备A的目录A下没有缓存有效的电子设备B的目录A下的元数据文件B,可以执行步骤S2103。When the electronic device A determines that the cached metadata file B is invalid, the electronic device A may determine that there is no valid metadata file B under the directory A of the electronic device B cached in the directory A of the electronic device A, and may execute step S2103.
S2103、电子设备A向电子设备B发出获取电子设备B的目录A下元数据文件B的请求;S2103, the electronic device A sends a request to the electronic device B to obtain the metadata file B under the directory A of the electronic device B;
S2104、电子设备B在电子设备B的读取记录中记录电子设备A的标识和读取元数据文件B的对应关系;S2104, the electronic device B records the correspondence between the identification of the electronic device A and the read metadata file B in the read record of the electronic device B;
S2105、电子设备B向电子设备A推送元数据文件B;S2105, the electronic device B pushes the metadata file B to the electronic device A;
S2106、电子设备A在电子设备A的目录A下缓存该元数据文件B;S2106, the electronic device A caches the metadata file B under the directory A of the electronic device A;
步骤S2103~S2106与步骤S19031~S19034类似,可以参考步骤S19031~S19034中的描述,此处不再赘述。Steps S2103-S2106 are similar to steps S19031-S19034, and the description in steps S19031-S19034 can be referred to, and details are not repeated here.
S2107、电子设备A根据元数据文件B中文件B的索引路径,请求获取电子设备B中目录A下的文件B;S2107, the electronic device A requests to obtain the file B under the directory A in the electronic device B according to the index path of the file B in the metadata file B;
电子设备A在确定电子设备A下缓存了有效的元数据文件B后,可以根据该元数据文件B中记录的元数据信息,确定文件B的索引路径。按照该索引路径,向电子设备B请求获取电子设备B中目录A下的文件B。After determining that a valid metadata file B is cached under the electronic device A, the electronic device A can determine the index path of the file B according to the metadata information recorded in the metadata file B. According to the index path, the electronic device B is requested to obtain the file B under the directory A in the electronic device B.
S2108、电子设备B向电子设备A发送文件B;S2108, electronic device B sends file B to electronic device A;
电子设备B在接收到电子设备A发送的获取文件B的请求后,可以向电子设备A发送文件B。After receiving the request for acquiring file B sent by electronic device A, electronic device B may send file B to electronic device A.
S2109、电子设备A在电子设备A的目录A下缓存文件B。S2109 , the electronic device A caches the file B under the directory A of the electronic device A.
可以理解的是,电子设备A接收到电子设备发送的文件B后,可以在电子设备A的目录A下缓存文件B。It can be understood that, after receiving the file B sent by the electronic device, the electronic device A can cache the file B in the directory A of the electronic device A.
可选的,电子设备也可以不执行上述步骤S2107~S2109,在目录A下缓存该元数据文件B后,显示该元数据文件B中记录的文件时,向电子设备B获取该元数据文件B中记录的所有文件的真实数据。在目录A下缓存该元数据B中记录的所有文件。这种情况下,电子设备A的目录A下也可以缓存到电子设备B的目录A下的文件B。Optionally, the electronic device may not perform the above steps S2107 to S2109, and after caching the metadata file B in the directory A, when displaying the file recorded in the metadata file B, obtain the metadata file B from the electronic device B. real data for all files recorded in . All files recorded in this metadata B are cached under directory A. In this case, the file B under the directory A of the electronic device B may also be cached under the directory A of the electronic device A.
示例性的,如图22所示,为本申请实施例中一组用户界面示意图。Exemplarily, as shown in FIG. 22 , it is a schematic diagram of a group of user interfaces in this embodiment of the present application.
如图22中的(a)所示,电子设备A的目录A下缓存了电子设备B的目录A下的元数据文件B以及电子设备C的目录A下的元数据文件C,并显示出元数据文件B中记录的文件B和元数据文件C中记录的文件C1和文件C2。但是显示的其他设备中的这些文件为根据元数据文件中的元数据信息生成,是没有实际数据的链接文件。As shown in (a) of FIG. 22 , the metadata file B under the directory A of the electronic device B and the metadata file C under the directory A of the electronic device C are cached under the directory A of the electronic device A, and the metadata file C under the directory A of the electronic device C is cached. File B recorded in data file B and file C1 and file C2 recorded in metadata file C. However, these files in other devices displayed are generated based on the metadata information in the metadata file, and are linked files without actual data.
在电子设备A接收到访问电子设备B的目录A下文件B的请求后,电子设备A可以按 照上述S2101~S2109的步骤,缓存文件B的实际数据到电子设备A的目录A下。如图22中的(b)所示,电子设备A缓存了文件B到目录A下,此时电子设备A的目录A下的文件B中具有实际数据,可直接访问或修改,不再是没有实际数据的链接文件。After electronic device A receives a request to access file B in directory A of electronic device B, electronic device A can cache the actual data of file B in directory A of electronic device A according to the steps of S2101-S2109. As shown in (b) in Figure 22, the electronic device A caches the file B under the directory A. At this time, the file B under the directory A of the electronic device A has actual data, which can be directly accessed or modified. Link file for actual data.
(5)修改缓存的其他电子设备中的文件:(5) Modify cached files in other electronic devices:
下面以分布式文件系统中的电子设备A修改电子设备A的目录A下缓存的电子设备B的目录A下的文件B的过程为例,对本申请实施例中的元数据管理方法进行说明。The following describes the metadata management method in the embodiment of the present application by taking the process of modifying the file B in the directory A of the electronic device B cached in the directory A of the electronic device A by the electronic device A in the distributed file system as an example.
可以理解的是,在执行如图23所示的步骤之前,分布式文件系统中的电子设备均已执行过上述步骤S1501。因此,电子设备A在该目录A下维护有一个元数据文件A,该元数据文件A中存储了该电子设备A的目录A下其他所有文件的元数据信息。电子设备B在电子设备B的目录A下维护有一个元数据文件B,该元数据文件B中存储了该电子设备B的目录A下其他所有文件的元数据信息。It can be understood that, before the steps shown in FIG. 23 are executed, the electronic devices in the distributed file system have all executed the above step S1501. Therefore, the electronic device A maintains a metadata file A under the directory A, and the metadata file A stores the metadata information of all other files in the directory A of the electronic device A. The electronic device B maintains a metadata file B under the directory A of the electronic device B, and the metadata file B stores metadata information of all other files in the directory A of the electronic device B.
可选的,电子设备A在执行如图23所示的步骤之前,可以已经执行过步骤S2101~S2104,也可以没有执行过步骤S2101~S2104,此处不作限定。Optionally, before the electronic device A performs the steps shown in FIG. 23 , steps S2101 to S2104 may be performed, or steps S2101 to S2104 may not be performed, which is not limited here.
可以理解的是,电子设备A在执行如图23所示的步骤之前,已经在电子设备A的目录A下缓存了电子设备B的目录A下的文件B。It can be understood that, before the electronic device A performs the steps shown in FIG. 23 , the file B under the directory A of the electronic device B has been cached under the directory A of the electronic device A.
如图23所示,为本申请实施例中元数据管理方法另一个信令交互示意图。As shown in FIG. 23 , it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
S2301、电子设备A修改电子设备A中目录A下缓存的电子设备B中目录A下的文件B并保存;S2301, the electronic device A modifies and saves the file B under the directory A in the electronic device B cached under the directory A in the electronic device A;
S2302、电子设备A发送更新后的文件B到电子设备B;S2302, the electronic device A sends the updated file B to the electronic device B;
S2303、电子设备B更新电子设备B的目录A下的文件B;S2303, the electronic device B updates the file B under the directory A of the electronic device B;
S2304、电子设备B在电子设备B的目录A下的元数据文件B中更新文件B的元数据信息;S2304, the electronic device B updates the metadata information of the file B in the metadata file B under the directory A of the electronic device B;
对于文件修改引起元数据文件更新的描述,可以参阅上述术语介绍(2)元数据文件中2.2元数据文件的使用和更新中图4所示的描述,此处不再赘述。For the description of metadata file update caused by file modification, please refer to the description shown in FIG. 4 in 2.2 Use and Update of Metadata File in the above term introduction (2) Metadata file, which will not be repeated here.
S2305、电子设备B确定分布式文件系统中是否存在请求了元数据文件B且在线的电子设备;S2305, the electronic device B determines whether there is an online electronic device that has requested the metadata file B in the distributed file system;
S2306、电子设备B推送元数据文件B给该分布式文件系统中请求获取了元数据文件B且在线的电子设备;S2306, the electronic device B pushes the metadata file B to the electronic device that requests to obtain the metadata file B and is online in the distributed file system;
S2307、电子设备B删除读取记录中请求获取了元数据文件B但不在线的电子设备读取元数据文件B的记录;S2307, the electronic device B deletes the record of requesting to obtain the metadata file B but is not online to read the metadata file B in the read record;
S2308、电子设备B等待执行新的指令;S2308, the electronic device B waits for a new instruction to be executed;
步骤S2305~S2307与步骤S1704~S1707类似,可以参考对步骤S1704~S1707的描述,此处不再赘述。Steps S2305-S2307 are similar to steps S1704-S1707, and reference may be made to the description of steps S1704-S1707, which will not be repeated here.
S2309、电子设备A更新电子设备A中目录A下缓存的元数据文件B。S2309 , the electronic device A updates the metadata file B cached under the directory A in the electronic device A.
在电子设备B确定分布式文件系统中电子设备A请求过电子设备B的元数据文件B时,电子设备B会向电子设备A发送更新了的元数据文件B。电子设备A接收到该更新的元数据文件B后,会更新电子设备A中目录A下缓存的元数据文件B。When the electronic device B determines that the electronic device A has requested the metadata file B of the electronic device B in the distributed file system, the electronic device B sends the updated metadata file B to the electronic device A. After receiving the updated metadata file B, the electronic device A will update the metadata file B cached under the directory A in the electronic device A.
示例性的,结合图22所示的用户界面,如图24所示,为本申请实施例的另一组用户界面示意图。Exemplarily, with reference to the user interface shown in FIG. 22 , as shown in FIG. 24 , it is another set of schematic diagrams of user interfaces in this embodiment of the present application.
如图24中的(a)所示,用户可以对电子设备A的目录A下缓存的文件B进行修改并保存,该文件B可以更新为文件B1。电子设备A可以发送更新后的文件B1到电子设备B,指示文件B已经更新为文件B1。As shown in (a) of FIG. 24 , the user can modify and save the file B cached in the directory A of the electronic device A, and the file B can be updated to the file B1. Electronic device A may send the updated file B1 to electronic device B, indicating that file B has been updated to file B1.
如图24中的(b)所示,电子设备B接收文件B1后,可以将电子设备B的目录A下的文件B更新为文件B1,并更新该目录A下元数据文件B中记录的文件B的元数据信息。电子设备B的目录A下的元数据文件B更新为元数据文件B1。电子设备B通过读取记录确定此前电子设备A请求获取过电子设备B的元数据文件B。将更新后的元数据文件B1发送给电子设备A,指示元数据文件B更新成了元数据文件B1。As shown in (b) of FIG. 24 , after receiving the file B1, the electronic device B can update the file B under the directory A of the electronic device B to the file B1, and update the file recorded in the metadata file B under the directory A B's metadata information. The metadata file B under the directory A of the electronic device B is updated to the metadata file B1. The electronic device B determines by reading the records that the electronic device A has requested to obtain the metadata file B of the electronic device B before. The updated metadata file B1 is sent to the electronic device A, indicating that the metadata file B is updated to the metadata file B1.
如图24中的(c)所示,电子设备A接收到元数据文件B1后,在电子设备A的目录A下将元数据文件B更新成元数据文件B1。As shown in (c) of FIG. 24 , after receiving the metadata file B1, the electronic device A updates the metadata file B under the directory A of the electronic device A to the metadata file B1.
(6)电子设备下线后和上线前的元数据文件清理:(6) Metadata file cleaning after the electronic device goes offline and before it goes online:
可以理解的是,为了确保分布式文件系统中电子设备缓存的其他电子设备的元数据文件有效,电子设备可以在下线后或上线前对缓存的其他电子设备的元数据文件进行清理。在需要时再重新获取最新的元数据文件。It can be understood that, in order to ensure that the metadata files of other electronic devices cached by the electronic device in the distributed file system are valid, the electronic device may clean up the cached metadata files of other electronic devices after going offline or before going online. Re-fetch the latest metadata file when needed.
下面以分布式文件系统中的电子设备A下线后或上线前清理元数据文件过程为例,对本申请实施例中的元数据管理方法进行说明。The following describes the metadata management method in the embodiment of the present application by taking the process of cleaning up the metadata file after the electronic device A in the distributed file system goes offline or before going online as an example.
如图25所示,为本申请实施例中元数据管理方法另一个信令交互示意图。As shown in FIG. 25 , it is another schematic diagram of signaling interaction of the metadata management method in the embodiment of the present application.
阶段一:下线后的元数据文件清理:Phase 1: Metadata file cleanup after offline:
S2501、电子设备A断开与分布式文件系统的网络连接;S2501, the electronic device A disconnects the network connection with the distributed file system;
可以理解的是,电子设备A断开与分布式文件系统的网络连接可以有很多种情况,例如电子设备A退出建立分布式文件系统的网络账号,或电子设备A断开与建立分布式文件系统的局域网网络的连接,或电子设备A断开所有网络连接等等,此处不作限定。It can be understood that there may be many situations when the electronic device A disconnects the network connection with the distributed file system, for example, the electronic device A quits the network account for establishing the distributed file system, or the electronic device A disconnects and establishes the distributed file system. The connection to the local area network network, or the electronic device A disconnects all network connections, etc., which are not limited here.
S2502、电子设备A清理文件系统中各目录下缓存的其他电子设备的元数据文件;S2502, the electronic device A cleans up the metadata files of other electronic devices cached in each directory in the file system;
电子设备A断开与分布式文件系统的网络连接后,可以清理分布式文件系统挂载的文件系统中各目录下缓存的其他电子设备的元数据文件。After the electronic device A is disconnected from the network connection with the distributed file system, the metadata files of other electronic devices cached in each directory in the file system mounted by the distributed file system can be cleaned up.
可选的,电子设备A还可以清理各目录下缓存的其他电子设备的文件,此处不作限定。Optionally, the electronic device A may also clean up files of other electronic devices cached in each directory, which is not limited here.
阶段二:上线前的元数据文件清理:Stage 2: Metadata file cleanup before going live:
S2503、电子设备A接收到接入分布式文件系统的请求;S2503, the electronic device A receives a request for accessing the distributed file system;
可以理解的是,电子设备A接收接入分布式文件系统的请求可以有多种方式,例如可以为登陆建立分布式文件系统的网络账号,或接入建立分布式文件系统的局域网网络连接,或接收到分布式文件系统中电子设备发出的邀请加入信息等,此处不作限定。It can be understood that, the electronic device A can receive the request for accessing the distributed file system in various ways, for example, it can establish a network account of the distributed file system for logging in, or access the local area network network connection for establishing the distributed file system, or The invitation to join information sent by the electronic device in the distributed file system is received, which is not limited here.
S2504、电子设备A清理文件系统中各目录下缓存的其他电子设备的元数据文件;S2504, the electronic device A cleans up the metadata files of other electronic devices cached in each directory in the file system;
电子设备接收到接入分布式文件系统的请求后,可以先清理会被分布式文件系统挂载的文件系统中各目录下缓存的其他电子设备的元数据文件。After receiving the request to access the distributed file system, the electronic device may first clean up the metadata files of other electronic devices cached in each directory in the file system to be mounted by the distributed file system.
可选的,电子设备A还可以清理各目录下缓存的其他电子设备的文件,此处不作限定。Optionally, the electronic device A may also clean up files of other electronic devices cached in each directory, which is not limited here.
S2505、电子设备A接入分布式文件系统。S2505, the electronic device A is connected to the distributed file system.
在清理了各目录下缓存的其他电子设备的元数据文件后,电子设备A可以接入分布式文件系统。然后可以根据访问需求,在分布式文件系统中缓存需要的元数据文件到相应目录。After cleaning the metadata files of other electronic devices cached in each directory, electronic device A can access the distributed file system. Then, according to the access requirements, the required metadata files can be cached in the corresponding directory in the distributed file system.
可以理解的是,根据实际需要、出厂设置或用户设置的不同。在一些实施例中,阶段一 的步骤S2501~S2502可以执行,也可以不执行,此处不作限定。在一些实施例中,阶段二的步骤S2503~S2505可以执行,也可以不执行,此处不作限定。It can be understood that it is different according to actual needs, factory settings or user settings. In some embodiments, steps S2501-S2502 of Phase 1 may or may not be performed, which is not limited here. In some embodiments, steps S2503 to S2505 of the second stage may or may not be performed, which is not limited here.
示例性的,图26为本申请实施例中另一组用户界面示意图。Exemplarily, FIG. 26 is a schematic diagram of another group of user interfaces in this embodiment of the present application.
如图26中的(a)所示,电子设备A的目录A下可以缓存有分布式文件系统中电子设备B的目录A下的元数据文件B和电子设备C的目录A下的元数据文件C。该电子设备A的目录A下还可以缓存有电子设备B中目录A下的文件B,以及根据元数据文件C显示出的文件C1和文件C2。As shown in (a) of FIG. 26 , the directory A of the electronic device A may cache the metadata file B under the directory A of the electronic device B and the metadata file under the directory A of the electronic device C in the distributed file system C. The directory A of the electronic device A may further cache the file B under the directory A in the electronic device B, as well as the file C1 and the file C2 displayed according to the metadata file C.
如图26中的(b)所示,在电子设备A下线后,和/或在电子设备A上线前,根据上述步骤S2501~S2505,电子设备A可以将缓存的电子设备B中的元数据文件B和电子设备C中的元数据文件C清理掉。同时也可以将缓存的电子设备B中的文件B,以及根据元数据文件C显示出来的文件C1和文件C2也清理掉。仅保留电子设备A的目录A下自己电子设备中的文件。As shown in (b) of FIG. 26 , after the electronic device A goes offline, and/or before the electronic device A goes online, according to the above steps S2501 to S2505 , the electronic device A can store the cached metadata in the electronic device B Metadata file C in file B and electronic device C is cleaned up. At the same time, the cached file B in the electronic device B, and the file C1 and the file C2 displayed according to the metadata file C can also be cleaned up. Only keep the files in the own electronic device under the directory A of the electronic device A.
作为本申请另一个实施例,下面以电子设备A访问电子设备B中路径为“/A/B/file.txt”的文件的过程为例,对本申请实施例中电子设备访问分布式文件系统中多层目录中的文件的过程进行说明:As another embodiment of the present application, the following takes the process of electronic device A accessing a file with a path of "/A/B/file.txt" in electronic device B as an example to describe how the electronic device accesses the distributed file system in the embodiment of the present application. The procedure for files in a multi-level directory is explained:
假设电子设备A中的第一本地文件系统刚被分布式文件系统挂载,第一本地文件系统中还没有缓存被分布式文件系统挂载的其他电子设备的本地文件系统中的元数据文件。则访问过程可以有以下两种可选方案:Assuming that the first local file system in the electronic device A has just been mounted by the distributed file system, the metadata files in the local file systems of other electronic devices mounted by the distributed file system have not been cached in the first local file system. Then the access process can have the following two options:
方案1:plan 1:
电子设备A确定本地文件系统中存在“/A/B/file.txt”,则直接返回该本地文件file.txt。Electronic device A determines that "/A/B/file.txt" exists in the local file system, and directly returns the local file file.txt.
否则,电子设备A可以向分布式文件系统中的其他电子设备请求路径“/”下的元数据文件,例如向电子设备B请求路径“/”下的元数据文件。Otherwise, the electronic device A may request the metadata file under the path "/" from other electronic devices in the distributed file system, for example, request the electronic device B for the metadata file under the path "/".
解析这些元数据文件,分析哪些电子设备的元数据文件中包含目录A的元数据信息,则可以确定这些电子设备的本地文件系统中包含目录A。再向这些含有目录A的电子设备请求路径“/A/”下的元数据文件(如果都没有则返回路径错误;如果有元数据文件存在在路径“/A/”下,但目录A在电子设备A的本地文件系统中不存在则在该电子设备A的本地文件系统中创建目录A)。By parsing these metadata files, and analyzing the metadata files of which electronic devices contain the metadata information of the directory A, it can be determined that the local file system of these electronic devices contains the directory A. Then request the metadata files under the path "/A/" from these electronic devices containing the directory A (if there is none, return the path error; if there is a metadata file under the path "/A/", but the directory A is in the electronic device. If the local file system of the device A does not exist, the directory A) is created in the local file system of the electronic device A).
解析这些元数据文件,分析哪些电子设备的元数据文件中包含目录B的元数据信息,再向这些含有目录B的电子设备请求路径“/A/B/”下的元数据文件。These metadata files are parsed, the metadata files of which electronic devices contain the metadata information of the directory B are analyzed, and the metadata files under the path "/A/B/" are requested from these electronic devices containing the directory B.
解析这些元数据文件,分析哪些电子设备的元数据文件中包含有文件“file.txt”的元数据信息。These metadata files are parsed, and the metadata files of which electronic devices contain metadata information of the file "file.txt" are analyzed.
若存在多个元数据文件中含有文件“file.txt”的元数据信息,则可以返回其中一个电子设备上的该名称文件(例如设备号最小的电子设备上的该名称文件),也可以返回所有电子设备上的该名称文件,此处不作限定。If there are multiple metadata files containing the metadata information of the file "file.txt", the name file on one of the electronic devices can be returned (for example, the name file on the electronic device with the smallest device number), or the name file can be returned. This name file on all electronic devices is not limited here.
访问文件“/A/B/file.txt”过程中,电子设备A可以将访问过的其他电子设备的元数据文件缓存至该电子设备A的本地文件系统,下次访问路径“/”、“/A/”“/A/B/”下的文件时,可以访问本地缓存的相应的元数据文件以加速访问过程。In the process of accessing the file "/A/B/file.txt", the electronic device A can cache the metadata files of other electronic devices that have been accessed to the local file system of the electronic device A, and the next access paths are "/", " /A/" and "/A/B/", you can access the corresponding metadata file cached locally to speed up the access process.
方案2:Scenario 2:
电子设备A确定本地文件系统中存在“/A/B/file.txt”,则直接返回该本地文件file.txt。Electronic device A determines that "/A/B/file.txt" exists in the local file system, and directly returns the local file file.txt.
否则,电子设备A向其他电子设备发送文件路径“/A/B/file.txt”,在该路径“/A/B/”中含有“file.txt”的电子设备返回路径“/A/B/”下的元数据文件。电子设备A根据返回的元数据文件,访问文件“file.txt”。Otherwise, the electronic device A sends the file path "/A/B/file.txt" to other electronic devices, and the electronic device containing "file.txt" in the path "/A/B/" returns the path "/A/B" /" metadata file. The electronic device A accesses the file "file.txt" according to the returned metadata file.
若存在多个元数据文件中含有文件“file.txt”的元数据信息,则可以返回其中一个电子设备上的该名称文件(例如设备号最小的电子设备上的该名称文件),也可以返回所有电子设备上的该名称文件,此处不作限定。If there are multiple metadata files containing the metadata information of the file "file.txt", the name file on one of the electronic devices can be returned (for example, the name file on the electronic device with the smallest device number), or the name file can be returned. This name file on all electronic devices is not limited here.
结合上述实施例,本申请的一些实施例中,电子设备A可以被称为第二电子设备,电子设备B可以被称为第一电子设备。In combination with the foregoing embodiments, in some embodiments of the present application, electronic device A may be referred to as a second electronic device, and electronic device B may be referred to as a first electronic device.
本申请的一些实施例中,电子设备B中被分布式文件系统挂载的文件系统可以被称为第一本地文件系统,电子设备A中被分布式文件系统挂载的文件系统可以被称为第二本地文件系统。In some embodiments of the present application, the file system mounted by the distributed file system in the electronic device B may be referred to as the first local file system, and the file system mounted by the distributed file system in the electronic device A may be referred to as The second local file system.
本申请的一些实施例中,电子设备B中的目录A中的文件B可以被称为第一本地文件;电子设备B中的目录A中的元数据文件B可以被称为第二本地文件。In some embodiments of the present application, the file B in the directory A in the electronic device B may be referred to as the first local file; the metadata file B in the directory A in the electronic device B may be referred to as the second local file.
通过上述元数据管理方法,可以在无中心节点的分布式文件系统中的一个电子设备中显示另一个电子设备中的文件。在分布式文件系统中,假设电子设备A的某个路径(例如路径P)下存在文件X,而另一个电子设备B的相同路径P下存在同名文件X。在电子设备A中路径P下显示分布式文件系统中该路径P下所有文件时,电子设备A需要识别分布式文件系统中所有电子设备的路径P下的同名文件,并且修改同名文件的文件名,以使得分布式文件系统的路径P下所有文件的文件名唯一。Through the above metadata management method, a file in one electronic device in a distributed file system without a central node can be displayed in another electronic device. In the distributed file system, it is assumed that a file X exists in a certain path (eg, path P) of electronic device A, and a file X with the same name exists in the same path P of another electronic device B. When displaying all files under the path P in the distributed file system in the electronic device A, the electronic device A needs to identify the files with the same name under the path P of all electronic devices in the distributed file system, and modify the file names of the files with the same name , so that the file names of all files under the path P of the distributed file system are unique.
对于现有的有中心节点的分布式文件系统,由中心节点维护分布式文件系统中所有文件的元数据信息。在有电子设备接入该有中心节点的分布式文件系统时,接入的电子设备将自己的各路径下的文件的元数据信息同步到中心节点的过程中,中心节点会检查是否与分布式文件系统中各路径下的文件存在同名文件,从而保证同一个路径下不出现同名文件。For an existing distributed file system with a central node, the central node maintains the metadata information of all files in the distributed file system. When an electronic device accesses the distributed file system with a central node, the connected electronic device synchronizes the metadata information of the files under its own paths to the central node, and the central node will check whether it is compatible with the distributed file system. Files with the same name exist in each path in the file system, so as to ensure that files with the same name do not appear in the same path.
而对于无中心节点的分布式文件系统,分布式文件系统中的任何设备在任何时间都有可能下线,没有中心节点来管理分布式文件系统的全局信息,目前还没有较好的能适用的同名文件识别方法。For a distributed file system without a central node, any device in the distributed file system may go offline at any time, and there is no central node to manage the global information of the distributed file system. At present, there is no better applicable A method for identifying files with the same name.
而本申请实施例中提供的同名文件识别方法,能在无中心节点的分布式文件系统中,快速的确定各电子设备的一个路径下是否存在同名文件。However, the method for identifying a file with the same name provided in the embodiment of the present application can quickly determine whether a file with the same name exists in a path of each electronic device in a distributed file system without a central node.
二、同名文件识别方法:Second, the same name file identification method:
下面先对本申请实施例涉及同名文件识别方法的相关术语及概念进行介绍。The following first introduces related terms and concepts related to the method for identifying files with the same name in the embodiments of the present application.
(1)有中心节点的分布式文件系统:(1) Distributed file system with central node:
有中心节点的分布式文件系统通常由一个元数据服务器和若干个数据服务器组成,元数据服务器作为中心节点,存储元数据信息,而数据服务器管理存储分布式文件系统中文件的实际数据。当用户访问文件数据时,需要先访问作为中心节点的元数据服务器获取文件的基本信息和数据索引信息,再根据基本信息和数据索引信息访问数据服务器获取文件数据。A distributed file system with a central node usually consists of a metadata server and several data servers. The metadata server acts as a central node to store metadata information, while the data server manages and stores the actual data of files in the distributed file system. When users access file data, they need to first access the metadata server as the central node to obtain the basic information and data index information of the file, and then access the data server to obtain file data according to the basic information and data index information.
图10为有中心节点的分布式文件系统的一个示例性场景示意图。组成有中心节点的分布式文件系统的设备A、设备B和设备C,都需要通过作为中心节点的元数据服务器才能访问数据服务器中的文件。设备A、设备B和设备C都可以分别作为一个数据服务器,而作为中 心节点的元数据服务器可以是其中的一个电子设备,也可以是一个独立的服务器。当作为中心节点的元数据服务器下线时,该有中心节点的分布式文件系统的服务就不可用了,各电子设备不再能读取到其他电子设备中的文件。FIG. 10 is a schematic diagram of an exemplary scenario of a distributed file system with a central node. Device A, Device B, and Device C that form a distributed file system with a central node all need to pass through the metadata server as the central node to access the files in the data server. Device A, Device B, and Device C can all be used as a data server respectively, and the metadata server as the central node can be one of the electronic devices or an independent server. When the metadata server serving as the central node goes offline, the service of the distributed file system with the central node is unavailable, and each electronic device can no longer read files in other electronic devices.
(2)无中心节点的分布式文件系统:(2) Distributed file system without central node:
本申请实施例中同名文件识别方法,可以适用于无中心节点的分布式文件系统。在无中心节点的分布式文件系统中,由各个电子设备自己管理其他电子设备中文件的元数据信息。可以直接根据自己管理的其他电子设备中文件的元数据信息,显示或访问其他电子设备中的文件,而不需要通过中心节点。The method for identifying a file with the same name in the embodiment of the present application can be applied to a distributed file system without a central node. In a distributed file system without a central node, each electronic device manages metadata information of files in other electronic devices by itself. Files in other electronic devices can be displayed or accessed directly according to the metadata information of files in other electronic devices managed by oneself without going through a central node.
图12为本申请实施例中无中心节点的分布式文件系统的一个示例性场景示意图。组成无中心节点的分布式文件系统的设备A、设备B、设备C、设备D和设备E分别自己管理其他电子设备中文件的元数据信息,可以直接显示或访问其他电子设备中存储的文件。例如,文件A存储在电子设备A中,文件B存储在电子设备B中,文件C存储在电子设备C中。电子设备A中可以存储有该文件B和文件C的元数据信息,从而可以直接显示或访问该文件B或文件C。同理,电子设备D中也可以存储有该文件A、文件B和文件C的元数据信息,从而可以直接显示或访问该文件A、文件B或文件C。FIG. 12 is a schematic diagram of an exemplary scenario of a distributed file system without a central node in an embodiment of the present application. Device A, Device B, Device C, Device D, and Device E, which constitute the distributed file system without a central node, manage metadata information of files in other electronic devices by themselves, and can directly display or access files stored in other electronic devices. For example, file A is stored in electronic device A, file B is stored in electronic device B, and file C is stored in electronic device C. The metadata information of the file B and the file C can be stored in the electronic device A, so that the file B or the file C can be directly displayed or accessed. Similarly, the metadata information of the file A, the file B, and the file C may also be stored in the electronic device D, so that the file A, the file B, or the file C can be directly displayed or accessed.
(3)分布式文件系统中的文件显示:(3) The file display in the distributed file system:
分布式文件系统为分布在各电子设备上任意位置的资源提供了一个逻辑上的文件系统结构,从而使访问分布在各电子设备上的共享文件更加简便。The distributed file system provides a logical file system structure for resources distributed at any position on each electronic device, thereby making it easier to access shared files distributed on each electronic device.
在分布式文件系统中的某个电子设备上,在显示被分布式文件系统挂载的文件系统中某个目录(或称为某个路径)下的文件时,除了可以显示本电子设备中在该目录下存储的文件,还可以显示分布式文件系统中其他电子设备中在该目录下的文件。On an electronic device in a distributed file system, when displaying a file under a certain directory (or a certain path) in the file system mounted by the distributed file system, in addition to displaying the file in the electronic device The files stored in this directory can also display the files in this directory in other electronic devices in the distributed file system.
示例性的,图27为本申请实施例中一组用户界面示意图。Exemplarily, FIG. 27 is a schematic diagram of a group of user interfaces in this embodiment of the present application.
图27中的(a)示出了电子设备A中的用户界面310。该用户界面310为显示电子设备A中被分布式文件系统挂载的文件系统中根目录下文件的一个用户界面。可见,该电子设备A的根目录下存储有文件1和目录A。(a) in FIG. 27 shows the user interface 310 in the electronic device A. As shown in FIG. The user interface 310 is a user interface for displaying files in the root directory of the file system mounted by the distributed file system in the electronic device A. It can be seen that file 1 and directory A are stored in the root directory of the electronic device A.
图27中的(b)示出了电子设备B中用户界面320。该用户界面320为显示电子设备B中被分布式文件系统挂载的文件系统中根目录下文件的一个用户界面。可见,该电子设备B的根目录下存储有文件2、文件3和目录A。(b) of FIG. 27 shows the user interface 320 in the electronic device B. As shown in FIG. The user interface 320 is a user interface for displaying files in the root directory of the file system mounted by the distributed file system in the electronic device B. It can be seen that file 2, file 3 and directory A are stored in the root directory of the electronic device B.
图27中的(c)示出了电子设备A和电子设备B组成分布式文件系统后,电子设备A中的用户界面310。此时,该用户界面310中除了可以显示出该电子设备A中在该根目录下存储的文件1和目录A。还可以显示有电子设备B中在该根目录下存储的文件2、文件3。由于目录A表示相同路径,因此不重复显示。(c) of FIG. 27 shows the user interface 310 in the electronic device A after the electronic device A and the electronic device B form a distributed file system. At this time, the user interface 310 can display the file 1 and the directory A stored in the electronic device A under the root directory. The file 2 and file 3 stored in the root directory in the electronic device B may also be displayed. Since directory A represents the same path, it is not displayed repeatedly.
图中以长虚线表示显示出的文件2和文件3是其他电子设备中的文件,可以为链接文件,也可以为真实文件。链接文件中不包含文件的实际数据,为电子设备A根据文件2和文件3的元数据信息生成的文件。在本申请其他附图中,也可以以这种方式来表示,后续不再赘述。The long dashed lines in the figure indicate that the displayed files 2 and 3 are files in other electronic devices, which may be linked files or real files. The link file does not contain the actual data of the file, and is a file generated by the electronic device A according to the metadata information of the file 2 and the file 3. In other drawings of the present application, it can also be represented in this way, which will not be repeated in the following.
(4)布隆过滤器(Bloom Filter):(4) Bloom filter (Bloom Filter):
布隆过滤器是一种利用多哈希函数判断元素是否在集合中的算法。它是一种概率型数据结构,用于确定某样东西一定不存在或者可能存在,其返回的结果是概率性的。布隆过滤器 包含一个N个比特位的位数组和K个哈希函数。Bloom filter is an algorithm that uses multiple hash functions to determine whether an element is in a set. It is a probabilistic data structure used to determine that something must not exist or may exist, and the returned result is probabilistic. A bloom filter consists of a bit array of N bits and K hash functions.
图28为布隆过滤器位数组的一组状态示意图。下面结合图28对布隆过滤器的工作过程进行示例性描述:Figure 28 is a set of state diagrams of a Bloom filter bit array. The working process of the Bloom filter is exemplarily described below in conjunction with FIG. 28 :
示例性的,图28中的(a)为本申请实施例中布隆过滤器位数组的一个结构示意图。图28中以该布隆过滤器包含8个比特位的位数组和3个哈希函数为例。此时每个比特位的值均初始化为0。Exemplarily, (a) in FIG. 28 is a schematic structural diagram of a bloom filter bit array in an embodiment of the present application. In FIG. 28, the bloom filter includes an 8-bit bit array and 3 hash functions as an example. At this time, the value of each bit is initialized to 0.
如果需要映射一个值到布隆过滤器位数组中,则需要使用多个不同的哈希函数生成多个哈希值,并对每个生成的哈希值指向的布隆过滤器位数组中的一个比特位。If you need to map a value to the bloom filter bit array, you need to use multiple different hash functions to generate multiple hash values, and each generated hash value points to the bloom filter bit array in the bloom filter bit array. a bit.
例如对于值“filename”,使用三个不同的哈希函数(例如为Hash1、Hash2和Hash3)可以分别生成哈希值1、4、7。则可以将图28中的(a)所示的布隆过滤器位数组的状态转变为图28中的(b)所示的布隆过滤器位数组的状态:将第1个,第4个和第7个比特位的值置为1。For example for the value "filename", using three different hash functions (eg Hash1, Hash2 and Hash3) can generate hash values 1, 4, 7 respectively. Then the state of the bloom filter bit array shown in (a) in FIG. 28 can be changed to the state of the bloom filter bit array shown in (b) in FIG. 28: the first and fourth and the value of the 7th bit is set to 1.
再如对于值“shouji”,如果三个哈希函数返回的哈希值为3、4、8。则可以将图28中的(b)所示的布隆过滤器位数组的状态转变为图28中的(c)所示的布隆过滤器位数组的状态:将第3个,第4个和第8个比特位的值置为1。可以理解的是,第4个比特位由于两个值的哈希函数都返回了这个位置,因此它被覆盖了,第4个比特位的值仍为1。Another example is for the value "shouji", if the hash values returned by the three hash functions are 3, 4, and 8. Then the state of the bloom filter bit array shown in (b) in FIG. 28 can be changed to the state of the bloom filter bit array shown in (c) in FIG. 28 : change the third and fourth and the value of the 8th bit is set to 1. Understandably, the 4th bit is overwritten because the hash function of both values returns this position, and the 4th bit still has the value 1.
此时,图28中的(c)所示的布隆过滤器位数组记录了两个值“filename”和“shouji”的信息。At this time, the bloom filter bit array shown in (c) in FIG. 28 records information of two values "filename" and "shouji".
如果此时想查询“diannao”这个值是否存在,三个哈希函数返回的哈希值为1、5、8三个值。我们可以发现,第5个比特位上的值为0。说明已记录的值中没有任何一个值映射到了这个比特位上,因此,可以很确定“diannao”这个值不存在。If you want to query whether the value of "diannao" exists at this time, the hash values returned by the three hash functions are 1, 5, and 8. We can find that the value on the 5th bit is 0. It means that none of the recorded values is mapped to this bit, so it is pretty sure that the value "diannao" does not exist.
而若想查询“filename”这个值是否存在,三个哈希函数返回的哈希值一定为1、4、7。我们可以发现这三个比特位上的值均为1。因此,可以确定“filename”这个值可能存在。If you want to query whether the value of "filename" exists, the hash values returned by the three hash functions must be 1, 4, and 7. We can find that the values on these three bits are all 1. Therefore, it can be determined that the value "filename" may exist.
因为随着记录增加的值越来越多,被置为1的比特位也会越来越多。这样即使某个值没有被存储过,但是哈希函数返回的三个比特位也可能都被其他值置为了1。因此布隆过滤器返回的结果是概率性的。Because as more and more values are added to the record, more and more bits are set to 1. In this way, even if a value has not been stored, the three bits returned by the hash function may all be set to 1 by other values. Therefore, the results returned by the Bloom filter are probabilistic.
可见,位数组的比特位过少的布隆过滤器很快所有的比特位均为1,那么查询任何值都会返回可能存在,起不到过滤的目的。布隆过滤器位数组越长,其误报率越小。It can be seen that the Bloom filter with too few bits in the bit array will soon have all the bits set to 1, then query any value will return possible existence, which cannot achieve the purpose of filtering. The longer the bloom filter bit array, the lower its false positive rate.
哈希函数的个数越多,这布隆过滤器位数组的比特位置为1的速度越快,且布隆过滤器的效率越低。但若哈希函数的个数过少,则误报率会变高。The more the number of hash functions, the faster the bit position of the bloom filter bit array is 1, and the lower the efficiency of the bloom filter. However, if the number of hash functions is too small, the false positive rate will increase.
因此,需要根据实际需求,设定合适的位数组中比特位的数目和哈希函数的数目。Therefore, it is necessary to set an appropriate number of bits in the bit array and the number of hash functions according to actual requirements.
本申请实施例中,可以使用布隆过滤器确定各电子设备的相同目录下是否存在同名文件:In this embodiment of the present application, a Bloom filter can be used to determine whether a file with the same name exists in the same directory of each electronic device:
例如,若需要确定电子设备A和电子设备B的目录A下是否存在同名文件。则可以在电子设备A和电子设备B上布置参数相同的布隆过滤器(即使用的各个哈希函数相同,以及位数组的位数相同)。假设位数组的位数为N,哈希函数数量为K。For example, if it is necessary to determine whether a file with the same name exists in the directory A of the electronic device A and the electronic device B. Then, Bloom filters with the same parameters can be arranged on the electronic device A and the electronic device B (that is, the hash functions used are the same, and the number of bits of the bit array is the same). Suppose the number of bits in the bit array is N and the number of hash functions is K.
电子设备A可以将自己的目录A下所有文件名作为键值,通过K个哈希函数映射到布隆过滤器位数组BA;电子设备B可以将自己的目录A下所有文件名作为键值,通过K个哈希函数映射到布隆过滤器位数组BB。此时,可以将各电子设备的布隆过滤器位数组作为一个整体来进行判断。统计BA和BB相同位置的比特位同时为1的个数:Electronic device A can use all file names in its own directory A as key values, and map them to Bloom filter bit array BA through K hash functions; electronic device B can use all file names in its own directory A as key values, Map to Bloom filter bit array BB through K hash functions. In this case, the bloom filter bit array of each electronic device can be judged as a whole. Count the number of bits in the same position of BA and BB that are 1 at the same time:
图29为本申请实施例中将两个电子设备的布隆过滤器位数组进行比对的一个示例性场 景示意图。由于如果电子设备A和电子设备B的目录A下存在一个同名文件,则这个同名文件基于相同的K个哈希函数必然得到相同的K个哈希值,分别映射到BA和BB上。则会使得BA和BB中必然至少出有K个相同的比特位同时为1。因此:FIG. 29 is a schematic diagram of an exemplary scenario in which the Bloom filter bit arrays of two electronic devices are compared in an embodiment of the present application. Because if a file with the same name exists in the directory A of the electronic device A and the electronic device B, the file with the same name must obtain the same K hash values based on the same K hash functions, which are mapped to BA and BB respectively. Therefore, there must be at least K identical bits in BA and BB that are 1 at the same time. therefore:
若BA和BB相同位置的比特位同时为1的个数小于哈希函数的个数K,则表示电子设备A和电子设备B的目录A下不可能存在同名文件;If the number of bits in the same position of BA and BB that are 1 at the same time is less than the number K of the hash function, it means that there cannot be files with the same name in the directory A of the electronic device A and the electronic device B;
若BA和BB相同位置的比特位同时为1的个数大于或等于哈希函数的个数K,则说明电子设备A和电子设备B的目录A下可能存在同名文件。If the number of bits in the same position of BA and BB that are 1 at the same time is greater than or equal to the number K of the hash function, it means that there may be files with the same name in the directory A of the electronic device A and the electronic device B.
根据图27所示的分布式文件系统中的文件显示可知,分布式文件系统中一个电子设备可以在某个目录下显示其他电子设备中在该相同目录下的所有文件。这些电子设备的相同目录下可能存在同名文件,而文件系统中在显示时同一个目录下一般不允许存在同名文件。因此为了对用户显示不同文件名称,各电子设备需要进行同名文件检查并对同名文件进行重命名处理。可以理解的是,重命名指的是修改对用户显示的文件名,可以不修改文件存储的实际名称。According to the file display in the distributed file system shown in FIG. 27, one electronic device in the distributed file system can display all files in the same directory in other electronic devices under a certain directory. There may be files with the same name in the same directory of these electronic devices, and files with the same name are generally not allowed to exist in the same directory when displayed in the file system. Therefore, in order to display different file names to the user, each electronic device needs to check the files with the same name and rename the files with the same name. It can be understood that renaming refers to modifying the file name displayed to the user, and may not modify the actual name of the file storage.
下面以电子设备A和电子设备B的目录A中存在同名文件,电子设备A和电子设备B组成分布式文件系统后需要在电子设备A的目录A中显示电子设备B的目录A中的文件为例,进行示例性说明。In the following, a file with the same name exists in the directory A of the electronic device A and the electronic device B. After the electronic device A and the electronic device B form a distributed file system, the file in the directory A of the electronic device B needs to be displayed in the directory A of the electronic device A as For example, an exemplary description is given.
示例性的,图30为本申请实施例中另一组用户界面示意图。Exemplarily, FIG. 30 is a schematic diagram of another group of user interfaces in this embodiment of the present application.
图30中的(a)示出了电子设备A中的用户界面610。该用户界面610为显示电子设备A中被分布式文件系统挂载的文件系统中根目录下目录A中文件的一个用户界面。可见,该电子设备A的目录A中存储有文件名为文件1、文件2和文件3的文件。(a) in FIG. 30 shows the user interface 610 in the electronic device A. As shown in FIG. The user interface 610 is a user interface for displaying the files in the directory A under the root directory in the file system mounted by the distributed file system in the electronic device A. It can be seen that files with file names of file 1, file 2 and file 3 are stored in the directory A of the electronic device A.
图30中的(b)示出了电子设备B中的用户界面620。该用户界面620为显示电子设备B中被分布式文件系统挂载的文件系统中根目录下目录A中文件的一个用户界面。可见,该电子设备B的目录A中存储有文件名为文件1、文件4和文件5的文件。(b) of FIG. 30 shows the user interface 620 in the electronic device B. As shown in FIG. The user interface 620 is a user interface for displaying the files in the directory A under the root directory in the file system mounted by the distributed file system in the electronic device B. It can be seen that files with file names of file 1, file 4 and file 5 are stored in the directory A of the electronic device B.
图30中的(c)示出了电子设备A和电子设备B组成分布式文件系统后,电子设备A中的用户界面610。此时,该用户界面610中不仅需要显示已有的文件名为文件1、文件2和文件3的文件,还需要显示电子设备B中目录A下文件名为文件1、文件4和文件5的文件。电子设备A可以通过同名文件识别方法,识别出电子设备B中目录A下与电子设备A的目录A中存在一个同名文件:文件1。因此,电子设备A可以将电子设备B中该目录A下的该文件1重命名为文件1-B。(c) of FIG. 30 shows the user interface 610 in electronic device A after electronic device A and electronic device B form a distributed file system. At this time, the user interface 610 not only needs to display the existing files named File 1, File 2 and File 3, but also needs to display the files named File 1, File 4 and File 5 in the directory A in the electronic device B. document. The electronic device A can recognize that there is a file with the same name in the directory A of the electronic device B and the directory A of the electronic device A: file 1 through the same-name file identification method. Therefore, the electronic device A can rename the file 1 under the directory A in the electronic device B to file 1-B.
现有技术中,如图10所示,在有中心节点的分布式文件系统中,由作为中心节点的元数据服务器来进行各目录下的同名文件识别,从而保障相同目录下不存在同名文件。然而,在无中心节点的分布式文件系统中,由于没有中心节点,因此,不能再使用该方式来进行同名文件识别。In the prior art, as shown in FIG. 10 , in a distributed file system with a central node, the metadata server as the central node identifies files with the same name in each directory, thereby ensuring that no files with the same name exist in the same directory. However, in a distributed file system without a central node, since there is no central node, this method cannot be used to identify files with the same name.
在另一种同名文件的识别方式中,若需要显示无中心节点的分布式文件系统中某个目录下的全部文件时,可以将所有电子设备中该目录下的每一个文件的文件名两两比较以判断是否相同。假设分布式文件系统由3个电子设备组成:电子设备A、电子设备B和电子设备C。3个电子设备在分布式文件系统的目录A下各有5个文件。若电子设备A需要显示目录A下的所有文件,需要判断电子设备B和电子设备C在该目录A下是否存在同名文件。则电子设备A需要先分别将电子设备A的目录A下的5个文件一一与电子设备B的目录A下的5个 文件的文件名进行比较,共比较25次得到结果。然后,再将电子设备A的目录A下的5个文件一一与电子设备C的目录A下的5个文件的文件名进行比较,再次比较25次得到结果。最后,再将电子设备B的目录A下的5个文件一一与电子设备C的目录A下的5个文件的文件名进行比较,再次比较25次得到结果。总计比较75次才能得到结果。In another way of identifying files with the same name, if it is necessary to display all files in a directory in a distributed file system without a central node, the file name of each file in the directory in all electronic devices can be displayed in pairs. Compare to see if they are the same. It is assumed that the distributed file system consists of 3 electronic devices: electronic device A, electronic device B, and electronic device C. The three electronic devices each have five files in the directory A of the distributed file system. If electronic device A needs to display all files in directory A, it is necessary to determine whether electronic device B and electronic device C have files with the same name in directory A. Then the electronic device A needs to compare the file names of the five files under the directory A of the electronic device A with the file names of the five files under the directory A of the electronic device B respectively, and compare the results 25 times in total. Then, compare the file names of the five files under the directory A of the electronic device A with the file names of the five files under the directory A of the electronic device C, and compare them again 25 times to obtain the result. Finally, compare the file names of the five files under the directory A of the electronic device B with the file names of the five files under the directory A of the electronic device C, and compare them again 25 times to obtain the result. A total of 75 comparisons are required to get the result.
而在实际应用中,显示分布式文件系统某路径下所有文件为高频次操作,分布式文件系统中会有更多个电子设备,各电子设备的目录下会有非常多的文件,采用该方式进行同名文件识别需要花费过多的时间,并占用过多的资源。In practical applications, it is shown that all files in a certain path of the distributed file system are high-frequency operations, there will be more electronic devices in the distributed file system, and there will be a lot of files in the directory of each electronic device. It takes too much time and takes up too many resources to identify files with the same name.
而本申请实施例中的同名文件识别方法,可以采用布隆过滤器对无中心节点的分布式文件系统中多个电子设备中同目录下存在同名文件的可能性进行整体判断,得到一定没有同名文件和可能存在同名文件的结果,在根据整体判断的结果进行后续处理。由于各电子设备中同目录下存在同名文件的情况并不是非常多,因此,在大多数情况下都能直接通过该整体判断得到同名文件识别的结果,即使没有得到最终结果,也能显著的缩小进行同名文件识别的范围。极大的降低了进行同名文件识别时的处理时长,减少了进行同名文件识别时消耗的资源。However, in the method for identifying files with the same name in the embodiments of the present application, a Bloom filter can be used to make an overall judgment on the possibility that files with the same name exist in the same directory in multiple electronic devices in a distributed file system without a central node, and it is found that there must be no files with the same name. The result of the file and the possibly existing file with the same name will be processed according to the result of the overall judgment. Since there are not very many files with the same name in the same directory in each electronic device, in most cases, the result of identifying the file with the same name can be obtained directly through the overall judgment. Even if the final result is not obtained, it can be significantly reduced. Scope for identifying files with the same name. This greatly reduces the processing time when identifying files with the same name, and reduces the resources consumed when identifying files with the same name.
结合对图13所示的电子设备100的硬件结构示意图的描述,本申请的一些实施例中,电子设备100可以通过移动通信模块150或无线通信模块160与其他电子设备组成无中心节点的分布式文件系统。该处理器110可以调用内部存储器121中存储的计算机指令以使得电子设备100执行本申请实施例中的同名文件识别方法。With reference to the description of the schematic diagram of the hardware structure of the electronic device 100 shown in FIG. 13 , in some embodiments of the present application, the electronic device 100 may form a distributed distributed network without a central node through the mobile communication module 150 or the wireless communication module 160 and other electronic devices File system. The processor 110 may call the computer instructions stored in the internal memory 121 to cause the electronic device 100 to execute the method for identifying a file with the same name in the embodiment of the present application.
结合对图14所示的电子设备100的软件结构示意图的描述,如图31所示,本申请的一些实施例中,电子设备100在该应用程序层还可以包括同名文件识别模块。With reference to the description of the schematic diagram of the software structure of the electronic device 100 shown in FIG. 14 , as shown in FIG. 31 , in some embodiments of the present application, the electronic device 100 may further include a file identification module with the same name at the application layer.
该同名文件识别模块用于执行本申请实施例中的同名文件识别方法。The same-name file identification module is used to execute the same-name file identification method in the embodiment of the present application.
可以理解的是,该同名文件识别模块也可以位于该分层构架中的其他层级,此处不作限定。It can be understood that the file identification module with the same name may also be located at other levels in the hierarchical structure, which is not limited here.
下面结合上述示例性电子设备100的软硬件结构,以分布式文件系统中的电子设备A需要显示目录A下所有文件为例,对本申请实施例中的同名文件识别方法进行具体描述:Below in conjunction with the software and hardware structure of the above-mentioned exemplary electronic device 100, the electronic device A in the distributed file system needs to display all files under the directory A as an example, and the method for identifying files with the same name in the embodiment of the present application is described in detail:
图32为本申请实施例中同名文件识别方法的一个信令交互示意图。FIG. 32 is a schematic diagram of signaling interaction of a method for identifying a file with the same name in an embodiment of the present application.
本申请实施例中,为便于描述,将该分布式文件系统中电子设备A之外的其他在线电子设备都称为电子设备X。In the embodiments of the present application, for convenience of description, other online electronic devices other than electronic device A in the distributed file system are referred to as electronic device X.
可以理解的是,该分布式文件系统中每个电子设备中都包含有布隆过滤器,且布隆过滤器的参数相同。具体的,各电子设备中的布隆过滤器的位数组的位数均为第一预设数值N,使用的哈希函数的数目均为第二预设数值K。K个哈希函数互不相同,但各电子设备均使用相同的K个哈希函数。It can be understood that each electronic device in the distributed file system includes a bloom filter, and the parameters of the bloom filter are the same. Specifically, the number of bits of the bit array of the Bloom filter in each electronic device is the first preset value N, and the number of hash functions used is the second preset value K. The K hash functions are different from each other, but the same K hash functions are used by each electronic device.
S3201、电子设备A接收到显示分布式文件系统中目录A下所有文件的请求;S3201, the electronic device A receives a request for displaying all files under the directory A in the distributed file system;
可以理解的是,电子设备A接收到的显示分布式文件系统中目录A下所有文件的请求,可以为用户在电子设备A上打开目录A的请求,也可以为电子设备A中的应用程序访问目录A或目录A下文件的请求,此处不作限定。It can be understood that the request for displaying all files under the directory A in the distributed file system received by the electronic device A can be a request by the user to open the directory A on the electronic device A, or it can be accessed by an application in the electronic device A. The request for directory A or files under directory A is not limited here.
S3202、电子设备A根据目录A下所有本地文件的文件名计算电子设备A的布隆过滤器 位数组;S3202, electronic device A calculates the Bloom filter bit array of electronic device A according to the file names of all local files under directory A;
在电子设备A接收到显示分布式文件系统中目录A下所有文件的请求后,可以根据目录A下所有本地文件的文件名,计算电子设备A的布隆过滤器位数组。After the electronic device A receives the request to display all files in the directory A in the distributed file system, it can calculate the Bloom filter bit array of the electronic device A according to the file names of all the local files in the directory A.
具体的,电子设备A可以将目录A下所有文件的文件名作为键值,分别使用电子设备A的布隆过滤器中的K个哈希函数求值,然后映射到该布隆过滤器的N个位数组上,得到电子设备A的布隆过滤器位数组。此时,该电子设备A的布隆过滤器位数组中记录有电子设备A的目录A下所有本地文件的文件名的相关信息。Specifically, electronic device A can use the file names of all files in directory A as key values, use K hash functions in the bloom filter of electronic device A to evaluate respectively, and then map them to N of the bloom filter. On the one bit array, the Bloom filter bit array of electronic device A is obtained. At this time, the relevant information of the file names of all local files under the directory A of the electronic device A is recorded in the bloom filter bit array of the electronic device A.
将文件名作为键值,使用哈希函数求值并映射到位数组上的过程,可以参考上述术语介绍(4)布隆过滤器中对布隆过滤器工作过程的描述,此处不再赘述。For the process of using the file name as the key value, using the hash function to evaluate and map it to the bit array, you can refer to the description of the working process of the bloom filter in the above terminology introduction (4) Bloom filter, which will not be repeated here.
S3203、电子设备A向电子设备X发送获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组的请求;S3203, electronic device A sends a request to electronic device X to obtain the file names of all local files under directory A in electronic device X and the Bloom filter bit array of electronic device X;
在电子设备A接收到显示分布式文件系统中目录A下所有文件的请求后,可以向电子设备X发送获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组的请求。After the electronic device A receives the request to display all the files in the directory A in the distributed file system, it can send the electronic device X to obtain the file names of all the local files in the directory A in the electronic device X and the Bloom filter bit of the electronic device X Array of requests.
可以理解的是,电子设备X为分布式文件系统中除电子设备A为的其他在线电子设备。电子设备X可以为一个电子设备,也可以为多个电子设备,例如两个、三个、四个或者更多个,此处不作限定。It can be understood that the electronic device X is an online electronic device other than the electronic device A in the distributed file system. The electronic device X may be one electronic device, or may be multiple electronic devices, such as two, three, four or more, which is not limited here.
若电子设备X为多个电子设备,则电子设备A可以分别向这些电子设备X发送获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组的请求,也可以在分布式文件系统中广播获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组的请求,此处不作限定。If the electronic device X is multiple electronic devices, then the electronic device A can send to these electronic devices X respectively a request to obtain the file names of all local files in the directory A of the electronic device X and the Bloom filter bit array of the electronic device X, and also A request for obtaining the file names of all local files in the directory A of the electronic device X and the Bloom filter bit array of the electronic device X may be broadcast in the distributed file system, which is not limited here.
S3204、电子设备X根据电子设备X中目录A下所有本地文件的文件名,计算电子设备X的布隆过滤器位数组;S3204, the electronic device X calculates the Bloom filter bit array of the electronic device X according to the file names of all local files under the directory A in the electronic device X;
电子设备X接收到电子设备A发送的获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组的请求后,可以根据电子设备X中目录A下所有本地文件的文件名,计算电子设备X的布隆过滤器位数组。After the electronic device X receives the request sent by the electronic device A to obtain the file names of all the local files in the directory A in the electronic device X and the Bloom filter bit array of the electronic device X, it can The filename to compute the Bloom filter bit array for electronic device X.
具体的,电子设备X可以将目录A下所有文件的文件名作为键值,分别使用电子设备X的布隆过滤器中的K个哈希函数求值,然后映射到该布隆过滤器的N个位数组上,得到电子设备X的布隆过滤器位数组。此时,该电子设备X的布隆过滤器位数组中记录有电子设备X的目录A下所有本地文件的文件名的相关信息。Specifically, electronic device X can use the file names of all files in directory A as key values, use K hash functions in the bloom filter of electronic device X to evaluate, and then map to N of the bloom filter. On the ones bit array, the Bloom filter bit array of electronic device X is obtained. At this time, the relevant information of the file names of all local files under the directory A of the electronic device X is recorded in the bloom filter bit array of the electronic device X.
将文件名作为键值,使用哈希函数求值并映射到位数组上的过程,可以参考上述术语介绍(4)布隆过滤器中对布隆过滤器工作过程的描述,此处不再赘述。For the process of using the file name as the key value, using the hash function to evaluate and map it to the bit array, you can refer to the description of the working process of the bloom filter in the above terminology introduction (4) Bloom filter, which will not be repeated here.
S3205、电子设备A接收电子设备X返回的电子设备X中目录A下所有本地文件的文件名和计算出的电子设备X的布隆过滤器位数组;S3205, electronic device A receives the file names of all local files in directory A in electronic device X returned by electronic device X and the Bloom filter bit array of electronic device X that is calculated;
电子设备X计算出电子设备X的布隆过滤器位数组后,可以将计算出的电子设备X的布隆过滤器位数组和目录A下所有本地文件的文件名发送给电子设备A。After the electronic device X calculates the bloom filter bit array of the electronic device X, it can send the calculated bloom filter bit array of the electronic device X and the file names of all local files in the directory A to the electronic device A.
上述步骤S3203~S3205,为电子设备A获取电子设备X中目录A下所有本地文件的文件 名和电子设备X的布隆过滤器位数组的一种方式。在实际应用中,电子设备A还可以有其他的方式获取电子设备X中目录A下所有本地文件的文件名和电子设备X的布隆过滤器位数组:The above steps S3203 to S3205 are a way for the electronic device A to obtain the file names of all local files in the directory A of the electronic device X and the Bloom filter bit array of the electronic device X. In practical applications, electronic device A can also obtain the file names of all local files in directory A of electronic device X and the Bloom filter bit array of electronic device X in other ways:
可选的,由于电子设备A和电子设备X组成了分布式文件系统,电子设备A中可以存储有电子设备X中所有本地文件的元数据信息,电子设备A可以根据存储的电子设备X中目录A下所有本地文件的元数据信息,获取到电子设备X中目录A下所有本地文件的文件名。Optionally, since electronic device A and electronic device X form a distributed file system, electronic device A can store metadata information of all local files in electronic device X, and electronic device A can The metadata information of all local files under A is obtained, and the file names of all local files under directory A in electronic device X are obtained.
在一些实施例中,在步骤S3203中,电子设备X可以只需要向电子设备X发送获取电子设备X的布隆过滤器位数组的请求;在步骤S3205中电子设备X可以只需要返回计算出的电子设备X的布隆过滤器位数组。In some embodiments, in step S3203, the electronic device X may only need to send a request to the electronic device X to obtain the Bloom filter bit array of the electronic device X; in step S3205, the electronic device X may only need to return the calculated Array of bloom filter bits for electronics X.
在一些实施例中,电子设备A可以不执行上述步骤S3203~S3205,在根据存储的电子设备X中目录A下所有本地文件的元数据信息,获取到电子设备X中目录A下所有本地文件的文件名后,电子设备A可以直接计算出电子设备X的布隆过滤器位数组。In some embodiments, electronic device A may not perform the above steps S3203 to S3205, and obtains the metadata information of all local files in directory A in electronic device X according to the stored metadata information of all local files in directory A in electronic device X After the file name, electronic device A can directly calculate the bloom filter bit array of electronic device X.
S3206、电子设备A根据各电子设备的布隆过滤器位数组,判断各电子设备中目录A下是否可能存在同名文件;S3206, the electronic device A determines whether a file with the same name may exist under the directory A in each electronic device according to the Bloom filter bit array of each electronic device;
电子设备A获取到分布式文件系统中其他各在线电子设备的布隆过滤器位数组后,可以根据各电子设备的布隆过滤器位数组,判断各电子设备中目录A下是否可能存在同名文件;After the electronic device A obtains the bloom filter bit array of other online electronic devices in the distributed file system, it can judge whether there may be a file with the same name in the directory A of each electronic device according to the bloom filter bit array of each electronic device ;
判断各电子设备中目录A下是否可能存在同名文件,具体可以为:确定每两个电子设备中目录A下是否可能存在同名文件;Determining whether a file with the same name may exist under the directory A in each electronic device may specifically be: determining whether a file with the same name may exist under the directory A in every two electronic devices;
当确定有两个电子设备中目录A下可能存在同名文件时,电子设备A可以执行步骤S3207;When it is determined that there may be a file with the same name under the directory A in two electronic devices, the electronic device A can perform step S3207;
可选的,只要电子设备A确定有两个电子设备中目录A下可能存在同名文件,就可以执行步骤S3207;Optionally, as long as the electronic device A determines that there may be a file with the same name under the directory A in two electronic devices, step S3207 can be executed;
可选的,电子设备A可以最多确定预设数目组两个电子设备中目录A下可能存在同名文件后,再执行步骤S3207;Optionally, the electronic device A may determine at most that a file with the same name may exist under the directory A in the two electronic devices in a preset number of groups, and then perform step S3207;
可选的,电子设备A可以将所有电子设备的布隆过滤器位数组比较完成后,再执行步骤S3207。Optionally, the electronic device A may perform step S3207 after comparing the Bloom filter bit arrays of all electronic devices.
当确定各电子设备中目录A下不可能存在同名文件时,电子设备A可以执行步骤S3208。When it is determined that a file with the same name cannot exist under the directory A in each electronic device, the electronic device A may execute step S3208.
若分布式文件系统中只有两个在线电子设备,例如电子设备A和电子设备B。则电子设备A根据各电子设备的布隆过滤器位数组,判断电子设备A和电子设备B中目录A下是否可能存在同名文件的过程参考对图5的描述,此处不再赘述。If there are only two online electronic devices in the distributed file system, for example, electronic device A and electronic device B. The process of determining whether a file with the same name may exist in the directory A of the electronic device A and the electronic device B according to the Bloom filter bit array of each electronic device A refers to the description of FIG. 5 and will not be repeated here.
若分布式文件系统中有大于两个的在线电子设备,则电子设备A根据各电子设备的布隆过滤器位数组,判断各电子设备中目录A下是否可能存在同名文件的方式可以有多种,下面分别进行描述:If there are more than two online electronic devices in the distributed file system, electronic device A can determine whether there may be a file with the same name in directory A in each electronic device according to the Bloom filter bit array of each electronic device. , which are described below:
可选的,电子设备A可以对得到的布隆过滤器位数组进行两两比较判断:Optionally, the electronic device A may perform a pairwise comparison judgment on the obtained Bloom filter bit array:
图33为本申请实施例中判断是否可能存在同名文件的一个流程示意图。FIG. 33 is a schematic flowchart of judging whether a file with the same name may exist in an embodiment of the present application.
S3301、电子设备A分别两两判断各电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K;S3301, the electronic device A respectively judges whether the number of digits that are 1 at the same position in the Bloom filter bit array of each electronic device is less than K;
电子设备A获取到分布式文件系统中其他各在线电子设备的布隆过滤器位数组后,可以 分别两两判断各电子设备的布隆过滤器位数组中相同位置同时为1的位数是否小于K;After the electronic device A obtains the bloom filter bit arrays of other online electronic devices in the distributed file system, it can judge whether the number of digits in the bloom filter bit arrays of the electronic devices that are at the same position at the same time is less than or equal to 1. K;
当确定两个电子设备的布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以执行步骤S3302;When it is determined that the same position in the Bloom filter bit arrays of the two electronic devices is 1 at the same time, the number of digits is less than K, the electronic device A can perform step S3302;
当确定两个电子设备的布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以执行步骤S3303。When it is determined that the number of bits in the bloom filter bit arrays of the two electronic devices where the same position is 1 at the same time is not less than K, the electronic device A may execute step S3303.
S3302、电子设备A确定这两个电子设备的目录A下不可能存在同名文件;S3302, the electronic device A determines that it is impossible for a file with the same name to exist in the directory A of the two electronic devices;
当确定两个电子设备的布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定这两个电子设备的目录A下不可能存在同名文件。When it is determined that the number of bits in the Bloom filter bit arrays of the two electronic devices that are 1 at the same time is less than K, the electronic device A can determine that it is impossible for a file with the same name to exist in the directory A of the two electronic devices.
S3303、电子设备A确定这两个电子设备的目录A下可能存在同名文件。S3303, the electronic device A determines that there may be files with the same name under the directory A of the two electronic devices.
当确定两个电子设备的布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定这两个电子设备的目录A下可能存在同名文件。When it is determined that the same position in the Bloom filter bit array of the two electronic devices is not less than K at the same time, the electronic device A may determine that a file with the same name may exist in the directory A of the two electronic devices.
示例性的,图34为本申请实施例中判断是否可能存在同名文件的一个示例性场景示意图。Exemplarily, FIG. 34 is a schematic diagram of an exemplary scenario for determining whether a file with the same name may exist in this embodiment of the present application.
电子设备A获取到了分布式文件系统中其他两个在线的电子设备:电子设备B、电子设备C的布隆过滤器位数组。为便于描述,将电子设备A的布隆过滤器位数组记为BA,将电子设备B的布隆过滤器位数组记为BB,将电子设备C的布隆过滤器位数组记为BC。Electronic device A obtains the Bloom filter bit arrays of the other two online electronic devices in the distributed file system: electronic device B and electronic device C. For convenience of description, the bloom filter bit array of electronic device A is denoted as BA, the bloom filter bit array of electronic device B is denoted as BB, and the bloom filter bit array of electronic device C is denoted as BC.
则电子设备A会分别将BA、BB和BC进行两两比较,从而确定电子设备A、电子设备B和电子设备C的目录A下是否可能存在同名文件,具体的:Then electronic device A will compare BA, BB and BC in pairs, so as to determine whether there may be files with the same name in directory A of electronic device A, electronic device B and electronic device C, specifically:
电子设备A将BA和BB进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下可能存在同名文件。Electronic device A compares BA and BB, and when the number of 1 bits at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine that electronic device A and electronic device B are not in directory A. A file with the same name may exist; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that a file with the same name may exist in the directory A of the electronic device A and the electronic device B.
电子设备A将BA和BC进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备A和电子设备C的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备C的目录A下可能存在同名文件。Electronic device A compares BA and BC. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device A and electronic device C are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that there may be files with the same name in the directory A of the electronic device A and the electronic device C.
电子设备A将BB和BC进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备B和电子设备C的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备B和电子设备C的目录A下可能存在同名文件。Electronic device A compares BB and BC. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine that electronic device B and electronic device C are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, electronic device A can determine that there may be files with the same name in directory A of electronic device B and electronic device C.
示例性的,图35为本申请实施例中判断是否可能存在同名文件的一个示例性场景示意图。Exemplarily, FIG. 35 is a schematic diagram of an exemplary scenario for determining whether a file with the same name may exist in this embodiment of the present application.
电子设备A获取到了分布式文件系统中其他三个在线的电子设备:电子设备B、电子设备C和电子设备D的布隆过滤器位数组。为便于描述,将电子设备A的布隆过滤器位数组记为BA,将电子设备B的布隆过滤器位数组记为BB,将电子设备C的布隆过滤器位数组记为BC、将电子设备D的布隆过滤器位数组记为BD。Electronic device A obtains the Bloom filter bit arrays of the other three online electronic devices in the distributed file system: electronic device B, electronic device C, and electronic device D. For the convenience of description, the bloom filter bit array of electronic device A is denoted as BA, the bloom filter bit array of electronic device B is denoted as BB, the bloom filter bit array of electronic device C is denoted as BC, and the The bloom filter bit array of electronic device D is denoted as BD.
则电子设备A会分别将BA、BB、BC、BD进行两两比较,从而确定电子设备A、电子设备B、电子设备C和电子设备D的目录A下是否可能存在同名文件,具体的:Then electronic device A will compare BA, BB, BC, and BD, respectively, to determine whether there may be files with the same name under directory A of electronic device A, electronic device B, electronic device C, and electronic device D. Specifically:
电子设备A将BA和BB进行比较,当这两个布隆过滤器位数组中相同位置同时为1的 位数小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下可能存在同名文件。Electronic device A compares BA and BB, and when the number of 1 bits at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine that electronic device A and electronic device B are not in directory A. A file with the same name may exist; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that a file with the same name may exist in the directory A of the electronic device A and the electronic device B.
电子设备A将BA和BC进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备A和电子设备C的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备C的目录A下可能存在同名文件。Electronic device A compares BA and BC. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device A and electronic device C are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that there may be files with the same name in the directory A of the electronic device A and the electronic device C.
电子设备A将BA和BD进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备A和电子设备D的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备D的目录A下可能存在同名文件。Electronic device A compares BA and BD. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device A and electronic device D are not in directory A. A file with the same name may exist; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that a file with the same name may exist in the directory A of the electronic device A and the electronic device D.
电子设备A将BB和BC进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备B和电子设备C的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备B和电子设备C的目录A下可能存在同名文件。Electronic device A compares BB and BC. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine that electronic device B and electronic device C are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, electronic device A can determine that there may be files with the same name in directory A of electronic device B and electronic device C.
电子设备A将BB和BD进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备B和电子设备D的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备B和电子设备D的目录A下可能存在同名文件。Electronic device A compares BB and BD. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device B and electronic device D are not in directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, electronic device A can determine that there may be files with the same name in directory A of electronic device B and electronic device D.
电子设备A将BC和BD进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备C和电子设备D的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备C和电子设备D的目录A下可能存在同名文件。Electronic device A compares BC and BD, and when the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine that electronic device C and electronic device D are not under directory A. There may be files with the same name; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, the electronic device A can determine that there may be files with the same name in the directory A of the electronic device C and the electronic device D.
在两两比较完所有电子设备的布隆过滤器位数组后,电子设备可以执行步骤S3207,对同名文件重命名,再执行步骤S3208。After comparing the Bloom filter bit arrays of all electronic devices pairwise, the electronic device may execute step S3207, rename the file with the same name, and then execute step S3208.
优选的,电子设备可以通过对确定不可能存在同名文件的电子设备的布隆过滤器位数组进行逻辑或操作,再与其他布隆过滤器位数组比较,来进一步减少比较次数:Preferably, the electronic device can further reduce the number of comparisons by performing a logical OR operation on the bloom filter bit array of the electronic device that is determined to be impossible to exist in a file with the same name, and then compares it with other bloom filter bit arrays:
电子设备A可以将获取到的m个布隆过滤器位数组排序,对应m个电子设备(包括电子设备A)。电子设备A先比较第一个电子设备和第二个电子设备的布隆过滤器位数组,若确定两个电子设备的目录A中可能存在同名文件,则执行步骤S3207,对同名文件重命名或确定不可能存在同名文件。The electronic device A may sort the acquired m Bloom filter bit arrays, corresponding to the m electronic devices (including the electronic device A). The electronic device A first compares the Bloom filter bit arrays of the first electronic device and the second electronic device. If it is determined that there may be files with the same name in the directory A of the two electronic devices, step S3207 is executed to rename or rename the files with the same name. Make sure that a file with the same name cannot exist.
在对同名文件重命名后,或确定两个电子设备的目录A中不可能存在同名文件后,电子设备A将这两个电子设备的布隆过滤器位数组进行逻辑或操作,记为逻辑或布隆过滤器位数组。再将该逻辑或布隆过滤器位数组与第三个电子设备的布隆过滤器位数组比较,确定第三个电子设备和第一个电子设备的目录A中、第三个电子设备和第二个电子设备的目录A中是否存在同名文件。若确定某两个电子设备中可能存在同名文件,则执行步骤S3207,对同名文件重命名或确定不可能存在同名文件。After renaming the file with the same name, or after determining that it is impossible for a file with the same name to exist in the directory A of the two electronic devices, the electronic device A performs a logical OR operation on the Bloom filter bit arrays of the two electronic devices, which is recorded as logical OR Bloom filter bit array. Then compare the logical OR bloom filter bit array with the bloom filter bit array of the third electronic device, and determine the third electronic device and the first electronic device in the directory A, the third electronic device and the third electronic device. Whether a file with the same name exists in the directory A of the two electronic devices. If it is determined that a file with the same name may exist in some two electronic devices, step S3207 is executed to rename the file with the same name or it is determined that a file with the same name cannot exist.
在对同名文件重命名后,或确定这三个电子设备的目录A中不可能存在同名文件后,电子设备A将该逻辑或布隆过滤器位数组与第三个电子设备的布隆过滤器位数组再进行逻辑或操作,更新该逻辑或布隆过滤器位数组。再将该逻辑或布隆过滤器位数组与第四个电子设备 的布隆过滤器位数组比较,依次类推,最终确定m个电子设备中都不可能存在同名文件后,执行步骤S3208。After renaming a file with the same name, or after determining that a file with the same name cannot possibly exist in directory A of the three electronics, electronics A combines the logical OR of the bloom filter bit array with the bloom filter of the third electronics The bit array is then logically ORed to update the logical OR Bloom filter bit array. The logical OR Bloom filter bit array is then compared with the Bloom filter bit array of the fourth electronic device, and so on. After it is finally determined that there is no file with the same name in the m electronic devices, step S3208 is executed.
下面以该电子设备A获取到了电子设备B和电子设备C的布隆过滤器位数组为例,对这种判断是否可能存在同名文件的方式进行具体说明:Taking the electronic device A obtained the Bloom filter bit arrays of the electronic device B and the electronic device C as an example, this method of judging whether there may be a file with the same name will be described in detail:
图36为本申请实施例中判断是否可能存在同名文件的一个流程示意图。FIG. 36 is a schematic flowchart of judging whether a file with the same name may exist in an embodiment of the present application.
S3601、确定电子设备A的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数是否小于K;S3601. Determine whether the number of digits in the Bloom filter bit array of electronic device A and the Bloom filter bit array of electronic device B that are at the same position at the same time is less than K;
当确定小于K时,执行步骤S3602;When it is determined that it is less than K, perform step S3602;
当确定不小于K时,执行步骤S3603。When it is determined that it is not less than K, step S3603 is performed.
S3602、确定电子设备A和电子设备B的目录A下不可能存在同名文件;S3602. Determine that it is impossible for a file with the same name to exist in the directory A of the electronic device A and the electronic device B;
当确定电子设备A的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数小于K时,可以确定电子设备A和电子设备B的目录A下不可能存在同名文件。可以执行步骤S3605。When it is determined that the number of bits in the bloom filter bit array of electronic device A and the bloom filter bit array of electronic device B that are at the same position at the same time is less than K, it can be determined that electronic device A and electronic device B are not under directory A. A file with the same name may exist. Step S3605 may be performed.
S3603、确定电子设备A和电子设备B的目录A下可能存在同名文件;S3603. Determine that a file with the same name may exist in the directory A of the electronic device A and the electronic device B;
当确定电子设备A的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数不小于K时,可以确定电子设备A和电子设备B的目录A下可能存在同名文件。可以执行步骤S3604。When it is determined that the number of bits in the bloom filter bit array of electronic device A and the bloom filter bit array of electronic device B that are at the same position at the same time is not less than K, it can be determined that electronic device A and electronic device B are under directory A A file with the same name may exist. Step S3604 may be performed.
S3604、执行步骤S3207;S3604, execute step S3207;
当确定电子设备A和电子设备B的目录A下可能存在同名文件时,可以执行步骤S3207,将电子设备A和电子设备B的目录A下的同名文件重命名,或确定电子设备A和电子设备B的目录A下不存在同名文件。When it is determined that a file with the same name may exist in the directory A of the electronic device A and the electronic device B, step S3207 may be executed to rename the file with the same name under the directory A of the electronic device A and the electronic device B, or determine the electronic device A and the electronic device. There is no file with the same name in directory A of B.
在执行完步骤S3604后,可以执行步骤S3605。After step S3604 is performed, step S3605 may be performed.
S3605、对电子设备A的布隆过滤器位数组与电子设备B的布隆过滤器位数组进行逻辑或操作,得到逻辑或布隆过滤器位数组;S3605, performing a logical OR operation on the bloom filter bit array of electronic device A and the bloom filter bit array of electronic device B to obtain a logical OR bloom filter bit array;
在步骤S3602确定电子设备A和电子设备B的目录A下不可能存在同名文件后,或步骤S3604对电子设备A和电子设备B的目录A下的同名文件重命名后,或步骤S3604排除电子设备A和电子设备B的目录A下存在同名文件的可能性后,可以对电子设备A的布隆过滤器位数组与电子设备B的布隆过滤器位数组进行逻辑或操作,得到逻辑或布隆过滤器位数组。After it is determined in step S3602 that it is impossible for a file with the same name to exist in the directory A of the electronic device A and the electronic device B, or the file with the same name in the directory A of the electronic device A and the electronic device B is renamed in step S3604, or the electronic device is excluded in step S3604 After it is possible that a file with the same name exists in directory A of electronic device A and electronic device B, logical OR operation can be performed on the bloom filter bit array of electronic device A and the bloom filter bit array of electronic device B to obtain a logical OR bloom. Filter bit array.
进行逻辑或操作,具体为在两个位数相同的布隆过滤器位数组中,在相同位置有任一个的值为1,则将得到的逻辑或布隆过滤器位数组中该位置的值置为1;若相同位置的值都为0,则将得到的逻辑或布隆过滤器位数组中该位置的值置为0。Perform a logical OR operation, specifically, in the Bloom filter bit array with the same number of digits, if any one of the same positions has a value of 1, the value of the position in the resulting logical OR Bloom filter bit array will be obtained. Set to 1; if the values in the same position are all 0, set the value of that position in the resulting logical OR Bloom filter bit array to 0.
示例性的,图37为对布隆过滤器位数组进行逻辑或操作的一个示例性示意图。布隆过滤器位数组1和布隆过滤器位数组2的位数均为8。其中,布隆过滤器位数组1中,第3、4、7、8个比特位上的值为1;布隆过滤器位数组2中,第1、4、6个比特位上的值为1。则对布隆过滤器位数组1和布隆过滤器位数组2进行逻辑或操作,得到的布隆过滤器位数组3中,第1、3、4、6、7、8个比特位上的值为1,其他比特位上的值为0。Exemplarily, FIG. 37 is an exemplary schematic diagram of performing a logical OR operation on a Bloom filter bit array. Both bloom filter bit array 1 and bloom filter bit array 2 have 8 bits. Among them, in the bloom filter bit array 1, the values of the 3rd, 4th, 7th, and 8th bits are 1; in the bloom filter bit array 2, the values of the 1st, 4th, and 6th bits are 1. Then perform the logical OR operation on the bloom filter bit array 1 and the bloom filter bit array 2, and in the obtained bloom filter bit array 3, the values on the 1st, 3rd, 4th, 6th, 7th, and 8th bits is 1, and the other bits are 0.
S3606、确定逻辑或布隆过滤器位数组与电子设备C的布隆过滤器位数组中相同位置同时为1的位数是否小于K;S3606, determine whether the number of digits that are 1 at the same position in the logical OR Bloom filter bit array and the Bloom filter bit array of the electronic device C at the same time is less than K;
在得到逻辑或布隆过滤器位数组后,可以确定逻辑或布隆过滤器位数组与电子设备C的布隆过滤器位数组中相同位置同时为1的位数是否小于K;After the logical OR Bloom filter bit array is obtained, it can be determined whether the number of bits that are 1 at the same position in the logical OR Bloom filter bit array and the Bloom filter bit array of the electronic device C at the same time is less than K;
当确定小于K时,可以执行步骤S3607;When it is determined that it is less than K, step S3607 can be performed;
当确定不小于K时,可以执行步骤S3608。When it is determined that it is not less than K, step S3608 may be performed.
S3607、确定电子设备A、电子设备B、电子设备C的目录A下不可能存在同名文件;S3607. Determine that it is impossible for a file with the same name to exist under directory A of electronic device A, electronic device B, and electronic device C;
当确定逻辑或布隆过滤器位数组与电子设备C的布隆过滤器位数组中相同位置同时为1的位数小于K时,可以确定电子设备A、电子设备B、电子设备C的目录A下不可能存在同名文件。When it is determined that the number of bits in the same position of the logical OR Bloom filter bit array and the Bloom filter bit array of electronic device C that are 1 at the same time is less than K, the directory A of electronic device A, electronic device B, and electronic device C can be determined. A file with the same name cannot exist.
S3608、确定电子设备C和电子设备A、电子设备C和电子设备B的目录A下可能存在同名文件;S3608. Determine that there may be files with the same name in the directory A of the electronic device C and the electronic device A, and the electronic device C and the electronic device B;
当确定逻辑或布隆过滤器位数组与电子设备C的布隆过滤器位数组中相同位置同时为1的位数不小于K时,可以确定电子设备C和电子设备A、电子设备C和电子设备B的目录A下可能存在同名文件。可以执行步骤S3609和S3613,分别确定电子设备C和电子设备A的目录A下是否可能存在同名文件,以及电子设备C和电子设备B的目录A下是否可能存在同名文件。When it is determined that the number of bits in the same position of the logical OR Bloom filter bit array and the Bloom filter bit array of the electronic device C that are 1 at the same time is not less than K, it can be determined that the electronic device C and the electronic device A, the electronic device C and the electronic device A file with the same name may exist in directory A of device B. Steps S3609 and S3613 may be executed to determine whether a file with the same name may exist in the directory A of the electronic device C and the electronic device A, and whether there may be a file with the same name in the directory A of the electronic device C and the electronic device B.
S3609、确定电子设备C的布隆过滤器位数组与电子设备A的布隆过滤器位数组中相同位置同时为1的位数是否小于K;S3609, determine whether the number of digits in the Bloom filter bit array of the electronic device C and the Bloom filter bit array of the electronic device A that are at the same position at the same time is 1 is less than K;
当确定小于K时,可以执行步骤S3610;When it is determined that it is less than K, step S3610 can be performed;
当确定不小于K时,可以执行步骤S3611。When it is determined that it is not less than K, step S3611 may be performed.
S3610、确定电子设备C和电子设备A的目录A下不可能存在同名文件;S3610. Determine that it is impossible for a file with the same name to exist in the directory A of the electronic device C and the electronic device A;
当确定电子设备C的布隆过滤器位数组与电子设备A的布隆过滤器位数组中相同位置同时为1的位数小于K时,可以确定电子设备C和电子设备A的目录A下不可能存在同名文件。When it is determined that the number of bits in the bloom filter bit array of electronic device C and the bloom filter bit array of electronic device A that are at the same position at the same time is less than K, it can be determined that electronic device C and electronic device A are not in directory A. A file with the same name may exist.
S3611、确定电子设备C和电子设备A的目录A下可能存在同名文件;S3611. Determine that a file with the same name may exist in the directory A of the electronic device C and the electronic device A;
当确定电子设备C的布隆过滤器位数组与电子设备A的布隆过滤器位数组中相同位置同时为1的位数不小于K时,可以确定电子设备C和电子设备A的目录A下可能存在同名文件。可以执行步骤S3612。When it is determined that the number of bits in the bloom filter bit array of electronic device C and the bloom filter bit array of electronic device A that are at the same position at the same time is not less than K, it can be determined that the electronic device C and the electronic device A are under the directory A A file with the same name may exist. Step S3612 may be performed.
S3612、执行步骤S3207;S3612, execute step S3207;
当确定电子设备C和电子设备A的目录A下可能存在同名文件时,可以执行步骤S3207,将电子设备A和电子设备C的目录A下的同名文件重命名,或确定电子设备C和电子设备A的目录A下不存在同名文件。When it is determined that a file with the same name may exist in the directory A of the electronic device C and the electronic device A, step S3207 may be executed to rename the file with the same name under the directory A of the electronic device A and the electronic device C, or determine the electronic device C and the electronic device. A file with the same name does not exist in directory A of A.
S3613、确定电子设备C的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数是否小于K;S3613, determine whether the number of digits in the Bloom filter bit array of electronic device C and the Bloom filter bit array of electronic device B that are at the same position at the same time is 1 is less than K;
当确定小于K时,可以执行步骤S3614;When it is determined that it is less than K, step S3614 can be performed;
当确定不小于K时,可以执行步骤S3615。When it is determined that it is not less than K, step S3615 may be performed.
S3614、确定电子设备C和电子设备B的目录A下不可能存在同名文件;S3614. Determine that it is impossible for a file with the same name to exist in the directory A of the electronic device C and the electronic device B;
当确定电子设备C的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数小于K时,可以确定电子设备C和电子设备B的目录A下不可能存在同名文件。When it is determined that the number of bits in the bloom filter bit array of electronic device C and the bloom filter bit array of electronic device B that are at the same position at the same time is less than K, it can be determined that electronic device C and electronic device B are not under directory A. A file with the same name may exist.
S3615、确定电子设备C和电子设备B的目录A下可能存在同名文件;S3615. Determine that a file with the same name may exist in the directory A of the electronic device C and the electronic device B;
当确定电子设备C的布隆过滤器位数组与电子设备B的布隆过滤器位数组中相同位置同时为1的位数不小于K时,可以确定电子设备C和电子设备B的目录A下可能存在同名文件。可以执行步骤S3616。When it is determined that the number of bits in the Bloom filter bit array of electronic device C and the bloom filter bit array of electronic device B that are at the same position at the same time is not less than K, it can be determined that the electronic device C and the electronic device B are under the directory A A file with the same name may exist. Step S3616 may be performed.
S3616、执行步骤S3207。S3616. Step S3207 is performed.
当确定电子设备C和电子设备B的目录A下可能存在同名文件时,可以执行步骤S3207,将电子设备A和电子设备B的目录A下的同名文件重命名,或确定电子设备C和电子设备B的目录A下不存在同名文件。When it is determined that a file with the same name may exist in the directory A of the electronic device C and the electronic device B, step S3207 may be executed to rename the file with the same name under the directory A of the electronic device A and the electronic device B, or determine the electronic device C and the electronic device. There is no file with the same name in directory A of B.
在上述步骤S3610与S3612中任一个执行且S3614与S3616中任一个执行之后,或步骤S3607之后,可以确定此时电子设备A、电子设备B、电子设备C的目录A下不存在同名文件,可以执行步骤S3208。After any one of the above-mentioned steps S3610 and S3612 is executed and any one of S3614 and S3616 is executed, or after step S3607, it can be determined that there is no file with the same name in the directory A of the electronic device A, electronic device B, and electronic device C at this time. Step S3208 is executed.
若该电子设备A不仅仅获取到电子设备B和电子设备C的布隆过滤器位数组,还获取到了电子设备D的布隆过滤器位数组。则还需要将该逻辑或布隆过滤器位数组与电子设备C的布隆过滤器位数组进行比较,并执行相应的操作,使得可以确定电子设备A、电子设备B、电子设备C和电子设备D的目录A下不存在同名文件,才能再执行步骤S3208。若电子设备A获取到了更多的电子设备的布隆过滤器位数组,可以以此类推进行操作,此处不作赘述。If the electronic device A not only obtains the Bloom filter bit array of the electronic device B and the electronic device C, but also obtains the Bloom filter bit array of the electronic device D. Then it is also necessary to compare the logical OR bloom filter bit array with the bloom filter bit array of electronic device C, and perform corresponding operations, so that electronic device A, electronic device B, electronic device C and electronic device can be determined. If there is no file with the same name in the directory A of D, step S3208 can be executed again. If the electronic device A obtains more bloom filter bit arrays of the electronic device, operations can be performed in a similar manner, which will not be repeated here.
示例性的,图38为本申请实施例中使用逻辑或操作判断是否可能存在同名文件的一个示例性场景示意图。Exemplarily, FIG. 38 is a schematic diagram of an exemplary scenario in which a logical OR operation is used to determine whether a file with the same name may exist in this embodiment of the present application.
电子设备A获取到了分布式文件系统中其他两个在线的电子设备:电子设备B、电子设备C的布隆过滤器位数组。为便于描述,将电子设备A的布隆过滤器位数组记为BA,将电子设备B的布隆过滤器位数组记为BB,将电子设备C的布隆过滤器位数组记为BC。Electronic device A obtains the Bloom filter bit arrays of the other two online electronic devices in the distributed file system: electronic device B and electronic device C. For convenience of description, the bloom filter bit array of electronic device A is denoted as BA, the bloom filter bit array of electronic device B is denoted as BB, and the bloom filter bit array of electronic device C is denoted as BC.
电子设备A可以先将BA和BB进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备A和电子设备B的目录A下不可能存在同名文件。Electronic device A can compare BA and BB first, and when the number of bits that are 1 at the same position in the two Bloom filter bit arrays is not less than K, electronic device A can determine the directory of electronic device A and electronic device B A file with the same name may exist under A; when the number of 1 bits at the same position in the two Bloom filter bit arrays is less than K, the electronic device A can determine that the directory A of the electronic device A and the electronic device B cannot exist under the same name. document.
在确定电子设备A和电子设备B的目录A下不可能存在同名文件后,电子设备A可以将BA和BB进行逻辑或操作,得到逻辑或布隆过滤器位数组,记为BAB。After determining that it is impossible for electronic device A and electronic device B to have files with the same name in directory A, electronic device A can perform logical OR operation on BA and BB to obtain a logical OR Bloom filter bit array, denoted as BAB.
电子设备A可以再将BC和BAB进行比较,当这两个布隆过滤器位数组中相同位置同时 为1的位数小于K时,电子设备A可以确定电子设备A和电子设备C的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备C与电子设备A,或者电子设备C与电子设备B的目录A下可能存在同名文件。Electronic device A can then compare BC and BAB. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine the directory A of electronic device A and electronic device C. It is impossible for a file with the same name to exist in the following two Bloom filter bit arrays; when the number of 1 bits at the same position in the two Bloom filter bit arrays is not less than K, the electronic device A can determine the electronic device C and the electronic device A, or the electronic device C and the electronic device. A file with the same name may exist in directory A of device B.
电子设备A可以再将BC和BA进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备C和电子设备A的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备C和电子设备A的目录A下可能存在同名文件。Electronic device A can then compare BC and BA. When the number of bits that are 1 at the same position in the two Bloom filter bit arrays at the same time is less than K, electronic device A can determine the directory A of electronic device C and electronic device A. It is impossible for a file with the same name to exist in the two Bloom filter bit arrays; when the number of digits that are 1 at the same position in the two Bloom filter bit arrays at the same time is not less than K, electronic device A can determine that electronic device C and electronic device A may exist in directory A with the same name document.
同时,电子设备A可以再将BC和BB进行比较,当这两个布隆过滤器位数组中相同位置同时为1的位数小于K时,电子设备A可以确定电子设备C和电子设备B的目录A下不可能存在同名文件;当这两个布隆过滤器位数组中相同位置同时为1的位数不小于K时,电子设备A可以确定电子设备C和电子设备B的目录A下可能存在同名文件。At the same time, electronic device A can compare BC and BB again, and when the number of 1 bits at the same position in the two Bloom filter bit arrays is less than K, electronic device A can determine the difference between electronic device C and electronic device B. It is impossible for a file with the same name to exist in the directory A; when the number of 1 bits at the same position in the two Bloom filter bit arrays is not less than K, the electronic device A can determine that the electronic device C and the electronic device B may be in the directory A. A file with the same name exists.
示例性的,假设分布式文件系统由m个电子设备组成,各电子设备利用参数相同的布隆过滤器,假设布隆过滤器使用哈希函数个数为k。当显示分布式文件系统某路径下所有文件时,各电子设备在该路径下的所有文件的文件名通过布隆过滤器的哈希函数映射修改本电子设备的位数组,用BF i表示第i个(1≤i≤m)电子设备的位数组。用f(BF i,BF j)表示位数组BF i与BF j相同位置的比特位同时为1的总数。则步骤S3206和S3207确定各电子设备中目录A下是否可能存在同名文件的一种方式可以如图39中伪代码所示。 Exemplarily, it is assumed that the distributed file system consists of m electronic devices, each electronic device uses a Bloom filter with the same parameters, and it is assumed that the number of hash functions used by the Bloom filter is k. When displaying all files in a certain path of the distributed file system, the file names of all files in the path of each electronic device are mapped through the hash function of the Bloom filter to modify the bit array of the electronic device, and BF i is used to represent the i-th A bit array of (1≤i≤m) electronic devices. Let f(BF i , BF j ) represent the total number of bits in the same position of the bit array BF i and BF j that are 1 at the same time. Then, steps S3206 and S3207 determine whether a file with the same name may exist in the directory A in each electronic device may be shown in the pseudo code in FIG. 39 .
图39中伪代码包括Check函数和CheckFileName函数。其中CheckFileName函数的执行过程是步骤S3206的一种实现方式,Check函数的执行过程是步骤S3207的一种实现方式。The pseudocode in Figure 39 includes the Check function and the CheckFileName function. The execution process of the CheckFileName function is an implementation manner of step S3206, and the execution process of the Check function is an implementation manner of step S3207.
图39中的CheckFileName函数,利用各电子设备的位数组,统计两个不同位数组的相同位置同时为1的总数,以达到快速判断在电子设备间是否存在同名文件的目的。若两个位数组相同位置同时为1的位数小于K,则说明不存在同名文件;否则,可能存在同名文件,继续调用图39中的Check函数用暴力枚举的方法确认是否存在同名文件。The CheckFileName function in Figure 39 uses the bit arrays of each electronic device to count the total number of 1s in the same position of two different bit arrays at the same time, so as to quickly determine whether a file with the same name exists between electronic devices. If the number of 1 bits in the same position of the two bit arrays is less than K, it means that there is no file with the same name; otherwise, there may be a file with the same name. Continue to call the Check function in Figure 39 to confirm whether there is a file with the same name by violent enumeration.
具体的,CheckFileName函数的函数体中的第一行表示:先设逻辑或布隆过滤器位数组BF tmp等于BF 1Specifically, the first line in the function body of the CheckFileName function indicates: first set the logical OR Bloom filter bit array BF tmp equal to BF 1 .
第二行表示:将变量i从2循环到m。The second line says: loop the variable i from 2 to m.
第三行表示:在变量i的每次循环中,如果BF tmp和BF i相同位置的比特位同时为1的总数大于或等于K,则执行第四行;否则跳过后续步骤,进行变量i的下一次循环。 The third line means: in each loop of variable i, if the total number of bits in the same position of BF tmp and BF i is 1 at the same time greater than or equal to K, then execute the fourth line; otherwise, skip the subsequent steps and go to variable i the next cycle.
第四行表示:在变量i的每次循环中,将变量j从1到i-1进行循环。The fourth line means: in each loop of variable i, loop the variable j from 1 to i-1.
第五行表示:在变量j的每次循环中,如果BF i和BF j相同位置的比特位同时为1的总数大于或等于K,则执行第六行;否则跳过后续步骤,进行变量j的下一次循环。 The fifth line means: in each loop of variable j, if the total number of bits in the same position of BF i and BF j is 1 at the same time greater than or equal to K, then execute the sixth line; otherwise, skip the subsequent steps and carry out the variable j. next cycle.
第六行表示:对本轮循环的i和j执行Check函数。The sixth line means: execute the Check function on i and j of this round of loops.
第七行表示:在变量i的每次循环中,在第六行的操作完成后,对BF tmp与本轮的BF i进行逻辑或操作,将结果更新到BF tmp,作为变量i的下一次循环中的BF tmpThe seventh line indicates: in each loop of variable i, after the operation of the sixth line is completed, perform logical OR operation on BF tmp and BF i of this round, and update the result to BF tmp as the next time of variable i. BF tmp in a loop.
具体的,Check函数的函数体中的第一行表示:对于电子设备i中该路径下的每个文件x执行后续循环操作。Specifically, the first line in the function body of the Check function indicates that the subsequent loop operation is performed for each file x under the path in the electronic device i.
第二行表示:对于电子设备j中该路径下的每个文件y执行后续循环操作。The second line indicates that the subsequent loop operation is performed for each file y under the path in the electronic device j.
第三行表示:如果文件x的文件名与文件y的文件名相同,则执行第四行;否则跳过后续步骤,进行下一次循环,使用电子设备i中的文件x与电子设备j中的下一个文件y比对。The third line means: if the file name of the file x is the same as the file name of the file y, execute the fourth line; otherwise, skip the subsequent steps, go to the next cycle, use the file x in the electronic device i and the file in the electronic device j The next file y is compared.
第四行表示:对文件x重命名。The fourth line means: rename the file x.
第五行表示:跳出对电子设备j中该路径下的每个文件y的循环,开始对电子设备i中下一个文件x的循环。The fifth line represents: jump out of the loop for each file y under the path in the electronic device j, and start the loop for the next file x in the electronic device i.
S3207、电子设备A确定可能存在同名文件的两个电子设备中目录A下的同名文件,对同名文件重命名;S3207, the electronic device A determines that the file with the same name in the directory A may exist in two electronic devices with the same name, and renames the file with the same name;
在步骤S3206中确定两个电子设备中目录A下有可能存在同名文件时,电子设备A可以确定可能存在同名文件的这两个电子设备中目录A下的同名文件,并对同名文件重命名;或者确定可能存在同名文件的两个电子设备中目录A下不存在同名文件。然后,可以返回结果并再次执行步骤S3206。When it is determined in step S3206 that there may be a file with the same name under the directory A in the two electronic devices, the electronic device A can determine that there may be a file with the same name in the two electronic devices with the same name. Or it is determined that a file with the same name does not exist in the directory A in two electronic devices that may have a file with the same name. Then, the result can be returned and step S3206 can be performed again.
具体的,电子设备A确定可能存在同名文件的这两个电子设备中目录A下的同名文件的方式有很多:Specifically, there are many ways for electronic device A to determine files with the same name under directory A in the two electronic devices that may have files with the same name:
可选的,电子设备A可以直接将这两个电子设备中目录A下的每个文件的文件名两两比较,确定是否存在同名文件。当存在同名文件时,对同名文件重命名。当比较完成后还未找到同名文件时,可以确定这两个电子设备中目录A下不存在同名文件。示例性的,可以为图39所示的伪代码中Check函数表示的方式,此处不再赘述。Optionally, the electronic device A may directly compare the file names of each file under the directory A in the two electronic devices to determine whether there is a file with the same name. When a file with the same name exists, rename the file with the same name. When the file with the same name is not found after the comparison is completed, it can be determined that there is no file with the same name in the directory A in the two electronic devices. Exemplarily, it may be the manner represented by the Check function in the pseudo code shown in FIG. 39 , which will not be repeated here.
可选的,电子设备A可以先根据这两个电子设备中第一个电子设备的布隆过滤器位数组,来确定第二个电子设备中目录A下的某个文件在该第一个电子设备的目录A下是否有可能存在同名文件;在确定有可能存在同名文件时,才使用该第二个电子设备中目录A下的该文件的文件名与该第一个电子设备的目录A下的每个文件的文件名进行比较。当确定存在同名文件时,对同名文件重命名。在将第二个电子设备中目录A下的每个文件都比较完成后,还未找到同名文件时,可以确定这两个电子设备中目录A下不存在同名文件。Optionally, electronic device A may first determine, according to the Bloom filter bit array of the first electronic device in the two electronic devices, that a certain file under directory A in the second electronic device is in the first electronic device. Whether there may be a file with the same name in the directory A of the device; only when it is determined that there may be a file with the same name, the file name of the file in the directory A in the second electronic device and the file in the directory A in the first electronic device are used. The filenames of each file are compared. When it is determined that a file with the same name exists, the file with the same name is renamed. After comparing each file under the directory A in the second electronic device, if no file with the same name is found, it can be determined that there is no file with the same name in the directory A in the two electronic devices.
可以理解的是,还可以有其他的确定可能存在同名文件的这两个电子设备中目录A下的同名文件的方式,此处不作限定。It can be understood that there may also be other ways of determining the files with the same name under the directory A in the two electronic devices that may have files with the same name, which are not limited here.
S3208、电子设备A显示分布式文件系统中目录A下的所有文件。S3208, the electronic device A displays all files under the directory A in the distributed file system.
在电子设备A确定各电子设备中目录A下不可能存在同名文件后,电子设备A可以显示分布式文件系统中目录A下的所有文件。After the electronic device A determines that it is impossible for a file with the same name to exist under the directory A in each electronic device, the electronic device A can display all the files under the directory A in the distributed file system.
可以理解的是,显示分布式文件系统中目录A下的所有文件可以为显示分布式文件系统中目录A下的文件信息。具体的,目录A下的文件信息可以包括分布式文件系统中各电子设备的目录A下本地文件的文件信息。例如包括电子设备A的目录A下的本地文件的文件信息,电子设备B的目录A下的本地文件的文件信息等。It can be understood that displaying all files under the directory A in the distributed file system may be displaying file information under the directory A in the distributed file system. Specifically, the file information under the directory A may include the file information of the local files under the directory A of each electronic device in the distributed file system. For example, it includes the file information of the local file under the directory A of the electronic device A, the file information of the local file under the directory A of the electronic device B, and the like.
可选的,文件信息至少可以包括文件名、文件图标,还可以包括有文件的实际数据等,此处不作限定。Optionally, the file information may include at least a file name, a file icon, and may also include actual data of the file, etc., which is not limited here.
示例性的,显示分布式文件系统中目录A下的所有文件可以参考图6相应的描述,此处不再赘述。Exemplarily, for displaying all the files under the directory A in the distributed file system, reference may be made to the corresponding description in FIG. 6 , which will not be repeated here.
可以理解的是,本申请实施例中的同名文件识别方法,可以应用在无中心节点的分布式文件系统,也可以应用在有中心节点的分布式文件系统,此处不作限定。It can be understood that the method for identifying files with the same name in the embodiments of the present application can be applied to a distributed file system without a central node or a distributed file system with a central node, which is not limited here.
本申请实施例中,电子设备A通过比较无中心节点的分布式文件系统中各电子设备的布隆过滤器,可以快速的对每两个电子设备中同目录下存在同名文件的可能性进行整体判断,得到一定不可能存在同名文件和可能存在同名文件的结果。再根据整体判断的结果,对可能存在同名文件的电子设备进行后续处理,确定其中的同名文件进行重命名。由于各电子设备 中同目录下存在同名文件的情况并不是非常多,因此,在大多数情况下都能直接通过该整体判断得到同名文件识别的结果,即使没有得到最终结果,也可能快速的排除大多数不可能存在同名文件的电子设备,显著的缩小了进行同名文件识别的范围。极大的降低了进行同名文件识别时的处理时长,减少了进行同名文件识别时消耗的资源。In the embodiment of the present application, the electronic device A can quickly analyze the possibility that a file with the same name exists in the same directory in every two electronic devices by comparing the Bloom filters of the electronic devices in the distributed file system without a central node. It is judged that there must be a result that a file with the same name cannot exist and a file with the same name may exist. Then, according to the result of the overall judgment, follow-up processing is performed on the electronic device that may have a file with the same name, and it is determined that the file with the same name is renamed. Since there are not many cases of files with the same name in the same directory in each electronic device, in most cases, the result of identifying files with the same name can be obtained directly through the overall judgment. Even if the final result is not obtained, it may be quickly eliminated. Most of the electronic devices where the file with the same name cannot exist, significantly narrows the scope of the identification of the file with the same name. This greatly reduces the processing time when identifying files with the same name, and reduces the resources consumed when identifying files with the same name.
通过上述同名文件识别方法,可以在一个电子设备中显示另一个电子设备中的文件时快速检测出同名文件。在分布式文件系统中,一个电子设备不仅可以显示另一个电子设备中的文件,还可以读取另一个电子设备中的文件。为加快不同电子设备间进行数据读取的速度,可以采用数据预读技术。With the above method for identifying files with the same name, it is possible to quickly detect files with the same name when one electronic device displays a file in another electronic device. In a distributed file system, one electronic device can not only display files in another electronic device, but also read files in another electronic device. In order to speed up the data reading speed between different electronic devices, data pre-reading technology can be used.
目前的数据预读技术,会在读取完请求的数据后,再多预读固定的多个内存页的数据。然后在倒数的第固定数值个内存页上设置一个预读标志位。当访问到该预读标志位时,可以触发进行下一次预读。The current data pre-reading technology will pre-read more fixed multiple memory pages after reading the requested data. Then set a read-ahead flag on the last fixed value memory page. When the pre-reading flag is accessed, the next pre-reading can be triggered.
然而,在分布式文件系统中,各电子设备间的网络环境经常处于动态变化中。且各电子设备的性能也各有不同。在一个电子设备对另一个电子设备进行数据预读时,经常会由于网络环境的变化或设备性能的差异而导致预读效果较差。However, in a distributed file system, the network environment among various electronic devices is often in dynamic change. And the performance of each electronic device is also different. When one electronic device performs data pre-reading on another electronic device, the pre-reading effect is often poor due to changes in the network environment or differences in device performance.
而本申请实施例中提供的数据预读方法,能提升分布式文件系统中电子设备的预读性能。However, the data pre-reading method provided in the embodiment of the present application can improve the pre-reading performance of the electronic device in the distributed file system.
三、数据预读方法:3. Data pre-reading method:
下面先对本申请实施例涉及数据预读方法的相关术语及概念进行介绍。The related terms and concepts related to the data pre-reading method in the embodiments of the present application are first introduced below.
(1)分布式文件系统:(1) Distributed file system:
本申请实施例中,多个电子设备组成了分布式文件系统。In the embodiments of the present application, multiple electronic devices form a distributed file system.
分布式文件系统为分布在各电子设备上任意位置的资源提供一个逻辑上的文件系统结构,从而使访问分布在各电子设备上的共享文件更加简便。The distributed file system provides a logical file system structure for resources distributed at any position on each electronic device, thereby making it easier to access shared files distributed on each electronic device.
可以理解的是,本申请实施例中,该分布式文件系统可以为有中心的分布式文件系统,即有一个主电子设备管理分布式文件系统中所有文件的元数据信息;也可以为无中心的分布式文件系统,即所有电子设备都可以管理分布式文件系统中所有文件的元数据信息,此处不作限定。其中,一个文件的元数据信息中包含有描述该文件的元数据。例如,一个文件的元数据信息中包含的该文件的元数据可以包括:文件名、文件类型、文件大小、修改时间、访问权限、数据索引信息等,此处不作限定。It can be understood that, in this embodiment of the present application, the distributed file system may be a centered distributed file system, that is, a master electronic device manages the metadata information of all files in the distributed file system; it may also be a non-centered distributed file system. The distributed file system, that is, all electronic devices can manage the metadata information of all files in the distributed file system, which is not limited here. Among them, the metadata information of a file contains metadata describing the file. For example, the metadata of a file contained in the metadata information of the file may include: file name, file type, file size, modification time, access authority, data index information, etc., which are not limited here.
示例性的,图12为本申请实施例中多个电子设备组成的分布式文件系统的一个示例性示意图。例如,文件A为电子设备A中的文件,文件B为电子设备B中的文件,文件C为电子设备C中的文件。设备A、设备B、设备C和设备D组成分布式文件系统后,设备A可以访问文件B,设备D也可以访问文件C。即分布式文件系统中任一个电子设备均可以便捷的访问该分布式文件系统中其他电子设备中的文件。Exemplarily, FIG. 12 is an exemplary schematic diagram of a distributed file system composed of multiple electronic devices in an embodiment of the present application. For example, file A is a file in electronic device A, file B is a file in electronic device B, and file C is a file in electronic device C. After device A, device B, device C, and device D form a distributed file system, device A can access file B, and device D can also access file C. That is, any electronic device in the distributed file system can conveniently access files in other electronic devices in the distributed file system.
(2)内存页:(2) Memory page:
操作系统将内存空间划分为大小相同的页面进行管理,这样的页面称为内存页。The operating system divides the memory space into pages of the same size for management, and such pages are called memory pages.
根据操作系统设置的不同,不同电子设备的操作系统中内存页的大小可以不同,例如为4KB、8KB或16KB等。According to different operating system settings, the sizes of memory pages in operating systems of different electronic devices may be different, for example, 4KB, 8KB, or 16KB.
而在一个电子设备的操作系统中,以固定大小的内存页作为内存空间的最小分配单位,将电子设备中的数据以内存页的形式进行管理。因此也可以以内存页来作为数据量大小的单 位。In an operating system of an electronic device, a fixed-size memory page is used as the minimum allocation unit of memory space, and data in the electronic device is managed in the form of memory pages. Therefore, memory pages can also be used as the unit of data size.
下面对内存分页管理进行相关说明:The following describes the memory paging management:
2.1、内存管理:2.1, memory management:
操作系统中两个重要的概念为CPU和内存。CPU用于执行指令。内存用于存储计算机可执行程序代码、操作系统、程序、数据等。内存也可以被称为内部存储器。Two important concepts in an operating system are CPU and memory. The CPU is used to execute instructions. Memory is used to store computer executable program code, operating systems, programs, data, and the like. Memory can also be referred to as internal storage.
对于内存来说,它是资源有限的,如果进程占用内存较大甚至大于物理内存,并且要同时执行多个进程,这就需要涉及到内存管理。For memory, it has limited resources. If a process occupies a large amount of memory or even larger than physical memory, and multiple processes are to be executed at the same time, memory management needs to be involved.
理想情况下用户对内存的期待是大容量、高速度和持久性,但是现实中内存却是一个由缓存、主存、磁盘组成的内存架构。该架构中,缓存低容量、速度快但成本高,主存中速度、中容量和中成本,磁盘大容量、持久性但速度慢。Ideally, users' expectations for memory are large capacity, high speed, and durability, but in reality, memory is a memory architecture consisting of cache, main memory, and disk. In this architecture, the cache is low-capacity, high-speed but high-cost, the main memory has medium-speed, medium-capacity, and medium-cost, and the disk has large-capacity, persistence, but slow speed.
内存管理就是要对“用户”提供一个统一的抽象,屏蔽缓存、主存和磁盘之间的差异,甚至感知不到它们的存在。用户无需担心程序是存储在缓存、主存还是磁盘上,只要运行、输出的结果是一样的即可。Memory management is to provide a unified abstraction for "users", shielding the differences between cache, main memory and disk, or even unaware of their existence. Users do not need to worry about whether the program is stored in the cache, main memory or disk, as long as the operation and output results are the same.
且操作系统在同时执行多个进程的程序时,需要保证它们之间互不干扰,也就是说一个进程不能访问另一个进程的内存空间。程序中读写特定内存数据时,不能直接映射到物理内存,也就是说程序发出的内存地址和物理内存要是独立的。Moreover, when the operating system executes the programs of multiple processes at the same time, it needs to ensure that they do not interfere with each other, that is to say, one process cannot access the memory space of another process. When reading and writing specific memory data in a program, it cannot be directly mapped to physical memory, that is to say, the memory address issued by the program and the physical memory must be independent.
而使用虚拟内存就可以满足这些内存管理的需要。The use of virtual memory can meet the needs of these memory management.
2.2、虚拟内存:2.2, virtual memory:
虚拟内存是操作系统发展史上一个重要的里程碑。虚拟内存的使用,避免程序直接和物理内存打交道,并且对缓存、主存和磁盘做了统一抽象,这样程序就可以突破物理内存的大小限制,当然程序还是要受制于虚拟内存的大小限制。Virtual memory is an important milestone in the history of operating system development. The use of virtual memory prevents the program from directly dealing with physical memory, and abstracts the cache, main memory and disk so that the program can break through the size limit of physical memory. Of course, the program is still subject to the size limit of virtual memory.
使用虚拟内存后,程序中看到的内存地址是虚拟内存地址,程序对虚拟内存地址的读写会被映射到实际的物理内存中,这个映射称为翻译。这个翻译工作是由内存管理单元(memory management unit,MMU)来完成,MMU接收CPU发出的虚拟地址,将其翻译为物理地址后发送给内存,内存按照该物理地址进行相应访问后读出或写入相关数据。After using virtual memory, the memory address seen in the program is the virtual memory address, and the program's read and write to the virtual memory address will be mapped to the actual physical memory. This mapping is called translation. This translation work is done by the memory management unit (MMU). The MMU receives the virtual address sent by the CPU, translates it into a physical address and sends it to the memory. The memory reads or writes according to the physical address. Enter relevant data.
图40为本申请实施例中应用程序、虚拟内存和物理内存的一个关系示意图。电子设备中的缓存、主存、硬盘等物理内存在物理机器界面都可以统一抽象为虚拟内存,在虚拟机器界面提供虚拟内存地址给电子设备中的应用程序。用户通过应用程序对虚拟内存地址的读写会映射到实际的物理内存中。FIG. 40 is a schematic diagram of a relationship among an application program, virtual memory, and physical memory in an embodiment of the present application. The physical memory such as cache, main memory, hard disk, etc. in the electronic device can be abstracted into virtual memory uniformly on the physical machine interface, and the virtual memory address is provided to the application program in the electronic device on the virtual machine interface. The user's reading and writing of virtual memory addresses through the application program will be mapped to the actual physical memory.
2.3、内存空间分页管理:2.3, memory space paging management:
内存空间分页管理的核心是将虚拟内存空间和物理内存空间皆划分为大小相同的页面,并以页面作为内存空间的最小分配单位,一个程序的一个页面可以存放在任意一个物理页面里。The core of memory space paging management is to divide the virtual memory space and the physical memory space into pages of the same size, and use the page as the minimum allocation unit of the memory space. One page of a program can be stored in any physical page.
通过内存空间的分页管理,可以实现连续的虚拟空间映射到不一定连续的物理内存。这样可以使得进程中连续的数据段存储在不连续的物理内存中,使得对内存空间的管理更加灵活。Through the paging management of memory space, continuous virtual space can be mapped to physical memory that is not necessarily continuous. In this way, continuous data segments in the process can be stored in discontinuous physical memory, which makes the management of memory space more flexible.
图41为本申请实施例中内存分页管理的一个示例性示意图。分页机制可以将数据拆分成内存页大小,分配虚拟地址空间中的连续地址。这些在虚拟地址空间中地址连续的内存页可 以打散分配到在物理地址空间中未分配页。FIG. 41 is an exemplary schematic diagram of memory paging management in an embodiment of the present application. The paging mechanism can split data into memory page sizes and allocate contiguous addresses in the virtual address space. These memory pages with contiguous addresses in the virtual address space can be fragmented and allocated to unallocated pages in the physical address space.
本申请一些实施例中,内存页也可以简称为页,后续不再赘述。In some embodiments of the present application, a memory page may also be referred to as a page for short, which will not be described in detail later.
在一些实施例中,可以将用来缓存文件数据的内存页称为文件页,此处不作限定。In some embodiments, a memory page used to cache file data may be called a file page, which is not limited here.
(3)数据预读:(3) Data pre-reading:
本申请实施例中,分布式文件系统中一个电子设备访问另一个电子设备中的文件时,为提高访问效率,可以采用数据预读技术。In the embodiment of the present application, when one electronic device in the distributed file system accesses a file in another electronic device, in order to improve the access efficiency, a data pre-reading technology may be used.
下面以分布式文件系统中电子设备A访问电子设备B中的文件A为例进行说明:The following is an example of how electronic device A accesses file A in electronic device B in the distributed file system:
3.1、若不进行数据预读:3.1. If data pre-reading is not performed:
图42为进行数据访问的一个示例性场景示意图。FIG. 42 is a schematic diagram of an exemplary scenario for data access.
电子设备A访问电子设备B的文件A的过程中,电子设备A会根据需要,向电子设备B读取文件A下一部分的数据。例如,假设文件A为一个文档,该文档是数据占据25个内存页,按顺序为Y1至Y25。During the process of accessing the file A of the electronic device B by the electronic device A, the electronic device A will read the data of the next part of the file A from the electronic device B as required. For example, suppose file A is a document whose data occupies 25 memory pages, in order Y1 to Y25.
如图42中的(a)所示,若电子设备A已经读取了文件A的一部分数据,对应内存页为Y1~Y10。当用户翻页后,电子设备A要显示文件A的下一部分数据,对应内存页为Y11~Y15。则电子设备A可以向电子设备B请求访问Y11~Y15。As shown in (a) of FIG. 42 , if the electronic device A has read a part of the data of the file A, the corresponding memory pages are Y1 to Y10. After the user turns the pages, the electronic device A wants to display the next part of the data of the file A, and the corresponding memory pages are Y11-Y15. Then the electronic device A can request the electronic device B to access Y11-Y15.
如图42中的(b)所示,电子设备A可以缓存Y11~Y15并显示。当用户翻页后,电子设备A需要显示文件A的下一部分数据,对应内存页为Y16~Y20。则电子设备A需要再向电子设备B请求访问Y16~Y20才能再显示文件A的下一部分。As shown in (b) of FIG. 42 , the electronic device A can buffer and display Y11 to Y15. After the user turns the pages, the electronic device A needs to display the next part of the data of the file A, and the corresponding memory pages are Y16-Y20. Then, the electronic device A needs to request the electronic device B to access Y16-Y20 again to display the next part of the file A again.
这样可能使得用户在电子设备A上查看文件A时不连续,在查看一部分数据后,需要等待一段时间才能查看另一部分数据。This may cause the user to view the file A on the electronic device A discontinuously. After viewing a part of the data, it takes a period of time to view another part of the data.
3.2、若进行数据预读:3.2. If data pre-reading is performed:
图43为进行数据预读的一个示例性场景示意图。FIG. 43 is a schematic diagram of an exemplary scenario for performing data pre-reading.
电子设备A访问电子设备B的文件A的过程中,电子设备A会根据当前读取文件A的数据的进度,向电子设备B读取文件A下一部分的数据。例如,假设文件A为一个文档,该文档是数据占据25个内存页,按顺序为Y1至Y25。During the process of accessing the file A of the electronic device B by the electronic device A, the electronic device A will read the data of the next part of the file A from the electronic device B according to the current progress of reading the data of the file A. For example, suppose file A is a document whose data occupies 25 memory pages, in order Y1 to Y25.
如图43中的(a)所示,若电子设备A已经读取了文件A的一部分数据,对应内存页为Y1~Y10。在电子设备A读取已缓存的Y6~Y10,显示Y6~Y10的过程中,当电子设备A读取到Y8时,电子设备A就向电子设备B发送预读文件A的Y11~Y15的内存页的请求。As shown in (a) of FIG. 43 , if the electronic device A has read a part of the data of the file A, the corresponding memory pages are Y1 to Y10. During the process of electronic device A reading the cached Y6-Y10 and displaying Y6-Y10, when electronic device A reads Y8, electronic device A sends the memory of Y11-Y15 of pre-read file A to electronic device B page request.
如图43中的(b)所示,在用户看完电子设备A显示的Y6~Y10的数据,翻页想要看文件A的下一部分数据时,电子设备A已经预读完成了Y11~Y15,可以直接显示Y11~Y15。而不再需要向电子设备B请求访问Y11~Y15,等待电子设备B返回数据后才能显示。As shown in (b) of FIG. 43 , when the user reads the data of Y6 to Y10 displayed by the electronic device A and turns the page to see the next part of the data of the file A, the electronic device A has completed the pre-reading of Y11 to Y15 , Y11~Y15 can be displayed directly. It is no longer necessary to request the electronic device B to access Y11 to Y15, and wait for the electronic device B to return data before displaying.
并且,在电子设备A读取已缓存的Y11~Y15,显示Y11~Y15的过程中,当电子设备A读取到Y13时,电子设备A就可以向电子设备B发送预读文件A的Y16~Y20的内存页的请求。In addition, during the process of electronic device A reading the buffered Y11-Y15 and displaying Y11-Y15, when electronic device A reads Y13, electronic device A can send Y16-Y16-Y13 of pre-read file A to electronic device B. Y20 memory page request.
这样,使用数据预读能极大的提升电子设备A访问电子设备B中文件时的流畅度,节省数据获取时间。In this way, using data pre-reading can greatly improve the fluency of electronic device A when accessing files in electronic device B, and save data acquisition time.
(4)预读窗口大小:(4) Pre-reading window size:
本申请实施例中,预读窗口大小为电子设备在每次预读时获取的数据占内存页的数目。In this embodiment of the present application, the size of the pre-reading window is the number of memory pages occupied by data acquired by the electronic device in each pre-reading.
例如,若每次预读N个内存页,则预读窗口大小为N。For example, if N memory pages are read ahead at a time, the size of the read ahead window is N.
(5)预读标志位:(5) Pre-read flag bit:
本申请实施例中,电子设备可以在预读的内存页中设置预读标志位,当访问到具有预读标志位的内存页时,就触发该电子设备进行下一次预读。In the embodiment of the present application, the electronic device may set a pre-reading flag in the pre-reading memory page, and when accessing a memory page with the pre-reading flag, the electronic device is triggered to perform the next pre-reading.
结合图43,图44为本申请实施例中预读标志位一个示例性场景示意图。电子设备A在缓存预读的内存页Y6~Y10时,可以在内存页Y8中设置预读标志位。在电子设备A在显示Y6~Y10的过程中,当电子设备A访问到内存页Y8时,由于内存页Y8中具有预读标志位,因此就会触发电子设备A进行下一次预读。例如按照预读窗口大小5向电子设备B预读文件A的Y11~Y15部分的数据。With reference to FIG. 43 , FIG. 44 is a schematic diagram of an exemplary scenario of a pre-reading flag bit in an embodiment of the present application. When the electronic device A caches the pre-read memory pages Y6 to Y10, the pre-read flag can be set in the memory page Y8. When the electronic device A is displaying Y6-Y10, when the electronic device A accesses the memory page Y8, since the memory page Y8 has a pre-reading flag, the electronic device A will be triggered to perform the next pre-reading. For example, the data of the parts Y11 to Y15 of the file A are pre-read to the electronic device B according to the pre-read window size 5.
可以理解的是,内存页中除了可以存储数据,还可以存在一些空间存储其他的特殊字段。例如可以修改某个特殊字段的值,使得该字段成为预读标志位,此处不作限定。It is understandable that, in addition to storing data, there may also be some space to store other special fields in the memory page. For example, the value of a special field can be modified to make the field a pre-reading flag, which is not limited here.
(6)网络往返延迟:(6) Network round-trip delay:
6.1、网络往返延迟的定义:6.1. Definition of network round-trip delay:
网络往返延迟,在计算机网络中它是一个重要的性能指标,表示从发送端发送数据开始,到发送端收到来自接收端的确认(接收端收到数据后便立即发送确认),总共经历的时延。The network round-trip delay is an important performance indicator in computer networks, indicating that from the sender sending data to the sender receiving the confirmation from the receiver (the receiver sends the confirmation immediately after receiving the data), the total time extension.
例如,电子设备A向电子设备B发送数据,若电子设备A发送数据后200ms收到电子设备B的确认,则可以认为此时电子设备A与电子设备B之间的网络延迟为200ms。For example, electronic device A sends data to electronic device B. If electronic device A receives confirmation from electronic device B 200ms after sending data, it can be considered that the network delay between electronic device A and electronic device B is 200ms at this time.
6.2、网络往返延迟的波动:6.2. The fluctuation of network round-trip delay:
本申请实施例中,分布式文件系统中电子设备间进行数据访问时,由于电子设备的类型可能不同,电子设备所处的网络环境可能不同,或者网络环境处于变化中等情况,会使得电子设备之间的网络往返延迟波动较大,可能处于持续的变化状态。In the embodiment of the present application, when data access is performed between electronic devices in a distributed file system, since the types of electronic devices may be different, the network environment where the electronic devices are located may be different, or the network environment is changing, etc. The network round-trip delay between them fluctuates greatly and may be in a constant state of change.
例如,若电子设备A访问电子设备B中的数据,电子设备A和电子设备B均为移动终端,使用无线移动网络。则受电子设备A和电子设备B所使用的移动网络服务商在周围布置基站的数目,周围使用无线移动网络的用户数目,与基站距离的远近等因素等影响,都会使得电子设备A和电子设备B之间的网络延迟动态变化。For example, if electronic device A accesses data in electronic device B, both electronic device A and electronic device B are mobile terminals and use a wireless mobile network. Influenced by factors such as the number of base stations arranged around by the mobile network service provider used by electronic equipment A and electronic equipment B, the number of users using wireless mobile networks around, the distance from the base station and other factors, electronic equipment A and electronic equipment will be affected. The network latency between B varies dynamically.
6.3、网络往返延迟的确定:6.3. Determination of network round-trip delay:
本申请实施例中,电子设备可以通过获取与分布式文件系统中另一个电子设备间的TCP链接中的往返时延(round trip time,RTT),来确定与该电子设备的网络往返延迟。In the embodiment of the present application, the electronic device may determine the network round-trip delay with the electronic device by obtaining the round trip delay (round trip time, RTT) in the TCP link with another electronic device in the distributed file system.
由于发送端与接收端的每一次通信都可以获取到最新的RTT,因此,电子设备可以实时监测与另一个电子设备间的网络往返延迟。Since the latest RTT can be obtained for each communication between the sender and the receiver, the electronic device can monitor the network round-trip delay with another electronic device in real time.
(7)网络带宽:(7) Network bandwidth:
网络带宽,是指在单位时间(例如,1秒钟)内能传输的数据量。Network bandwidth refers to the amount of data that can be transmitted in a unit of time (for example, 1 second).
例如,若电子设备A和电子设备B之间1秒钟能传输500bit的数据,则可以认为电子设备A和电子设备B之间的网络带宽为500bit/s。For example, if 500 bits of data can be transmitted between electronic device A and electronic device B in one second, it can be considered that the network bandwidth between electronic device A and electronic device B is 500 bits/s.
本申请实施例中,可以通过多种方式确定分布式文件系统中电子设备A和电子设备B之间的网络带宽:例如,可以使电子设备A和电子设备B之间进行网络传输测试,从而确定电 子设备A和电子设备B之间的网络带宽;再如,可以根据电子设备A的信号强度和/或电子设备A使用的网络频段,预估电子设备A的网络带宽。还可以有很多其他的确定电子设备A和电子设备B之间网络带宽的方式,此处不作限定。In this embodiment of the present application, the network bandwidth between electronic device A and electronic device B in the distributed file system can be determined in various ways: for example, a network transmission test can be performed between electronic device A and electronic device B to determine Network bandwidth between electronic device A and electronic device B; for another example, the network bandwidth of electronic device A can be estimated according to the signal strength of electronic device A and/or the network frequency band used by electronic device A. There may also be many other ways of determining the network bandwidth between the electronic device A and the electronic device B, which are not limited here.
(8)设备类型:(8) Equipment type:
本申请实施例中,按照电子设备的能力的大小,可以将电子设备分为不同的设备类型。对于不同的设备类型,可以将预读标志位设置在预读的内存页中的不同位置。In the embodiment of the present application, according to the capability of the electronic device, the electronic device can be divided into different device types. For different device types, the read-ahead flag can be set at different locations in the read-ahead memory page.
可选的,可以将超出预设能力值的电子设备称为第一能力设备,例如手机、电脑等;将不超出预设能力值的电子设备称为第二能力设备,例如手表、路由器等。该预设能力值可以包括cpu核心数和频率,内存大小等参数,此处不作限定。Optionally, an electronic device that exceeds the preset capability value may be referred to as a first capability device, such as a mobile phone, computer, etc.; an electronic device that does not exceed the preset capability value may be referred to as a second capability device, such as a watch, router, etc. The preset capability value may include parameters such as the number and frequency of cpu cores, memory size, etc., which are not limited here.
示例性的,图45为本申请实施例中根据不同设备类型设置不同预读标志位的一个示例性示意图。以电子设备A从另一个电子设备中预读了包含有内存页Y1~Y25数据的文件A中的内存页Y6~Y10的数据为例。Exemplarily, FIG. 45 is an exemplary schematic diagram of setting different pre-reading flag bits according to different device types in an embodiment of the present application. It is assumed that electronic device A pre-reads data of memory pages Y6 to Y10 in file A containing data of memory pages Y1 to Y25 from another electronic device.
如图45中的(a)所示,若电子设备A是从第一能力设备中预读的数据。由于第一能力设备的能力较强,每次接收到预读请求时能较快的进行反馈处理,因此,电子设备A可以将预读的内存页中预读标志位的位置设置的比较靠后。例如设置为内存页Y6~Y10中的Y9上,这样,也足够该第一能力设备在后续时间内发送来新的预读数据。As shown in (a) of FIG. 45 , if the electronic device A is data pre-read from the first capability device. Since the first capability device has a relatively strong capability, it can perform feedback processing faster each time a pre-read request is received. Therefore, the electronic device A can set the position of the pre-read flag bit in the pre-read memory page to a later date. . For example, it is set to Y9 in the memory pages Y6 to Y10, so that it is sufficient for the device of the first capability to send new pre-read data in the subsequent time.
如图45中的(b)所示,若电子设备A是从第二能力设备中预读的数据。由于第二能力设备的能力较弱,每次接收到预读请求时需要较多的时间进行反馈处理。因此,电子设备A需要将预读的内存页中预读标志位的位置设置的比较靠前。例如设置为内存页Y6~Y10中的Y7上,这样,留下足够该第二能力设备发送来新的预读数据的时间。从而保障电子设备A在读取完内存页Y10的数据时,已经接收到了该第二能力设备发送来的电子设备A预读的下一部分数据。As shown in (b) of FIG. 45 , if the electronic device A is data pre-read from the second capability device. Since the capability of the second capability device is weak, more time is required for feedback processing each time a pre-reading request is received. Therefore, the electronic device A needs to set the position of the pre-read flag bit in the pre-read memory page relatively forward. For example, it is set to Y7 in the memory pages Y6 to Y10, so that there is enough time for the device of the second capability to send new pre-read data. Therefore, it is ensured that when the electronic device A finishes reading the data of the memory page Y10, it has already received the next part of the data pre-read by the electronic device A sent by the second capability device.
本申请实施例中,电子设备中存储有分布式文件系统中已经建立通信连接的电子设备与其设备类型的对应关系。则电子设备在从分布式文件系统中另一个电子设备预读数据后,可以根据该存储的对应关系中该另一个电子设备的设备类型,在预读数据所在的内存页中相应位置设置预读标志位。In the embodiment of the present application, the electronic device stores the correspondence between the electronic devices that have established communication connections in the distributed file system and their device types. Then, after the electronic device pre-reads data from another electronic device in the distributed file system, it can set pre-reading in the corresponding position in the memory page where the pre-read data is located according to the device type of the other electronic device in the stored correspondence. flag bit.
可以理解的是,本申请实施例中以将设备类型划分为第一能力设备和第二能力设备为例,在实际应用中,可以根据电子设备的能力的大小,将电子设备划分为更多不同的设备类型,为更多不同的设备类型设置更多不同的预读标志位的相对位置,此处不作限定。It can be understood that in this embodiment of the present application, the device types are divided into first capability devices and second capability devices as an example. In practical applications, electronic devices can be divided into more different types according to the capabilities of the electronic devices. For more different device types, set more different relative positions of pre-read flag bits, which are not limited here.
(9)前台应用:(9) Foreground application:
本申请实施例中,电子设备可以确定请求预读数据的应用是否为前台应用。In this embodiment of the present application, the electronic device may determine whether an application requesting pre-reading data is a foreground application.
具体的,电子设备中,由应用的进程发起请求,应用的进程中可以具有应用类型标识,该应用类型标识用于标识该进程所属应用的应用类型。若该应用类型标识为前台应用标识,则可以确定该进程所属的应用当前为前台应用。若该应用类型标识不是前台应用标识,则可以确定该进程所属的应用当前不是前台应用。Specifically, in the electronic device, a process of an application initiates a request, and the process of the application may have an application type identifier, and the application type identifier is used to identify the application type of the application to which the process belongs. If the application type identifier is the foreground application identifier, it can be determined that the application to which the process belongs is currently the foreground application. If the application type identifier is not the foreground application identifier, it can be determined that the application to which the process belongs is not currently the foreground application.
(10)文件类型:(10) File type:
本申请实施例中,电子设备可以确定访问文件的文件类型。In this embodiment of the present application, the electronic device may determine the file type of the access file.
具体的,电子设备在访问某个文件时,需要发送访问请求,该访问请求中可以携带需访 问文件的索引信息,该索引信息中可以包含有需访问文件的扩展名(或称为后缀名)。电子设备可以根据该扩展名来确定访问文件的文件类型。Specifically, when an electronic device accesses a certain file, it needs to send an access request. The access request may carry index information of the file to be accessed, and the index information may include the extension (or suffix name) of the file to be accessed. . The electronic device can determine the file type of the access file according to the extension.
例如,若访问的文件的扩展名为rmvb、mp4、avi等视频文件的扩展名,则电子设备可以确定访问的文件为视频文件。For example, if the extension of the accessed file is the extension of a video file such as rmvb, mp4, avi, etc., the electronic device may determine that the accessed file is a video file.
可以理解的是,视频文件的扩展名还可以有很多种,例如flv、mov、wmv等等,此处不作限定。It can be understood that the extension of the video file can also have many kinds, such as flv, mov, wmv, etc., which are not limited here.
图46为现有技术中进行数据预读的一个示例性信令交互示意图。结合图46,图47为现有技术中数据预读的内存页一个示例性状态示意图。假设电子设备A中预先设定的默认预读窗口大小为10,预读标志位的默认位置为-5。电子设备A接收到访问电子设备B中文件A的请求后,电子设备A读取当前需要使用的数据后,还可以按照默认预读窗口大小10,在预读起始位置后预读文件A的10个内存页的数据。然后,在预读的内存页中,按照默认位置-5,在倒数第5个内存页,设置一个预读标志位。当电子设备A读取到有预读标志位的内存页时,电子设备A触发对文件A的下一次预读。可以理解的是,下一次预读也会按照默认预读窗口大小10,预读标志位的默认位置-5来进行处理。FIG. 46 is a schematic diagram of an exemplary signaling interaction for data pre-reading in the prior art. With reference to FIG. 46 , FIG. 47 is a schematic diagram of an exemplary state of a memory page for data pre-reading in the prior art. Assume that the default pre-reading window size preset in the electronic device A is 10, and the default position of the pre-reading flag is -5. After the electronic device A receives the request to access the file A in the electronic device B, after the electronic device A reads the data that needs to be used, it can also pre-read the file A after the pre-reading starting position according to the default pre-reading window size of 10. 10 memory pages of data. Then, in the pre-read memory page, according to the default position -5, in the penultimate memory page, a pre-read flag is set. When the electronic device A reads the memory page with the pre-reading flag, the electronic device A triggers the next pre-reading of the file A. It is understandable that the next pre-reading will also be processed according to the default pre-reading window size of 10 and the default position of the pre-reading flag bit -5.
因此,在分布式文件系统间各电子设备相互访问文件的场景中,各电子设备间的网络环境经常处于动态变化中,且各电子设备的性能也各有不同。例如,若当前电子设备A与电子设备B之间的网络环境较差,延迟较高。可能会出现在电子设备A读取完上一次预读的10个内存页的数据时,还没有接收到下一次预读的10个内存页的数据。电子设备A需要等待更多的时间才能获取到预读的数据,导致电子设备A无法连续的处理数据,降低了电子设备A的处理效率。且可能使得用户使用电子设备A查看文件A的过程不连续,降低了用户体验。Therefore, in a scenario in which various electronic devices access files between distributed file systems, the network environment among the various electronic devices is often in dynamic change, and the performance of each electronic device is also different. For example, if the current network environment between electronic device A and electronic device B is poor, the delay is high. It may happen that when the electronic device A finishes reading the data of the 10 memory pages pre-read last time, it has not yet received the data of the next pre-reading 10 memory pages. The electronic device A needs to wait for more time to obtain the pre-read data, so that the electronic device A cannot process the data continuously, which reduces the processing efficiency of the electronic device A. Furthermore, the process of viewing the file A by the user using the electronic device A may be discontinuous, which reduces the user experience.
而采用本申请实施例中的数据预读方法,电子设备A可以根据当前与电子设备B之间的网络延迟和网络带宽,确定合适的预读窗口。且能够根据需要访问的文件的类型、访问文件的应用的类型以及电子设备B的设备类型,确定在预读的内存页中设置预读标志位的数目和位置。这样可使得确定的预读窗口大小和设置的预读标志位更符合当前的需求,减小了网络环境变化和电子设备B的设备类型等因素对预读效果的影响,从而可以提升分布式文件系统中电子设备的预读性能,加快电子设备之间的数据访问速度。However, by using the data pre-reading method in the embodiment of the present application, electronic device A can determine an appropriate pre-reading window according to the current network delay and network bandwidth between electronic device B and electronic device B. And the number and position of pre-reading flag bits to be set in the pre-reading memory page can be determined according to the type of the file to be accessed, the type of the application accessing the file, and the device type of the electronic device B. In this way, the determined pre-reading window size and the set pre-reading flag can be more in line with the current requirements, and the influence of factors such as network environment changes and the device type of electronic device B on the pre-reading effect can be reduced, thereby improving the distributed file The read-ahead performance of electronic devices in the system speeds up data access between electronic devices.
示例性的,图48为本申请实施例中数据预读的一个示例性场景示意图。若电子设备A预读了电子设备B中文件A的数据,电子设备A预读了N个内存页,这N个内存页中有K个预读标志位,最后一个预读标志的位置为-M。则其中的预读窗口大小N为根据电子设备A与电子设备B之间网络往返延迟和网络带宽确定的,其中的K为根据文件A的文件类型确定的,其中的M为根据电子设备B的设备类型确定的。而不是使用的默认设定值。Exemplarily, FIG. 48 is a schematic diagram of an exemplary scenario of data pre-reading in this embodiment of the present application. If electronic device A pre-reads the data of file A in electronic device B, and electronic device A pre-reads N memory pages, there are K pre-read flag bits in these N memory pages, and the position of the last pre-read flag is - M. Then the pre-reading window size N is determined according to the network round-trip delay and network bandwidth between electronic device A and electronic device B, where K is determined according to the file type of file A, and M is determined according to the file type of electronic device B. Device type is determined. instead of using the default settings.
这样,根据网络环境的不同,电子设备A确定的预读窗口大小不同:在网络环境较差时可以预读更多的内存页,在网络环境较好时可以预读较少的内存页。在降低电子设备A的功耗的同时保障了电子设备A每次都能预读合适数目的内存页。In this way, according to different network environments, the size of the pre-reading window determined by the electronic device A is different: more memory pages can be pre-read when the network environment is poor, and fewer memory pages can be pre-read when the network environment is good. While reducing the power consumption of the electronic device A, it is ensured that the electronic device A can pre-read a suitable number of memory pages each time.
而根据需要访问的文件A的文件类型、访问文件A的应用的类型和电子设备B的设备类型不同,电子设备A可以在预读的内存页中设置不同数目和位置的预读标志位:Depending on the file type of file A that needs to be accessed, the type of application accessing file A, and the device type of electronic device B, electronic device A can set different numbers and positions of pre-read flags in the pre-read memory page:
对于视频类型的文件,由于用户可能需要跳转查看,因此可以在每次预读的内存页中多设置几个预读标志位,甚至可以在每个预读的内存页中设置预读标志位,使用户跳转查看到任意位置后,都可以触发后续的预读标志位进行预读。For video type files, since users may need to jump to view, several more pre-read flags can be set in each pre-read memory page, or even pre-read flags can be set in each pre-read memory page , so that after the user jumps to any position, the subsequent pre-reading flag can be triggered for pre-reading.
对于其他类型的文件,即使只设置一个预读标志位:如果是前台应用访问远端文件,为了使前台应用获取更好的远端数据读写性能,因此可以将预读标志位设置在靠前的位置,例如将预读标志位设置在预读的内存页中的第一个内存页上;而对于后台应用访问远端文件,为了降低电子设备的网络负载,可以将预读标志位设置在较靠后的位置,使得预读的时机靠后。例如,将预读标志位设置在预读的内存页中倒数1/4的位置等。For other types of files, even if only one pre-reading flag is set: if the foreground application accesses the remote file, in order to enable the foreground application to obtain better remote data read and write performance, the pre-reading flag can be set at the front. For example, set the pre-reading flag on the first memory page of the pre-reading memory pages; for background applications accessing remote files, in order to reduce the network load of the electronic device, you can set the pre-reading flag at The later position makes the timing of pre-reading later. For example, the pre-read flag is set at the last 1/4 position in the pre-read memory page, etc.
即使都是前台应用,也可以根据远端的电子设备B的设备类型,在预读的内存页中设置不同位置的预读标志位:因为电子设备B的能力越强,电子设备B反馈数据的速度越快,则可以将预读标志位设置在相对靠后的位置,这样也有足够的时间接收到电子设备B反馈的预读数据。而如果电子设备B的能力较弱,电子设备B反馈数据的速度较慢,则需要将预读标志位设置在相对靠前的位置。使得电子设备A在处理完已有数据之前,能接收到电子设备B返回的预读数据。Even if they are all foreground applications, pre-read flags at different positions can be set in the pre-read memory page according to the device type of the remote electronic device B: because the stronger the capability of the electronic device B, the better the ability of the electronic device B to feed back data. The faster the speed is, the pre-reading flag bit can be set at a relatively backward position, so that there is enough time to receive the pre-reading data fed back by the electronic device B. However, if the capability of the electronic device B is weak and the speed of the electronic device B feeding back data is slow, the pre-reading flag needs to be set at a relatively front position. This enables the electronic device A to receive the pre-read data returned by the electronic device B before processing the existing data.
因此,根据网络环境适应性的确定预读窗口大小,根据需要访问的文件A的文件类型、访问文件A的应用的类型和电子设备B的设备类型适应性的设置不同数目和位置的预读标志位,可以使得电子设备A更大可能的在处理完已有预读数据之前接收到电子设备B返回的新的预读数据,且不需要存储过多的预读数据,在极大的提升了分布式文件系统中电子设备的预读性能的同时,消耗了较少的网络和存储资源。Therefore, the size of the pre-reading window is determined adaptively according to the network environment, and different numbers and positions of pre-reading flags are set adaptively according to the file type of the file A to be accessed, the type of the application accessing the file A, and the device type of the electronic device B. bit, which can make it more likely that electronic device A will receive the new pre-read data returned by electronic device B before processing the existing pre-read data, and does not need to store too much pre-read data, which greatly improves the The read-ahead performance of electronic devices in a distributed file system consumes less network and storage resources.
结合对图13所示的电子设备100的硬件结构示意图的描述,本申请的一些实施例中,电子设备100可以通过移动通信模块150或无线通信模块160与其他电子设备组成分布式文件系统。该处理器110可以调用内部存储器121中存储的计算机指令以使得电子设备100执行本申请实施例中的数据预读方法。With reference to the description of the hardware structure diagram of the electronic device 100 shown in FIG. 13 , in some embodiments of the present application, the electronic device 100 may form a distributed file system with other electronic devices through the mobile communication module 150 or the wireless communication module 160 . The processor 110 may call the computer instructions stored in the internal memory 121 to cause the electronic device 100 to execute the data pre-reading method in the embodiment of the present application.
结合对图14所示的电子设备100的软件结构示意图的描述,如图49所示,本申请的一些实施例中,该内核层还可以包含有数据预读模块。With reference to the description of the schematic diagram of the software structure of the electronic device 100 shown in FIG. 14 , as shown in FIG. 49 , in some embodiments of the present application, the kernel layer may further include a data pre-reading module.
该数据预读模块用于在电子设备100访问分布式文件系统中其他电子设备的文件时,执行本申请实施例中的数据预读方法。The data pre-reading module is configured to execute the data pre-reading method in this embodiment of the present application when the electronic device 100 accesses files of other electronic devices in the distributed file system.
可以理解的是,在一些实施例中,该数据预读模块还可以位于该分层构架的其他层级,例如应用程序层,应用程序框架层,系统库等,此处不作限定。It can be understood that, in some embodiments, the data pre-reading module may also be located at other levels of the hierarchical architecture, such as an application program layer, an application program framework layer, a system library, etc., which are not limited here.
下面结合上述示例性电子设备100的软硬件结构,对本申请实施例中数据预读方法进行具体描述。本申请实施例中的电子设备A或电子设备B都可以采用上述示例性电子设备100的软硬件结构,此处不作限定。The data pre-reading method in the embodiment of the present application will be described in detail below with reference to the software and hardware structure of the above-mentioned exemplary electronic device 100 . Both the electronic device A or the electronic device B in the embodiment of the present application may adopt the software and hardware structure of the foregoing exemplary electronic device 100, which is not limited here.
本申请实施例中的数据预读方法可分为三个阶段:The data pre-reading method in the embodiment of the present application can be divided into three stages:
(1)预读窗口大小确定阶段:根据网络延迟和网络带宽实时确定预读窗口大小。(1) Pre-reading window size determination stage: The pre-reading window size is determined in real time according to network delay and network bandwidth.
(2)预读标志位确定阶段:根据访问的文件的文件类型、访问文件的应用的应用类型、以及对端电子设备的设备类型确定预读的内存页中需设置的预读标志位的数目和位置;(2) Pre-reading flag determination stage: determine the number of pre-reading flag bits to be set in the pre-reading memory page according to the file type of the file being accessed, the application type of the application accessing the file, and the device type of the peer electronic device and location;
(3)预读阶段:按照(1)预读窗口大小确定阶段中实时确定的预读窗口大小,和(2)预读标志位确定阶段中确定的需设置的预读标志位的数目和位置,从对端电子设备预读数据并设置预读标志位。(3) Pre-reading stage: According to (1) the pre-reading window size determined in real time in the pre-reading window size determination stage, and (2) the number and position of the pre-reading flag bits to be set determined in the pre-reading flag bit determination stage , pre-read data from the peer electronic device and set the pre-read flag.
可以理解的是,Understandably,
(1)预读窗口大小确定阶段可以持续的重复执行,实时更新预读窗口大小。(1) The pre-reading window size determination stage can be continuously and repeatedly executed, and the pre-reading window size is updated in real time.
(2)预读标志位确定阶段可以仅在向一个电子设备访问一个新的文件时执行一次,确定访问该电子设备中该文件时进行数据预读时需设置的预读标志位的数目和位置,后续在(3)预读阶段预读该文件的数据时均可以直接使用之前确定的预读标志位的数目和位置。也可以在(3)预读阶段预读该文件前或过程中多次重复执行,实时更新需设置的预读标志位的数目和位置,此处不作限定。(2) The pre-reading flag determination stage can be executed only once when a new file is accessed to an electronic device, and the number and position of the pre-reading flags to be set when pre-reading the data when accessing the file in the electronic device is determined. , the number and position of the pre-read flag bits determined before can be directly used when pre-reading the data of the file in the subsequent (3) pre-reading stage. Before or during the pre-reading stage (3), the pre-reading of the file can also be performed repeatedly, and the number and position of the pre-reading flag bits to be set are updated in real time, which is not limited here.
(3)预读阶段会在每次电子设备读取到有预读标志位的内存页时触发执行。(3) The pre-reading stage will trigger execution every time the electronic device reads a memory page with a pre-reading flag.
下面以分布式文件系统中电子设备A中的应用A访问电子设备B中的文件F为例,分别对本申请实施例中数据预读的这三个阶段进行详细描述:The following three stages of data pre-reading in the embodiments of the present application are described in detail by taking the example of application A accessing the file F in the electronic device B in the electronic device A in the distributed file system:
(1)预读窗口大小确定阶段:(1) Pre-reading window size determination stage:
图50为本申请实施例中预读窗口大小确定阶段的一个信令交互示意图。FIG. 50 is a schematic diagram of signaling interaction in the stage of determining the size of the pre-reading window in the embodiment of the present application.
S5001、电子设备A中的应用A访问电子设备B中的文件F;S5001, application A in electronic device A accesses file F in electronic device B;
响应于用户操作或电子设备A中的自动任务,电子设备A中的应用A可以访问与该电子设备A处于同一个分布式文件系统中的电子设备B中的文件F。In response to a user operation or an automatic task in the electronic device A, the application A in the electronic device A can access the file F in the electronic device B that is in the same distributed file system as the electronic device A.
电子设备A访问电子设备B中的文件F时,可以先从分布式文件系统中唯一的元数据服务器中查询文件F的元数据信息,再根据文件F的元数据信息向电子设备B访问文件F;也可以查询本电子设备中缓存的文件F的元数据信息,在根据文件F的元数据信息向电子设备B访问文件F,此处不作限定。When electronic device A accesses file F in electronic device B, it can first query the metadata information of file F from the unique metadata server in the distributed file system, and then access file F to electronic device B according to the metadata information of file F. ; You can also query the metadata information of the file F cached in the electronic device, and access the file F to the electronic device B according to the metadata information of the file F, which is not limited here.
电子设备A中的应用A访问电子设备B中文件F的过程中,会根据应用A当前的需求,一段段的从电子设备B中获取文件F的部分数据,而不会直接获取文件F的全部数据。若一次性将远端文件整体读至本地,缓存在本地的内存或磁盘上,会使得网络开销和存储资源占用比按需读取的开销大很多,会极大的浪费网络与存储资源。In the process of accessing the file F in the electronic device B, the application A in the electronic device A will obtain part of the data of the file F from the electronic device B according to the current needs of the application A, instead of directly obtaining the entire file F. data. If the entire remote file is read to the local at one time and cached in the local memory or disk, the network overhead and storage resource usage will be much larger than the overhead of on-demand reading, which will greatly waste network and storage resources.
可以理解的是,电子设备A中的应用A需要访问电子设备B中的文件F时,会先向电子设备A发送访问电子设备B中文件F的请求。电子设备A接受到该访问电子设备B中文件F的请求后,可以执行步骤S5002。It can be understood that, when application A in electronic device A needs to access file F in electronic device B, it will first send a request for accessing file F in electronic device B to electronic device A. After the electronic device A accepts the request for accessing the file F in the electronic device B, step S5002 may be executed.
S5002、电子设备A实时监测与电子设备B之间的网络往返延迟;S5002, the network round-trip delay between electronic device A and electronic device B is monitored in real time;
在电子设备A接收到访问电子设备B中文件F的请求后,电子设备A可以实时监测与电子设备B之间的网络往返延迟。After the electronic device A receives the request to access the file F in the electronic device B, the electronic device A can monitor the network round-trip delay with the electronic device B in real time.
可以理解的是,电子设备A中的应用A访问电子设备B中的文件F的过程中,电子设备A会与电子设备B建立TCP链接。It can be understood that, during the process that the application A in the electronic device A accesses the file F in the electronic device B, the electronic device A will establish a TCP link with the electronic device B.
优选地,电子设备A可以实时获取与电子设备B之间的TCP链接的RTT参数值,作为与电子设备B之间的网络往返延迟。Preferably, the electronic device A can acquire the RTT parameter value of the TCP link with the electronic device B in real time, as the network round-trip delay with the electronic device B.
可选的,电子设备A可以通过周期性的向电子设备B发送一个请求,将接收到电子设备B返回的响应的时长作为与电子设备B之间的网络往返延迟。Optionally, the electronic device A may send a request to the electronic device B periodically, and use the duration of receiving the response returned by the electronic device B as the network round-trip delay with the electronic device B.
电子设备A还可以通过其他的方式实时监测与电子设备B之间的网络往返延迟,此处不作限定。The electronic device A may also monitor the network round-trip delay with the electronic device B in real time by other means, which is not limited here.
S5003、电子设备A确定与电子设备B之间的网络带宽;S5003, the electronic device A determines the network bandwidth with the electronic device B;
在电子设备A接收到访问电子设备B中文件F的请求后,电子设备A可以确定与电子设备B之间的网络带宽。After the electronic device A receives the request to access the file F in the electronic device B, the electronic device A can determine the network bandwidth with the electronic device B.
电子设备A确定与电子设备B之间的网络带宽的方式可以有很多种:There are many ways for electronic device A to determine the network bandwidth with electronic device B:
例如,可以通过分别确定电子设备A和电子设备B的网络带宽上限,将其中较小的网络带宽上限作为电子设备A与电子设备B之间的网络带宽。For example, the upper limit of the network bandwidth of the electronic device A and the electronic device B can be determined respectively, and the smaller upper limit of the network bandwidth can be used as the network bandwidth between the electronic device A and the electronic device B.
再如,可以使电子设备A和电子设备B之间进行网络传输测试,从而确定电子设备A和电子设备B之间的网络带宽;For another example, a network transmission test can be performed between the electronic device A and the electronic device B, thereby determining the network bandwidth between the electronic device A and the electronic device B;
再如,可以根据电子设备A的信号强度和/或电子设备A使用的网络频段,预估电子设备A和电子设备B之间的网络带宽。For another example, the network bandwidth between the electronic device A and the electronic device B can be estimated according to the signal strength of the electronic device A and/or the network frequency band used by the electronic device A.
电子设备A还可以有很多其他的确定与电子设备B之间的网络带宽的方式,此处不作限定。The electronic device A may also have many other ways of determining the network bandwidth with the electronic device B, which is not limited here.
可以理解的是,电子设备A确定的与电子设备B之间的网络带宽,可以是一个准确值,也可以是一个可能的估计值,此处不作限定。It can be understood that, the network bandwidth between the electronic device A and the electronic device B can be an exact value or a possible estimated value, which is not limited here.
S5004、电子设备A按照与电子设备B的网络往返延迟和网络带宽计算预读窗口大小;S5004, the electronic device A calculates the pre-reading window size according to the network round-trip delay and network bandwidth with the electronic device B;
电子设备A在确定与电子设备B之间的网络往返延迟和网络带宽后,可以根据该网络往返延迟和网络带宽计算预读窗口大小。After electronic device A determines the network round-trip delay and network bandwidth with electronic device B, the size of the read-ahead window may be calculated according to the network round-trip delay and network bandwidth.
具体的,如下为一种根据网络往返延迟和网络带宽计算预读窗口大小的方式:Specifically, the following is a way to calculate the size of the read-ahead window according to the network round-trip delay and network bandwidth:
首先定义符号S、T、L、N、D如下:First define the symbols S, T, L, N, D as follows:
S表示读取数据的最大速度;S represents the maximum speed of reading data;
T表示网络带宽;T represents network bandwidth;
L表示网络往返延迟;L represents the network round-trip delay;
N表示预读窗口大小;N represents the size of the read-ahead window;
D表示一个内存页的大小(一般一个内存页的大小为4KB)。D represents the size of a memory page (generally, the size of a memory page is 4KB).
通过对电子设备读取远端数据的性能S、网络带宽T、网络往返延迟L以及预读窗口大小N建模,最终可以得到预读窗口大小N与电子设备读取远端数据的性能S有如下关系:By modeling the performance S of the electronic device reading remote data, the network bandwidth T, the network round-trip delay L, and the size of the pre-reading window N, it can finally be obtained that the size of the pre-reading window N and the performance S of the electronic device reading remote data are as follows: The following relationship:
Figure PCTCN2021118646-appb-000001
Figure PCTCN2021118646-appb-000001
根据该公式1,可以确定按照如下公式2设置预读窗口大小N时,可以使得读取远端数据的性能S较大且消耗的网络带宽与存储资源较小:According to the formula 1, it can be determined that when the pre-reading window size N is set according to the following formula 2, the performance S of reading remote data can be larger and the network bandwidth and storage resources consumed are smaller:
N=L*T/D    (公式2)N=L*T/D (Formula 2)
可选的,对于该预读窗口大小N,还可以设置一个上限值,以防计算值过大。Optionally, for the pre-reading window size N, an upper limit value may also be set to prevent the calculated value from being too large.
可以理解的是,以上公式2仅仅是根据网络往返延迟和网络带宽计算预读窗口大小的一种方式,在实际应用中,可以在该公式2的基础上加减一定的偏移量,或乘除一定的系数等,还可以采用很多其他的根据方式来根据网络往返延迟和网络带宽计算预读窗口大小,此处不作限定。It can be understood that the above formula 2 is only a way to calculate the size of the read-ahead window according to the network round-trip delay and network bandwidth. In practical applications, a certain offset can be added or subtracted based on the formula 2, or multiplication and division Certain coefficients, etc., and many other methods can also be used to calculate the pre-reading window size according to the network round-trip delay and network bandwidth, which is not limited here.
示例性的,若电子设备A确定与电子设备B之间的网络往返延迟L为200ms,与电子设备B之间的网络带宽T为800kB/s,一个内存页大小D为4KB,则按照公式2可以计算出预读窗口大小为N=(0.2s*800kB/s)/4kB=40。Exemplarily, if electronic device A determines that the network round-trip delay L between electronic device A and electronic device B is 200 ms, the network bandwidth T between electronic device B and electronic device B is 800 kB/s, and the size D of a memory page is 4 KB, then according to formula 2 The pre-reading window size can be calculated as N=(0.2s*800kB/s)/4kB=40.
本申请实施例中,使用网络往返延迟作为一个参数计算预读窗口大小。可选的,在实际应用中,电子设备A也可以使用其他类型的网络延迟作为参数来计算预读窗口大小,例如,使用电子设备A发送数据到电子设备B的网络延迟,或使用电子设备B发送数据段敖电子设备A的网络延迟等,此处不作限定。In this embodiment of the present application, the network round-trip delay is used as a parameter to calculate the pre-reading window size. Optionally, in practical applications, electronic device A can also use other types of network delays as parameters to calculate the pre-reading window size, for example, using the network delay of electronic device A sending data to electronic device B, or using electronic device B The network delay of the electronic device A for sending the data segment, etc., is not limited here.
步骤S5001~S5004中,电子设备A可以根据与电子设备B的网络往返延迟和网络带宽计算出初始的预读窗口大小,提供给(3)预读阶段使用。在实际应用中,电子设备A还可以继续对与电子设备B的网络往返延迟实时监测,对预读窗口大小进行实时更新后提供给(3)预读阶段使用。In steps S5001-S5004, electronic device A can calculate the initial pre-reading window size according to the network round-trip delay and network bandwidth with electronic device B, and provide it for use in (3) pre-reading stage. In practical applications, the electronic device A can also continue to monitor the network round-trip delay with the electronic device B in real time, update the pre-reading window size in real time, and provide it for use in the (3) pre-reading stage.
S5005、当确定与电子设备B的网络往返延迟的变化达到预设变化阈值时,按照新的网络往返延迟更新预读窗口大小。S5005. When it is determined that the change of the network round-trip delay with the electronic device B reaches a preset change threshold, update the pre-reading window size according to the new network round-trip delay.
步骤S5004中电子设备A按照与电子设备B的网络往返延迟和网络带宽计算出预读窗口大小后,电子设备A还可以继续执行步骤S5002,实时监测与电子设备B之间的网络往返延迟,确定相对于步骤S5004中计算时使用的网络往返延迟,与电子设备B之间的网络往返延迟的变化是否达到预设变化阈值:In step S5004, after electronic device A calculates the pre-reading window size according to the network round-trip delay and network bandwidth with electronic device B, electronic device A can also continue to perform step S5002, monitor the network round-trip delay with electronic device B in real time, and determine Relative to the network round-trip delay used in the calculation in step S5004, whether the change of the network round-trip delay with the electronic device B reaches the preset change threshold:
当确定与电子设备B之间的网络往返延迟的变化达到预设变化阈值时,表示与电子设备B之间的网络环境有较大的波动,则电子设备A可以按照新的网络往返延迟更新预读窗口大小。When it is determined that the change of the network round-trip delay with the electronic device B reaches the preset change threshold, it means that the network environment with the electronic device B fluctuates greatly, then the electronic device A can update the preset change according to the new network round-trip delay. Read window size.
可以理解的是,按照新的网络往返延迟更新预读窗口大小,可以使用步骤S5004中相同的方法,按照与电子设备B的网络带宽和新的网络往返延迟计算新的预读窗口大小。It can be understood that to update the pre-reading window size according to the new network round-trip delay, the same method in step S5004 can be used to calculate the new pre-reading window size according to the network bandwidth of electronic device B and the new network round-trip delay.
示例性的,若预设变化阈值为200ms。在电子设备A按照与电子设备B的网络往返延迟为200ms计算出预读窗口大小为40后,若电子设备A监测到与电子设备B的网络往返延迟更新为300ms,电子设备A可以确定该变化没有超出预设变化阈值200ms,不对预读窗口大小进行更新,继续监测与电子设备B的网络往返延迟。若电子设备A监测到与电子设备B的网络往返延迟更新为400ms,电子设备A确定与电子设备B的网络往返延迟的变化达到预设变化阈值200ms,需要更新预读窗口大小。则电子设备A可以根据该公式2,按照最新的网络往返延迟,重新计算出预读窗口大小N=(0.4s*800kB/s)/4kB=80。Exemplarily, if the preset change threshold is 200ms. After electronic device A calculates the pre-reading window size as 40 according to the network round-trip delay with electronic device B is 200ms, if electronic device A monitors that the network round-trip delay with electronic device B is updated to 300ms, electronic device A can determine the change If the preset change threshold of 200ms is not exceeded, the size of the pre-reading window is not updated, and the network round-trip delay with electronic device B continues to be monitored. If electronic device A monitors that the network round-trip delay with electronic device B is updated to 400ms, electronic device A determines that the change in network round-trip delay with electronic device B reaches the preset change threshold of 200ms, and needs to update the pre-reading window size. Then, the electronic device A can recalculate the pre-reading window size N=(0.4s*800kB/s)/4kB=80 according to the latest network round-trip delay according to the formula 2.
(2)预读标志位确定阶段:(2) Pre-reading flag determination stage:
可以理解的是,(2)预读标志位确定阶段在电子设备A中的应用A访问电子设备B中的文件F后执行,其可以在电子设备A从电子设备B中预读数据前执行,也可以在电子设备A从电子设备B中预读数据之后执行,还可以在电子设备A从电子设备B预读数据的过程中执行,此处不作限定。It can be understood that (2) the pre-reading flag determination stage is executed after application A in electronic device A accesses file F in electronic device B, and it can be executed before electronic device A pre-reads data from electronic device B, It can also be executed after electronic device A pre-reads data from electronic device B, and can also be executed during the process of electronic device A pre-reading data from electronic device B, which is not limited here.
(2)预读标志位确定阶段的目的是根据电子设备A访问的文件的文件类型、访问文件的应用的应用类型、以及对端电子设备的设备类型,确定预读的内存页中需设置的预读标志位的数目和位置。下面结合电子设备A中的应用A访问电子设备B中的文件F为例,进行详细说明:(2) The purpose of the pre-reading flag determination stage is to determine the pre-reading memory page to be set according to the file type of the file accessed by the electronic device A, the application type of the application accessing the file, and the device type of the peer electronic device. Number and position of read-ahead flags. The following is an example of accessing the file F in the electronic device B by the application A in the electronic device A to describe in detail:
图51为本申请实施例中预读标志位确定阶段的一个流程示意图。FIG. 51 is a schematic flowchart of a pre-reading flag determination stage in an embodiment of the present application.
可以理解的是,在执行下述步骤之前,电子设备A已经执行了步骤S5001,此处不再赘述。It can be understood that, before executing the following steps, the electronic device A has already executed step S5001, and details are not repeated here.
S5101、电子设备A确定文件F是否为视频文件;S5101, the electronic device A determines whether the file F is a video file;
在电子设备A中的应用A访问电子设备B中的文件F后,电子设备A可以确定文件F的文件类型:After application A in electronic device A accesses file F in electronic device B, electronic device A can determine the file type of file F:
当确定文件F为视频文件时,电子设备A可以执行步骤S5102;When it is determined that the file F is a video file, the electronic device A can perform step S5102;
当确定文件F不是视频文件时,电子设备A可以执行步骤S5103。When it is determined that the file F is not a video file, the electronic device A may perform step S5103.
可以理解的是,在实际应用中,电子设备A也可以通过确定文件F是其他不同格式的文件而执行不同的步骤,确定需在预读的内存页中设置不同数目或位置的预读标志位,此处不作限定。It can be understood that, in practical applications, the electronic device A can also perform different steps by determining that the file F is a file of other different formats, and determine that different numbers or positions of pre-reading flags need to be set in the pre-reading memory page. , which is not limited here.
对于如何确定文件F的文件类型,可以参考上述术语介绍(10)文件类型中的描述,此处不再赘述。For how to determine the file type of the file F, reference may be made to the description in the above terminology introduction (10) file type, which will not be repeated here.
在一些实施例中,也可以没有步骤S5101中对访问的文件类型的判断,而直接执行步骤S5103,此处不作限定。In some embodiments, step S5103 may be directly executed without determining the type of the accessed file in step S5101, which is not limited here.
S5102、电子设备A确定需设置多个预读标志位;S5102, the electronic device A determines that multiple pre-reading flags need to be set;
电子设备A确定文件F是视频文件时,可以确定需设置多个预读标志位。When the electronic device A determines that the file F is a video file, it may determine that multiple pre-reading flags need to be set.
需设置的多个预读标志位的具体数目可以预先设定,此处不作限定。The specific number of the multiple pre-reading flag bits to be set may be preset, which is not limited here.
示例性的,电子设备A在确定文件F是视频文件时,可以确定需在预读的每个内存页中都设置预读标志位。Exemplarily, when the electronic device A determines that the file F is a video file, it may determine that a pre-read flag needs to be set in each pre-read memory page.
示例性的,电子设备A在确定文件F是视频文件时,可以确定需在预读的内存页中每隔两个内存页设置一个预读标志位。Exemplarily, when the electronic device A determines that the file F is a video file, it may determine that a pre-reading flag needs to be set every two memory pages in the pre-read memory pages.
可以理解的是,还可以有其他设置多个预读标志位的方式,此处不作限定。It can be understood that, there may also be other ways of setting multiple pre-reading flag bits, which are not limited here.
S5103、电子设备A确定应用A是否为前台应用;S5103, the electronic device A determines whether the application A is a foreground application;
电子设备A可以确定访问文件F的应用A的应用类型:The electronic device A can determine the application type of the application A that accesses the file F:
当确定应用A不是前台应用时,电子设备A可以执行步骤S5104;When it is determined that the application A is not a foreground application, the electronic device A may perform step S5104;
当确定应用A是前台应用时,电子设备A可以执行步骤S5105。When it is determined that the application A is the foreground application, the electronic device A may perform step S5105.
对于如何确定应用A的应用类型,可以参考上述术语介绍(9)前台应用中的描述,此处不再赘述。For how to determine the application type of the application A, reference may be made to the description in the above term introduction (9) foreground application, which will not be repeated here.
可以理解的是,在实际应用中,电子设备A也可以通过应用A是其他不同的应用类型而执行不同的步骤,确定需在预读的内存页中设置不同数目或位置的预读标志位,此处不作限定。It can be understood that, in practical applications, the electronic device A can also perform different steps by applying A to other different application types to determine that different numbers or positions of pre-read flags need to be set in the pre-read memory page, There is no limitation here.
在一些实施例中,也可以没有步骤S5103中对访问的文件的应用的应用类型的判断,而直接执行步骤S5105,此处不作限定。In some embodiments, step S5105 may be directly executed without determining the application type of the application of the accessed file in step S5103, which is not limited here.
S5104、电子设备A确定需设置一个预读标志位,位置为第一位置;S5104, the electronic device A determines that a pre-reading flag needs to be set, and the position is the first position;
当电子设备A确定文件F不是视频文件,且应用A不是前台应用时,电子设备A可以确定需在预读的内存页中设置一个预读标志位,且位置为第一位置。由于不是前台应用,因此对数据处理的及时性要求较低,因此,该第一位置可以在预读的内存页中比较靠后的位置。When electronic device A determines that file F is not a video file and application A is not a foreground application, electronic device A may determine that a pre-read flag needs to be set in the pre-read memory page, and the position is the first position. Since it is not a foreground application, the timeliness of data processing is relatively low, and therefore, the first position may be a later position in the pre-read memory page.
该第一位置的具体位置可以预先设定,例如可以设定为在预读的内存页中倒数1/4的位置等,此处不作限定。The specific position of the first position can be preset, for example, it can be set as the position of the last 1/4 in the pre-read memory page, etc., which is not limited here.
S5105、电子设备A确定电子设备B是否为第一能力设备;S5105, the electronic device A determines whether the electronic device B is the first capability device;
当电子设备A确定文件F不是视频文件,且应用A是前台应用时,电子设备A可以确定电子设备B的设备类型:When electronic device A determines that file F is not a video file and application A is a foreground application, electronic device A can determine the device type of electronic device B:
当电子设备A确定电子设备B是第一能力设备时,电子设备A可以执行步骤S5106;When the electronic device A determines that the electronic device B is the first capability device, the electronic device A may perform step S5106;
当电子设备A确定电子设备B不是第一能力设备时,电子设备A可以执行步骤S5107。When the electronic device A determines that the electronic device B is not the first capability device, the electronic device A may perform step S5107.
可以理解的是,在实际应用中,电子设备A也可以通过文件B是其他不同的设备类型而执行不同的步骤,确定需在预读的内存页中不同位置的设置预读标志位,此处不作限定。It can be understood that, in practical applications, electronic device A can also perform different steps by using file B as a different device type to determine that the pre-reading flag needs to be set at different positions in the pre-reading memory page, here Not limited.
对于如何确定电子设备B的设备类型,可以参考上述术语介绍(8)设备类型中的描述,此处不再赘述。For how to determine the device type of the electronic device B, reference may be made to the description in the above term introduction (8) device type, which will not be repeated here.
在一些实施例中,也可以没有步骤S5105~S5107中对对端电子设备的设备类型的判断,此处不作限定。In some embodiments, the determination of the device type of the opposite end electronic device in steps S5105 to S5107 may also be omitted, which is not limited here.
S5106、电子设备A确定需设置一个预读标志位,位置为第二位置;S5106, the electronic device A determines that a pre-reading flag needs to be set, and the position is the second position;
当电子设备A确定文件F不是视频文件,应用A是前台应用,且电子设备B是第一能力设备时,电子设备A可以确定需在预读的内存页中设置一个预读标志位,位置为第二位置。由于应用A是前台应用,对数据的处理需求较大,处理速度较快,因此该第二位置在第一位置之前,以便更早的触发对下一段数据的预读。When electronic device A determines that file F is not a video file, application A is a foreground application, and electronic device B is a first-capable device, electronic device A can determine that a pre-reading flag needs to be set in the pre-reading memory page at the location of second position. Since application A is a foreground application, the data processing demand is large and the processing speed is fast, so the second position is before the first position, so as to trigger the pre-reading of the next piece of data earlier.
该第二位置的具体位置可以预先设定,例如可以设定为在预读的内存页中1/2的位置等,此处不作限定。The specific position of the second position may be preset, for example, it may be set as a position of 1/2 in the pre-read memory page, etc., which is not limited here.
S5107、电子设备确定需设置一个预读标志位,位置为第三位置;S5107, the electronic device determines that a pre-reading flag needs to be set, and the position is the third position;
当电子设备A确定文件F不是视频文件,应用A是前台应用,且电子设备B不是第一能力设备时,电子设备A可以确定需在预读的内存页中设置一个预读标志位,位置为第三位置。由于电子设备B不是第一能力设备,其对数据的处理速度较慢,需要更早的从电子设备B预读数据,因此,该第三位置在第二位置之前,以便更早的触发对下一段数据的预读。When electronic device A determines that file F is not a video file, application A is a foreground application, and electronic device B is not a device with the first capability, electronic device A can determine that a pre-reading flag needs to be set in the pre-reading memory page at the location of third position. Since electronic device B is not a first-capable device, its data processing speed is relatively slow, and it needs to pre-read data from electronic device B earlier. Therefore, the third position is before the second position, so that the next position can be triggered earlier. A read-ahead of a piece of data.
该第三位置的具体位置可以预先设定,例如可以设定为在预读的内存页中的起始位置等,此处不作限定。The specific position of the third position may be preset, for example, may be set as the starting position in the pre-read memory page, etc., which is not limited here.
示例性的,图52为本申请实施例中预读标志位的不同位置的一个示例性示意图。按照对预读的内存页读取时,读取顺序从左到右为例,设置预读标志位的第一位置在最右边,相比于第二位置和第三位置的内存页,该位置的内存页会最后被读取。第二位置的内存页相比第一位置的内存页会先被读取,相比第三位置的内存页会后被读取。第三位置的内存页相比第一位置和第二位置的内存页会最先被读取。可以理解的是,图52是对三种不同情况下设置预读标志位的不同位置的一个示例性对比示意图,并不表示会在预读的内存页中这三个位置均设置预读标志位。Exemplarily, FIG. 52 is an exemplary schematic diagram of different positions of the pre-read flag bits in this embodiment of the present application. Taking the reading sequence from left to right as an example when reading a pre-read memory page, the first position where the pre-read flag is set is on the far right. Compared with the memory pages in the second and third positions, this position is The memory page will be read last. The memory page in the second position will be read first compared to the memory page in the first position, and will be read later than the memory page in the third position. The memory page in the third position will be read first than the memory pages in the first and second positions. It can be understood that FIG. 52 is an exemplary comparative schematic diagram of different positions where the pre-read flag is set in three different situations, and does not mean that the pre-read flag will be set in these three positions in the pre-read memory page. .
(3)预读阶段:(3) Pre-reading stage:
可以理解的是,(3)预读阶段在(1)预读窗口大小确定阶段确定出预读窗口大小后即可执行,在(3)预读阶段的执行过程中,可以根据(1)预读窗口大小确定阶段更新的预读窗口大小进行后续的预读。It can be understood that (3) the pre-reading stage can be executed after the pre-reading window size is determined in (1) the pre-reading window size determination stage. The read window size determines the size of the read-ahead window updated in the phase for subsequent read-ahead.
(2)预读标志位确定阶段可以在(3)预读阶段之前完成,也可以在(3)预读阶段的执行过程中完成,此处不作限定。(2) The pre-reading flag determination phase may be completed before (3) the pre-reading phase, or may be completed during the execution of (3) the pre-reading phase, which is not limited here.
图53为本申请实施例中预读阶段的一个信令交互示意图。FIG. 53 is a schematic diagram of signaling interaction in the pre-reading stage in this embodiment of the present application.
S5301、电子设备A按照确定的预读窗口大小为第一数值,从电子设备B预读文件F的第一数值个内存页的数据;S5301, electronic device A pre-reads the data of the first value and memory page of file F from electronic device B according to the determined pre-reading window size as the first value;
上述步骤S5004中,电子设备A按照与电子设备B的网络往返延迟和网络带宽计算出预读窗口大小,假设计算出的预读窗口的大小为第一数值。则电子设备A可以按照该确定的预 读窗口大小为第一数值,从电子设备B预读文件F的第一数值个内存页的数据。In the above step S5004, the electronic device A calculates the size of the pre-reading window according to the network round-trip delay and the network bandwidth with the electronic device B, assuming that the calculated size of the pre-reading window is the first value. Then the electronic device A can pre-read the data of the first value and the memory page of the file F from the electronic device B according to the determined pre-reading window size as the first value.
S5302、电子设备A根据文件F的文件类型、和/或应用A的应用类型、和/或电子设备B的设备类型,在该第一数值个内存页中设置预读标志位;S5302, according to the file type of file F, and/or the application type of application A, and/or the device type of electronic device B, electronic device A sets the read-ahead flag in the first number of memory pages;
对于不同的文件类型、和/或应用类型、和/或设备类型,设置的预读标志位的数目和位置不同,具体可以参阅(2)预读标志位确定阶段中的描述,此处不再赘述。For different file types, and/or application types, and/or device types, the number and position of the pre-reading flags to be set are different. For details, please refer to the description in (2) Pre-reading flag determination phase, which is not repeated here. Repeat.
电子设备A预读文件F的第一数值个内存页的数据后,可以根据文件F的文件类型、和/或应用A的应用类型、和/或电子设备B的设备类型,在该第一数值个内存页中设置预读标志位。After the electronic device A pre-reads the data of the first numerical memory page of the file F, it can, according to the file type of the file F, and/or the application type of the application A, and/or the device type of the electronic device B, in the first numerical value The read-ahead flag is set in each memory page.
可选的,若在步骤S5302执行前已经执行过(2)预读标志位确定阶段的步骤,则电子设备A可以按照(2)预读标志位确定阶段确定的需设置预读标志位的数目和位置,在该第一数值个内存页中设置预读标志位。Optionally, if the step of (2) the pre-reading flag determination stage has been performed before the execution of step S5302, then the electronic device A can set the number of pre-reading flags determined according to (2) the pre-reading flag determination stage. and location, set the read-ahead flag in the first number of memory pages.
可选的,若在步骤S5302执行前还没有执行过(2)预读标志位确定阶段的步骤,则电子设备执行S5302时,可以先执行该(2)预读标志位确定阶段的步骤:根据文件F的文件类型、和/或应用A的应用类型、和/或电子设备B的设备类型,确定需设置预读标志位的数目和位置。然后再按照确定的需设置预读标志位的数目和位置,在该第一数值个内存页中设置预读标志位。Optionally, if the step of (2) the pre-reading flag determination stage has not been performed before the execution of step S5302, then when the electronic device executes S5302, the step of (2) the pre-reading flag determination stage can be performed first: according to The file type of the file F, and/or the application type of the application A, and/or the device type of the electronic device B, determine the number and position of the pre-reading flags to be set. Then, according to the determined number and position of the pre-reading flag bits to be set, the pre-reading flag bits are set in the first number of memory pages.
S5303、电子设备A读取到有预读标志位的内存页;S5303, the electronic device A reads a memory page with a pre-read flag;
电子设备A可以读取预读的内存页,当电子设备A读取到有预读标志位的内存页时,可以触发步骤S5304。The electronic device A can read the pre-read memory page, and when the electronic device A reads the memory page with the pre-read flag bit, step S5304 can be triggered.
S5304、电子设备A进行下一次预读。S5304, the electronic device A performs the next pre-reading.
当电子设备A读取到有预读标志位的内存页时,可以触发下一次预读。When the electronic device A reads the memory page with the pre-reading flag, it can trigger the next pre-reading.
若当前的预读窗口大小还未更新,则该下一次预读会从电子设备B预读文件F后续数据中的第一数值个内存页的数据,并根据文件F的文件类型、和/或应用A的应用类型、和/或电子设备B的设备类型,在该第一数值个内存页中设置预读标志位。以此类推,文件F的数据被读取完或应用A停止读取文件F的数据。If the current pre-reading window size has not been updated, the next pre-reading will pre-read the data of the first number of memory pages in the subsequent data of the file F from the electronic device B, and according to the file type of the file F, and/or The application type of the application A and/or the device type of the electronic device B, the pre-reading flag is set in the first number of memory pages. By analogy, the data of file F has been read or application A stops reading the data of file F.
步骤S5301~S5304中,电子设备A会按照确定的预读窗口大小和需设置预读标志位的数目和位置,从电子设备B预读内存页并设置预读标志位。在实际应用中,若由于网络波动,电子设备A执行了步骤S5005,对预读窗口大小进行了更新,则电子设备A可以执行S5305~S5308,按照更新后的预读窗口大小进行预读。In steps S5301-S5304, the electronic device A pre-reads the memory page from the electronic device B and sets the pre-read flag bits according to the determined pre-read window size and the number and position of the pre-read flag bits to be set. In practical applications, if the electronic device A performs step S5005 to update the pre-reading window size due to network fluctuations, the electronic device A may execute S5305 to S5308 to perform pre-reading according to the updated pre-reading window size.
S5305、电子设备A更新预读窗口大小为第二数值;S5305, the electronic device A updates the size of the pre-reading window to a second value;
若电子设备A执行了步骤S5005,更新了预读窗口大小。假设更新的预读窗口大小为第二数值,该第二数值与该第一数值不同。If the electronic device A executes step S5005, the size of the pre-reading window is updated. It is assumed that the updated pre-read window size is a second value, and the second value is different from the first value.
S5306、电子设备A读取到有预读标志位的内存页;S5306, the electronic device A reads the memory page with the pre-read flag;
在电子设备A更新预读窗口大小为第二数值后,电子设备A可以继续读取预读的内存页,当电子设备A读取到有预读标志位的内存页时,可以触发步骤S5307。After the electronic device A updates the pre-read window size to the second value, the electronic device A can continue to read the pre-read memory page, and when the electronic device A reads the memory page with the pre-read flag, it can trigger step S5307.
S5307、电子设备A从电子设备B预读文件F的第二数值个内存页的数据;S5307, the electronic device A pre-reads the data of the second numerical memory page of the file F from the electronic device B;
在电子设备A更新预读窗口大小为第二数值后,且电子设备A读取到有预读标志位的内存页时,电子设备A可以从电子设备B预读文件F的第二数值个内存页的数据。After the electronic device A updates the pre-reading window size to the second value, and the electronic device A reads the memory page with the pre-reading flag, the electronic device A can pre-read the second value of the memory of the file F from the electronic device B page data.
S5308、电子设备A根据文件F的文件类型、和/或应用A的应用类型、和/或电子设备B的设备类型,在该第二数值个内存页中设置预读标志位。S5308. The electronic device A sets the read-ahead flag in the second numerical memory page according to the file type of the file F, and/or the application type of the application A, and/or the device type of the electronic device B.
与步骤S5302类似,此处不再赘述。It is similar to step S5302 and will not be repeated here.
在一些实施例中,步骤S5305~S5308可以不执行,此处不作限定。In some embodiments, steps S5305 to S5308 may not be executed, which is not limited here.
本申请实施例中,电子设备A可以根据网络往返延迟和网络带宽实时确定预读窗口大小,从而使得预读窗口大小与当前的网络情况契合,能随着网络环境的变化而变化,使得电子设备A预读足够数目的内存页又不占用过多的存储空间。在预读合适的内存页后,电子设备A还可以根据需要访问文件的文件类型,访问文件的应用的应用类型以及对端电子设备的设备类型的不同情况,在预读的内存页中设置不同数目和位置的内存页。从而保障在数据读取的连续性,使得在读取完已预读的内存页前,能够接收到下一次预读的数据,且不占用过多的存储空间。在极大的提升了分布式文件系统中电子设备的预读性能的同时,消耗了较少的网络资源和存储资源。In the embodiment of the present application, the electronic device A can determine the size of the pre-reading window in real time according to the network round-trip delay and network bandwidth, so that the size of the pre-reading window fits the current network situation and can be changed with the change of the network environment, so that the electronic device can A pre-reads a sufficient number of memory pages without taking up too much storage space. After pre-reading a suitable memory page, the electronic device A can also set different settings in the pre-read memory page according to the different conditions of the file type of the file accessing the file, the application type of the application accessing the file, and the device type of the opposite electronic device The number and location of memory pages. Thus, the continuity of data reading is ensured, so that the next pre-read data can be received before the pre-read memory page is read without occupying too much storage space. While greatly improving the read-ahead performance of electronic devices in the distributed file system, less network resources and storage resources are consumed.
上面实施例中,第二电子设备为与第一电子设备位于同一个分布式文件系统中的一个电子设备。在一些实施例中,第二电子设备也可以不为与该第一电子设备在同一个分布式文件系统中的电子设备,此处不作限定。In the above embodiment, the second electronic device is an electronic device located in the same distributed file system as the first electronic device. In some embodiments, the second electronic device may not be an electronic device in the same distributed file system as the first electronic device, which is not limited here.
上面对本申请实施例中的数据预读方法分阶段进行了示例性描述。The data pre-reading method in the embodiment of the present application has been exemplarily described in stages above.
作为本申请另一个实施例,下面从实际方法执行的角度对本申请实施例中数据预读的方法进行描述:As another embodiment of the present application, the following describes the data pre-reading method in the embodiment of the present application from the perspective of actual method execution:
Y101、第一电子设备从第二电子设备上获取第一文件中第一数值的文件页,在该第一数值的文件页中的第N个文件页中设置预读标志位;Y101, the first electronic device obtains the file page of the first value in the first file from the second electronic device, and sets the pre-reading flag in the Nth file page in the file page of the first value;
第二电子设备的本地文件系统或外部存储中存储有第一文件。第一电子设备中的第一应用访问该第二电子设备中的第一文件时,该第一电子设备可以从第二电子设备的本地文件系统或外部存储中读取该第一文件的数据。由于内存空间分页管理机制,第一电子设备可以先将第一文件的一部分数据以内存页大小为单位读取到第二电子设备的内存中,缓存为第一数值的文件页。The first file is stored in the local file system or external storage of the second electronic device. When the first application in the first electronic device accesses the first file in the second electronic device, the first electronic device can read data of the first file from the local file system or external storage of the second electronic device. Due to the paging management mechanism of the memory space, the first electronic device can first read a part of the data of the first file into the memory of the second electronic device in the unit of the memory page size, and cache it as the file page of the first value.
可选的,该第一数值可以为预设读取数值,也可以为根据与第二电子设备间的网络延迟和网络带宽确定的数值,还可以为根据其他参数(例如第一文件的文件类型、第一应用的应用类型等)确定的数值,此处不作限定。Optionally, the first value may be a preset read value, or a value determined according to the network delay and network bandwidth with the second electronic device, or may be based on other parameters (for example, the file type of the first file). , the application type of the first application, etc.), which is not limited here.
在第一电子设备从第二电子设备上获取到第一文件中第一数值的文件页后,该第一电子设备可以在该第一数值的文件页中的第N个文件页中设置预读标志位。其中,N可以由第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备类型确定。After the first electronic device obtains the file page of the first value in the first file from the second electronic device, the first electronic device may set the pre-reading in the Nth file page in the file page of the first value flag bit. Wherein, N may be determined by the file type of the first file, and/or the application type of the first application, and/or the device type of the second electronic device.
本申请实施例中,第一电子设备在从第二电子设备读取第一文件中某个数值的文件页后,可以根据第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备类型,来确定在这些文件页中设置预读标志位的数量和位置。In this embodiment of the present application, after reading a file page of a certain value in the first file from the second electronic device, the first electronic device may, according to the file type of the first file, and/or the application type of the first application, and /or the device type of the second electronic device, to determine the number and position of pre-reading flag bits set in these file pages.
下面以在该第一数值的文件页中的第N个文件页中设置预读标志位为例,对设置不同数目和位置的预读标志位的不同情况进行说明:The following takes setting the pre-reading flag bit in the Nth file page in the file page of the first numerical value as an example to describe the different situations of setting different numbers and positions of the pre-reading flag bit:
在一些实施例中,第一电子设备可以确定该第一文件的文件类型是否为视频文件;当确定该第一文件的文件类型为视频文件时,该第一电子设备可以在该第一数值的文件页中的多个文件页中设置预读标志位。In some embodiments, the first electronic device may determine whether the file type of the first file is a video file; when determining that the file type of the first file is a video file, the first electronic device may The read-ahead flag is set in multiple file pages in a file page.
可以理解的是,该多个文件页为至少两个文件页,也可以为每个文件页,此处不作限定。It can be understood that the multiple file pages are at least two file pages, and may also be each file page, which is not limited here.
第一电子设备确定该第一文件的文件类型是否为视频文件的方式有多种:There are multiple ways for the first electronic device to determine whether the file type of the first file is a video file:
优选的,该第一电子设备可以确定该第一文件的扩展名是否为视频文件的扩展名;当确定该第一文件的扩展名为视频文件的扩展名时,该第一电子设备可以确定该第一文件的文件类型为视频文件;当确定该第一文件的扩展名不是视频文件的扩展名时,该第一电子设备可以确定该第一文件的文件类型不是视频文件。Preferably, the first electronic device can determine whether the extension of the first file is the extension of the video file; when determining that the extension of the first file is the extension of the video file, the first electronic device can determine whether the extension of the first file is the extension of the video file. The file type of the first file is a video file; when it is determined that the extension of the first file is not that of a video file, the first electronic device may determine that the file type of the first file is not a video file.
可选的,该第一电子设备还可以根据该第一文件的元数据信息来确定该第一文件的文件类型。Optionally, the first electronic device may further determine the file type of the first file according to metadata information of the first file.
第一电子设备还可以有很多其他的确定该第一文件的文件类型是否为视频文件的方式,此处不作限定。The first electronic device may also have many other ways of determining whether the file type of the first file is a video file, which is not limited here.
在一些实施例中,当确定该第一文件的文件类型不是视频文件时,该第一电子设备还可以确定第一应用的应用类型是否为前台应用;当确定该第一应用的应用类型不是前台应用时,该第一电子设备可以在该第一数值的文件页中的第N1个文件页中设置预读标志位;该第N1个文件页在该第一数值的文件页中的位置为第一位置,其中N1大于第一数值的1/2。即该第N1个文件页在该第一数值的文件页中后半部分的位置。In some embodiments, when it is determined that the file type of the first file is not a video file, the first electronic device may also determine whether the application type of the first application is a foreground application; when it is determined that the application type of the first application is not a foreground application During application, the first electronic device may set a pre-reading flag bit in the N1 th file page in the file page of the first value; the position of the N1 th file page in the file page of the first value is the th A position where N1 is greater than 1/2 of the first value. That is, the position of the N1 th file page in the second half of the file page of the first value.
第一电子设备确定该第一应用的应用类型是否为前台应用的方式有多种:There are multiple ways for the first electronic device to determine whether the application type of the first application is a foreground application:
优选的,该第一电子设备可以确定该第一应用的进程中是否包含前台应用标识;当确定该第一应用的进程中包含前台应用标识时,第一电子设备可以确定该第一应用的应用类型为前台应用;当确定该第一应用的进程中不包含前台应用标识时,第一电子设备可以确定该第一应用的应用类型不是前台应用。Preferably, the first electronic device can determine whether the process of the first application contains a foreground application identifier; when it is determined that the process of the first application contains a foreground application identifier, the first electronic device can determine the application of the first application The type is foreground application; when it is determined that the process of the first application does not contain a foreground application identifier, the first electronic device may determine that the application type of the first application is not a foreground application.
可选的,该第一电子设备还可以根据GPU反馈的数据来确定该第一应用的应用类型是否为前台应用。Optionally, the first electronic device may further determine whether the application type of the first application is a foreground application according to data fed back by the GPU.
第一电子设备还可以有很多其他的确定该第一应用的应用类型是否为前台应用的方式,此处不作限定。The first electronic device may also have many other ways of determining whether the application type of the first application is a foreground application, which is not limited here.
在一些实施例中,当确定该第一应用的应用类型是前台应用时,该第一电子设备可以确定该第二电子设备的设备类型是否为第一能力设备;该第一能力设备为能力超出预设能力值的电子设备;当确定该第一电子设备的设备类型是第一能力设备时,该第一电子设备可以在该第一数值的文件页中的第N2个文件页中设置预读标志位;该第N2个文件页在该第一数值的文件页中的位置为第二位置,该第二位置在该第一位置之前;当确定该第一电子设备的设备类型不是第一能力设备时,第一电子设备可以在该第一数值的文件页中的第N3个文件页中设置预读标志位;第N3个文件页在该第一数值的文件页中的位置为第三位置,该第三位置在该第二位置之前,其中N3小于该第一数值的1/2。即该第N3个文件页在该第一数值的文件页中前半部分的位置。In some embodiments, when it is determined that the application type of the first application is a foreground application, the first electronic device may determine whether the device type of the second electronic device is a first capability device; the first capability device is a capability exceeding An electronic device with a preset capability value; when it is determined that the device type of the first electronic device is a device with a first capability, the first electronic device can set pre-reading in the N2th file page in the file page of the first value Flag bit; the position of the N2th file page in the file page of the first value is the second position, and the second position is before the first position; when it is determined that the device type of the first electronic device is not the first capability device, the first electronic device can set the pre-reading flag bit in the N3 th file page in the file page of the first value; the position of the N3 th file page in the file page of the first value is the third position , the third position is before the second position, wherein N3 is less than 1/2 of the first value. That is, the position of the N3 th file page in the first half of the file page of the first value.
可见,根据第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备 类型的不同情况,第一电子设备可以在该第一数值的文件页中的不同数量和位置的文件页中设置预读标志位。It can be seen that, according to the file type of the first file, and/or the application type of the first application, and/or the device type of the second electronic device, the first electronic device may be different in the file page of the first value. Set the read-ahead flag in the number and position of the file pages.
可以理解的是,后续第一电子设备从第二电子设备再读取某数值的文件页(例如第二数值的文件页、第三数值的文件页等)后,在这些文件页中设置预读标志位时,也可以根据第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备类型,来确定在这些文件页中设置预读标志位的数量和位置。具体可以参考在第一数值的文件页中的第N个文件页中设置预读标志位的过程,此处不再赘述。It can be understood that, after the first electronic device subsequently reads file pages of a certain value (for example, a file page of a second value, a file page of a third value, etc.) from the second electronic device, pre-reading is set in these file pages. When the flag bit is used, the number of pre-reading flag bits to be set in these file pages and the Location. For details, reference may be made to the process of setting the pre-reading flag bit in the Nth file page in the file page of the first value, which will not be repeated here.
Y102、第一电子设备监测与第二电子设备间的网络往返延迟;Y102, the first electronic device monitors the network round-trip delay between the first electronic device and the second electronic device;
Y103、第一电子设备确定与第二电子设备间的网络带宽;Y103, the first electronic device determines the network bandwidth with the second electronic device;
Y104、第一电子设备根据与第二电子设备之间的网络往返延迟和网络带宽,确定当前预读窗口大小为第二数值;Y104, the first electronic device determines that the current pre-reading window size is the second value according to the network round-trip delay and network bandwidth between the first electronic device and the second electronic device;
步骤Y102~Y104的执行过程可参考步骤S5002~S5004,此处不再赘述。For the execution process of steps Y102-Y104, reference may be made to steps S5002-S5004, which will not be repeated here.
Y105、当第一应用访问到设置预读标志位的文件页时,第一电子设备从第二电子设备上获取第一文件中第二数值的文件页;Y105, when the first application accesses the file page for which the pre-read flag is set, the first electronic device obtains the file page of the second value in the first file from the second electronic device;
第一电子设备从第二电子设备读取第一文件中第一数值的文件页,并在其中设置标志位后,当第一应用访问到设置预读标志位的文件页时,会触发第一电子设备的下一次预读。下一次预读的预读窗口大小为根据网络往返延迟和网络带宽实时计算出的当前预读窗口大小。根据步骤Y104,由于当前预读窗口大小为第二数值,因此,第一电子设备可以从第二电子设备上获取第一文件中第二数值的文件页。The first electronic device reads the file page of the first value in the first file from the second electronic device, and after setting the flag in it, when the first application accesses the file page with the pre-read flag set, it will trigger the first Next read ahead for electronic devices. The read-ahead window size of the next read-ahead is the current pre-read window size calculated in real time according to the network round-trip delay and network bandwidth. According to step Y104, since the current pre-reading window size is the second value, the first electronic device can acquire the file page of the second value in the first file from the second electronic device.
可以理解的是,该第一文件中第二数值的文件页是该第一文件中第一数值的文件页之后的数据。It can be understood that the file page of the second numerical value in the first file is the data after the file page of the first numerical value in the first file.
Y106、第一电子设备在第一文件中第二数值的文件页中的第M个文件页中设置预读标志位;Y106, the first electronic device sets the read-ahead flag in the Mth file page in the file page of the second numerical value in the first file;
第一电子设备可以根据第一文件的文件类型,和/或第一应用的应用类型,和/或第二电子设备的设备类型,在第一文件中第二数值的文件页中的第M个文件页中设置预读标志位。其具体过程可以参考步骤Y101中该第一电子设备在第一文件中第一数值的文件中的第N个文件页中设置预读标志位的过程,此处不再赘述。The first electronic device may, according to the file type of the first file, and/or the application type of the first application, and/or the device type of the second electronic device, the Mth in the file page of the second numerical value in the first file The read-ahead flag is set in the file page. For the specific process, reference may be made to the process of setting the pre-reading flag bit by the first electronic device in the N th file page in the file with the first value in the first file in step Y101 , which will not be repeated here.
Y107、第一电子设备确定计算出预读窗口大小为第二数值时的网络往返延迟与当前网络往返延迟的差值是否达到预设变化阈值;Y107, the first electronic device determines whether the difference between the network round-trip delay and the current network round-trip delay when the calculated pre-reading window size is the second value reaches a preset change threshold;
Y108、当确定达到预设变化阈值时,第一电子设备根据当前网络往返延迟和网络带宽,确定当前预读窗口大小为第三数值;Y108, when it is determined that the preset change threshold is reached, the first electronic device determines that the current pre-reading window size is a third value according to the current network round-trip delay and network bandwidth;
步骤Y107~Y108的执行过程可参考步骤S5005,此处不再赘述。For the execution process of steps Y107-Y108, reference may be made to step S5005, which will not be repeated here.
Y109、当第一应用访问到第二数值的文件页中设置预读标志位的文件页时,第一电子设备从第二电子设备上获取第一文件中第三数值的文件页;Y109, when the first application accesses the file page of the pre-reading flag in the file page of the second numerical value, the first electronic device obtains the file page of the third numerical value in the first file from the second electronic device;
Y110、第一电子设备在所述第一文件中第三数值的文件页中的第J个文件页中设置预读标志位。Y110. The first electronic device sets a pre-reading flag bit in the J th file page in the file pages of the third numerical value in the first file.
步骤Y109~Y110中,在当前预读窗口大小更新为第三数值,且第一应用再次访问到设置 预读标志位的文件页时,可以触发第一电子设备的下一次预读。由于当前预读窗口大小为第三数值,因此,第一电子设备可以从第二电子设备上获取第一文件中第三数值的文件页,并设置预读标志位。其具体过程与步骤Y105~Y106类似,此处不再赘述。In steps Y109-Y110, when the current pre-reading window size is updated to a third value, and the first application accesses the file page with the pre-reading flag set again, the next pre-reading of the first electronic device can be triggered. Since the current pre-reading window size is the third numerical value, the first electronic device may acquire the file page of the third numerical value in the first file from the second electronic device, and set the pre-reading flag bit. The specific process is similar to steps Y105-Y106, and details are not repeated here.
通过上述数据预读方法,可以提升电子设备从其他电子设备读取数据时的预读性能。分布式文件系统中,若电子设备A和电子设备C读取了电子设备B的磁盘上的数据D,则电子设备A和电子设备C的内存中都缓存了数据D。若电子设备A将数据D更新为数据D',此时电子设备B和电子设备C的内存中的数据仍然为D,则电子设备B和电子设备C访问的该数据不是最新的数据。因此,电子设备B和电子设备C也需要将内存中的数据D更新为最新的数据D',以保持数据一致性。Through the above data pre-reading method, the pre-reading performance of the electronic device when reading data from other electronic devices can be improved. In the distributed file system, if electronic device A and electronic device C read data D on the disk of electronic device B, data D is cached in the memory of electronic device A and electronic device C. If electronic device A updates data D to data D', and the data in the memory of electronic device B and electronic device C is still D, the data accessed by electronic device B and electronic device C is not the latest data. Therefore, the electronic device B and the electronic device C also need to update the data D in the memory to the latest data D' to maintain data consistency.
当前,为保持数据一致性,分布式文件系统中的电子设备会以文件为粒度清理内存中的缓存。当判断文件中的数据不是最新时,会将整个文件在内存中的数据缓存全部标记为失效,这样的缓存清理方式可以保持分布式文件系统中的数据一致性。Currently, in order to maintain data consistency, electronic devices in a distributed file system clear the cache in memory at the granularity of files. When it is judged that the data in the file is not up to date, all the data caches in the memory of the entire file will be marked as invalid. Such a cache cleaning method can maintain the data consistency in the distributed file system.
然而,以文件为粒度清理内存中的缓存,会将该文件中大部分没有更新的数据也清理掉。在需要读取该文件时,又需要再次加载该文件的全部数据。不仅降低了分布式文件系统中数据访问的速度,而且消耗了过多的网络资源。However, clearing the in-memory cache at a file granularity will also clear most of the unupdated data in that file. When the file needs to be read, all the data of the file needs to be loaded again. It not only reduces the speed of data access in the distributed file system, but also consumes too many network resources.
而本申请实施例中提供的保持数据一致性的方法,能在分布式文件系统中保持数据一致性时,提升数据访问的速度,减少网络资源的消耗。However, the method for maintaining data consistency provided in the embodiments of the present application can improve the speed of data access and reduce the consumption of network resources when maintaining data consistency in a distributed file system.
四、保持数据一致性的方法:Fourth, the method of maintaining data consistency:
下面先对本申请实施例涉及保持数据一致性的方法的相关术语及概念进行介绍。The following first introduces relevant terms and concepts related to the method for maintaining data consistency in the embodiments of the present application.
(1)分布式文件系统:(1) Distributed file system:
分布式文件系统为分布在各电子设备上任意位置的资源提供了一个逻辑上的文件系统结构,从而使访问分布在各电子设备上的共享文件更加简便。The distributed file system provides a logical file system structure for resources distributed at any position on each electronic device, thereby making it easier to access shared files distributed on each electronic device.
可选的,本申请实施例中的分布式文件系统可以为有中心节点的分布式文件系统,也可以为无中心节点的分布式文件系统,此处不作限定。Optionally, the distributed file system in this embodiment of the present application may be a distributed file system with a central node, or may be a distributed file system without a central node, which is not limited here.
具体的,有中心节点的分布式文件系统通常由一个元数据服务器和若干个数据服务器组成,元数据服务器作为中心节点,存储元数据信息,而数据服务器管理存储分布式文件系统中文件的实际数据。当用户访问文件数据时,需要先访问作为中心节点的元数据服务器获取文件的基本信息和数据索引信息,再根据基本信息和数据索引信息访问数据服务器获取文件数据。Specifically, a distributed file system with a central node usually consists of a metadata server and several data servers. The metadata server acts as a central node to store metadata information, and the data server manages and stores the actual data of files in the distributed file system. . When users access file data, they need to first access the metadata server as the central node to obtain the basic information and data index information of the file, and then access the data server to obtain file data according to the basic information and data index information.
示例性的,图10为有中心节点的分布式文件系统的一个示例性场景示意图。组成有中心节点的分布式文件系统的设备A、设备B和设备C,都需要通过作为中心节点的元数据服务器才能访问数据服务器中的文件。设备A、设备B和设备C都可以分别作为一个数据服务器,而作为中心节点的元数据服务器可以是其中的一个电子设备,也可以是一个独立的服务器。Exemplarily, FIG. 10 is a schematic diagram of an exemplary scenario of a distributed file system with a central node. Device A, Device B, and Device C that form a distributed file system with a central node all need to pass through the metadata server as the central node to access the files in the data server. Device A, Device B, and Device C can all act as a data server, respectively, and the metadata server serving as a central node can be one of the electronic devices or an independent server.
具体的,无中心节点的分布式文件系统中,由各个电子设备自己管理其他电子设备中文件的元数据信息。可以直接根据自己管理的其他电子设备中文件的元数据信息,显示或访问其他电子设备中的文件,而不需要通过中心节点。Specifically, in a distributed file system without a central node, each electronic device manages metadata information of files in other electronic devices by itself. Files in other electronic devices can be displayed or accessed directly according to the metadata information of files in other electronic devices managed by oneself without going through a central node.
示例性的,图12为本申请实施例中无中心节点的分布式文件系统的一个示例性场景示意图。组成无中心节点的分布式文件系统的设备A、设备B、设备C和设备D分别自己管理其他电子设备中文件的元数据信息,可以直接显示或访问其他电子设备中存储的文件。例如, 文件A存储在设备A中,文件B存储在设备B中,文件C存储在设备C中。设备A中可以存储有该文件B和文件C的元数据信息,从而可以直接显示或访问该文件B或文件C。同理,设备D中也可以存储有该文件A、文件B和文件C的元数据信息,从而可以直接显示或访问该文件A、文件B或文件C。Exemplarily, FIG. 12 is a schematic diagram of an exemplary scenario of a distributed file system without a central node in an embodiment of the present application. Device A, Device B, Device C, and Device D constituting the distributed file system without a central node manage metadata information of files in other electronic devices by themselves, and can directly display or access files stored in other electronic devices. For example, file A is stored in device A, file B is stored in device B, and file C is stored in device C. The metadata information of the file B and the file C can be stored in the device A, so that the file B or the file C can be directly displayed or accessed. Similarly, the metadata information of the file A, the file B, and the file C can also be stored in the device D, so that the file A, the file B, or the file C can be directly displayed or accessed.
(2)内存页:(2) Memory page:
操作系统将内存空间划分为大小相同的页面进行管理,这样的页面称为内存页。The operating system divides the memory space into pages of the same size for management, and such pages are called memory pages.
根据操作系统设置的不同,不同电子设备的操作系统中内存页的大小可以不同,例如为4KB、8KB或16KB等。According to different operating system settings, the sizes of memory pages in operating systems of different electronic devices may be different, for example, 4KB, 8KB, or 16KB.
而在一个电子设备的操作系统中,以固定大小的内存页作为内存空间的最小分配单位,将电子设备中的数据以内存页的形式进行管理。因此也可以以内存页来作为数据量大小的单位。In an operating system of an electronic device, a fixed-size memory page is used as the minimum allocation unit of memory space, and data in the electronic device is managed in the form of memory pages. Therefore, memory pages can also be used as the unit of data size.
下面对内存分页管理进行相关说明:The following describes the memory paging management:
2.1、内存管理:2.1, memory management:
操作系统中两个重要的概念为CPU和内存。CPU用于执行指令。内存用于存储计算机可执行程序代码、操作系统、程序、数据等。内存也可以被称为内部存储器。Two important concepts in an operating system are CPU and memory. The CPU is used to execute instructions. Memory is used to store computer executable program code, operating systems, programs, data, and the like. Memory can also be referred to as internal storage.
对于内存来说,它是资源有限的,如果进程占用内存较大甚至大于物理内存,并且要同时执行多个进程,这就需要涉及到内存管理。For memory, it has limited resources. If a process occupies a large amount of memory or even larger than physical memory, and multiple processes are to be executed at the same time, memory management needs to be involved.
理想情况下用户对内存的期待是大容量、高速度和持久性,但是现实中内存却是一个由缓存、主存、磁盘组成的内存架构。该架构中,缓存低容量、速度快但成本高,主存中速度、中容量和中成本,磁盘大容量、持久性但速度慢。Ideally, users' expectations for memory are large capacity, high speed, and durability, but in reality, memory is a memory architecture consisting of cache, main memory, and disk. In this architecture, the cache is low-capacity, high-speed but high-cost, the main memory has medium-speed, medium-capacity, and medium-cost, and the disk has large-capacity, persistence, but slow speed.
内存管理就是要对“用户”提供一个统一的抽象,屏蔽缓存、主存和磁盘之间的差异,甚至感知不到它们的存在。用户无需担心程序是存储在缓存、主存还是磁盘上,只要运行、输出的结果是一样的即可。Memory management is to provide a unified abstraction for "users", shielding the differences between cache, main memory and disk, or even unaware of their existence. Users do not need to worry about whether the program is stored in the cache, main memory or disk, as long as the operation and output results are the same.
且操作系统在同时执行多个进程的程序时,需要保证它们之间互不干扰,也就是说一个进程不能访问另一个进程的内存空间。程序中读写特定内存数据时,不能直接映射到物理内存,也就是说程序发出的内存地址和物理内存要是独立的。Moreover, when the operating system executes the programs of multiple processes at the same time, it needs to ensure that they do not interfere with each other, that is to say, one process cannot access the memory space of another process. When reading and writing specific memory data in a program, it cannot be directly mapped to physical memory, that is to say, the memory address issued by the program and the physical memory must be independent.
而使用虚拟内存就可以满足这些内存管理的需要。The use of virtual memory can meet the needs of these memory management.
2.2、虚拟内存:2.2, virtual memory:
虚拟内存是操作系统发展史上一个重要的里程碑。虚拟内存的使用,避免程序直接和物理内存打交道,并且对缓存、主存和磁盘做了统一抽象,这样程序就可以突破物理内存的大小限制,当然程序还是要受制于虚拟内存的大小限制。Virtual memory is an important milestone in the history of operating system development. The use of virtual memory prevents the program from directly dealing with physical memory, and abstracts the cache, main memory and disk so that the program can break through the size limit of physical memory. Of course, the program is still subject to the size limit of virtual memory.
使用虚拟内存后,程序中看到的内存地址是虚拟内存地址,程序对虚拟内存地址的读写会被映射到实际的物理内存中,这个映射称为翻译。这个翻译工作是由内存管理单元(memory management unit,MMU)来完成,MMU接收CPU发出的虚拟地址,将其翻译为物理地址后发送给内存,内存按照该物理地址进行相应访问后读出或写入相关数据。After using virtual memory, the memory address seen in the program is the virtual memory address, and the program's read and write to the virtual memory address will be mapped to the actual physical memory. This mapping is called translation. This translation work is done by the memory management unit (MMU). The MMU receives the virtual address sent by the CPU, translates it into a physical address and sends it to the memory. The memory reads or writes according to the physical address. Enter relevant data.
图40为本申请实施例中应用程序、虚拟内存和物理内存的一个关系示意图。电子设备中的缓存、主存、硬盘等物理内存在物理机器界面都可以统一抽象为虚拟内存,在虚拟机器界面提供虚拟内存地址给电子设备中的应用程序。用户通过应用程序对虚拟内存地址的读写会 映射到实际的物理内存中。FIG. 40 is a schematic diagram of a relationship among an application program, virtual memory, and physical memory in an embodiment of the present application. The physical memory such as cache, main memory, hard disk, etc. in the electronic device can be abstracted into virtual memory uniformly on the physical machine interface, and the virtual memory address is provided to the application program in the electronic device on the virtual machine interface. The user's reading and writing of virtual memory addresses through the application program will be mapped to the actual physical memory.
2.3、内存空间分页管理:2.3, memory space paging management:
内存空间分页管理的核心是将虚拟内存空间和物理内存空间皆划分为大小相同的页面,并以页面作为内存空间的最小分配单位,一个程序的一个页面可以存放在任意一个物理页面里。The core of memory space paging management is to divide the virtual memory space and the physical memory space into pages of the same size, and use the page as the minimum allocation unit of the memory space. One page of a program can be stored in any physical page.
通过内存空间的分页管理,可以实现连续的虚拟空间映射到不一定连续的物理内存。这样可以使得进程中连续的数据段存储在不连续的物理内存中,使得对内存空间的管理更加灵活。Through the paging management of memory space, continuous virtual space can be mapped to physical memory that is not necessarily continuous. In this way, continuous data segments in the process can be stored in discontinuous physical memory, which makes the management of memory space more flexible.
图41为本申请实施例中内存分页管理的一个示例性示意图。分页机制可以将数据拆分成内存页大小,分配虚拟地址空间中的连续地址。这些在虚拟地址空间中地址连续的内存页可以打散分配到在物理地址空间中未分配页。FIG. 41 is an exemplary schematic diagram of memory paging management in an embodiment of the present application. The paging mechanism can split data into memory page sizes and allocate contiguous addresses in the virtual address space. These memory pages with contiguous addresses in the virtual address space can be allocated to unallocated pages in the physical address space.
本申请一些实施例中,内存页也可以简称为页,后续不再赘述。In some embodiments of the present application, a memory page may also be referred to as a page for short, which will not be described in detail later.
在一些实施例中,也可以将用来缓存文件的内存页称为文件页,此处不作限定。In some embodiments, a memory page used for caching files may also be called a file page, which is not limited here.
(3)基数树:(3) Radix tree:
文件数据以内存页(Page)的形式存在于内存中,例如每个内存页的大小可以为4KB,内存页以页缓存(Page Cache)机制进行管理。页缓存利用了基数树(Radix Tree)的数据结构来组织所属某个文件的页,即在页缓存中每个文件都有一个属于自己的基数树。The file data exists in the memory in the form of memory pages (Page), for example, the size of each memory page can be 4KB, and the memory pages are managed by the page cache (Page Cache) mechanism. The page cache uses the Radix Tree data structure to organize pages belonging to a certain file, that is, each file in the page cache has its own radix tree.
示例性的,图54为文件F在内存中的基数树。基数树的树根(radix tree root)中包含了该树的高度信息(height),树的每个节点(radix tree node)包含了64个指针,每个指针可以为无效或者指向下一级树的节点或者页。此外,树的每个节点中包含了该节点的64个指针中有效指针的数量(count)。如图54所示,文件F的基数树的树根表示该基数树的高度信息为2,并且指向基数树第一级的节点。Exemplarily, Figure 54 shows the radix tree of file F in memory. The tree root (radix tree root) of the radix tree contains the height information (height) of the tree, and each node (radix tree node) of the tree contains 64 pointers, each pointer can be invalid or point to the next level tree node or page. In addition, each node of the tree contains the number of valid pointers (count) of the 64 pointers for that node. As shown in FIG. 54 , the root of the radix tree of file F indicates that the height information of the radix tree is 2, and points to the node of the first level of the radix tree.
基数树第一层的节点表示该节点包含了2个有效指针:A node at the first level of the radix tree indicates that the node contains 2 valid pointers:
1、在位置0处的有效指针slots[0]指向了基数树第二级的一个节点,该节点中也包含了2个有效指针。在位置0处的指针slots[0]指向了文件F的索引(index)为0的内存页(page);在位置4处的指针slots[4]指向了文件F的索引为4的内存页。1. The valid pointer slots[0] at position 0 points to a node at the second level of the radix tree, which also contains 2 valid pointers. The pointer slots[0] at position 0 points to the memory page with index 0 of file F; the pointer slots[4] at position 4 points to the memory page with index 4 of file F.
2、在位置2处的有效指针slots[2]指向了基数树第二级的另一个节点,该节点包含1个有效指针。在位置3处的指针slots[3]指向了文件F的索引为131的内存页。2. The valid pointer slots[2] at position 2 points to another node in the second level of the radix tree, which contains 1 valid pointer. The pointer slots[3] at position 3 points to the memory page at index 131 of file F.
本申请实施例中,若内存页中的数据更新,则可以将该页标记为脏。在脏页超过一定比例数量时,可以回刷到磁盘。在回刷脏页之前,页中的数据与磁盘中的数据会出现不一致的情况,由于系统总是先访问内存中的数据,所以可以读到最新的数据。In this embodiment of the present application, if the data in the memory page is updated, the page may be marked as dirty. When dirty pages exceed a certain percentage, they can be flushed back to disk. Before the dirty page is flushed, the data in the page will be inconsistent with the data in the disk. Since the system always accesses the data in the memory first, the latest data can be read.
图55为现有技术中保持数据一致性的方法的一个示例性场景示意图。电子设备A、电子设备B和电子设备C组成了分布式文件系统。文件F存储在电子设备B的磁盘中。电子设备A、电子设备B和电子设备C访问该文件F,均从电子设备B的磁盘中读取文件F到自己的内存中。若此时,电子设备A在内存中将文件F修改为文件F'。为保持数据一致性,电子设备B和电子设备C需要直接丢弃内存中的文件F,即将内存中文件F的整个基数树全部置为无效。然后在电子设备A将修改后的文件F'写回电子设备B的磁盘后,电子设备B和电子设备C再从电子设备B的磁盘读取修改后的文件F'到自己的内存中,重新建立文件F'的基数树。FIG. 55 is a schematic diagram of an exemplary scenario of a method for maintaining data consistency in the prior art. Electronic device A, electronic device B, and electronic device C form a distributed file system. File F is stored in the disk of electronic device B. Electronic device A, electronic device B, and electronic device C access the file F, and all read file F from the disk of electronic device B into their own memory. At this time, the electronic device A modifies the file F to the file F' in the memory. In order to maintain data consistency, the electronic device B and the electronic device C need to directly discard the file F in the memory, that is, invalidate the entire radix tree of the file F in the memory. Then, after electronic device A writes the modified file F' back to the disk of electronic device B, electronic device B and electronic device C read the modified file F' from the disk of electronic device B into their own memory, Build the radix tree of file F'.
这样以文件为粒度清理内存中的缓存,会将该文件中大部分没有更新的数据也清理掉。在需要读取该文件时,又需要再次加载该文件的全部数据。不仅降低了分布式文件系统中数据访问的速度,而且消耗了过多的网络资源。In this way, the cache in the memory is cleaned at the granularity of the file, and most of the unupdated data in the file will also be cleaned up. When the file needs to be read, all the data of the file needs to be loaded again. It not only reduces the speed of data access in the distributed file system, but also consumes too many network resources.
而采用本申请实施例中保持数据一致性的方法,直接在内存中文件的基数树上对内存页大小的数据进行更新,不需要对内存中缓存的整个文件的数据(即基数树整体)进行删除和重新加载。只需要在基数树上将相应内存页的数据进行更新即可,使得在分布式文件系统中保持数据一致性时,极大的提升数据访问的速度,减少网络资源的消耗。However, by adopting the method of maintaining data consistency in the embodiment of the present application, the data of the memory page size is directly updated on the radix tree of the file in the memory, and the data of the entire file cached in the memory (that is, the entire radix tree) does not need to be updated. Delete and reload. It is only necessary to update the data of the corresponding memory page on the radix tree, so that when data consistency is maintained in the distributed file system, the speed of data access is greatly improved and the consumption of network resources is reduced.
示例性的,图56为本申请实施例中保持数据一致性的方法的一个示例性场景示意图。将电子设备B中磁盘上文件F以内存页大小进行划分,可以视为其包括有f1~fd的内存页大小的数据,其中包含有数据fx。电子设备A、电子设备B和电子设备C都从该电子设备B的磁盘中读取了该文件F的f1~fx的数据,缓存在自己的内存中。若此时,电子设备A在内存中修改文件F,具体的,其将内存中文件F的基数树上某个内存页上的数据fx修改为fx'。为保持数据一致性,电子设备A将该修改通知电子设备B,电子设备B接收到该通知后,不需要要丢弃内存中文件F的整个基数树,只需要将内存中文件F的基数树上保存有数据fx的内存页中的数据修改为fx'即可。电子设备B确定电子设备C也读取过该数据fx,为保持数据一致性,电子设备B可以通知电子设备C数据fx已失效。电子设备C会在自己的内存中文件F的基数树上丢弃内存页大小的数据fx,即将保存有数据fx的内存页标记为脏即可,也不需要丢弃文件F的整个基数树。一段时间后,电子设备B可以将该修改后的数据fx'回写到磁盘中,更新磁盘中存储的文件F中的数据fx。Exemplarily, FIG. 56 is a schematic diagram of an exemplary scenario of the method for maintaining data consistency in this embodiment of the present application. The file F on the disk in the electronic device B is divided by the memory page size, and it can be considered that it includes data of the memory page size of f1 to fd, which includes the data fx. The electronic device A, the electronic device B, and the electronic device C all read the data of f1 to fx of the file F from the disk of the electronic device B, and cache the data in their own memory. If at this time, the electronic device A modifies the file F in the memory, specifically, it modifies the data fx on a certain memory page on the radix tree of the file F in the memory to fx'. In order to maintain data consistency, electronic device A notifies electronic device B of the modification. After electronic device B receives the notification, it does not need to discard the entire radix tree of file F in memory. The data in the memory page where the data fx is stored can be changed to fx'. The electronic device B determines that the electronic device C has also read the data fx. In order to maintain data consistency, the electronic device B may notify the electronic device C that the data fx is invalid. The electronic device C will discard the data fx of the size of the memory page on the radix tree of the file F in its own memory, that is, the memory page storing the data fx can be marked as dirty, and the entire radix tree of the file F does not need to be discarded. After a period of time, the electronic device B can write back the modified data fx' to the disk, and update the data fx in the file F stored in the disk.
可以理解的是,本申请实施例中以磁盘存储文件为例,在一些实施例中,电子设备还可以使用其他的非易失性存储器存储文件,此处不作限定。It can be understood that, in the embodiments of the present application, a disk is used as an example to store files, and in some embodiments, the electronic device may also use other non-volatile memory to store files, which is not limited here.
结合对图13所示的电子设备100的硬件结构示意图的描述,本申请的一些实施例中,电子设备100可以使用移动通信模块150或无线通信模块160与其他电子设备组成分布式文件系统。该处理器110可以调用内部存储器121中存储的计算机指令以使得该电子设备100执行本申请实施例中保持数据一致性的方法。With reference to the description of the schematic hardware structure of the electronic device 100 shown in FIG. 13 , in some embodiments of the present application, the electronic device 100 may use the mobile communication module 150 or the wireless communication module 160 to form a distributed file system with other electronic devices. The processor 110 may invoke computer instructions stored in the internal memory 121 to cause the electronic device 100 to execute the method for maintaining data consistency in the embodiments of the present application.
结合对图14所示的电子设备100的软件结构示意图的描述,如图57所示,本申请的一些实施例中,应用程序层还可以包含有数据一致性模块。With reference to the description of the schematic diagram of the software structure of the electronic device 100 shown in FIG. 14 , as shown in FIG. 57 , in some embodiments of the present application, the application layer may further include a data consistency module.
该数据一致性模块可以用于执行本申请实施例中保持数据一致性的方法。The data consistency module may be used to execute the method for maintaining data consistency in the embodiments of the present application.
在一些实施例中,该数据一致性模块也可以位于分层架构中的其他层级,例如应用程序框架层、系统库或内核层等,此处不作限定。In some embodiments, the data consistency module may also be located at other layers in the layered architecture, such as an application framework layer, a system library or a kernel layer, etc., which are not limited here.
下面结合上述示例性电子设备100的软硬件结构,以在电子设备A、电子设备B和电子设备C组成的分布式文件系统中,电子设备A访问或修改电子设备B中的文件F为例,对本申请实施例中保持数据一致性的方法进行具体描述:In the following, in conjunction with the software and hardware structure of the above-mentioned exemplary electronic device 100, in a distributed file system composed of electronic device A, electronic device B, and electronic device C, electronic device A accesses or modifies file F in electronic device B as an example, The method for maintaining data consistency in the embodiment of the present application is described in detail:
图58为本申请实施例中保存数据一致性的方法一个信令交互示意图。FIG. 58 is a schematic diagram of signaling interaction of a method for preserving data consistency in an embodiment of the present application.
S5801、电子设备A接收到访问电子设备B中文件F的数据fx的请求;S5801, electronic device A receives a request to access data fx of file F in electronic device B;
数据fx为文件F中偏移量为x的内存页大小的数据。将文件F划分为N个内存页大小的数据,若将文件F的第一个内存页大小的数据的偏移量设为0,则文件F的第二个内存页大小的数据的偏移量为1,文件F的第三个内存页大小的数据的偏移量为2,以此类推,文件F的第N个内存页大小的数据的偏移量为N-1。The data fx is the data of the memory page size at the offset of x in the file F. Divide file F into N memory pages of data. If the offset of the first memory page of file F is set to 0, then the offset of the second memory page of file F will be offset. is 1, the offset of the data of the size of the third memory page of the file F is 2, and so on, the offset of the data of the size of the Nth memory page of the file F is N-1.
在一些实施例中,若将文件F的第一个内存页大小的数据的偏移量设为1,则文件F的第二个内存页大小的数据的偏移量为2,文件F的第三个内存页大小的数据的偏移量为3,以此类推,文件F的第N个内存页代销的数据的偏移量为N。In some embodiments, if the offset of the data of the size of the first memory page of the file F is set to 1, the offset of the data of the size of the second memory page of the file F is 2, and the offset of the data of the size of the second memory page of the file F is 2. The offset of the data of the size of three memory pages is 3, and so on, the offset of the data sold on behalf of the Nth memory page of file F is N.
具体对偏移量的设定可以根据实际情况而定,此处不作限定。The specific setting of the offset may be determined according to the actual situation, which is not limited here.
在本申请一些实施例中,该数据fx也可以被称为第一数据。In some embodiments of the present application, the data fx may also be referred to as first data.
S5802、电子设备A在本地内存中查找文件F的基数树中是否已经缓存数据fx;S5802, the electronic device A searches in the local memory whether the data fx has been cached in the radix tree of the file F;
可以理解的是,电子设备A访问文件时,缓存的文件在内存中会以基数树的形式保存。对基数树的描述可以参阅上述术语介绍(3)基数树,此处不再赘述。It is understandable that when the electronic device A accesses the file, the cached file will be stored in the memory in the form of a radix tree. For the description of the radix tree, please refer to the above terminology introduction (3) Radix tree, which will not be repeated here.
在接收到访问电子设备B中文件F中数据fx的请求后,电子设备A可以在本地内存中查找文件F的基数树中是否已经缓存数据fx;After receiving the request to access the data fx in the file F in the electronic device B, the electronic device A can search in the local memory whether the data fx has been cached in the radix tree of the file F;
当确定没有缓存数据fx时,电子设备A可以执行步骤S5803。When it is determined that the data fx is not cached, the electronic device A may perform step S5803.
当确定已经缓存了数据fx时,电子设备A可以执行步骤S5807。When it is determined that the data fx has been cached, the electronic device A may perform step S5807.
S5803、电子设备A向电子设备B发送读电子设备B中文件F的数据fx的请求;S5803, the electronic device A sends a request to read the data fx of the file F in the electronic device B to the electronic device B;
当电子设备A确定在本地内存中文件F的基数树中没有缓存数据fx时,电子设备A可以向电子设备B发送读电子设备B中文件F的数据fx的请求。When the electronic device A determines that there is no cached data fx in the radix tree of the file F in the local memory, the electronic device A may send a request to the electronic device B to read the data fx of the file F in the electronic device B.
该请求中可以包含:读指令的命令编号、电子设备A的设备标识、要访问文件的路径(即文件F的路径),以及要访问的数据在文件中的偏移量(即偏移量x)。The request may include: the command number of the read instruction, the device identifier of the electronic device A, the path of the file to be accessed (that is, the path of the file F), and the offset of the data to be accessed in the file (that is, the offset x ).
S5804、电子设备B将本地文件F的数据fx从磁盘读取到内存中文件F的基数树中缓存;S5804, the electronic device B reads the data fx of the local file F from the disk into the radix tree of the file F in the memory and caches it;
电子设备B在接收到电子设备A发送的读电子设备B中文件F的数据fx的请求后,可以将本地文件F的数据fx从磁盘读取到内存中文件F的基数树中缓存。然后执行步骤S5805。After receiving the request to read the data fx of the file F in the electronic device B sent by the electronic device A, the electronic device B can read the data fx of the local file F from the disk into the radix tree of the file F in the memory and cache. Then step S5805 is executed.
S5805、电子设备B记录数据fx和电子设备A的设备标识的对应关系;S5805, the correspondence between the electronic device B records the data fx and the device identification of the electronic device A;
分布式文件系统中每个电子设备中可以保存有一个本地数据读取记录,该本地数据读取记录可以用于记录分布式文件系统中其他电子设备读取本电子设备中文件的数据的对应关系。Each electronic device in the distributed file system can save a local data read record, and the local data read record can be used to record the correspondence between other electronic devices in the distributed file system reading the data of the file in the electronic device .
在电子设备B在接收到电子设备A发送的读电子设备B中文件F的数据fx的请求后,后,电子设备B可以根据该请求,在自己的本地数据读取记录中记录数据fx和电子设备A的设备标识的对应关系。After the electronic device B receives the request sent by the electronic device A to read the data fx of the file F in the electronic device B, the electronic device B can record the data fx and the electronic device B in its own local data reading record according to the request The corresponding relationship between the device IDs of device A.
可选的,电子设备B可以将该本地数据读取记录缓存在内存中。Optionally, the electronic device B may cache the local data read record in the memory.
示例性的,如下表7为电子设备B中存储的该本地数据读取记录的一个示例性示意:Exemplarily, the following table 7 is an exemplary illustration of the local data reading record stored in the electronic device B:
电子设备的设备标识Device identification for electronic equipment 读取的数据read data
电子设备AElectronic equipment A f1、f2、f3、f4、fxf1, f2, f3, f4, fx
电子设备CElectronic equipment C f1、f2、f3、f4、fx、f10、f20f1, f2, f3, f4, fx, f10, f20
表7Table 7
可选的,电子设备的设备标识可以为电子设备的设备号、MAC地址、IP地址或设备名称等能在该分布式文件系统中唯一标识一个电子设备的标识,此处不作限定。Optionally, the device identifier of the electronic device may be an identifier that can uniquely identify an electronic device in the distributed file system, such as the device number, MAC address, IP address, or device name of the electronic device, which is not limited here.
可以理解的是,表7仅是该本地数据读取记录的一个示例,在实际应用中,该本地数据读取记录还可以是其他的数据类型或数据结构,例如矩阵、数组、数据库等,此处不作限定。It can be understood that Table 7 is only an example of the local data read record. In practical applications, the local data read record can also be other data types or data structures, such as a matrix, an array, a database, etc. There are no restrictions.
S5806、电子设备B返回响应,该响应中包含该数据fx;S5806, the electronic device B returns a response, and the response contains the data fx;
电子设备B在自己的本地数据读取记录中记录了数据fx和电子设备A的设备标识的对应关系后,可以返回响应给电子设备A,在该响应中包含有该请求中请求的数据fx。After the electronic device B records the correspondence between the data fx and the device identification of the electronic device A in its local data reading record, it can return a response to the electronic device A, where the response contains the data fx requested in the request.
可选的,该响应中可以包含有与该请求中读指令的命令编号相同的编号,以表明该响应为对该请求的响应。Optionally, the response may contain the same number as the command number of the read instruction in the request to indicate that the response is a response to the request.
S5807、电子设备A从文件F的基数树中读取数据fx;S5807, the electronic device A reads the data fx from the radix tree of the file F;
当电子设备A确定在本地内存中文件F的基数树中缓存有数据fx时,电子设备A可以直接从文件F的基数树中读取数据fx,可以不需要执行上述步骤S5804~S5806。When the electronic device A determines that the data fx is cached in the radix tree of the file F in the local memory, the electronic device A can directly read the data fx from the radix tree of the file F without performing the above steps S5804-S5806.
上述步骤S5806~S5807中,电子设备A基于请求读取到文件F的数据fx。然后,在下述步骤中,电子设备A可以对数据fx进行修改,并在分布式文件系统中保持该数据的一致性。In the above steps S5806 to S5807, the electronic device A reads the data fx of the file F based on the request. Then, in the following steps, the electronic device A can modify the data fx and maintain the consistency of the data in the distributed file system.
S5808、电子设备A修改本地内存中文件F的基数树中数据fx为数据fx';S5808, the electronic device A modifies the data fx in the radix tree of the file F in the local memory to be the data fx';
在电子设备A读取数据fx后,响应于用户操作或响应于电子设备A中应用程序的处理,电子设备A可以修改本地内存中文件F的基数树中数据fx为数据fx'。After the electronic device A reads the data fx, in response to a user operation or in response to the processing of an application program in the electronic device A, the electronic device A can modify the data fx in the radix tree of the file F in the local memory to data fx'.
本申请的一些实施例中,该数据fx'也可以被称为第二数据。In some embodiments of the present application, the data fx' may also be referred to as second data.
例如,文件F是一个文档,电子设备A修改了文档中的某些连续的字符。For example, file F is a document, and electronic device A modifies certain consecutive characters in the document.
S5809、电子设备A延迟预设时长;S5809, the electronic device A delays the preset duration;
在电子设备A修改本地内存中文件F的基数树中数据fx为数据fx'后,可以延迟预设时长再执行步骤S5810。After the electronic device A modifies the data fx in the radix tree of the file F in the local memory to the data fx', step S5810 may be executed after a preset time period.
这样可以防止连续修改内存中的数据时,频繁触发后续的数据更新步骤。This can prevent frequent triggering of subsequent data update steps when data in memory is continuously modified.
S5810、电子设备A向电子设备B发送将电子设备B中文件F的数据fx改写为数据fx'的请求;S5810, electronic device A sends a request to electronic device B to rewrite data fx of file F in electronic device B into data fx';
在电子设备A修改本地内存中文件F的基数树中数据fx为数据fx'后,且延迟了预设时长都没有接收到其他的数据修改时,电子设备A可以向电子设备B发送将电子设备B中文件F的数据fx改写为数据fx'的请求。After the electronic device A modifies the data fx in the radix tree of the file F in the local memory to the data fx', and no other data modification is received after a preset time period, the electronic device A can send the electronic device B to the electronic device B. A request for rewriting data fx of file F in B into data fx'.
可以理解的是,将电子设备B中文件F的数据fx改写为数据fx'的请求中可以包含电子设备A的设备标识、文件F的路径、数据fx在文件F中的偏移量等,此处不作限定。It can be understood that the request to rewrite the data fx of the file F in the electronic device B into the data fx' may include the device identification of the electronic device A, the path of the file F, the offset of the data fx in the file F, etc. There are no restrictions.
S5811、电子设备B将本地内存中文件F的基数树中数据fx改写为数据fx';S5811, the electronic device B rewrites the data fx in the radix tree of the file F in the local memory to the data fx';
响应于将文件F的数据fx改写为数据fx'的请求,电子设备B可以将本地内存中文件F的基数树中数据fx改写为数据fx'。In response to the request to rewrite the data fx of the file F into the data fx', the electronic device B may rewrite the data fx in the radix tree of the file F in the local memory into the data fx'.
可以理解的是,电子设备B只需要改写本地内存中文件F的基数树中数据fx所在的内存页上的数据为数据fx'即可。It can be understood that the electronic device B only needs to rewrite the data on the memory page where the data fx in the radix tree of the file F in the local memory is located to the data fx'.
可以理解的是,响应于电子设备A发送的将文件F的数据fx改写为数据fx'的请求,电子设备B还可以将自己的本地数据读取记录中电子设备A读取数据fx的读取记录,修改为电子设备A读取数据fx'的读取记录。It can be understood that, in response to the request sent by the electronic device A to rewrite the data fx of the file F into the data fx', the electronic device B can also read the data fx read by the electronic device A in its own local data reading record. The record is modified to the read record of the electronic device A's read data fx'.
示例性的,若电子设备B中此前的本地数据读取记录为上表7所示,则此时电子设备B可以将该本地数据读取记录更新为下表8所示:Exemplarily, if the previous local data reading record in electronic device B is shown in Table 7 above, then electronic device B can update the local data reading record as shown in Table 8 below:
电子设备的设备标识Device identification for electronic equipment 读取的数据read data
电子设备AElectronic equipment A f1、f2、f3、f4、fx'f1, f2, f3, f4, fx'
电子设备CElectronic equipment C f1、f2、f3、f4、fx、f10、f20f1, f2, f3, f4, fx, f10, f20
表8Table 8
S5812、电子设备B确定数据fx还被电子设备C读取过;S5812, the electronic device B determines that the data fx has also been read by the electronic device C;
在电子设备B响应的某个电子设备的请求,修改了内存中的某个数据后,电子设备B可以根据自己的本地数据读取记录中存储的数据读取的对应关系,确定出该数据被分布式文件系统中除了修改来源的电子设备外的哪些电子设备读取过。After the electronic device B responds to a request of an electronic device and modifies a certain data in the memory, the electronic device B can determine that the data is read according to the corresponding relationship of the data read stored in its local data read record. Which electronic devices in the distributed file system have been read except the electronic device that modified the source.
在确定出其他电子设备读取过该数据时,可以执行步骤S5813;When it is determined that other electronic devices have read the data, step S5813 can be performed;
在确定没有其他电子设备读取过该数据时,可以直接执行步骤S5815。When it is determined that no other electronic device has read the data, step S5815 may be directly executed.
示例性的,若电子设备B的本地数据读取记录为上述表8所示。则电子设备B可以确定该数据fx还被电子设备C读取过。可以执行步骤S5813。Exemplarily, if the local data read record of the electronic device B is as shown in Table 8 above. Then the electronic device B can determine that the data fx has also been read by the electronic device C. Step S5813 may be performed.
S5813、电子设备B向电子设备C发送标记数据fx无效的通知;S5813, the electronic device B sends a notification that the marking data fx is invalid to the electronic device C;
在电子设备B将内存中的数据fx改写为fx',并确定该数据fx还被电子设备C读取过之后,电子设备B可以向电子设备C发送标记数据fx无效的通知。After the electronic device B rewrites the data fx in the memory to fx' and determines that the data fx has been read by the electronic device C, the electronic device B can send a notification to the electronic device C that the marked data fx is invalid.
可以理解的是,若该电子设备B确定该数据fx还被分布式文件系统中其他电子设备读取过,则该电子设备B也可以向该其他电子设备发送标记数据fx无效的通知。It can be understood that, if the electronic device B determines that the data fx has also been read by other electronic devices in the distributed file system, the electronic device B can also send a notification that the marked data fx is invalid to the other electronic device.
S5814、电子设备C清除本地内存中文件F的基数树上数据fx的缓存;S5814, the electronic device C clears the cache of the data fx on the radix tree of the file F in the local memory;
电子设备C响应于接收到的标记数据fx无效的通知,清除本地内存中文件F的基数树上数据fx的缓存。In response to the received notification that the marked data fx is invalid, the electronic device C clears the cache of the data fx on the radix tree of the file F in the local memory.
可以理解的是,电子设备C清除本地内存中文件F的基数树上数据fx的缓存,具体可以为将文件F的基数树上数据fx所在的内存页标记为脏。It can be understood that the electronic device C clears the cache of the data fx on the radix tree of the file F in the local memory, specifically, marking the memory page where the data fx on the radix tree of the file F is located as dirty.
S5815、电子设备B删除电子设备C对数据fx的读取信息;S5815, the electronic device B deletes the reading information of the data fx by the electronic device C;
在电子设备B向电子设备C发送标记数据fx无效的通知后,电子设备B可以删除自己的本地数据读取记录中电子设备C对数据fx的读取信息。After the electronic device B sends a notification to the electronic device C that the marked data fx is invalid, the electronic device B can delete the reading information of the data fx by the electronic device C in its own local data reading record.
示例性的,若电子设备B中此前的本地数据读取记录为上表8所示,则此时电子设备B可以将该本地数据读取记录更新为下表9所示:Exemplarily, if the previous local data reading record in electronic device B is shown in Table 8 above, then electronic device B can update the local data reading record as shown in Table 9 below:
电子设备的设备标识Device identification for electronic equipment 读取的数据read data
电子设备AElectronic equipment A f1、f2、f3、f4、fx'f1, f2, f3, f4, fx'
电子设备CElectronic equipment C f1、f2、f3、f4、f10、f20f1, f2, f3, f4, f10, f20
表9Table 9
S5816、电子设备B将磁盘中存储的文件F中的数据fx修改为fx'。S5816, the electronic device B modifies the data fx in the file F stored in the disk to fx'.
电子设备B将内存中文件F的数据fx修改为fx'后,在预设写回时长后,电子设备B可以将磁盘中存储的文件F中的数据fx修改为fx'。After the electronic device B modifies the data fx of the file F in the memory to fx', the electronic device B can modify the data fx in the file F stored in the disk to fx' after a preset write-back time.
可以理解的是,若在该预设写回时间长内,内存中文件F的数据还有其他的修改,也可以一起写回到磁盘上的文件F中。It can be understood that, if the data of the file F in the memory has other modifications within the preset write-back time, it can also be written back to the file F on the disk together.
本申请实施例中,在电子设备A修改了内存中从电子设备B中文件的数据fx时,电子设备B可以直接在内存中文件F的基数树上对内存页大小的数据fx进行更新,不需要对内存中缓存的整个文件F的数据(即基数树整体)进行删除和重新加载。只需要在基数树上将相应内存页的数据进行更新即可,对于分布式文件系统中的其他电子设备,也可以直接发送标记数据fx无效的通知,使得接收到的电子设备只需要将文件F的基数树中fx所在的内存页置为无效即可,也不需要对内存中缓存的整个文件F的数据进行删除和重新加载。使得在分布式文件系统中保持数据一致性时,极大的提升数据访问的速度,减少网络资源的消耗。In the embodiment of the present application, when electronic device A modifies the data fx of the file in the memory from the electronic device B, the electronic device B can directly update the data fx of the memory page size on the radix tree of the file F in the memory, without It is necessary to delete and reload the data of the entire file F cached in memory (ie, the entirety of the radix tree). It is only necessary to update the data of the corresponding memory page on the radix tree. For other electronic devices in the distributed file system, it is also possible to directly send a notification that the marked data fx is invalid, so that the received electronic device only needs to update the file F. The memory page where fx is located in the radix tree can be invalidated, and there is no need to delete and reload the data of the entire file F cached in the memory. This greatly improves the speed of data access and reduces the consumption of network resources when maintaining data consistency in the distributed file system.
可以理解的是,本申请上述实施例中的电子设备除了可以为移动电子设备,也可以为其他类型的电子设备,例如电视、电脑、智能打印机等,此处不作限定。It can be understood that the electronic device in the above embodiments of the present application may be not only a mobile electronic device, but also other types of electronic devices, such as a TV, a computer, a smart printer, etc., which are not limited here.
示例性的,图59是本申请实施例提供的示例性电子设备200的另一个结构示意图。Exemplarily, FIG. 59 is another schematic structural diagram of an exemplary electronic device 200 provided by an embodiment of the present application.
该电子设备200可以包括:输入装置5901、输出装置5902、处理器5903和存储器5904(其中电子设备200中的处理器5903的数量可以一个或多个,图59中以一个处理器5903为例)。在本申请的一些实施例中,输入装置5901、输出装置5902、处理器5903和存储器5904可通过总线或其它方式连接,其中,图59中以通过总线连接为例。The electronic device 200 may include: an input device 5901, an output device 5902, a processor 5903 and a memory 5904 (wherein the number of processors 5903 in the electronic device 200 may be one or more, and one processor 5903 is taken as an example in FIG. 59) . In some embodiments of the present application, the input device 5901 , the output device 5902 , the processor 5903 and the memory 5904 may be connected by a bus or in other ways, wherein the connection by a bus is taken as an example in FIG. 59 .
在本申请的一些实施例中,该处理器5903可以通过调用存储器5904存储的操作指令,以使得该电子设备200执行本申请实施例中的元数据管理方法。具体过程与上述电子设备100执行本申请实施例中的元数据管理方法类似,此处不再赘述;In some embodiments of the present application, the processor 5903 may call the operation instructions stored in the memory 5904 to cause the electronic device 200 to execute the metadata management method in the embodiments of the present application. The specific process is similar to the above-mentioned electronic device 100 executing the metadata management method in the embodiment of the present application, and details are not repeated here;
在本申请的一些实施例中,该处理器5903可以通过调用存储器5904存储的操作指令,以使得该电子设备200执行本申请实施例中的同名文件识别方法。具体过程与上述电子设备100执行本申请实施例中的同名文件识别方法类似,此处不再赘述;In some embodiments of the present application, the processor 5903 may call the operation instructions stored in the memory 5904, so that the electronic device 200 executes the method for identifying a file with the same name in the embodiments of the present application. The specific process is similar to the above-mentioned electronic device 100 executing the method for identifying a file with the same name in the embodiment of the present application, and details are not repeated here;
在本申请的一些实施例中,该处理器5903可以通过调用存储器5904存储的操作指令,以使得该电子设备200执行本申请实施例中的数据预读方法。具体过程与上述电子设备100执行本申请实施例中的数据预读方法类似,此处不再赘述;In some embodiments of the present application, the processor 5903 may call the operation instructions stored in the memory 5904 to cause the electronic device 200 to execute the data pre-reading method in the embodiments of the present application. The specific process is similar to that of the electronic device 100 performing the data pre-reading method in the embodiment of the present application, and details are not repeated here;
在本申请的一些实施例中,该处理器5903可以通过调用存储器5904存储的操作指令,以使得该电子设备200执行本申请实施例中保持数据一致性的方法。具体过程与上述电子设备100执行本申请实施例中保持数据一致性的方法类似,此处不再赘述。In some embodiments of the present application, the processor 5903 may call the operation instructions stored in the memory 5904 to cause the electronic device 200 to execute the method for maintaining data consistency in the embodiments of the present application. The specific process is similar to that of the electronic device 100 performing the method for maintaining data consistency in the embodiments of the present application, and details are not described herein again.
上述实施例中,该电子设备A、电子设备B和电子设备C也可以被称为第一电子设备、第二电子设备或第三电子设备等,此处不作限定。In the above embodiment, the electronic device A, the electronic device B, and the electronic device C may also be referred to as the first electronic device, the second electronic device, or the third electronic device, etc., which are not limited here.
例如,在一些实施例中,电子设备A可以为第一电子设备,电子设备B可以为第二电子设备,电子设备C可以为第三电子设备;在一些实施例中,电子设备A可以为第一电子设备,电子设备B可以为第三电子设备,电子设备C可以为第二电子设备;在一些实施例中,电子设备A可以为第一电子设备,电子设备B可以为第二电子设备,电子设备C也可以为第二电子设备;在一些实施例中,电子设备A可以为第二电子设备,电子设备B可以为第一电子设备,电子设备C可以为第三电子设备;在一些实施例中,电子设备A可以为第二电子设备,电子设备B可以为第三电子设备,电子设备C可以为第一电子设备;在一些实施例中,电子设备A可以为第二电子设备,电子设备B可以为第一电子设备,电子设备C也可以为第二电子设备;在一些实施例中,电子设备A可以为第二电子设备,电子设备B也可以为第二电子设备,电子设备C可以为第一电子设备;在一些实施例中,电子设备A可以为第三电子设备,电子设备B可以为第一电子设备,电子设备C可以为第二电子设备;在一些实施例中,电子设备A可以为第三电子设备,电子设备B可以为第二电子设备,电子设备C可以为第一电子 设备;还可以有其他的电子设备A、电子设备B和电子设备C与第一电子设备、第二电子设备或第三电子设备的对应情况,此处不作限定。For example, in some embodiments, electronic device A may be the first electronic device, electronic device B may be the second electronic device, and electronic device C may be the third electronic device; in some embodiments, electronic device A may be the first electronic device An electronic device, electronic device B can be a third electronic device, electronic device C can be a second electronic device; in some embodiments, electronic device A can be a first electronic device, electronic device B can be a second electronic device, Electronic device C can also be a second electronic device; in some embodiments, electronic device A can be a second electronic device, electronic device B can be a first electronic device, and electronic device C can be a third electronic device; in some implementations In an example, the electronic device A may be the second electronic device, the electronic device B may be the third electronic device, and the electronic device C may be the first electronic device; in some embodiments, the electronic device A may be the second electronic device, the electronic device Device B can be a first electronic device, and electronic device C can also be a second electronic device; in some embodiments, electronic device A can be a second electronic device, electronic device B can also be a second electronic device, and electronic device C can be the first electronic device; in some embodiments, the electronic device A can be the third electronic device, the electronic device B can be the first electronic device, and the electronic device C can be the second electronic device; in some embodiments, the electronic device Device A may be the third electronic device, electronic device B may be the second electronic device, and electronic device C may be the first electronic device; there may also be other electronic devices A, B and C and the first electronic device , the corresponding situation of the second electronic device or the third electronic device is not limited here.
可以理解的是,上述实施例中各电子设备执行的步骤仅受限于具体场景,各电子设备均可以具有执行上述实施例中任意步骤的能力,此处不作限定。It can be understood that the steps performed by each electronic device in the foregoing embodiments are only limited to specific scenarios, and each electronic device may have the ability to execute any steps in the foregoing embodiments, which is not limited here.
可以理解的是,根据实际场景的需求,本申请实施例中的电子设备可以执行上述元数据管理方法、同名文件识别方法、数据预读方法以及保持数据一致性的方法中的任意一个或多个方法,此处不作限定。It can be understood that, according to the requirements of the actual scene, the electronic device in the embodiment of the present application can execute any one or more of the above-mentioned metadata management method, same-name file identification method, data pre-reading method, and data consistency method. method, which is not limited here.
示例性的,结合对图14所示的电子设备100的软件结构示意图的描述,如图60所示,为本申请实施例中电子设备的另一个软件结构框架示意图。Exemplarily, combined with the description of the schematic diagram of the software structure of the electronic device 100 shown in FIG. 14 , as shown in FIG. 60 , it is another schematic diagram of the software structure framework of the electronic device in this embodiment of the present application.
其中,该电子设备的应用程序层还可以包含有元数据管理模块、同名文件识别模块和数据一致性模块。该电子设备的内核层还可以包含有数据预读模块。Wherein, the application layer of the electronic device may further include a metadata management module, a file identification module with the same name and a data consistency module. The kernel layer of the electronic device may also include a data pre-reading module.
该元数据管理模块可用于执行本申请实施例中的元数据管理方法;The metadata management module can be used to execute the metadata management method in the embodiment of the present application;
该同名文件识别模块用于执行本申请实施例中的同名文件识别方法;The same-name file identification module is used to execute the same-name file identification method in the embodiment of the present application;
该数据一致性模块用于执行本申请实施例中保持数据一致性的方法;The data consistency module is used to execute the method for maintaining data consistency in the embodiments of the present application;
该数据预读模块用于执行本申请实施例中的数据预读方法。The data pre-reading module is used to execute the data pre-reading method in the embodiment of the present application.
在一些实施例中,该元数据管理模块、同名文件识别模块、数据一致性模块和数据预读模块也可以分别位于该分层架构的其他层级,此处不作限定。In some embodiments, the metadata management module, the file identification module with the same name, the data consistency module, and the data pre-reading module may also be located at other levels of the hierarchical architecture, which are not limited here.
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand: The technical solutions described in the embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。As used in the above embodiments, the term "when" may be interpreted to mean "if" or "after" or "in response to determining..." or "in response to detecting..." depending on the context. Similarly, depending on the context, the phrases "in determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining..." or "in response to determining..." or "on detecting (the stated condition or event)" or "in response to the detection of (the stated condition or event)".
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general purpose computer, special purpose computer, computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes an integration of one or more available media. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented. The process can be completed by instructing the relevant hardware by a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed , which may include the processes of the foregoing method embodiments. The aforementioned storage medium includes: ROM or random storage memory RAM, magnetic disk or optical disk and other mediums that can store program codes.

Claims (30)

  1. 一种元数据管理方法,其特征在于,包括:A method for managing metadata, comprising:
    第一电子设备在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,所述第二本地文件中包括所述第一本地文件的元数据信息;The first electronic device includes a first local file and a second local file in a first directory in a first local file system of the first electronic device, and the second local file includes metadata information of the first local file ;
    当第二电子设备接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,所述第二电子设备向所述第一电子设备发送分布式文件系统获取所述第二本地文件的请求;When the second electronic device receives a request to access the first directory in the second local file system of the second electronic device, the second electronic device sends the distributed file system to the first electronic device to obtain the second local file requests;
    所述第一电子设备向所述第二电子设备发送所述第二本地文件;sending, by the first electronic device, the second local file to the second electronic device;
    所述第二电子设备将所述第二本地文件缓存到第二本地文件系统中的第一目录中,并根据所述第二本地文件,在所述第二本地文件系统中的第一目录中显示所述第一本地文件。The second electronic device caches the second local file in the first directory in the second local file system, and according to the second local file, in the first directory in the second local file system The first local file is displayed.
  2. 一种元数据管理方法,其特征在于,包括:A method for managing metadata, comprising:
    第一电子设备在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,所述第二本地文件中包括第一本地文件的元数据信息;The first electronic device includes a first local file and a second local file in a first directory in the first local file system of the first electronic device, and the second local file includes metadata information of the first local file;
    当所述第一电子设备接收到第二电子设备发送的分布式文件系统获取所述第二本地文件的请求时,所述第一电子设备向所述第二电子设备发送所述第二本地文件,使得在第二电子设备的第二本地文件系统中的第一目录中显示所述第一本地文件。When the first electronic device receives the request sent by the second electronic device for the distributed file system to obtain the second local file, the first electronic device sends the second local file to the second electronic device , so that the first local file is displayed in the first directory in the second local file system of the second electronic device.
  3. 根据权利要求2所述的方法,其特征在于,所述元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。The method according to claim 2, wherein the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
  4. 根据权利要求2或3所述的方法,其特征在于,所述方法还包括:The method according to claim 2 or 3, wherein the method further comprises:
    当所述第一电子设备在所述第一本地文件系统中的第一目录中增加第三本地文件时,所述第一电子设备在所述第二本地文件中增加第三本地文件的元数据信息。When the first electronic device adds a third local file to the first directory in the first local file system, the first electronic device adds metadata of the third local file to the second local file information.
  5. 根据权利要求2至4中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 2 to 4, wherein the method further comprises:
    当所述第一电子设备删除所述第一本地文件时,所述第一电子设备在所述第二本地文件中删除所述第一本地文件的元数据信息。When the first electronic device deletes the first local file, the first electronic device deletes the metadata information of the first local file in the second local file.
  6. 根据权利要求2至5中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 2 to 5, wherein the method further comprises:
    当所述第一电子设备修改所述第一本地文件时,所述第一电子设备根据对所述第一本地文件的修改,在所述第二本地文件中更新所述第一本地文件的元数据信息。When the first electronic device modifies the first local file, the first electronic device updates the metadata of the first local file in the second local file according to the modification to the first local file Data information.
  7. 根据权利要求2至6中任一项所述的方法,其特征在于,所述第一目录为第二目录中的一个目录;所述方法还包括:The method according to any one of claims 2 to 6, wherein the first directory is a directory in the second directory; the method further comprises:
    所述第一电子设备接收所述第二电子设备发送的分布式文件系统获取所述第一本地文件系统中的第二目录中第四本地文件的请求;所述第四本地文件中包括所述第一本地文件系统中的第一目录的元数据信息;The first electronic device receives a request sent by the second electronic device for the distributed file system to obtain a fourth local file in the second directory in the first local file system; the fourth local file includes the metadata information of the first directory in the first local file system;
    所述第一电子设备发送所述第四本地文件给所述第二电子设备;The first electronic device sends the fourth local file to the second electronic device;
    所述第一电子设备接收所述第二电子设备发送的分布式文件系统获取所述第一本地文件系统中的第一目录中的所述第二本地文件的请求;receiving, by the first electronic device, a request sent by the second electronic device for the distributed file system to obtain the second local file in the first directory in the first local file system;
    所述第一电子设备发送所述第二本地文件给所述第二电子设备;所述第二本地文件中包括所述第一本地文件系统中的第一目录中的第五本地文件的元数据信息;The first electronic device sends the second local file to the second electronic device; the second local file includes metadata of the fifth local file in the first directory in the first local file system information;
    所述第一电子设备接收所述第二电子设备对所述第五本地文件的访问。The first electronic device receives the access of the second electronic device to the fifth local file.
  8. 根据权利要求2至6中任一项所述的方法,其特征在于,所述第一目录为第二目录中的一个目录;所述方法还包括:The method according to any one of claims 2 to 6, wherein the first directory is a directory in the second directory; the method further comprises:
    所述第一电子设备接收所述第二电子设备发送的第五本地文件的路径;所述第五本地文件为所述第一本地文件系统中的第一目录中的一个文件;The first electronic device receives the path of the fifth local file sent by the second electronic device; the fifth local file is a file in the first directory in the first local file system;
    当所述第一电子设备确定所述第一本地文件系统中的第一目录下存在所述第五本地文件时,所述第一电子设备向所述第二电子设备发送所述第二本地文件;所述第二本地文件中包括所述第五本地文件的元数据信息;When the first electronic device determines that the fifth local file exists in the first directory in the first local file system, the first electronic device sends the second local file to the second electronic device ; The metadata information of the fifth local file is included in the second local file;
    所述第一电子设备接收所述第二电子设备对所述第五本地文件的访问。The first electronic device receives the access of the second electronic device to the fifth local file.
  9. 根据权利要求2至8中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 2 to 8, wherein the method further comprises:
    所述第一电子设备接收所述第二电子设备发送的更新后的第一本地文件;The first electronic device receives the updated first local file sent by the second electronic device;
    所述第一电子设备根据更新后的第一本地文件,更新所述第二本地文件;更新后的第二本地文件中包括更新后的第一本地文件的元数据信息。The first electronic device updates the second local file according to the updated first local file; the updated second local file includes metadata information of the updated first local file.
  10. 根据权利要求2至9中任一项所述的方法,其特征在于,所述第一电子设备中包括第一读取记录,所述第一读取记录中包括所述第二电子设备向所述第一电子设备请求获取包括元数据信息的本地文件的记录。The method according to any one of claims 2 to 9, wherein the first electronic device includes a first read record, and the first read record includes the second electronic device to the The first electronic device requests to obtain a record of a local file including metadata information.
  11. 根据权利要求2至10中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 2 to 10, wherein the method further comprises:
    当所述第一电子设备发送所述第二本地文件给所述第二电子设备,且所述第一电子设备更新所述第二本地文件后,所述第一电子设备将更新后的第二本地文件发送给所述第二电子设备。When the first electronic device sends the second local file to the second electronic device, and the first electronic device updates the second local file, the first electronic device sends the updated second local file The local file is sent to the second electronic device.
  12. 一种元数据管理方法,其特征在于,包括:A method for managing metadata, comprising:
    当第二电子设备接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,所述第二电子设备向第一电子设备发送分布式文件系统获取第二本地文件的请求;所述第二本地文件中包括第一电子设备的第一本地文件系统中的第一目录中第一本地文件的元数据信息;When the second electronic device receives a request for accessing the first directory in the second local file system of the second electronic device, the second electronic device sends a request for the distributed file system to obtain the second local file to the first electronic device ; The metadata information of the first local file in the first directory in the first local file system of the first electronic device is included in the second local file;
    所述第二电子设备接收所述第一电子设备发送的所述第二本地文件,并缓存到所述第二本地文件系统中的第一目录中;The second electronic device receives the second local file sent by the first electronic device, and caches it in the first directory in the second local file system;
    所述第二电子设备根据所述第二本地文件,在所述第二本地文件系统中的第一目录中显示所述第一本地文件。The second electronic device displays the first local file in a first directory in the second local file system according to the second local file.
  13. 根据权利要求12所述的方法,其特征在于,所述元数据信息中包括文件名、文件类型、文件大小、修改时间、访问权限中的至少一项。The method according to claim 12, wherein the metadata information includes at least one of file name, file type, file size, modification time, and access authority.
  14. 根据权利要求12或13所述的方法,其特征在于,所述第一目录为第二目录中的一个 目录;所述方法还包括:The method according to claim 12 or 13, wherein the first directory is a directory in the second directory; the method further comprises:
    当所述第二电子设备接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,所述第二电子设备向所述第一电子设备发送分布式文件系统获取所述第一本地文件系统中的第二目录中第四本地文件的请求;所述第四本地文件中包括所述第一目录的元数据信息;When the second electronic device receives a request to access the fifth local file in the first directory in the second directory in the distributed file system, the second electronic device sends the distributed file to the first electronic device The system obtains a request for a fourth local file in the second directory in the first local file system; the fourth local file includes metadata information of the first directory;
    当所述第二电子设备确定接收到的所述第四本地文件中包含所述第一目录的元数据信息时,所述第二电子设备向所述第一电子设备发送分布式文件系统获取所述第一本地文件系统中的第一目录中第二本地文件的请求;When the second electronic device determines that the received fourth local file contains the metadata information of the first directory, the second electronic device sends the distributed file system to the first electronic device to obtain the metadata information. Describe the request of the second local file in the first directory in the first local file system;
    所述第二电子设备根据接收到的所述第二本地文件,访问所述第五本地文件;所述第二本地文件中包括所述第五本地文件的元数据信息。The second electronic device accesses the fifth local file according to the received second local file; the second local file includes metadata information of the fifth local file.
  15. 根据权利要求12或13所述的方法,其特征在于,所述第一目录为第二目录中的一个目录;所述方法还包括:The method according to claim 12 or 13, wherein the first directory is a directory in the second directory; the method further comprises:
    当所述第二电子设备接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,所述第二电子设备向所述第一电子设备发送第五本地文件的路径;所述第五本地文件为所述第一本地文件系统中的第一目录中的一个文件;When the second electronic device receives a request to access the fifth local file in the first directory in the second directory in the distributed file system, the second electronic device sends the fifth local file to the first electronic device The path of the file; the fifth local file is a file in the first directory in the first local file system;
    当所述第二电子设备接收到所述第一电子设备发送的所述第二本地文件时,所述第二电子设备根据所述第二本地文件,访问所述第五本地文件。When the second electronic device receives the second local file sent by the first electronic device, the second electronic device accesses the fifth local file according to the second local file.
  16. 根据权利要求12至15中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 12 to 15, wherein the method further comprises:
    所述第二电子设备在所述第二本地文件系统中的第一目录中缓存所述第一本地文件;The second electronic device caches the first local file in a first directory in the second local file system;
    所述第二电子设备更新所述第一本地文件,将更新后的第一本地文件发送给所述第一电子设备。The second electronic device updates the first local file, and sends the updated first local file to the first electronic device.
  17. 根据权利要求12至16中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 12 to 16, wherein the method further comprises:
    当所述第二电子设备接收所述第一电子设备发送的第二本地文件后,所述第二电子设备接收所述第一电子设备发送的更新后的第二本地文件;After the second electronic device receives the second local file sent by the first electronic device, the second electronic device receives the updated second local file sent by the first electronic device;
    所述第二电子设备根据所述更新后的第二本地文件,在所述第二本地文件系统中的第一目录中,显示所述第一本地文件系统中的第一目录中的更新后的文件。The second electronic device displays, in the first directory in the second local file system, the updated file in the first directory in the first local file system according to the updated second local file. document.
  18. 根据权利要求12至17中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 12 to 17, wherein the method further comprises:
    在所述分布式文件系统停止挂载所述第二本地文件系统后,所述第二电子设备删除在所述第二本地文件系统中的第一目录中缓存的第二本地文件。After the distributed file system stops mounting the second local file system, the second electronic device deletes the second local file cached in the first directory in the second local file system.
  19. 一种第一电子设备,其特征在于,所述第一电子设备包括:一个或多个处理器和存储器;A first electronic device, characterized in that the first electronic device comprises: one or more processors and a memory;
    所述存储器与所述一个或多个处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述一个或多个处理器调用所述计算机指令以使得所述第一电子设备执行:The memory is coupled to the one or more processors for storing computer program code, the computer program code comprising computer instructions that the one or more processors invoke to cause the The first electronic device performs:
    在第一电子设备的第一本地文件系统中的第一目录中包括第一本地文件和第二本地文件,所述第二本地文件中包括第一本地文件的元数据信息;The first directory in the first local file system of the first electronic device includes a first local file and a second local file, and the second local file includes metadata information of the first local file;
    当接收到第二电子设备发送的分布式文件系统获取所述第二本地文件的请求时,向所述第二电子设备发送所述第二本地文件,使得在第二电子设备的第二本地文件系统中的第一目录中显示所述第一本地文件。When receiving the request sent by the second electronic device for the distributed file system to obtain the second local file, the second local file is sent to the second electronic device, so that the second local file of the second electronic device is stored in the second local file. The first local file is displayed in a first directory in the system.
  20. 根据权利要求19所述的第一电子设备,其特征在于,所述第一目录为第二目录中的一个目录;所述一个或多个处理器,还用于调用所述计算机指令以使得所述第一电子设备执行:The first electronic device according to claim 19, wherein the first directory is a directory in the second directory; the one or more processors are further configured to invoke the computer instructions to make all the The first electronic device described above performs:
    接收所述第二电子设备发送的分布式文件系统获取所述第一本地文件系统中的第二目录中第四本地文件的请求;所述第四本地文件中包括所述第一本地文件系统中的第一目录的元数据信息;Receive a request sent by the second electronic device for the distributed file system to obtain a fourth local file in the second directory in the first local file system; the fourth local file includes a file in the first local file system The metadata information of the first directory;
    发送所述第四本地文件给所述第二电子设备;sending the fourth local file to the second electronic device;
    接收所述第二电子设备发送的分布式文件系统获取所述第一本地文件系统中的第一目录中的所述第二本地文件的请求;receiving a request sent by the second electronic device for the distributed file system to obtain the second local file in the first directory in the first local file system;
    发送所述第二本地文件给所述第二电子设备;所述第二本地文件中包括所述第一本地文件系统中的第一目录中的第五本地文件的元数据信息;sending the second local file to the second electronic device; the second local file includes metadata information of the fifth local file in the first directory in the first local file system;
    接收所述第二电子设备对所述第五本地文件的访问。An access by the second electronic device to the fifth local file is received.
  21. 根据权利要求19所述的第一电子设备,其特征在于,所述第一目录为第二目录中的一个目录;所述一个或多个处理器,还用于调用所述计算机指令以使得所述第一电子设备执行:The first electronic device according to claim 19, wherein the first directory is a directory in the second directory; the one or more processors are further configured to invoke the computer instructions to make all the The first electronic device described above performs:
    接收所述第二电子设备发送的第五本地文件的路径;所述第五本地文件为所述第一本地文件系统中的第一目录中的一个文件;receiving the path of the fifth local file sent by the second electronic device; the fifth local file is a file in the first directory in the first local file system;
    当确定所述第一本地文件系统中的第一目录下存在所述第五本地文件时,向所述第二电子设备发送所述第二本地文件;所述第二本地文件中包括所述第五本地文件的元数据信息;When it is determined that the fifth local file exists in the first directory in the first local file system, the second local file is sent to the second electronic device; the second local file includes the 5. Metadata information of local files;
    接收所述第二电子设备对所述第五本地文件的访问。An access by the second electronic device to the fifth local file is received.
  22. 一种芯片系统,所述芯片系统应用于第一电子设备,所述芯片系统包括一个或多个处理器,所述处理器用于调用计算机指令以使得所述第一电子设备执行如权利要求2-11中任一项所述的方法。A chip system, the chip system is applied to a first electronic device, the chip system includes one or more processors, the processors are used for invoking computer instructions to cause the first electronic device to execute the method according to claim 2- The method of any one of 11.
  23. 一种包含指令的计算机程序产品,其特征在于,当所述计算机程序产品在第一电子设备上运行时,使得所述第一电子设备执行如权利要求2-11中任一项所述的方法。A computer program product comprising instructions, characterized in that, when the computer program product is run on a first electronic device, the first electronic device is caused to perform the method according to any one of claims 2-11 .
  24. 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在第一电子设备上运行时,使得所述第一电子设备执行如权利要求2-11中任一项所述的方法。A computer-readable storage medium, comprising instructions, characterized in that, when the instructions are executed on a first electronic device, the first electronic device is caused to execute the method according to any one of claims 2-11 .
  25. 一种第二电子设备,其特征在于,所述第二电子设备包括:一个或多个处理器和存储器;A second electronic device, characterized in that the second electronic device comprises: one or more processors and a memory;
    所述存储器与所述一个或多个处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述一个或多个处理器调用所述计算机指令以使得所述第二电子设备执行:The memory is coupled to the one or more processors for storing computer program code, the computer program code comprising computer instructions that the one or more processors invoke to cause the The second electronic device performs:
    当接收到访问第二电子设备的第二本地文件系统中的第一目录的请求时,向第一电子设备发送分布式文件系统获取第二本地文件的请求;所述第二本地文件中包括第一电子设备的 第一本地文件系统中的第一目录中第一本地文件的元数据信息;When a request for accessing the first directory in the second local file system of the second electronic device is received, a request for obtaining the second local file from the distributed file system is sent to the first electronic device; the second local file includes the Metadata information of the first local file in the first directory in the first local file system of an electronic device;
    接收所述第一电子设备发送的所述第二本地文件,并缓存到所述第二本地文件系统中的第一目录中;Receive the second local file sent by the first electronic device, and cache it in the first directory in the second local file system;
    根据所述第二本地文件,在所述第二本地文件系统中的第一目录中显示所述第一本地文件。The first local file is displayed in a first directory in the second local file system according to the second local file.
  26. 根据权利要求25所述的第二电子设备,其特征在于,所述第一目录为第二目录中的一个目录;所述一个或多个处理器,还用于调用所述计算机指令以使得所述第二电子设备执行:The second electronic device according to claim 25, wherein the first directory is a directory in the second directory; the one or more processors are further configured to invoke the computer instructions to make all the The second electronic device described above performs:
    当接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,向所述第一电子设备发送分布式文件系统获取所述第一本地文件系统中的第二目录中第四本地文件的请求;所述第四本地文件中包括所述第一目录的元数据信息;When a request for accessing a fifth local file in a first directory in a second directory in the distributed file system is received, send the distributed file system to the first electronic device to obtain the first file in the first local file system A request for a fourth local file in the second directory; the fourth local file includes the metadata information of the first directory;
    当确定接收到的所述第四本地文件中包含所述第一目录的元数据信息时,向所述第一电子设备发送分布式文件系统获取所述第一本地文件系统中的第一目录中第二本地文件的请求;When it is determined that the received fourth local file contains the metadata information of the first directory, send the distributed file system to the first electronic device to obtain the information in the first directory in the first local file system A request for a second local file;
    根据接收到的所述第二本地文件,访问所述第五本地文件;所述第二本地文件中包括所述第五本地文件的元数据信息。The fifth local file is accessed according to the received second local file; the second local file includes metadata information of the fifth local file.
  27. 根据权利要求25所述的第二电子设备,其特征在于,所述第一目录为第二目录中的一个目录;所述一个或多个处理器,还用于调用所述计算机指令以使得所述第二电子设备执行:The second electronic device according to claim 25, wherein the first directory is a directory in the second directory; the one or more processors are further configured to invoke the computer instructions to make all the The second electronic device described above performs:
    当接收到访问分布式文件系统中第二目录中的第一目录中的第五本地文件的请求时,向所述第一电子设备发送第五本地文件的路径;所述第五本地文件为所述第一本地文件系统中的第一目录中的一个文件;When a request for accessing a fifth local file in a first directory in a second directory in the distributed file system is received, the path of the fifth local file is sent to the first electronic device; the fifth local file is all Describe a file in the first directory in the first local file system;
    当接收到所述第一电子设备发送的所述第二本地文件时,根据所述第二本地文件,访问所述第五本地文件。When the second local file sent by the first electronic device is received, the fifth local file is accessed according to the second local file.
  28. 一种芯片系统,所述芯片系统应用于第二电子设备,所述芯片系统包括一个或多个处理器,所述处理器用于调用计算机指令以使得所述第二电子设备执行如权利要求12-18中任一项所述的方法。A chip system, the chip system is applied to a second electronic device, the chip system includes one or more processors, the processors are used for invoking computer instructions to cause the second electronic device to perform as claimed in claim 12- The method of any one of 18.
  29. 一种包含指令的计算机程序产品,其特征在于,当所述计算机程序产品在第二电子设备上运行时,使得所述第二电子设备执行如权利要求12-18中任一项所述的方法。A computer program product comprising instructions, wherein, when the computer program product is run on a second electronic device, the second electronic device is caused to perform the method according to any one of claims 12-18 .
  30. 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在第二电子设备上运行时,使得所述第二电子设备执行如权利要求12-18中任一项所述的方法。A computer-readable storage medium comprising instructions, characterized in that, when the instructions are executed on a second electronic device, the second electronic device is caused to perform the method according to any one of claims 12-18 .
PCT/CN2021/118646 2020-09-30 2021-09-16 Metadata management method, and electronic device WO2022068596A1 (en)

Applications Claiming Priority (10)

Application Number Priority Date Filing Date Title
CN202011062903.4 2020-09-30
CN202011066342.5 2020-09-30
CN202011063023.9 2020-09-30
CN202011066342 2020-09-30
CN202011062887.9 2020-09-30
CN202011062903 2020-09-30
CN202011063023 2020-09-30
CN202011062887 2020-09-30
CN202011377326.8A CN114328377A (en) 2020-09-30 2020-11-30 Metadata management method and electronic equipment
CN202011377326.8 2020-11-30

Publications (1)

Publication Number Publication Date
WO2022068596A1 true WO2022068596A1 (en) 2022-04-07

Family

ID=80949699

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/118646 WO2022068596A1 (en) 2020-09-30 2021-09-16 Metadata management method, and electronic device

Country Status (2)

Country Link
CN (1) CN114722021A (en)
WO (1) WO2022068596A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117493276A (en) * 2024-01-03 2024-02-02 柏科数据技术(深圳)股份有限公司 Reading method and device for Ceph file, server and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101354726A (en) * 2008-09-17 2009-01-28 中国科学院计算技术研究所 Method for managing memory metadata of cluster file system
CN102110146A (en) * 2011-02-16 2011-06-29 清华大学 Key-value storage-based distributed file system metadata management method
CN103559188A (en) * 2013-08-19 2014-02-05 曙光信息产业股份有限公司 Metadata management method and system
US20160210460A1 (en) * 2015-01-20 2016-07-21 Mediatek Inc. Methods for operating electronic devices, and electronic devices
CN108920613A (en) * 2018-06-28 2018-11-30 郑州云海信息技术有限公司 A kind of metadata management method, system and equipment and storage medium
CN111030784A (en) * 2019-11-13 2020-04-17 泰康保险集团股份有限公司 Information synchronization method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI571754B (en) * 2015-02-02 2017-02-21 群暉科技股份有限公司 Method for performing file synchronization control, and associated apparatus
CN107451139A (en) * 2016-05-30 2017-12-08 北京三星通信技术研究有限公司 File resource methods of exhibiting, device and corresponding smart machine
CN109697016B (en) * 2017-10-20 2022-02-15 伊姆西Ip控股有限责任公司 Method and apparatus for improving storage performance of containers

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101354726A (en) * 2008-09-17 2009-01-28 中国科学院计算技术研究所 Method for managing memory metadata of cluster file system
CN102110146A (en) * 2011-02-16 2011-06-29 清华大学 Key-value storage-based distributed file system metadata management method
CN103559188A (en) * 2013-08-19 2014-02-05 曙光信息产业股份有限公司 Metadata management method and system
US20160210460A1 (en) * 2015-01-20 2016-07-21 Mediatek Inc. Methods for operating electronic devices, and electronic devices
CN108920613A (en) * 2018-06-28 2018-11-30 郑州云海信息技术有限公司 A kind of metadata management method, system and equipment and storage medium
CN111030784A (en) * 2019-11-13 2020-04-17 泰康保险集团股份有限公司 Information synchronization method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117493276A (en) * 2024-01-03 2024-02-02 柏科数据技术(深圳)股份有限公司 Reading method and device for Ceph file, server and storage medium
CN117493276B (en) * 2024-01-03 2024-04-09 柏科数据技术(深圳)股份有限公司 Reading method and device for Ceph file, server and storage medium

Also Published As

Publication number Publication date
CN114722021A (en) 2022-07-08

Similar Documents

Publication Publication Date Title
WO2021083378A1 (en) Method for accelerating starting of application, and electronic device
WO2022257748A1 (en) Virtual memory management method and electronic device
WO2021159746A1 (en) File sharing method and system, and related device
WO2021115112A1 (en) Installation package downloading method, installation package distribution method, terminal device, server, and system
WO2020233556A1 (en) Call content processing method and electronic device
WO2021093626A1 (en) Memory management method and electronic device
JP7201827B2 (en) Image classification method and electronic device
WO2021185352A1 (en) Version upgrade method and related apparatus
CN111615820B (en) Method and equipment for performing domain name resolution by sending key value to GRS server
WO2022179275A1 (en) Terminal application control method, terminal device, and chip system
WO2022100141A1 (en) Plug-in management method, system and apparatus
WO2022068596A1 (en) Metadata management method, and electronic device
WO2022022674A1 (en) Application icon layout method and related apparatus
WO2021104117A1 (en) Method for constructing application program resource packet, construction apparatus, and terminal device
CN114328377A (en) Metadata management method and electronic equipment
CN114489471B (en) Input and output processing method and electronic equipment
WO2021238376A1 (en) Function pack loading method and apparatus, and server and electronic device
CN113485969B (en) Storage fragmentation method and device, terminal and computer storage medium
CN112783418B (en) Method for storing application program data and mobile terminal
CN113721836A (en) Data deduplication method and device
WO2023001208A1 (en) Multi-file synchronization method and electronic device
CN116414782B (en) Method for identifying repeated file and electronic equipment
CN114168115B (en) Communication system, application downloading method and device
EP4336357A1 (en) Message processing method and related apparatus
WO2024007944A1 (en) Method for extending memory isolation domain, and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21874257

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21874257

Country of ref document: EP

Kind code of ref document: A1