File synchronization method and device, electronic equipment and storage medium

By using the database for file synchronization in a distributed system, uploading file name lists for comparison and downloading missing files, the problem of network interoperability affecting efficiency between nodes is solved, and synchronization efficiency and security are improved.

CN118568170APending Publication Date: 2024-08-30BEIJING MATARNET TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410584295.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-11
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing technology, the file synchronization efficiency between nodes in the distributed system is low, requiring network communication between nodes, which affects efficiency and security.

Method used

Using the database as the core of information exchange, upload a list of file names for comparison, determine missing files and add new data requests in the database, download missing files for synchronization, and avoid direct connections between nodes.

Benefits of technology

It improves the efficiency and quality of file synchronization between nodes in a distributed system, enhances network security, and reduces the need for network policy and firewall adjustments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568170A
    Figure CN118568170A
Patent Text Reader

Abstract

The invention relates to the technical field of communication, and provides a file synchronization method and device, electronic equipment and a storage medium, and the method comprises the steps: uploading a first file name list of a first node to a database; comparing the first file name list with a second file name list uploaded by each second node in a database to determine missing files in the first file name list; newly adding a data request in a database according to the missing file; and according to the data request, downloading a missing file uploaded by the second node from the database so as to synchronize the missing file to the first node. According to the method, the database is used as an information exchange core, the nodes do not need to be directly connected, the communication requirement of a network between the nodes is avoided, the indirect communication mode is beneficial to enhancing the network security, and the modification of a network strategy and the adjustment of a firewall are reduced, so that the efficiency and the quality of file synchronization between the nodes in the distributed system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a file synchronization method, device, electronic device and storage medium. Background Art

[0002] At present, file synchronization between microservice deployment nodes is mainly carried out through FTP (File Transfer Protocol) tools to map file directories and achieve file synchronization between multiple nodes. However, this solution requires network connectivity between nodes, and often requires applying to close firewalls or open network policies. It is greatly affected by the network conditions between each node, thus affecting the efficiency of file synchronization between nodes in the distributed system. Summary of the invention

[0003] The present application provides a file synchronization method, device, electronic device and storage medium to solve the problem of low efficiency of file synchronization between nodes in a distributed system in the prior art.

[0004] The present application provides a file synchronization method, comprising:

[0005] Upload the first file name list of the first node to the database;

[0006] Comparing the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system;

[0007] Adding a new data request to the database according to the missing file;

[0008] According to the data request, the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node.

[0009] According to a file synchronization method provided by the present application, adding a new data request to the database according to the missing file includes:

[0010] Determine a first file synchronization state of the missing file; the first file synchronization state indicates that the missing file is in a file request state;

[0011] The data request is newly added in the database; the data request includes the node identifier of the first node, the file name of the missing file and the synchronization status of the first file.

[0012] According to a file synchronization method provided by the present application, downloading the missing file uploaded by the second node from the database according to the data request includes:

[0013] Querying missing files requested by the data request;

[0014] If the file synchronization state of the missing file is identified as a second file synchronization state, the missing file uploaded by the second node is downloaded from the database; the second file synchronization state indicates that the missing file is in a file response state.

[0015] According to a file synchronization method provided by the present application, after uploading the first file name list of the first node to the database, the method further includes:

[0016] Querying the requirement files of each second node;

[0017] If the first file name list includes the required file, the required file is saved to the database, and the file synchronization state of the required file is modified and the insertion time of the required file is stored.

[0018] The present application provides a file synchronization method, comprising:

[0019] Receive a new data request from a first node, wherein the data request is used to request a missing file of the first node;

[0020] receiving the missing file saved by the second node based on the data request;

[0021] A download request for the missing file sent by the first node is received, and the missing file is sent to the first node according to the download request, so as to synchronize the missing file to the first node.

[0022] According to a file synchronization method provided by the present application, after receiving the newly added data request from the first node, the method further includes:

[0023] If the missing file uploaded by the second node is not downloaded by the first node within a set time, the missing file uploaded by the second node is deleted.

[0024] According to a file synchronization method provided by the present application, a file synchronization table is established in a database; the file synchronization table is used to store a first file name list of the first node and a second file name list of the second node in a distributed system; the first node and the second node represent service instances in the distributed system.

[0025] The present application provides a file synchronization device, comprising:

[0026] A file upload module, used for uploading a first file name list of a first node to a database;

[0027] A file comparison module, configured to compare the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system;

[0028] A file request module, configured to add a new data request to the database according to the missing file;

[0029] a first file synchronization module, configured to download the missing file uploaded by the second node from the database according to the data request, so as to synchronize the missing file to the first node;

[0030] The present application provides a file synchronization device, comprising:

[0031] A first receiving module, configured to receive a new data request from a first node; the data request is used to request a missing file of the first node;

[0032] A second receiving module, configured to receive the missing file saved by the second node based on the data request;

[0033] The second file synchronization module is used to receive a download request for the missing file sent by the first node, and send the missing file to the first node according to the download request, so as to synchronize the missing file to the first node.

[0034] The present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the file synchronization method described above is implemented.

[0035] The present application also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the file synchronization method described in any one of the above methods is implemented.

[0036] The file synchronization method, device, electronic device and storage medium provided by the present application are implemented by uploading a first file name list of a first node to a database; comparing the first file name list with a second file name list uploaded by each second node in the database to determine the missing files in the first file name list; adding a data request to the database according to the missing files; downloading the missing files uploaded by the second node from the database according to the data request to synchronize the missing files to the first node. The present application uses the database as the core of information exchange, and there is no need for direct connection between nodes, thus avoiding the need for network connectivity between nodes. The indirect communication method helps to enhance network security, reduce the modification of network policies and the adjustment of firewalls, thereby improving the efficiency and quality of file synchronization between nodes in a distributed system. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0038] Figure 1 This is one of the flowcharts of the file synchronization method provided by this application;

[0039] Figure 2 This is the second flowchart of the file synchronization method provided by this application;

[0040] Figure 3 This is a schematic diagram of uploading the file list provided by this application;

[0041] Figure 4 It is a schematic diagram of the requested missing files provided by this application;

[0042] Figure 5 This is a schematic diagram of the upload requirement file provided by this application;

[0043] Figure 6 It is a schematic diagram of synchronous missing files provided by this application;

[0044] Figure 7 It is one of the structural schematic diagrams of the file synchronization device provided by the present application;

[0045] Figure 8 This is the second structural diagram of the file synchronization device provided by the present application;

[0046] Fig. 9 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] It should be noted that in the description of the embodiments of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those skilled in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0049] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0050] Combine the following Figure 1-Figure 9 The present invention describes a file synchronization method, device, electronic device and storage medium.

[0051] Specifically, the present application provides a file synchronization method, referring to Figure 1 , Figure 1This is one of the flowcharts of the file synchronization method provided by this application.

[0052] The file synchronization method provided in the embodiment of the present application is applied to a first node, including:

[0053] Step 100: Upload a first file name list of a first node to a database.

[0054] The embodiments of the present application are applicable to file synchronization scenarios in a distributed system. The distributed system includes multiple nodes, each of which can be understood as an independent service instance or server in the distributed system. The node can be a physical server, virtual machine, container, or other operating environment in which the service is deployed. Each node has a unique identifier for distinguishing and identifying it in the system.

[0055] In a distributed system, each node needs to share files or data, but due to limited network connectivity or poor network conditions, direct node-to-node communication may be limited. Therefore, the embodiment of the present application uses a database as the center for file synchronization, which can simplify communication and network configuration between nodes, and can improve the efficiency and quality of file synchronization between nodes by uniformly managing and synchronizing files or data through a database.

[0056] The first node can be understood as the current node or this node. The first node periodically uploads the node identifier of this node and all the file names contained in this node, i.e., the first file name list, to the database according to the scheduled tasks developed in the service. At the same time, other nodes in the distributed system (i.e., the second node) will also periodically upload the node identifier and the second file name list to the database according to the scheduled tasks developed in the service. Among them, the second node can be understood as other nodes in the distributed system except the first node. The first node and the second node represent the service instances in the distributed system.

[0057] It is understandable that uploading file data directly to the database will result in a large amount of network transmission, especially for large files, and will also cause the database space to be too large. By uploading only the list of file names, the network transmission volume can be reduced, improving the performance and efficiency of the system. At the same time, the storage requirements of the database can be reduced, thereby reducing the cost of database management.

[0058] Step 200: compare the first file name list with the second file name list uploaded by each second node in the database to determine the missing files in the first file name list.

[0059] After the first node uploads the first file name list to the database, it queries the second file name list of each second node, and compares the first file name list with each second file name list to determine the missing files in the first file name list. For example, the first node queries the database through a database query operation to obtain the second file name lists owned by other nodes, and then compares the second file name lists of other nodes with the first file name list of this node to find out the files missing from this node, that is, the missing files.

[0060] Step 300: Add a new data request to the database according to the missing file.

[0061] If the first node finds that it lacks a file owned by other nodes, it can add a data request to the database. When the first node initiates a data request, the request is in the file request state, indicating that the first node needs to obtain a file owned by other nodes but missing from the first node. In the file request state, the data request is saved in the database and waits for responses from other nodes.

[0062] It should be noted that missing files correspond to multiple file synchronization states, including file request status, file response status, file reception status, etc. The file synchronization status is used to track and manage the synchronization process of files in the distributed system to ensure data consistency and integrity. By setting the file synchronization status, you can clearly understand the synchronization status of the file in the distributed system, including whether the file request has been sent, whether other nodes have responded, whether the file has been received, etc., which helps to monitor the progress and status of file synchronization. On the other hand, by setting the file synchronization status, you can better monitor possible problems that may arise during the file synchronization process and take timely measures to deal with them, thereby improving the reliability and stability of the system.

[0063] Specifically, the first file synchronization state of the missing file is determined, wherein the first file synchronization state indicates that the missing file is in a file request state. A new data request is added to the database, and the data request includes the node identifier of the first node, the file name of the missing file, and the first file synchronization state. For example, it is first necessary to determine the table structure corresponding to the table storing the data request in the database, and the table includes some fields, such as the node identifier, the required file name, the data type, the file synchronization state, etc. Then, according to the database type and the table structure, a SQL statement is constructed for inserting a new data request into the database. The SQL statement includes an INSERT INTO statement, which specifies the table name of the data to be inserted, the fields to be inserted, and the corresponding values. The constructed SQL statement is executed through the database connection to insert the new data request into the database. For example, this can be achieved by using the database's API (Application Programming Interface) or ORM (Object-Relational Mapping) framework.

[0064] Step 400: Download the missing file uploaded by the second node from the database according to the data request, so as to synchronize the missing file to the first node.

[0065] After the first node adds a new data request in the database, it will wait for responses from other nodes. After other nodes query the data request, if there are corresponding files, they will respond to the request and provide the required files.

[0066] Specifically, the missing file requested by the query data request, if the file synchronization state of the missing file is identified as the second file synchronization state, then the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node, that is, the file synchronization between the first node and the second node is realized through the database. The second file synchronization state indicates that the missing file is in the file response state. When the missing file is in the file response state, the second node will save the file content of the missing file to the database, and identify the file synchronization state field in the corresponding data request record as a filled file.

[0067] For example, the first node periodically queries the database for the missing file requested by the data request, and if the file synchronization status field in the data request record is marked as the file response status, it indicates that the missing file has been filled. At this time, a download request is sent to the database, and according to the download request, the corresponding missing file is downloaded from the database.

[0068] The file synchronization method provided in the embodiment of the present application is performed by uploading a first file name list of a first node to a database; comparing the first file name list with the second file name list uploaded by each second node in the database to determine the missing files in the first file name list; the first node and the second node represent service instances in a distributed system; according to the missing files, a new data request is added to the database; according to the data request, the missing files uploaded by the second node are downloaded from the database to synchronize the missing files to the first node. The embodiment of the present application uses the database as the core of information exchange, and there is no need for direct connection between the nodes, thus avoiding the need for network connectivity between nodes. The indirect communication method helps to enhance network security, reduce the modification of network policies and the adjustment of firewalls, thereby improving the efficiency and quality of file synchronization between nodes in a distributed system.

[0069] Based on the above embodiment, after uploading the first file name list of the first node to the database, the method further includes:

[0070] Step S11, querying the requirement files of each second node;

[0071] Step S12: If the first file name list includes the required file, the required file is saved to the database, and the file synchronization state of the required file is modified and the insertion time of the required file is stored.

[0072] When the first node finds that other nodes need a file, it will check whether the node has the file. If it does, it will save the file content to the database, update the file synchronization status to the file response status, and record the file insertion time. Specifically, uploading the required file includes the following steps:

[0073] (1) Querying the demand file data of other nodes: The first node queries the database for the demand file data sent by other nodes, that is, the demand file corresponding to the file request status identified by the file synchronization status.

[0074] (2) Check whether this node contains the requirement file: For each requirement file, the first node will check whether this node contains the requirement file.

[0075] (3) Save the file content to the database: If the first node contains the required file, the file content is saved in the file_byte field of the corresponding record in the database. Based on this, other nodes can obtain the content of the required file through the database.

[0076] (4) Update file synchronization status and insertion time: After saving the file content, the first node marks the file synchronization status as the file response status, indicating that the file has been successfully filled. At the same time, the file insertion time is recorded for subsequent data management and cleaning.

[0077] The embodiment of the present application can ensure the consistency and reliability of the file by saving the file content in the database. Even if the communication between nodes fails, the file can still be obtained from the database, ensuring the completion and correctness of file synchronization.

[0078] Reference Figure 2 , Figure 2 This is the second flowchart of the file synchronization method provided by this application.

[0079] The file synchronization method provided in the embodiment of the present application is applied to a database, including:

[0080] Step 500: Receive a new data request from the first node.

[0081] Receive a list of file names uploaded by each node in a distributed system, including a first file name list uploaded by a first node and a second file name list uploaded by each second node, where the first node and the second node represent service instances in the distributed system. For example, develop a scheduled task in the service so that each node can upload the node identifier and the file names contained therein to a database, and set the data type to a file name list (i.e., a file metadata list). The implementation of uploading the file name list may include the following steps:

[0082] (1) Develop a scheduled task: Develop a scheduled task in the service to periodically perform the file name list upload operation. The scheduled task can be implemented using a task scheduler or timer to ensure that it is executed within the predetermined time interval.

[0083] (2) Obtaining the node identification and file name list of each node: Each time the scheduled task is executed, it is necessary to first obtain the node identification of each node and the file name list contained in each node. The node identification is a unique identifier used to identify different nodes; the file name list can be a list of names or paths of files stored in each node.

[0084] (3) Save data to the database: After obtaining the node ID of each node and the list of file names contained therein, the scheduled task saves this data to the database. For example, a database table is created to store this data. The fields in the table may include node ID, file name, data type, etc.

[0085] (4) Ensure data consistency: When the scheduled task performs the file name list upload operation, it is necessary to ensure the consistency and integrity of the data, including handling possible abnormal situations during the data upload process, such as network interruption, database connection failure, etc.

[0086] A file synchronization table is established in the database, wherein the file synchronization table is used to store a first file name list of a first node and a second file name list of a second node in the distributed system. The file synchronization table includes the following contents:

[0087] aFile information: basic information of each file, such as file name, file size, file type, etc.

[0088] bNode information: includes the node's unique identifier, the node's network address, etc.

[0089] cFile synchronization status: records the synchronization status of the file, including file request status, file response status, file reception status, etc.

[0090] dData type identifier: used to identify the type of record, such as requirement file, filled file, etc.

[0091] eInsert time: records the time when data is inserted into the database, which is used for data management and cleaning.

[0092] fRequired file information: including missing files for each node.

[0093] gThe id of each piece of data.

[0094] hOther metadata: includes additional metadata information such as the file creation time and last modification time.

[0095] In a specific embodiment, referring to Table 1, Table 1 is a file synchronization table.

[0096] Table 1

[0097]

[0098]

[0099] After each node uploads the file name list to the database, the database receives the data request newly added by the first node, where the data request is used to request the missing files of the first node. For example, after the first node uploads the first file name list to the database, it queries the second file name list of each second node and compares the first file name list with each second file name list. If the first node finds that the node lacks files owned by other nodes, it can add a new data request to the database.

[0100] Step 600: Receive the missing file saved by the second node based on the data request.

[0101] When the second node finds that the first node needs a missing file, it will check whether the node has the missing file. If it does, it will save the file content of the missing file to the database, update the file synchronization status to the file response status, and record the insertion time of the missing file. Therefore, the database will receive the missing file saved by the second node based on the data request.

[0102] Step 700: Receive a download request for the missing file sent by the first node, and send the missing file to the first node according to the download request to synchronize the missing file to the first node.

[0103] After the first node adds a new data request to the database, it will wait for responses from other nodes. At the same time, the first node periodically queries the missing files requested by the data request. If the file synchronization status field in the data request record is marked as the file response status, it indicates that the missing file has been filled. At this time, a download request is sent to the database. The database receives the download request for the missing file sent by the first node, and sends the missing file to the first node according to the download request to synchronize the missing file to the first node, that is, to achieve file synchronization between the first node and the second node through the database.

[0104] After the file transfer is completed, in order to save database space, the database needs to delete the data that has been transferred from the file synchronization table to ensure that the file synchronization table only contains data that has not been synchronized or is being synchronized, avoiding unnecessary data redundancy.

[0105] The file synchronization method provided in the embodiment of the present application receives a new data request from the first node; the data request is used to request the missing file of the first node; the missing file saved by the second node based on the data request is received; the download request of the missing file sent by the first node is received, and the missing file is sent to the first node according to the download request, so as to synchronize the missing file to the first node. The embodiment of the present application uses the database as the core of information exchange, and there is no need for direct connection between the nodes, thus avoiding the need for network interconnection between nodes. The indirect communication method helps to enhance network security, reduces the modification of network policies and the adjustment of firewalls, thereby improving the efficiency and quality of file synchronization between nodes in the distributed system.

[0106] Based on the above embodiment, after receiving the data request newly added by the first node, the method further includes:

[0107] Step 511: If the missing file uploaded by the second node is not downloaded by the first node within a set time, the missing file uploaded by the second node is deleted.

[0108] A scheduled task is set in the database to regularly check the file synchronization table for file data that has not been synchronized for a fixed period of time since the current time. For these unsynchronized data, the database will regard them as invalid data and delete them from the file synchronization table to save database space.

[0109] Specifically, the insertion time of the missing file is obtained, and the time difference between the insertion time and the current time is calculated. If the time difference is greater than the set time, such as 2 days, it means that the missing file has not been synchronized for a long time, that is, it has not been downloaded by the first node. At this time, the missing file uploaded by the second node needs to be deleted to clean up invalid data.

[0110] For example, cleaning invalid data includes the following processes:

[0111] Scheduled task triggering: Set up scheduled tasks in the database to periodically perform operations to clean up invalid data.

[0112] Query unsynchronized file data: The scheduled task first queries the data in the file synchronization table and filters out the file data that has not been synchronized for a fixed period of time since the current time.

[0113] Delete invalid data: For the unsynchronized file data found in the query, it is considered invalid data and deleted from the file synchronization table. This can free up database space, clean up invalid data, and avoid data accumulation leading to database performance degradation.

[0114] The embodiments of the present application can maintain the health of the database, improve the stability and performance of the database, and ensure the normal operation of the file synchronization function by regularly cleaning up invalid data.

[0115] In order to further analyze and explain the file synchronization method proposed in this application, refer to Figures 3 to 6 , and the following examples.

[0116] The embodiment of the present application specifically proposes a method for synchronizing uploaded files between distributed service instances, which can synchronize files between microservices deployed on different server nodes through the database connected to the bottom layer of the microservices without the need for direct port connection. The specific scheme is as follows:

[0117] (1) Create a file synchronization table in the business database with the following structure:

[0118] id: primary key, auto-increment;

[0119] data_type: data type of this item;

[0120] server_info: unique identifier of each service node;

[0121] include_file: file list / required file;

[0122] file_byte: the specific file, which can be clob or blob;

[0123] inser_time: data insertion time.

[0124] (2) File list upload: Develop a scheduled task in the service. Each node saves the node ID and the names of the files it contains into the database. The data type is marked as a file list, such as Figure 3 shown.

[0125] (3) Request missing files: Query the file name list of other nodes and compare it with the file name list of this node. If it is found that this node lacks files owned by other nodes, add a new demand data request to the database, including the unique identifier of this node, the required file, and the file request status, such as Figure 4 shown.

[0126] (4) Upload the required file: query the required file data of other nodes. If the file is included on this node, the file can be saved in the file_byte field of the data in the database. At the same time, the file synchronization status is marked as the file synchronization status, that is, the file has been filled, and the file insertion time insert_time is saved, such as Figure 5 shown.

[0127] (5) Synchronize missing files: Query the file data requested by this node. If the data has been marked as file synchronization status, the data can be downloaded to this node. After the transfer is completed, the data needs to be deleted to save database space. Figure 6 shown.

[0128] (6) Cleaning invalid data: In scheduled tasks, query the file data that has not been synchronized for a fixed time interval from the current time according to actual needs, and delete the data to save database space.

[0129] The method for synchronizing files uploaded between distributed service instances provided in the embodiment of the present application uses the database as the core of information exchange, synchronizes files between different nodes on the database, and synchronizes files on different server nodes through the database. The nodes are not directly connected to each other and need to be connected to the same database or database cluster. Currently, the underlying microservices all use databases. Therefore, there is no need to add other middleware or introduce other dependencies when using the database to synchronize data, which reduces the complexity of development. This method avoids the need for network connectivity between nodes, reduces network access and debugging operations, and reduces workload. This method does not limit the number of nodes and has strong scalability. After the number of nodes is increased, this function can be used without any sense of use and no special configuration is required.

[0130] Figure 7 This is one of the structural diagrams of the file synchronization device provided by this application, refer to Figure 7 An embodiment of the present application provides a file synchronization device, including a file upload module 701, a file comparison module 702, a file request module 703 and a first file synchronization module 704.

[0131] The file upload module 701 is used to upload a first file name list of a first node to a database;

[0132] A file comparison module 702 is used to compare the first file name list with the second file name list uploaded by each second node in the database to determine the missing files in the first file name list; the first node and the second node represent service instances in the distributed system;

[0133] A file request module 703, configured to add a new data request to the database according to the missing file;

[0134] The first file synchronization module 704 is used to download the missing file uploaded by the second node from the database according to the data request, so as to synchronize the missing file to the first node.

[0135] The file synchronization device provided by the embodiment of the present application uploads a first file name list of the first node to the database; compares the first file name list with the second file name list uploaded by each second node in the database to determine the missing files in the first file name list; the first node and the second node represent the service instance in the distributed system; according to the missing files, a new data request is added to the database; according to the data request, the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node. The embodiment of the present application uses the database as the core of information exchange, and there is no need for direct connection between the nodes, avoiding the need for network connectivity between nodes. The indirect communication method helps to enhance network security, reduce the modification of network policies and the adjustment of firewalls, thereby improving the efficiency and quality of file synchronization between nodes in the distributed system.

[0136] In one embodiment, the file request module 703 is further used to:

[0137] Determine a first file synchronization state of the missing file; the first file synchronization state indicates that the missing file is in a file request state;

[0138] The data request is newly added in the database; the data request includes the node identifier of the first node, the file name of the missing file and the synchronization status of the first file.

[0139] In one embodiment, the first file synchronization module 704 is further configured to:

[0140] Querying missing files requested by the data request;

[0141] If the file synchronization state of the missing file is identified as a second file synchronization state, the missing file uploaded by the second node is downloaded from the database; the second file synchronization state indicates that the missing file is in a file response state.

[0142] In one embodiment, the file upload module 701 is further used to:

[0143] Querying the requirement files of each second node;

[0144] If the first file name list includes the required file, the required file is saved to the database, and the file synchronization state of the required file is modified and the insertion time of the required file is stored.

[0145] Figure 8 This is the second structural diagram of the file synchronization device provided by this application, refer to Figure 8 An embodiment of the present application provides a file synchronization device, including a first receiving module 801, a second receiving module 802 and a second file synchronization module 803.

[0146] A first receiving module 801 is used to receive a new data request from a first node; the data request is used to request a missing file of the first node;

[0147] A second receiving module 802 is used to receive the missing file saved by the second node based on the data request;

[0148] The second file synchronization module 803 is used to receive a download request for the missing file sent by the first node, and send the missing file to the first node according to the download request, so as to synchronize the missing file to the first node.

[0149] The file synchronization device provided in the embodiment of the present application receives a new data request from the first node; the data request is used to request the missing file of the first node; receives the missing file saved by the second node based on the data request; receives the download request of the missing file sent by the first node, and sends the missing file to the first node according to the download request, so as to synchronize the missing file to the first node. The embodiment of the present application uses the database as the core of information exchange, and there is no need for direct connection between the nodes, avoiding the need for network interconnection between nodes. The indirect communication method helps to enhance network security, reduce the modification of network policies and the adjustment of firewalls, thereby improving the efficiency and quality of file synchronization between nodes in the distributed system.

[0150] In one embodiment, the first receiving module 801 is further configured to:

[0151] If the missing file uploaded by the second node is not downloaded by the first node within a set time, the missing file uploaded by the second node is deleted.

[0152] In one embodiment, a file synchronization table is established in the database; the file synchronization table is used to store a first file name list of the first node and a second file name list of the second node in the distributed system; the first node and the second node represent service instances in the distributed system.

[0153] Fig. 9 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9 As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930 and a communication bus 940, wherein the processor 910, the communication interface 920 and the memory 930 communicate with each other through the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute the file synchronization method, which includes:

[0154] Upload the first file name list of the first node to the database;

[0155] Comparing the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system;

[0156] Adding a new data request to the database according to the missing file;

[0157] According to the data request, the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node.

[0158] Alternatively, the processor 910 may call the logic instructions in the memory 930 to execute the file synchronization method, which includes:

[0159] Receive a new data request from a first node, wherein the data request is used to request a missing file of the first node;

[0160] receiving the missing file saved by the second node based on the data request;

[0161] A download request for the missing file sent by the first node is received, and the missing file is sent to the first node according to the download request, so as to synchronize the missing file to the first node.

[0162] In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0163] On the other hand, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the file synchronization method provided by the above methods, the method comprising:

[0164] Upload the first file name list of the first node to the database;

[0165] Comparing the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system;

[0166] Adding a new data request to the database according to the missing file;

[0167] According to the data request, the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node.

[0168] Alternatively, when the computer program is executed by a processor, the file synchronization method provided by the above methods is implemented, and the method includes:

[0169] Receive a new data request from a first node, wherein the data request is used to request a missing file of the first node;

[0170] receiving the missing file saved by the second node based on the data request;

[0171] A download request for the missing file sent by the first node is received, and the missing file is sent to the first node according to the download request, so as to synchronize the missing file to the first node.

[0172] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0173] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0174] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A file synchronization method, characterized in that: include: Upload the first file name list of the first node to the database; Comparing the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system; Adding a new data request to the database according to the missing file; According to the data request, the missing file uploaded by the second node is downloaded from the database to synchronize the missing file to the first node.

2. The file synchronization method according to claim 1, characterized in that: The adding a new data request in the database according to the missing file comprises: Determine a first file synchronization state of the missing file; the first file synchronization state indicates that the missing file is in a file request state; The data request is newly added in the database; the data request includes the node identifier of the first node, the file name of the missing file and the synchronization status of the first file.

3. The file synchronization method according to claim 1, characterized in that: The downloading, from the database, the missing file uploaded by the second node according to the data request includes: Querying missing files requested by the data request; If the file synchronization state of the missing file is identified as a second file synchronization state, the missing file uploaded by the second node is downloaded from the database; the second file synchronization state indicates that the missing file is in a file response state.

4. The file synchronization method according to claim 1, characterized in that: After uploading the first file name list of the first node to the database, the method further includes: Querying the requirement files of each second node; If the first file name list includes the required file, the required file is saved to the database, and the file synchronization state of the required file is modified and the insertion time of the required file is stored.

5. A file synchronization method, characterized in that: include: Receive a new data request from the first node; The data request is used to request the missing file of the first node; receiving the missing file saved by the second node based on the data request; A download request for the missing file sent by the first node is received, and the missing file is sent to the first node according to the download request, so as to synchronize the missing file to the first node.

6. The file synchronization method according to claim 5, characterized in that: After receiving the data request newly added by the first node, the method further includes: If the missing file uploaded by the second node is not downloaded by the first node within a set time, the missing file uploaded by the second node is deleted.

7. The file synchronization method according to claim 5, characterized in that: A file synchronization table is established in the database; the file synchronization table is used to store a first file name list of the first node and a second file name list of the second node in the distributed system; the first node and the second node represent service instances in the distributed system.

8. A file synchronization device, characterized in that: include: A file upload module, used for uploading a first file name list of a first node to a database; A file comparison module, configured to compare the first file name list with the second file name list uploaded by each second node in the database to determine missing files in the first file name list; the first node and the second node represent service instances in a distributed system; A file request module, configured to add a new data request to the database according to the missing file; a first file synchronization module, configured to download the missing file uploaded by the second node from the database according to the data request, so as to synchronize the missing file to the first node; Alternatively, the file synchronization device comprises: A first receiving module, configured to receive a new data request from a first node; the data request is used to request a missing file of the first node; A second receiving module, configured to receive the missing file saved by the second node based on the data request; The second file synchronization module is used to receive a download request for the missing file sent by the first node, and send the missing file to the first node according to the download request, so as to synchronize the missing file to the first node.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the file synchronization method as described in any one of claims 1 to 4 is implemented, or when the processor executes the program, the file synchronization method as described in any one of claims 5 to 7 is implemented.

10. 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, it implements the file synchronization method as described in any one of claims 1 to 4, or when the computer program is executed by a processor, it implements the file synchronization method as described in any one of claims 5 to 7.