Distributed file processing method, device, server, equipment and storage medium
Through the distributed file processing method, the files are fragmented using rectangular data frames and diagonal masks, and the server is selected using the ant colony algorithm, which solves the problems of low file storage efficiency and insufficient security in the existing technology. Efficient and secure file storage and recovery are achieved.
Patent Information
- Application Number
- CN202311699821.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-12-11
AI Technical Summary
Existing technology has high time complexity and low file fragmentation storage efficiency when storing and restoring files, and cannot effectively improve the user's storage experience and security.
Using a distributed file processing method, the files to be stored are fragmented according to the preset mask size, and fragmented through rectangular data frames and diagonal masks to improve the efficiency and security of file fragmentation, and use heuristic markers The forward feedback ant colony algorithm selects the master and slave servers in real time for storage and recovery.
It significantly reduces the time complexity of file fragmentation, improves the efficiency and security of file storage and recovery, enhances the user's storage experience, and is suitable for a variety of file processing scenarios.
Smart Images

Figure CN117667517B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a distributed file processing method, device, server, equipment and storage medium. Background Art
[0002] The existing technology for storing and restoring files reserves a space in the local machine for hidden storage, or divides the file to be stored into at least two object files, and corresponds each object file to a virtual storage node to avoid storage space occupation. Another improved existing technology for storing files in sequence into multiple segments can restore files, but the time complexity of the method of sequentially reading and dividing into multiple segments is the length of the file, that is, for a length of m 2 When storing files of The file storage efficiency is low. Summary of the invention
[0003] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and to propose a distributed file processing method, apparatus, server, device and storage medium, which can improve file storage efficiency.
[0004] In a first aspect, the present invention provides a distributed file processing method, comprising:
[0005] Acquire a first characteristic value of a file to be stored, and obtain a first characteristic value index identifying the file to be stored according to the first characteristic value;
[0006] Extracting first data streams of a preset size from the file to be stored in sequence, arranging the first data streams in a data frame of the same size as the preset mask, and performing a mask operation on the data frame according to the preset mask to obtain m first slice files; wherein m is a positive integer; and the size of the preset mask is a rectangular mask that is divisible by the number of the first slice files;
[0007] The m first segment files and the first feature value index are transmitted to the preset server in sequence, so that the preset server stores the m first segment files under the first feature value index.
[0008] The present invention arranges the data stream in the file to be stored in a data frame of the same size as a preset mask, and uses a rectangular mask whose size is divisible by the number of first fragment files to fragment the data stream. It can divide a data stream into multiple fragment files at the same time, thereby improving the efficiency of storing file fragments to a preset server and greatly improving the user experience of processing files.
[0009] In combination with the first aspect, in a possible implementation manner, arranging the first data stream in a data frame of the same size as a preset mask, and performing a mask operation on the data frame according to the preset mask to obtain m first fragment files includes:
[0010] Arrange a plurality of bits of bit data of the first data stream in rows and arrange a plurality of rows to obtain a rectangular data frame of the same size as the preset mask;
[0011] The rectangular data frame is subjected to a bitwise mask operation according to a preset mask that divides the m regions, and m bit data partitions are obtained at the same time. The bit data corresponding to each bit data partition on the first data stream is taken as a first slice file, and a total of m first slice files are obtained.
[0012] The present invention arranges the data stream in a rectangular data frame of the same size as the preset mask, and performs a mask operation on the rectangular data frame through the preset mask, thereby obtaining multiple fragment files at the same time. 2 The time complexity of the data flow is Compared with the time complexity of the existing technology of reading the data stream in sequence and dividing it into m continuous data segments The present invention exchanges space consumption for time consumption by constructing a rectangular data frame and a preset mask, thereby greatly reducing the time of file segmentation, improving the efficiency of file segmentation, and further improving the user's experience of storing files.
[0013] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, setting the preset mask includes:
[0014] According to the byte length of the first data stream, a mask with bits as the unit and a size of m rows and m columns is constructed, and the mask is equally divided into m areas in the diagonal direction to obtain the preset mask; wherein the size of the preset mask is not less than the byte length.
[0015] The present invention adopts a preset mask that divides the mask into m areas in a diagonal direction, so that after the preset mask and the data frame are subjected to a masking operation, a plurality of bit data partitions can be obtained at the same time, and each bit data partition is used as a shard file, thereby improving the efficiency of file sharding; and, when a shard file is stolen, since the internal data of the shard file divided by the diagonal line is not continuous and has higher randomness, it can be ensured that even if a stolen shard file is cracked, a complete piece of data cannot be obtained from a shard file, thereby improving the security of file storage.
[0016] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, after the preset server stores the m first segment files under the first feature value index, searching for the corresponding file to be downloaded according to the second feature value index of the file to be processed for file restoration or file transfer, including:
[0017] After the pre-selected master server receives the first feature value index, and based on the first feature value index and the at least one first fragment file received, and the at least one pre-selected slave server receives the first feature value index and the remaining first fragment files, a file index table is established to record the storage conditions of the master server and the slave server; wherein the master server and the slave server are selected in real time according to the ant colony algorithm with positive feedback of the trial mark;
[0018] When it is necessary to restore the file to be recovered or to transfer the file to be transmitted, the file to be downloaded corresponding to the file index table is searched according to the second characteristic value index of the file to be processed to perform file restoration or file transmission.
[0019] The present invention adopts a method of storing shard files by a master server and a slave server, and the master server establishes a file index table according to a first characteristic index and the shard files, thereby improving the file recovery mechanism based on encrypted transmission of file shards and making file processing applicable to more scenarios.
[0020] In combination with the first aspect and the above possible implementation manner, in another possible implementation manner, the master server and the slave server are selected in real time according to an ant colony algorithm with positive feedback of a trial mark, including:
[0021] Each time the file to be stored is uploaded, the same test data is sent to the plurality of servers, and the average delay per unit data volume for the plurality of servers to receive and process the test data and return the processing results is tracked;
[0022] When sending test data next time, the amount of first sub-test data sent to the server with the smallest average delay is greater than the amount of second sub-test data sent to the remaining servers, and the average delay is tracked again;
[0023] After repeated testing for many times, all test data are concentrated on the same server and marked as the master server, and the remaining servers are slave servers.
[0024] The present invention divides the master server and the slave server, and can select the optimal server for storing the sharded files, thereby improving the file transmission efficiency; and, since the master and slave servers are selected in real time each time for storing files, the master server and slave server for storing files each time are different, which improves the randomness of file storage, and can further improve the security of file storage by selecting different master and slave servers.
[0025] In combination with the first aspect and the above possible implementation manner, in another possible implementation manner, searching the file to be downloaded corresponding to the file index table according to the second characteristic value index of the file to be processed to perform file restoration includes:
[0026] Obtaining a second characteristic value of the file to be processed, performing a hash calculation on the second characteristic value to obtain a second characteristic value index, and querying the second characteristic value index in the file index table to obtain a first downloaded fragment file in the main server;
[0027] At the same time, the master server initiates a global match of the second feature value index to all slave servers to obtain the remaining second download segment files;
[0028] The first download segmented file and the second download segmented file are sent to the user terminal in batches, so that the user terminal reassembles the first download segmented file and the second download segmented file according to the preset mask to obtain the file to be restored or the transmission file.
[0029] The present invention uses the characteristic values of the files to be processed to obtain the corresponding downloaded segment files from the main server and the slave server, and provides a file recovery mechanism based on the file storage mechanism, so that it can be applied to the comprehensive scenarios of file transmission, file encryption and file recovery, and has higher applicability and practicality.
[0030] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, sending the first download segment file and the second download segment file to the user terminal in batches includes:
[0031] When the second characteristic values of the first downloaded segmented file and the second downloaded segmented file are consistent, the second characteristic value of the second downloaded segmented file is erased to obtain the sub-file to be processed, so that the first downloaded segmented file and the sub-file to be processed are sent to the user terminal in batches.
[0032] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, sequentially transmitting the m first segment files and the first feature value index to a preset server includes:
[0033] The m first shard files and the first characteristic value index are respectively transmitted to the preset m-1 slave servers and 1 main server; wherein each slave server receives a first shard file and one of the characteristic value indexes, and the main server receives a shard file and one of the characteristic value indexes; the number of divided first shard files is determined by the total number of the slave servers and the main servers.
[0034] The present invention adopts the method of determining the number of first shard files divided by the total number of servers, and each server receives one first shard file each time. When stealing data from one server, it is impossible to obtain complete data after decryption, and it is necessary to obtain data from all servers to obtain complete data, thereby improving the security of file storage. The number of first shard files divided is determined by the total number of the slave servers and the master server, which can avoid leaving idle servers, thereby improving the utilization rate of the servers.
[0035] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, sequentially extracting first data streams of a preset size from the file to be stored includes:
[0036] The binary data stream of the file to be stored is arranged into a square data block of M*M units by bytes, and L units of binary data stream are extracted from the square data block each time as the first data stream; wherein M and L are both positive integers.
[0037] In combination with the first aspect and the foregoing possible implementation manner, in another possible implementation manner, obtaining a first feature value of the file to be stored, and obtaining a first feature value index identifying the file to be stored according to the first feature value, includes:
[0038] Obtaining an absolute path file name of a file to be stored on a user terminal, and using the absolute path file name as a first sub-feature value; or performing a hash calculation on a file content at a preset location of the file to be stored to obtain a second sub-feature value, so as to establish a relationship table according to the second sub-feature value and the file name to be stored; wherein the first feature value includes: the first sub-feature value or the second sub-feature value;
[0039] After performing a hash operation on the first sub-feature value or the second sub-feature value, a first feature value index identifying the file to be stored is obtained.
[0040] The present invention adopts the absolute path file name on the user terminal and the hash value of part of the file content to obtain unique characteristic values respectively, which can reduce hash conflicts and increase file confidentiality.
[0041] In a second aspect, the present invention provides a distributed file processing device, comprising: a first feature value acquisition module, a sharding module and a storage module; wherein:
[0042] The first feature value acquisition module is used to acquire a first feature value of the file to be stored, and obtain a first feature value index identifying the file to be stored according to the first feature value;
[0043] The slicing module is used to sequentially extract first data streams of a preset size from the file to be stored, arrange the first data streams in a data frame of the same size as a preset mask, and perform a mask operation on the data frame according to the preset mask to obtain m first slicing files; wherein m is a positive integer; and the size of the preset mask is a rectangular mask that is divisible by the number of the first slicing files;
[0044] The storage module is used to transmit the m first segment files and the first feature value index to the preset server in sequence, so that the preset server stores the m first segment files under the first feature value index.
[0045] In a third aspect, the present invention provides a server, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distributed file processing method as described in the first aspect when executing the computer program.
[0046] In a fourth aspect, the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distributed file processing method as described in the first aspect when executing the computer program.
[0047] In a fifth aspect, the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the distributed file processing method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a flowchart of a distributed file processing method provided by an embodiment of the present application;
[0049] Figure 2 This is a schematic diagram of a preset mask divided into three equal parts and symmetrically provided in an embodiment of the present application;
[0050] Figure 3 This is a schematic diagram of a preset mask divided into five equal parts and symmetrically provided in an embodiment of the present application;
[0051] Figure 4This is a schematic diagram of a preset mask with symmetry in seven equal parts provided in an embodiment of the present application;
[0052] Figure 5 It is a flowchart of an ant colony algorithm with a trial mark positive feedback provided in an embodiment of the present application;
[0053] Figure 6 This is a flow chart of type I storage of files to be stored provided by an embodiment of the present application;
[0054] Figure 7 It is a type II storage flow chart of the file to be stored provided by the embodiment of the present application;
[0055] Figure 8 is a flowchart of restoring files to be restored provided by an embodiment of the present application;
[0056] Fig. 9 It is a schematic diagram of a process of recovering a type II storage file provided in an embodiment of the present application;
[0057] Fig.10 It is a schematic diagram of the process of file transmission provided by the embodiment of the present application;
[0058] Fig.11 is a structural diagram of a distributed file processing device provided in an embodiment of the present application;
[0059] Fig.12 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0061] It is worth noting that the file processing method can be deployed on a remote physical server cluster for external access. The remote physical server cluster is composed of multiple remote physical servers, which together form a cluster system to provide services to the outside world. The user terminal being served does not need to know specifically where the background service is deployed. The user terminal only needs to authorize the service to manage the file or file fragment, that is, once the user terminal uploads the file or file fragment to the server for hosting, the server has the storage right and use right of the file. However, precisely because of the specific requirements of authorization management, there is a risk of accidental disclosure of user files, so when the user terminal uploads the file, the processing method needs to perform certain encryption processing on the stored file.
[0062] If the user does not want to authorize the service to access the relevant file content, the user can perform encryption pre-processing on the stored file in advance, such as encrypting it using the Data Encryption Standard (DES) with a symmetric key known only to the user, and then uploading the encrypted file to the server to which it belongs. In this way, even if the service integrates all physical servers, it can only obtain the ciphertext of the file without the decryption key.
[0063] This application proposes a distributed file processing method, which extracts the user's to-be-stored files by evenly performing non-continuous data slicing through masks to improve the security of file storage and the efficiency of file access, and uploads them to a remote server through a certain matching algorithm to ensure the integrity and confidentiality of the files. Therefore, it can realize both file encryption transmission and fast processing of file encryption recovery, so that it can be integrated into a variety of application scenarios and has higher applicability and practicality. In order to better demonstrate the technical solution of this application, it will be explained through specific embodiments.
[0064] Example 1
[0065] See also Figure 1 , is a flow chart of a distributed file processing method provided in an embodiment of the present application, including steps S11 to S13, specifically:
[0066] Step S11: Acquire a first characteristic value of a file to be stored, and obtain a first characteristic value index identifying the file to be stored according to the first characteristic value.
[0067] In some embodiments of the present application, a first characteristic value of a file to be stored is obtained, and a first characteristic value index identifying the file to be stored is obtained based on the first characteristic value, including: obtaining an absolute path file name of the file to be stored on a user terminal, and taking the absolute path file name as a first sub-characteristic value; or performing a hash calculation on the file content of a preset position of the file to be stored to obtain a second sub-characteristic value, so as to establish a relationship table based on the second sub-characteristic value and the file name to be stored; wherein the first characteristic value includes: the first sub-characteristic value or the second sub-characteristic value; after performing a hash operation on the first sub-characteristic value or the second sub-characteristic value, a first characteristic value index identifying the file to be stored is obtained.
[0068] It is worth noting that when uploading a file to be stored, it is necessary to extract a characteristic value unique_value (uv) for the file to be stored, and perform a hash operation on it as a unique identifier for storing the file to be stored on the preset server, which is called the characteristic value index Hash (uv). When the preset server stores a large number of files to be stored, it will build a file index table StrTbl of (key, value) = (characteristic value index, file content) based on the characteristic value uv, so that when restoring or transferring files, the relevant content of the file to be processed can be quickly extracted.
[0069] As an optional embodiment of the present application, the absolute path file name of the file to be stored on the user terminal is obtained, the absolute path file name is used as the first sub-feature value, and a hash operation is performed on the first sub-feature value to obtain a first feature value index that identifies the file to be stored.
[0070] It is worth noting that due to the characteristics of the Hash operation itself, within the scope of the current commercial cryptographic application field, the results of the Hash operation on different contents can basically guarantee uniqueness, so the characteristic value index of the file to be stored can ensure uniqueness, and the characteristic value index after the Hash operation is more standardized and easier to manage than the original characteristic value (such as file name or file content).
[0071] As another optional embodiment of the present application, a hash calculation is performed on the file content of the preset location of the file to be stored to obtain a second sub-feature value, so that a relationship table is established based on the second sub-feature value and the name of the file to be stored; after a hash operation is performed on the second sub-feature value, a first feature value index identifying the file to be stored is obtained.
[0072] It is worth noting that, in order to reduce hash conflicts and increase file confidentiality, the file content at the preset location can be the beginning of a certain length of the file to be stored.
[0073] As a preferred embodiment of the present application, the first 1K bits of the file to be stored are selected for hash operation. If the file to be stored is less than 1KBits, 0 is automatically added and then hash operation is performed to obtain the second sub-eigenvalue.
[0074] As another optional embodiment of the present application, the first characteristic value is extracted according to the underlying storage identifier of the file, such as inode or some bytes at the end of the file.
[0075] It is worth noting that when the first eigenvalue index is obtained by performing a hash calculation based on the second sub-eigenvalue, the second sub-eigenvalue can be guaranteed to be unique on the server side based on the inherent characteristics of the hash algorithm and the controllability of the selected file length. Because the user only provides the file name of the file to be stored when using the processing method, the remote service is required to save an additional relationship table RelaTbl of (key, value) = (file name, second sub-eigenvalue), which records the corresponding relationship between the file name of the file to be stored and the second sub-eigenvalue, so as to quickly extract the relevant content of the file to be processed when restoring or transferring the file.
[0076] This application uses the characteristic value to combine and concatenate the character string based on the user space and the file path name; it can also extract the 1K bits at the beginning of the file to be processed as the characteristic value of the file, which can reduce the hash conflict of the characteristic value.
[0077] It is worth noting that when uploading files to be stored, the processing method also needs to perform certain encryption processing on the files to be stored. Because the user's files are to be hosted on the server, in order to prevent the user's files from being accidentally leaked during the transmission process or in the server-side storage, the processing method will perform certain separation, segmentation, fragmentation or encryption on the files to be stored. It is guaranteed that the complete user's original files will not be retained on any single remote physical server, and continuous file data will not be stored on a fragment.
[0078] Step S12, extracting first data streams of a preset size from the file to be stored in sequence, and arranging the first data streams in a data frame of the same size as a preset mask, performing a mask operation on the data frame according to the preset mask, and obtaining m first fragment files; wherein m is a positive integer; and the size of the preset mask is a rectangular mask that is divisible by the number of first fragment files.
[0079] In some embodiments of the present application, extracting a first data stream of a preset size in sequence from the file to be stored includes: arranging the binary data stream of the file to be stored into a square data block of M*M units by bytes, and extracting L units of binary data stream from the square data block as the first data stream each time; wherein M and L are both positive integers.
[0080] In an optional embodiment of the present application, the square data block may also be a rectangular data block, a circular data block, an elliptical data block or other irregular data blocks. In this case, the rectangular mask also needs to change accordingly based on the shape of the corresponding data block to adapt to data blocks of different shapes.
[0081] It is worth noting that the shape of the data block is constructed to facilitate rapid data extraction. When extracting L=1 unit of data from the square data block, the data stream corresponding to 1 unit of data is arranged into a graphic of the same size as the preset mask.
[0082] In an optional embodiment of the present application, the file to be stored includes: a binary file or a text file, etc.
[0083] As a preferred embodiment of the present application, the file to be stored in this embodiment is a binary file.
[0084] In some embodiments of the present application, the first data stream is arranged in a data frame of the same size as a preset mask, and a mask operation is performed on the data frame according to the preset mask to obtain m first slice files, including: arranging a number of bits of bit data of the first data stream in rows, and arranging a number of rows to obtain a rectangular data frame of the same size as the preset mask; performing a bit mask operation on the rectangular data frame according to a preset mask that divides m areas, and obtaining m bit data partitions at the same time, and taking the bit data corresponding to each bit data partition on the first data stream as 1 first slice file, and obtaining a total of m first slice files.
[0085] In one embodiment of the present application, the first data stream is arranged in a data frame of the same size as a preset mask, and the data frame is masked according to the preset mask to obtain m first slice files, including: arranging the bit data of m bits of the first data stream in rows, and arranging m rows to obtain a rectangular data frame of the same size as the preset mask; performing a bit masking operation on the rectangular data frame according to the preset mask that divides m areas, and obtaining m bit data partitions at the same time, and taking the bit data corresponding to each bit data partition on the first data stream as 1 first slice file, and obtaining a total of m first slice files.
[0086] In an optional embodiment of the present application, the bit data of m bits are arranged in columns in the first data stream, and m columns are arranged to obtain a rectangular data frame of the same size as the preset mask; the rectangular data frame is subjected to a bitwise mask operation according to the preset mask that divides the m areas, and m bit data partitions are obtained at the same time, and the bit data corresponding to each bit data partition on the first data stream is used as 1 first slice file, and a total of m first slice files are obtained.
[0087] This application arranges the data stream in a rectangular data frame of the same size as the preset mask, and performs a mask operation on the rectangular data frame through the preset mask, and obtains multiple fragment files at the same time, which processes a length of m 2 The time complexity of the data flow is Compared with the time complexity of the existing technology of reading the data stream in sequence and dividing it into m continuous data segments The present application constructs a rectangular data frame and a preset mask to exchange space consumption for time consumption, thereby greatly reducing the time of file segmentation, improving the efficiency of file segmentation, and further improving the user experience of storing files.
[0088] In some embodiments of the present application, setting the preset mask includes: constructing a mask with bits as units and a size of m rows and m columns according to the byte length of the first data stream, and dividing the mask into m equal areas in the diagonal direction to obtain the preset mask; wherein the size of the preset mask is not less than the byte length.
[0089] It is worth noting that the size of the preset mask is larger than the byte length when: when extracting data from the first data stream for the last time, there may not be enough mask bits to fill its m rows and m columns. In this case, the mask square is filled with 0s. Before extracting the data stream for the last time, the size of the preset mask is equal to the byte length.
[0090] The present application adopts a preset mask that divides the mask into m regions in a diagonal direction, so that after the preset mask and the data frame are masked, multiple bit data partitions are obtained at the same time, and each bit data partition is used as a fragment file, thereby improving the efficiency of file fragmentation. In addition, dividing the mask into m regions can fairly divide the data stream into fragment files of the same length, so that when the file is restored, multiple received fragment files can be quickly assembled and restored through the equally divided regions, thereby improving the efficiency of file recovery.
[0091] It is worth noting that the existing technology of encrypted transmission segments the files to be transmitted, and the data in each segmented file is continuous, and then a digital envelope such as a Public Key Infrastructure (PKI) encryption mechanism is used, or the encryption key is updated regularly according to the file information. However, once the entire segmented file is stolen, a complete piece of data can be obtained by cracking the segmented file, resulting in low security for file storage. However, the internal data of the segmented files divided by diagonal lines in this embodiment is not continuous and has higher randomness, so that even if the stolen segmented file is cracked, a complete piece of data cannot be obtained, thereby improving the security of file storage.
[0092] In an optional embodiment of the present application, the preset mask is symmetrically divided into m equal areas along the diagonal line.
[0093] In a preferred embodiment of the present application, when the preset mask is an odd number of areas, the area composed of the units on the diagonal line is taken as the starting area, and the (m-1) / 2 areas of m units corresponding to the upper diagonal are searched upward along the area adjacent to the edge of the starting area; when the number of units found along the starting area is less than m, the units on another diagonal line and the units adjacent to the found units are expanded to obtain an area of m units until two rectangular sides are reached, and the units corresponding to the two rectangular sides form the last area of the upper triangle; similarly, the same operation is performed on the lower triangle area to divide the (m-1) / 2 areas containing m units, and the preset mask divided into m equal parts of m areas is obtained.
[0094] It is worth noting that, since the (m-1) regions are divided along the diagonal adjacent regions, the (m-1) regions and the region corresponding to the diagonal are parallel along the diagonal direction.
[0095] In an optional embodiment of the present application, the mask may be divided by a left diagonal line or a right diagonal line to obtain a preset mask.
[0096] In an optional embodiment of the present application, see Figure 2 , is a schematic diagram of a 3-equally divided symmetrical preset mask provided in an embodiment of the present application. In the figure, m=3 regions are divided along the left diagonal, that is, the preset mask is a 3*3 rectangular mask, along the diagonal is a region (region A), and the upper and lower regions of the diagonal are independent regions (region C and region B), that is, each region is a bit data partition, and the preset mask divided into three regions is subjected to a bitwise masking operation with the square data block, and the data stream corresponding to each bit data partition on the square data block is obtained respectively.
[0097] In another optional embodiment of the present application, see Figure 3 , is a schematic diagram of a preset mask with 5 equal parts and symmetry provided in an embodiment of the present application. In the figure, m=5 regions are divided along the left diagonal, that is, the preset mask is a 5*5 rectangular mask, there is one region (region A) along the diagonal, the two adjacent regions above and below the diagonal are independent regions (region E and region D), and the remaining two upper right and lower left regions (region C and region B); wherein, in region E, it is composed of 4 E units and 1 E', E' is the adjacent unit of the E unit in the right diagonal direction; similarly, in region D, it is composed of 4 D units and 1 D', D' is the adjacent unit of the D unit in the right diagonal direction; regions B and C are respectively composed of the remaining units on the two sides of the rectangular mask, each of which is an area of m units. The preset mask divided into five regions is subjected to a bitwise masking operation with the square data block to obtain the data stream corresponding to each bit data partition on the square data block.
[0098] In another optional embodiment of the present application, see Figure 4 , is a schematic diagram of a 7-equally divided symmetrical preset mask provided in an embodiment of the present application. In the figure, m=7 regions are divided along the left diagonal, that is, the preset mask is a 7*7 rectangular mask, there is an area along the diagonal (area A), the two adjacent areas above and below the diagonal are independent areas (area G and area F), two upper right and lower left areas (area C and area B), the area clamped by the upper right area and the adjacent area on the diagonal (area E), and the area clamped by the lower left area and the adjacent area below the diagonal (area D). The preset mask divided into seven areas is subjected to a bit-by-bit masking operation on the square data block to obtain the data stream corresponding to each bit data partition on the square data block. According to the setting method of the preset mask, a multi-equally divided symmetrical mask can be obtained.
[0099] In another simple embodiment of the present application, the data stream is arranged bit by bit on the mask in m rows and m columns from left to right\from right to left\from top to bottom\from bottom to top, and each column\row is taken as a fragment file.
[0100] It is worth noting that the shard files of the preset mask constructed by arranging the data stream on the mask in rows from left to right\from right to left\from top to bottom\from bottom to top in m rows and columns, and taking each column\row as a shard file, have stronger regularity. Due to the overly simple sharding rule, the shard encryption method is less secure than the diagonal shard encryption method. The shard encryption method parallel to the diagonal line has lower file correlation and stronger randomness within the shard file, thus making it more secure. It is worth noting that the time complexity of the method of sharding the data stream using a mask is generally lower than the time complexity of the traditional sharding method of traversing the file to obtain continuous data within the slice, because the use of a mask can batch process a certain amount of data streams.
[0101] In one embodiment of the present application, the first data stream is arranged in a data frame of the same size as a preset mask, and a mask operation is performed on the data frame according to the preset mask to obtain m first slice files, including: arranging m1 bits of bit data of the first data stream by row, and arranging m2 rows to obtain a rectangular data frame of the same size as the preset mask; performing a mask operation on the rectangular data frame bit by bit according to a preset mask that divides m areas, and obtaining m bit data partitions at the same time, and taking the bit data corresponding to each bit data partition on the first data stream as 1 first slice file, and obtaining a total of m first slice files.
[0102] It is worth noting that m1 and m2 are not equal, that is, the mask at this time is a rectangular mask, and the m bit data partitions can divide m1*m2, thereby obtaining m evenly divided first slice files, and the data bits of each first slice file are (m1*m2) / m, and (m1*m2) / m is a positive integer.
[0103] As an optional embodiment of the present application, when performing mask slicing, first divide a mask square based on the size of the binary form of the file to be stored, that is, arrange the binary streams of the file to be stored in sequence on a sheet of N = M * M = M 2 When extracting data stream from the square data block, n=m*m data are taken each time, and the taken n data are placed on the preset mask in the form of m rows and m columns. The preset mask is a numerical filter layer preset in advance, and the data stream of the file to be stored is filtered according to the bit. After the loop processes all the contents of the file to be stored, the file is segmented and obtained into several data piles of different categories, and each data pile (that is, the fragmented file after the file mask) will be stored in different servers respectively to complete the encrypted storage of the file.
[0104] As an optional embodiment of the present application, when the size of the file to be stored is 345KByte, due to 18 2 ==324<345<19 2 =361, so M=19 is taken, that is, the binary stream of the file to be stored can be arranged in a square data block with 19 rows and 19 columns, and each row and column unit stores 1KB of data. The tail data after exceeding 345KByte is directly set to 0. Each time the fragmentation is performed, L=1 unit of data stream is taken from the square data block, that is, 1KByte=32*32B, that is, m=32 is taken for masking. Each mask unit stores a bit. After the masking operation, the classified data of this time is obtained. After all the row and column units are completed, the classified data is stored in different servers to complete the segmentation.
[0105] As another optional embodiment of the present application, each time sharding is performed, a data stream of L=2 units is taken from the square data block, that is, 2KByte=2*32*32B is taken, that is, m=32 and two bits are stored in each mask unit to perform the mask operation to obtain the classified data for this time. After all row and column units are completed, the classified data are stored in different servers to complete the segmentation.
[0106] It is worth noting that if a data stream of L=2 units is taken from a square data block, the data density that can be processed is higher than that of a data stream of L=1 unit from a square data block, so that large files can be quickly segmented, thereby improving the storage efficiency of large files; if multi-threading is used for batch processing, each thread uses a preset mask area to extract bit data partitions from the data stream, and the time complexity of processing a data stream is reduced to The constant level can greatly improve the efficiency of file fragmentation.
[0107] Step S13: sequentially transmit the m first segment files and the first feature value index to a preset server, so that the preset server stores the m first segment files under the first feature value index.
[0108] In some embodiments of the present application, the m first shard files and the first feature value index are transmitted to a preset server in sequence, including: the m first shard files and the first feature value index are transmitted to preset m-1 slave servers and 1 master server respectively; wherein each slave server receives a first shard file and one of the feature value indexes, and the master server receives a shard file and one of the feature value indexes; the number of divided first shard files is determined by the total number of the slave servers and the master servers.
[0109] In some embodiments of the present application, the preset server includes: a pre-selected master server and at least one slave server.
[0110] In this embodiment, the number of first shard files is determined by the total number of servers, and each server receives one first shard file each time. When stealing data from one server, it is impossible to obtain complete data after decryption, and it is necessary to obtain data from all servers to obtain complete data, thereby improving the security of file storage. The number of first shard files is determined by the total number of the slave servers and the master server, which can avoid leaving idle servers, thereby improving server utilization.
[0111] In some embodiments of the present application, after the preset server stores the m first segment files under the first feature value index, the corresponding file to be downloaded is searched according to the second feature value index of the file to be processed for file restoration or file transfer, including: after the pre-selected main server receives the first feature value index, and according to the first feature value index and at least one first segment file received, and at least one pre-selected slave server receives the first feature value index and the remaining first segment files, a file index table is established to record the storage status of the main server and the slave server; wherein the main server and the slave server are selected in real time according to the ant colony algorithm with positive feedback of the trial mark; when it is necessary to restore the file to be recovered or transmit the file to be transmitted, the file to be downloaded corresponding to the file index table is searched according to the second feature value index of the file to be processed for file restoration or file transfer.
[0112] In some embodiments of the present application, the first feature value index is transmitted to the preset server in sequence, so that both the main server and the slave server receive the first feature value index, so that the main server and the slave server respectively store the received first fragment file under the corresponding first feature index.
[0113] In some embodiments of the present application, after the first feature value index is combined with m first fragment files respectively, the obtained m fragment files to be transmitted are transmitted to the master-slave server, so that the master-slave server respectively stores the received first fragment files under the first feature value index.
[0114] The present application adopts the method of dividing the master server and the slave server, which can select the optimal server for storing the sharded files, thereby improving the file transfer efficiency; and, since the master and slave servers are selected in real time each time for storing files, the master server and slave server for storing files are different each time, which improves the randomness of file storage, thereby further improving the security of file storage by selecting different master and slave servers.
[0115] In some embodiments of the present application, the master server and the slave server are selected in real time based on the ant colony algorithm with positive feedback of the trial mark, see Figure 5 , is a flow chart of the ant colony algorithm with positive feedback of the tentative mark provided in the embodiment of the present application, including sub-steps S131 to S133, specifically:
[0116] Step S131: Each time the file to be stored is uploaded, the same test data is sent to several servers, and the average delay per unit data volume for the several servers to receive and process the test data and return the processing results is tracked.
[0117] In some embodiments of the present application, the test data may be obtained by performing a mask operation on a test data stream in a file to be stored according to a test mask smaller than a preset mask size, or may be preset data unrelated to the file to be stored.
[0118] Step S132: When sending test data next time, the amount of first sub-test data sent to the server with the smallest average delay is greater than the amount of second sub-test data sent to the remaining servers, and the average delay is tracked again.
[0119] In some embodiments of the present application, the first sub-test data amount sent to the server with the smallest average delay per unit data amount is greater than the second sub-test data amount sent to the remaining servers; wherein the data processing delay is specifically: the total delay used for the test data from reception, processing to sending / data size.
[0120] Step S133: After repeated testing for multiple times, all test data are concentrated on the same server and marked as the master server, and the remaining servers are slave servers.
[0121] It is worth mentioning that when uploading files to be stored, the connection between the location of the files to be stored at the user terminal and multiple remote servers may be affected by various factors such as geographical distance and network bandwidth, resulting in uneven transmission performance with different servers. Therefore, the server with higher transmission performance can be used as the main server. In this way, based on the high performance of the main server, the Hash (uv) matching search can be performed first, and then the main server can initiate a match to all slave servers with the Hash (uv) value. In this way, the work of initiating query matching to multiple servers can be transferred to the main server with higher performance, thereby further utilizing physical resources.
[0122] It is worth noting that the total delay of the master server is definitely greater than that of the slave server. This is because the master server has the largest amount of data during the detection phase. Therefore, what needs to be compared is the average delay per unit of data, that is, total delay / total data volume = average delay per unit of data volume. Since the network performance of the master server is good, the average delay is the lowest.
[0123] In some embodiments of the present application, additional redundant remote servers or\and additional original master-slave servers are added, and the same bit part is retained, so as to realize redundant backup of the processing method and enhance the data disaster recovery capability and anti-malicious attack capability of the file processing method, but at the cost of losing some storage capacity.
[0124] In an optional embodiment of the present application, when the main server is selected for the file to be stored, the same test data test_data can be sent to all remote servers first, and the average delay per unit data volume obtained by receiving and processing each remote service is tracked and recorded according to the total delay latency_time_all. When sending test data next time, there is a tendency to send more data to the server with a small delay time, and repeatedly record the average delay per unit data volume latency_time (the overall time consumption latency_time_all / data volume test_bits used to process all data). Each test tends to send more data to the server with the smallest average delay latency_time per unit data volume, so that the data volume test_bits of other servers will gradually become smaller. In the case of insufficient network performance, all test data will eventually be concentrated on a single server, and the main server is determined. When the file is subsequently uploaded to the main server, a mark will be added to the main server, and all query matches when performing transmission or recovery operations will be forwarded by the main server to the slave server.
[0125] In another optional embodiment of the present application, when the main server is selected for the file to be stored, m first slice files are used as test data test_data corresponding to the m servers, each server processes one first slice file and sends it to all remote servers at the same time, tracks and records the reception and processing of each remote service, and returns the average delay per unit data amount based on the total delay latency_time_all; when sending the next m first slice files for the next time, there is a tendency to send one more first slice file to the server with a smaller delay time, and repeatedly record the average delay per unit data amount latency_time (the overall time consumption latency_time_all for processing all data / data amount test_bits), and each test tends to send more data to the server with the smallest average delay latency_time per unit data amount in a tendency, so that the data amount test_bits of other servers will gradually decrease. When the network performance is not good enough, all the test data will eventually be concentrated on only one server, and the main server is determined. Later, when the remaining files to be stored have not been stored, a mark will be added to the master server when uploading the remaining files to the master server, and uploaded to the unmarked slave server. When performing transfer or recovery operations, all query matches will be forwarded from the master server to the slave server.
[0126] It is worth noting that when using the test file to screen the master and slave servers, you can first use a mask size smaller than the mask size of the master and slave servers in formal use. It is more efficient to use a small-size preset mask to determine the master and slave servers, and then use a large-size preset mask for large-scale data transmission.
[0127] It is worth noting that the selection of the primary server is based on a combination of factors such as network and region. Therefore, for the same file to be stored, once the upload is completed, its primary server is synchronously determined, that is, a file has only one primary server and it is fixed, but for different files, their primary servers may be different.
[0128] In some embodiments of the present application, when it is necessary to restore a file to be restored or to transmit a file to be transmitted, the file to be downloaded corresponding to the file index table is searched according to the second characteristic value index of the file to be processed for file restoration or file transmission, including: obtaining the second characteristic value of the processed file, performing hash calculation on the second characteristic value to obtain a second characteristic value index, and querying the second characteristic value index in the file index table to obtain the first download fragment file in the master server; at the same time, initiating a global match of the second characteristic value index to all slave servers according to the master server to obtain the remaining second download fragment files; sending the first download fragment file and the second download fragment file to the user terminal in batches, so that the user terminal recombines the first download fragment file and the second download fragment file according to the preset mask to obtain the file to be restored or the transmission file.
[0129] In some embodiments of the present application, the first downloaded segment file and the second downloaded segment file are sent to the user terminal in batches, including: when the second characteristic value of the first downloaded segment file is consistent with that of the second downloaded segment file, erasing the second characteristic value of the second downloaded segment file to obtain a sub-file to be processed, so that the first downloaded segment file and the sub-file to be processed are sent to the user terminal in batches.
[0130] This application uses the characteristic values of the files to be processed to obtain the corresponding downloaded segment files from the main server and the slave server, and provides a file recovery mechanism based on the file storage mechanism, so that it can be applied to comprehensive scenarios of file transfer, file encryption and file recovery, and has higher applicability and practicality.
[0131] It is worth noting that the second characteristic value includes: the third sub-characteristic value using the absolute path file name, or the fourth sub-characteristic value obtained by performing hash calculation using the file content of the preset location of the file to be stored.
[0132] In an optional embodiment of the present application, a third sub-feature value of the absolute path file name is obtained, a hash calculation is performed on the third sub-feature value to obtain a second feature value index, and the second feature value index is queried in the file index table to obtain the first download segment file in the master server, and at the same time, a global match is initiated for the second feature value index in all slave servers to obtain the remaining second download segment files; the first download segment file and the second download segment file are sent to the user terminal in batches, so that the user terminal recombines the first download segment file and the second download segment file according to the preset mask to obtain the file to be restored or the transmission file.
[0133] In another optional embodiment of the present application, a fourth sub-eigenvalue is obtained by performing a hash calculation on the file content at the preset location of the file to be stored, a hash calculation is performed on the fourth sub-eigenvalue to obtain a second eigenvalue index, and the second eigenvalue index is queried in the file index table to obtain the first download segment file in the master server, and at the same time, a global match is initiated on the second eigenvalue index in all slave servers to obtain the remaining second download segment files; the first download segment file and the second download segment file are sent to the user terminal in batches, so that the user terminal recombines the first download segment file and the second download segment file according to the preset mask to obtain the file to be restored or the transmission file.
[0134] It is worth noting that the main feature of the file processing method is to extract the file logically through a preset mask image and then encrypt it in segments. Compared with the general segment encryption method, its segmentation efficiency is higher, and because the data stream is segmented along the diagonal direction, the data of the obtained segmented file itself is not continuous, and its security is higher. The mask layer of the file segmentation can be pre-set according to the specific scenario, and the bits are extracted by logical AND operation. At the same time, the unique feature value can be based on "user name + file name" or "user name + 1kb content characters of the file" to match the optimal master and slave server for storage for the segmented file. Therefore, the unique feature value is extracted according to the file content and a file processing method that integrates storage, transmission and recovery operations is deployed remotely through algorithm matching. It has higher security, wider application scenarios, higher segmentation efficiency, and higher server resource utilization.
[0135] The present application arranges the data stream in the file to be stored in a data frame of the same size as a preset mask, and uses a rectangular mask that is equally divided into m areas along the direction parallel to the diagonal line to slice the data stream. The data stream can be divided into discontinuous slice files, thereby ensuring that even if the stolen slice file is cracked, a complete piece of data cannot be obtained, thereby improving the security of file storage.
[0136] Example 2
[0137] See also Figure 6 , is a flow chart of type I storage of files to be stored provided by an embodiment of the present application. The figure includes a process of feature value extraction, mask loop slicing, and storage to a server.
[0138] The first 1Kbits of the binary file content of the file to be stored is extracted as the eigenvalue uv, and the eigenvalue uv is hashed to obtain the eigenvalue index Hash(uv) and transmitted to all master and slave servers.
[0139] The binary file of the file to be stored is stored in N=M*M square data blocks in bytes, and the data stream extracted in a loop is arranged in rows in bits into a rectangular data frame of the same size as the preset mask. The preset mask is a square mask that divides the area into 5 equal parts in bits. The rectangular data frame and the preset mask are masked bit by bit to obtain a regional data stream of 5 bit data partitions in the rectangular data frame, and the regional data stream is read row by row and transmitted to the preset server, which contains 5 servers in total.
[0140] In order to improve the utilization rate of the servers, this embodiment uses a number of servers equal to the number of slice files.
[0141] Specifically, according to the test data, server A is the master server A, and the remaining servers are slave servers. The regional data stream corresponding to area A is transmitted to the master server A, and the regional data corresponding to area B, the regional data corresponding to area C, the regional data corresponding to area D, and the regional data corresponding to area E are transmitted to the slave server B, server C, server D, and server E respectively.
[0142] It is worth noting that since the bits of ABCDE shard files are all part of the files to be stored after being forcibly split, the leakage of any of them will not affect the users; at the same time, because the eigenvalue index Hash (uv) is stored on each server, the various file fragments have a certain connection as a whole.
[0143] The present application uses the method of slicing the data stream along the diagonal direction, and the data of the obtained slicing file itself is also discontinuous, so it has higher security; and, the slicing file is matched with the best master-slave server for storage, so that the storage of the file on the remote server is more secure and the server resource utilization rate is higher.
[0144] Example 3
[0145] Compared with Example 2, the difference is that the number of servers in this embodiment is less than the number of slice files, and the slice files divided into five equal parts are stored in three servers.
[0146] As a more general case, when the number of shards to store a file is not equal to the actual number of physical servers, see Figure 7 , is a type II storage flow chart of the files to be stored provided by the embodiment of the present application. In the figure, when the shard files divided into 5 equal parts are stored on 3 servers, the data stream of area A is stored on server A, the data streams of areas B and C are stored on server B, and the data streams of areas D and E are stored on server C.
[0147] In this way, a more general situation can be achieved where the number of categories is not equal to the number of servers. This is also for performance optimization and other considerations. The remote servers are divided into master servers Master and slave servers Slave, where there is only one master server (server A) and the rest are slave servers (server B and server C).
[0148] Because when uploading files, the connection between the location of the method and multiple remote servers may be affected by multiple factors such as geographical distance and network bandwidth, resulting in uneven transmission performance with different servers, the server with higher transmission performance can be used as the main server. In this way, based on the high performance of the main server, the Hash (uv) matching search can be performed first, and then the main server can initiate a match to all slave servers with the Hash (uv) value. In this way, the work of initiating query matching to multiple servers before is transferred to the main server with higher performance, thereby further utilizing physical resources.
[0149] The algorithm for selecting the master server can adopt the ant colony algorithm of the trial mark positive feedback, that is, when the master server is selected for the uploaded file, the same test data test_data can be sent to all remote servers first, and the average delay per unit data volume obtained by receiving and processing each remote service is tracked and recorded according to the total delay latency_time_all. When sending test data next time, there is a tendency to send more data to the server with a small average delay per unit data volume, and repeat the average delay latency_time per unit data volume (the total delay latency_time_all used to process all data / data volume test_bits). Each test tends to send more data to the server with the smallest average delay latency_time per unit data volume, so that the data volume test_bits of other servers will gradually decrease. In the case of insufficient network performance, all test data will eventually be concentrated on a single server, and the master server is determined. When the file is subsequently uploaded to the master server, a mark will be added to the master server, and all query matches during transmission or recovery operations will be forwarded by the master server to the slave server.
[0150] In this embodiment, the data stream of area A is sent to the master server Master (server A), the data streams of areas B and C are sent to the slave server Slave1 (server B), and the data streams of areas D and E are sent to the server Slave2 (server C), thereby achieving preferential matching of file fragments and remote servers.
[0151] The masked sharding encryption proposed in this application can divide the master and slave servers based on the number of file classifications and the number of remote servers, where the separation of master and slave data is completed when the mask layer is planned. The file shards after mask segmentation and the shards themselves are not complete, but each shard is associated with a file feature value, and these fragments can be matched one by one with the mask layer so that they are automatically marked with order for subsequent use in file assembly; and after splitting the file content, the ant colony algorithm with trial mark positive feedback is adopted to confirm a server with higher performance as the master server based on the network bandwidth, task delay time and other performance at that time, and it plays the role of initiating data queries to the remaining slave servers, thereby improving the overall resource utilization.
[0152] Example 4
[0153] See also Figure 8 , is a flowchart of restoring the file to be restored provided by the embodiment of the present application. The figure includes the processing flow of feature value extraction, feature value search, obtaining downloaded files and restoring the file to be stored, which is a flowchart of Figure 6 The reverse operation of the file storage process.
[0154] When the user wants to restore a file, he first finds the eigenvalue uv associated with the file through the file name, then calculates the eigenvalue index Hash(uv), and based on the eigenvalue index, initiates a query to the remote service to match all the files to be downloaded from the remote server. Finally, based on the mask layer, the eigenvalues are assembled and merged to finally restore the binary file of the file to be restored.
[0155] The present application uses mask fragmentation processing to ensure that the fragmented files and the fragmented files themselves have no integrity, so there is no fear of malicious attacks when stored on a remote server; since each fragmented file is associated with a file characteristic value, there is no fear of malicious tampering during network transmission; the ultimate integrity of the user file can be guaranteed through the processing of the remote server, even if a remote server is attacked or is tampered with by the network when the remote service is sent down for processing, the ultimate consistency of the user file can be guaranteed through characteristic value comparison and repeated delivery.
[0156] Example 5
[0157] This embodiment is based on Figure 7 For the file recovery process of Type II storage scenario, see Fig. 9 , is a flowchart of file recovery for type II storage files provided in an embodiment of the present application. After the file is uploaded to the remote server, the user can use the file processing method for various scenarios. This time, the principle steps of the file processing method are explained with the file transfer process and the file recovery process respectively. For the convenience of explanation, this regulation classifies the files into five equal-division masks, and the classified data is stored on three servers. Similarly, the data stream (bitA) of area A is stored under the characteristic value (uv) of the master server Master (server A), the data streams (bitB+bitC) of areas B and C are stored under the characteristic value (uv) of the slave server Slave1 (server B), and the data streams (bitD+bitE) of areas D and E are stored under the characteristic value (uv) of the server Slave2 (server C).
[0158] When a user accidentally deletes a local file and turns to the processing method for file recovery, the file name of the file to be recovered needs to be submitted, which can be directly obtained in the submitted history record. According to the previous discussion, the file contents stored by the three remote services correspond to [uv+bitA], [uv+bitB+bitC] and uv+bitD+bitE] respectively. The main server Master that performs the file recovery service, after obtaining the file name, the processing method will perform the following operation steps, including: Steps S51 to S58, specifically:
[0159] Step S51, firstly, obtain the characteristic value uv of the file to be restored according to the file name of the file to be restored. A relatively simple absolute path identifier is adopted for the characteristic value, that is, the user space name + file path name, which requires the remote server to perform storage search, and obtain uv after combining the user space and the file path name; if the characteristic value is the first 1K Bits part of the file to be restored, it is necessary to search the RelaTbl relationship table through the file name to obtain the 1K Bits content, that is, to obtain the characteristic value uv.
[0160] Step S52, perform a hash operation on the eigenvalue uv to obtain the eigenvalue index Hash(uv), and then perform a StrTbl table lookup operation to obtain the bitA portion of the file to be restored stored on the primary server, where bitA represents the matching content segment extracted from the mask position A during mask segmentation.
[0161] Step S53, the master server initiates a global match to all slave servers with the feature value uv, and obtains the parts corresponding to the feature value distributed in other slave servers, namely [uv+bitB+bitC] and [uv+bitD+bitE]. These content parts are all fragments of the file to be stored, and they cannot be restored to the final file even if they are all stolen by the network because the bitA part stored by the master server is missing; and the file to be stored is also non-continuous data, which cannot be restored even if it is stolen.
[0162] Step S54, compare the uv part in the received data, and proceed to step S55 to ensure that they are all consistent; otherwise, the inconsistency means that the network data is lost or maliciously tampered with, and proceed to step S541;
[0163] Step S541: re-initiate matching for inconsistent UVs and re-execute the above step S53.
[0164] Step S55, reversely erase the uv part received from the server according to the characteristic value uv, ensuring that the remaining part only contains the bit part, which becomes bitB, bitC, bitD and bitE after the erasure is completed.
[0165] Step S56: Send uv+bitA queried by the main server, and bitB, bitC, bitD and bitE obtained through the network to the user terminal in batches;
[0166] Step S57: Reassemble uv+bitA+bitB+bitC+bitD+bitE on the user terminal according to the preset mask, that is, restore to the original binary file.
[0167] Step S58: The user terminal checks whether the file is restored successfully. If it is successful, the process ends. If there is a problem, the file restoration operation can be performed again from step S51.
[0168] This embodiment extracts data from the file bit by bit and masks it in a circular manner, and stores the fragmented files in a remote server according to certain matching rules. At the same time, it maintains contact based on feature values that uniquely match the file information, thereby performing various operations such as recovery on the basis of encryption, transmission and storage of the integrated file, thereby being able to adapt to more scenarios and having higher applicability and practicality.
[0169] Example 6
[0170] When a user terminal needs to transmit a file to another user terminal, the sender does not need to download and then send the file from the server, but can directly rely on the processing method to complete the file sharing, while ensuring the encrypted transmission and reliable integrity of the file to be sent.
[0171] Similarly, when a user terminal transfers a file, it needs to submit the file name of the file to be transferred, which can also be directly obtained in the submitted history record.
[0172] This embodiment assumes that the first user terminal transmits a file to the second user terminal, that is, the first user terminal is the sender and the second user terminal is the receiver. It is worth noting that the first user terminal and the second user terminal include: mobile phones, computers, tablets, smart watches and other smart products; in addition, the rest of the assumptions are the same as the file recovery scenario in the above embodiment 5, see Fig.10 , is a schematic diagram of a file transmission process provided by an embodiment of the present application, including steps S61 to S68, specifically:
[0173] Step S61, first obtain the characteristic value uv according to the file name of the file to be transmitted. The acquisition method is the same as the scenario of the above-mentioned embodiment 5. Specifically, it includes: first, according to the file name of the file to be transmitted, obtain the characteristic value uv of the file to be transmitted. A relatively simple absolute path identifier is adopted for the characteristic value, that is, the user space name + file path name, which requires the remote server to perform storage search, and obtain the characteristic value uv after combining the user space and the file path name; if the characteristic value is the 1K Bits part at the beginning of the file to be transmitted, it is necessary to search the RelaTbl relationship table through the file name to obtain the 1K Bits content, that is, to obtain the characteristic value uv.
[0174] Step S62, obtain the characteristic value index Hash(uv) through the characteristic value uv, and then perform a StrTbl table lookup operation to obtain the bitA part of the file to be transmitted stored on the main server;
[0175] Step S63: Obtain information of the second user terminal from the first user terminal, and connect to the second user terminal through the network; wherein, the second user terminal is required to have authorized the use of the remote service.
[0176] Step S64: The master server initiates a global match to all slave servers using the characteristic value uv, and sends uv+bitB+bitC, uv+bitD+bitE and uv+bitA distributed on other slave servers to the second user terminal in the form of a temporary file tmp.
[0177] Step S65, compare the uv parts in each data, and if they are all consistent, go to step S66; if they are inconsistent, go to step S651.
[0178] Step S651: for the inconsistent parts, the corresponding master and slave servers will re-execute the above step S64.
[0179] Step S66: reversely erase the uv part received by other remote services according to the characteristic value uv to ensure that the remaining part only contains the bit part. After the erasure is completed, it finally becomes uv+bitA, bitB, bitC, bitD and bitE.
[0180] Step S67: On the second user terminal, uv+bitA+bitB+bitC+bitD+bitE are reassembled according to the preset mask, that is, the original binary file is restored. After the assembly is completed, the temporary file tmp is deleted.
[0181] Step S68: The second user terminal checks the file and notifies the first user terminal that the file reception is complete.
[0182] This application can be applied to a variety of practical scenarios, including but not limited to personal file recovery, two-party and multi-party file transfer, and has higher applicability and practicality; and after being deployed to remote services, it can have all the characteristics of distributed applications, which can greatly optimize various file operation processes and improve production efficiency.
[0183] Example 7
[0184] See also Fig.11 , is a structural diagram of a distributed file processing device provided in an embodiment of the present application, including: a first feature value acquisition module 71, a sharding module 72 and a storage module 73.
[0185] Among them, the first characteristic value acquisition module 71 is mainly used to obtain the first characteristic value of the file to be stored, and transmit the first characteristic value index corresponding to the first characteristic value to the storage module 73; the sharding module 72 is mainly used to shard the file to be stored into a first discontinuous shard file according to a preset mask, and transmit the first shard file to the storage module 73; after the storage module 73 receives the first characteristic index and the first shard file, the first shard file is stored under the first characteristic value index, so that the corresponding file to be recovered can be searched on the preset server according to the second characteristic value index of the file to be processed for file restoration or file transfer.
[0186] The first feature value acquisition module 71 is used to acquire a first feature value of a file to be stored, and obtain a first feature value index identifying the file to be stored according to the first feature value.
[0187] In some embodiments of the present application, a first characteristic value of a file to be stored is obtained, and a first characteristic value index identifying the file to be stored is obtained based on the first characteristic value, including: obtaining an absolute path file name of the file to be stored on a user terminal, and taking the absolute path file name as a first sub-characteristic value; or performing a hash calculation on the file content of a preset position of the file to be stored to obtain a second sub-characteristic value, so as to establish a relationship table based on the second sub-characteristic value and the file name to be stored; wherein the first characteristic value includes: the first sub-characteristic value or the second sub-characteristic value; after performing a hash operation on the first sub-characteristic value or the second sub-characteristic value, a first characteristic value index identifying the file to be stored is obtained.
[0188] The slicing module 72 is used to extract the first data stream of a preset size from the file to be stored in sequence, and arrange the first data stream in a data frame of the same size as the preset mask, and perform a mask operation on the data frame according to the preset mask to obtain m first slicing files; wherein m is a positive integer; the size of the preset mask is a rectangular mask that is divisible by the number of first slicing files.
[0189] In some embodiments of the present application, sequentially extracting a first data stream of a preset size from the file to be stored includes: arranging the binary data stream of the file to be stored into a square data block of M*M units by bytes, and extracting L units of binary data stream from the square data block each time as the first data stream; wherein M and L are both positive integers. .
[0190] In some embodiments of the present application, the first data stream is arranged in a data frame of the same size as a preset mask, and a mask operation is performed on the data frame according to the preset mask to obtain m first slice files, including: arranging a number of bits of bit data of the first data stream in rows, and arranging a number of rows to obtain a rectangular data frame of the same size as the preset mask; performing a bit mask operation on the rectangular data frame according to a preset mask that divides m areas, and obtaining m bit data partitions at the same time, and taking the bit data corresponding to each bit data partition on the first data stream as 1 first slice file, and obtaining a total of m first slice files.
[0191] In some embodiments of the present application, setting the preset mask includes: constructing a mask with bits as units and a size of m rows and m columns according to the byte length of the first data stream, and dividing the mask into m equal areas in the diagonal direction to obtain the preset mask; wherein the size of the preset mask is not less than the byte length.
[0192] The storage module 73 is used to transmit the m first segment files and the first feature value index to the preset server in sequence, so that the preset server stores the m first segment files under the first feature value index.
[0193] In some embodiments of the present application, the m first shard files and the first feature value index are transmitted to a preset server in sequence, including: the m first shard files and the first feature value index are transmitted to preset m-1 slave servers and 1 master server respectively; wherein each slave server receives a first shard file and one of the feature value indexes, and the master server receives a shard file and one of the feature value indexes; the number of divided first shard files is determined by the total number of the slave servers and the master servers.
[0194] In some embodiments of the present application, the preset server includes: a pre-selected master server and at least one slave server.
[0195] In this embodiment, the number of first shard files is determined by the total number of servers, and each server receives one first shard file each time. When stealing data from one server, it is impossible to obtain complete data after decryption, and it is necessary to obtain data from all servers to obtain complete data, thereby improving the security of file storage. The number of first shard files is determined by the total number of the slave servers and the master server, which can avoid leaving idle servers, thereby improving server utilization.
[0196] In some embodiments of the present application, after the preset server stores the m first segment files under the first feature value index, the corresponding file to be downloaded is searched according to the second feature value index of the file to be processed for file restoration or file transfer, including: after the pre-selected main server receives the first feature value index, and according to the first feature value index and at least one first segment file received, and at least one pre-selected slave server receives the first feature value index and the remaining first segment files, a file index table is established to record the storage status of the main server and the slave server; wherein the main server and the slave server are selected in real time according to the ant colony algorithm with positive feedback of the trial mark; when it is necessary to restore the file to be recovered or transmit the file to be transmitted, the file index table corresponding to the file to be downloaded is searched according to the second feature value index of the file to be processed for file restoration or file transfer.
[0197] In some embodiments of the present application, the master server and the slave server are selected in real time based on the ant colony algorithm with positive feedback of the trial mark, see Figure 5 , is a flow chart of the ant colony algorithm with positive feedback of the tentative mark provided in the embodiment of the present application, including sub-steps S131 to S133, specifically:
[0198] Step S131: Each time the file to be stored is uploaded, the same test data is sent to several servers, and the average delay per unit data volume for the several servers to receive and process the test data and return the processing results is tracked.
[0199] Step S132: When sending test data next time, the amount of first sub-test data sent to the server with the smallest average delay is greater than the amount of second sub-test data sent to the remaining servers, and the average delay is tracked again.
[0200] Step S133: After repeated testing for multiple times, all test data are concentrated on the same server and marked as the master server, and the remaining servers are slave servers.
[0201] In some embodiments of the present application, file restoration or file transfer is performed by searching the file to be downloaded corresponding to the file index table according to the second characteristic value index of the file to be processed, including: obtaining the second characteristic value of the file to be processed, performing hash calculation on the second characteristic value to obtain a second characteristic value index, and querying the second characteristic value index in the file index table to obtain the first download segment file in the master server; at the same time, initiating a global match of the second characteristic value index to all slave servers according to the master server to obtain the remaining second download segment files; sending the first download segment file and the second download segment file to the user terminal in batches, so that the user terminal recombines the first download segment file and the second download segment file according to the preset mask to obtain the file to be restored or the transmission file.
[0202] In some embodiments of the present application, the first downloaded segment file and the second downloaded segment file are sent to the user terminal in batches, including: when the second characteristic value of the first downloaded segment file is consistent with that of the second downloaded segment file, erasing the second characteristic value of the second downloaded segment file to obtain a sub-file to be processed, so that the first downloaded segment file and the sub-file to be processed are sent to the user terminal in batches.
[0203] This application uses a preset mask image to perform logical extraction of files for segmented encryption. Compared with general segmented encryption methods, its segmentation efficiency is higher, and because the data stream is segmented in the diagonal direction, the data of the obtained segmented file itself is not continuous, and its security is higher. The mask layer of the file segmentation can be pre-set according to the specific scenario, and the bits are extracted by logical AND operation. At the same time, the unique feature value can be based on "user name + file name" or "user name + file 1kb content characters" to match the optimal master and slave servers for storage for the segmented files. Therefore, according to the file content, the unique feature value is extracted and matched by the algorithm to remotely deploy a file processing method that integrates storage, transmission and recovery operations, which has higher security, wider application scenarios, higher segmentation efficiency, and higher server resource utilization.
[0204] Example 8
[0205] The present application provides a server, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distributed file processing method when executing the computer program.
[0206] This application uses a preset mask image to logically extract the file and encrypt it in segments, then matches the optimal master-slave server for storage of the sharded file. Therefore, a unique feature value is extracted according to the file content and matched to the optimal remote server for deployment through an algorithm. The file processing method that can integrate storage, transmission, and recovery operations and apply it to the server has higher security, wider application scenarios, higher sharding efficiency, and higher server resource utilization.
[0207] Example 9
[0208] See also Fig.12 , is a schematic diagram of an electronic device provided in an embodiment of the present application, the electronic device comprising: a memory 91, a processor 92, and a computer program stored in the memory 91 and executable on the processor, and the processor 92 implements the steps of the distributed file processing method when executing the computer program.
[0209] In some embodiments of the present application, the electronic device further includes: a communication interface 93 and a communication bus 94 ; wherein the processor 92 , the communication interface 93 and the memory 91 communicate with each other via the communication bus 94 .
[0210] This application uses a preset mask image to logically extract the file and encrypt it in segments, then matches the optimal master-slave server for storage of the segmented files. When the obtained file processing method is integrated on an electronic device, file storage, transmission, and recovery operations can be performed through various electronic devices, with a wider range of applicable scenarios and greater scalability.
[0211] Example 10
[0212] The present application provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the distributed file processing method described in the first aspect are implemented.
[0213] This application uses a preset mask image to logically extract the file and encrypt it in segments, then matches the optimal master-slave server for storage of the segmented files. When the obtained file processing program is stored in a storage medium, the file can be stored, transmitted, and restored by running or reading the file processing program in the storage medium. It has a wider range of applicable scenarios and stronger scalability.
[0214] Those skilled in the art will appreciate that the embodiments of the present application can also provide computer program products. Therefore, the present application can adopt the form of complete hardware embodiment, complete software embodiment or the embodiment in combination with software and hardware. Moreover, the present application can adopt the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0215] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0216] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0217] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0218] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A distributed file processing method, characterized in that: include: Acquire a first characteristic value of a file to be stored, and obtain a first characteristic value index identifying the file to be stored according to the first characteristic value; Extracting first data streams of a preset size from the file to be stored in sequence, arranging the first data streams in a data frame of the same size as the preset mask, and performing a mask operation on the data frame according to the preset mask to obtain m first slice files; wherein m is a positive integer; and the size of the preset mask is a rectangular mask that is divisible by the number of the first slice files; The m first segment files and the first feature value index are transmitted to the preset server in sequence, so that the preset server stores the m first segment files under the first feature value index.
2. The distributed file processing method according to claim 1, characterized in that: The step of arranging the first data stream in a data frame of the same size as a preset mask, and performing a mask operation on the data frame according to the preset mask to obtain m first fragment files includes: Arrange a plurality of bits of bit data of the first data stream in rows and arrange a plurality of rows to obtain a rectangular data frame of the same size as the preset mask; The rectangular data frame is subjected to a bitwise mask operation according to a preset mask that divides the m regions, and m bit data partitions are obtained at the same time. The bit data corresponding to each bit data partition on the first data stream is taken as a first slice file, and a total of m first slice files are obtained.
3. The distributed file processing method according to any one of claims 1 to 2, characterized in that: Setting the preset mask includes: According to the byte length of the first data stream, a mask with bits as the unit and a size of m rows and m columns is constructed, and the mask is equally divided into m areas in the diagonal direction to obtain the preset mask; wherein the size of the preset mask is not less than the byte length.
4. The distributed file processing method according to claim 1, characterized in that: After the preset server stores the m first segment files under the first characteristic value index, searching for the corresponding to-be-downloaded file according to the second characteristic value index of the to-be-processed file to perform file restoration or file transmission, including: After the pre-selected master server receives the first feature value index, and based on the first feature value index and the at least one first fragment file received, and the at least one pre-selected slave server receives the first feature value index and the remaining first fragment files, a file index table is established to record the storage conditions of the master server and the slave server; wherein the master server and the slave server are selected in real time according to the ant colony algorithm with positive feedback of the trial mark; When it is necessary to restore the file to be recovered or to transfer the file to be transmitted, the file to be downloaded corresponding to the file index table is searched according to the second characteristic value index of the file to be processed to perform file restoration or file transmission.
5. The distributed file processing method according to claim 4, characterized in that: The master server and the slave server are selected in real time according to an ant colony algorithm with positive feedback of a trial mark, including: Each time the file to be stored is uploaded, the same test data is sent to the plurality of servers, and the average delay per unit data volume for the plurality of servers to receive and process the test data and return the processing results is tracked; When sending test data next time, the amount of first sub-test data sent to the server with the smallest average delay is greater than the amount of second sub-test data sent to the remaining servers, and the average delay is tracked again; After repeated testing for many times, all test data are concentrated on the same server and marked as the master server, and the remaining servers are slave servers.
6. The distributed file processing method according to claim 4, characterized in that: The step of searching the file index table for the file to be downloaded corresponding to the file index table according to the second characteristic value index of the file to be processed to perform file restoration or file transfer includes: Obtaining a second characteristic value of the file to be processed, performing a hash calculation on the second characteristic value to obtain a second characteristic value index, and querying the second characteristic value index in the file index table to obtain a first downloaded fragment file in the main server; At the same time, the master server initiates a global match of the second feature value index to all slave servers to obtain the remaining second download segment files; The first download segment file and the second download segment file are sent to the user terminal in batches, so that the user terminal reassembles the first download segment file and the second download segment file according to the preset mask to obtain the file to be restored or the transmission file.
7. The distributed file processing method according to claim 6, characterized in that: The sending the first download segment file and the second download segment file to the user terminal in batches includes: When the second characteristic values of the first downloaded segmented file and the second downloaded segmented file are consistent, the second characteristic value of the second downloaded segmented file is erased to obtain the sub-file to be processed, so that the first downloaded segmented file and the sub-file to be processed are sent to the user terminal in batches.
8. The distributed file processing method according to claim 1, characterized in that: The sequentially transmitting the m first segment files and the first feature value index to a preset server includes: The m first shard files and the first characteristic value index are respectively transmitted to the preset m-1 slave servers and 1 main server; wherein each slave server receives a first shard file and one of the characteristic value indexes, and the main server receives a shard file and one of the characteristic value indexes; the number of divided first shard files is determined by the total number of the slave servers and the main servers.
9. The distributed file processing method according to claim 1, characterized in that: The step of sequentially extracting the first data stream of a preset size from the file to be stored includes: The binary data stream of the file to be stored is arranged into a square data block of M*M units by bytes, and L units of binary data stream are extracted from the square data block each time as the first data stream; wherein M and L are both positive integers.
10. The distributed file processing method according to claim 1, characterized in that: The acquiring a first characteristic value of the file to be stored, and obtaining a first characteristic value index identifying the file to be stored according to the first characteristic value, includes: Obtaining an absolute path file name of a file to be stored on a user terminal, and using the absolute path file name as a first sub-feature value; or performing a hash calculation on a file content at a preset location of the file to be stored to obtain a second sub-feature value, so as to establish a relationship table according to the second sub-feature value and the file name to be stored; wherein the first feature value includes: the first sub-feature value or the second sub-feature value; After performing a hash operation on the first sub-feature value or the second sub-feature value, a first feature value index identifying the file to be stored is obtained.
11. A distributed file processing device, characterized in that: include: A first feature value acquisition module, a slicing module and a storage module; wherein, The first feature value acquisition module is used to acquire a first feature value of the file to be stored, and obtain a first feature value index identifying the file to be stored according to the first feature value; The slicing module is used to sequentially extract first data streams of a preset size from the file to be stored, arrange the first data streams in a data frame of the same size as a preset mask, and perform a mask operation on the data frame according to the preset mask to obtain m first slicing files; wherein m is a positive integer; and the size of the preset mask is a rectangular mask that is divisible by the number of the first slicing files; The storage module is used to transmit the m first segment files and the first feature value index to the preset server in sequence, so that the preset server stores the m first segment files under the first feature value index.
12. A server, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distributed file processing method as claimed in any one of claims 1 to 10 when executing the computer program.
13. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the distributed file processing method as claimed in any one of claims 1 to 10 when executing the computer program.
14. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the distributed file processing method according to any one of claims 1 to 10 are implemented.
