WO2023231836A1 - 一种文件同步方法、装置、设备及存储介质 - Google Patents

一种文件同步方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2023231836A1
WO2023231836A1 PCT/CN2023/095772 CN2023095772W WO2023231836A1 WO 2023231836 A1 WO2023231836 A1 WO 2023231836A1 CN 2023095772 W CN2023095772 W CN 2023095772W WO 2023231836 A1 WO2023231836 A1 WO 2023231836A1
Authority
WO
WIPO (PCT)
Prior art keywords
synchronized
file
information
synchronization
subnet
Prior art date
Application number
PCT/CN2023/095772
Other languages
English (en)
French (fr)
Inventor
罗杰
石帅
郑文文
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023231836A1 publication Critical patent/WO2023231836A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Definitions

  • the present application relates to the field of data synchronization technology, and specifically to a file synchronization method, device, equipment and storage medium.
  • Hydraulic support equipment is a device that uses hydraulic pressure to achieve lifting, forward movement, etc., and perform roof support. It is a key equipment for comprehensive mechanized mining of coal mines and is of great significance to modern coal mine production.
  • the centralized control center equipment can synchronize files to multiple hydraulic support equipment. For example, when a software upgrade package for the hydraulic support equipment is developed or model configuration of the hydraulic support equipment needs to be performed, the centralized control center equipment It is necessary to send software upgrade packages or model configuration files to multiple hydraulic support equipment to realize the upgrade and configuration of multiple hydraulic support equipment.
  • the centralized control center equipment can also synchronize other files to the hydraulic support equipment. Among them, for multiple hydraulic support equipment of the same model, the files that need to be synchronized are the same.
  • the coal mine industrial network contains multiple subnets.
  • the centralized control center equipment and multiple hydraulic support equipment are in different subnets.
  • the centralized control center equipment is in subnet 1, and multiple hydraulic support equipment are in subnet 1.
  • the rack device is in subnet 2. Therefore, when the centralized control center equipment synchronizes files to the hydraulic support equipment, it needs to transmit the files that need to be synchronized across subnets to multiple hydraulic support equipment.
  • the transferred data packets (files that need to be synchronized) need to pass through multiple routing nodes.
  • the routing node needs to process the transmitted data packets, for example addressing, data encapsulation and data decapsulation, etc., so transferring files that need to be synchronized across subnets takes a long time and is inefficient.
  • the centralized control center equipment needs to synchronize the same file to multiple hydraulic support equipment, the centralized control center equipment needs to send the files that need to be synchronized to each hydraulic support equipment, resulting in a larger load on the centralized control center equipment, further increasing This reduces the time required for file synchronization and reduces the efficiency of file synchronization.
  • the present application provides a file synchronization method, device, equipment and storage medium to help solve the problem of low file synchronization efficiency in the prior art.
  • embodiments of the present application provide a file synchronization method, which is applied to a first device.
  • the method include:
  • the record information of the synchronization file and determine whether there is the subnet information of the second device and the file information that has been synchronized based on the subnet information of the device to be synchronized and the file information to be synchronized in the synchronization file;
  • the subnet information and synchronized file information of the second device are the same as the subnet information and file information to be synchronized of the device to be synchronized;
  • the record information of the synchronized file is used to record the completed file synchronization.
  • a synchronization control instruction is sent to the second device; the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • a possible implementation method for the first aspect also includes:
  • the record information of the synchronized file is updated according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • the method before obtaining the subnet information of the device to be synchronized and the file information to be synchronized, the method further includes:
  • synchronization file request message sent by the device to be synchronized;
  • the synchronization file request message carries subnet information and file information to be synchronized;
  • the obtaining the subnet information of the device to be synchronized and the file information to be synchronized includes:
  • the synchronization file request message also carries file transfer port information of the device to be synchronized; the file transfer port information is used to indicate the port used by the device to be synchronized for file transmission.
  • a possible implementation manner of the first aspect, before sending the synchronization control instruction to the second device, further includes:
  • the synchronization control instruction carries file transfer port information of the device to be synchronized.
  • sending a synchronization control instruction to the second device includes:
  • the devices to be synchronized include at least two;
  • Determining the target second device based on the load information of the at least two second devices includes:
  • the first device and the device to be synchronized belong to different subnets.
  • a possible implementation method for the first aspect also includes:
  • the record information of the synchronized file is updated according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • embodiments of the present application provide a file synchronization method, applied to a second device, and the method includes:
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized;
  • the synchronization control instruction determine the file information to be synchronized and the device to be synchronized;
  • a possible implementation method for the second aspect also includes:
  • the synchronization control instruction carries file transfer port information of the device to be synchronized; the file transfer port information is used to indicate the port used by the device to be synchronized for file transmission;
  • Sending the file to be synchronized to the device to be synchronized includes:
  • embodiments of the present application provide a file synchronization method, including:
  • a possible implementation of the third aspect, before receiving the file to be synchronized also includes:
  • the synchronization file request message carries subnet information and file information to be synchronized
  • the synchronization file request message also carries file transfer port information of the device to be synchronized; the file transfer port information is used to indicate the port used by the device to be synchronized for file transmission.
  • a possible implementation of the third aspect, before receiving the file to be synchronized also includes:
  • receiving files to be synchronized includes:
  • the file to be synchronized is received through the port indicated by the file transfer port information.
  • embodiments of the present application provide a file synchronization device, including:
  • the acquisition unit is used to obtain the subnet information of the device to be synchronized and the file information to be synchronized;
  • a processing unit configured to obtain the record information of the synchronization file, and determine whether the subnet information of the second device exists and has been completed based on the subnet information of the device to be synchronized and the file information to be synchronized in the synchronization file. Synchronized file information; wherein the subnet information of the second device and the synchronized file information are the same as the subnet information of the device to be synchronized and the file information to be synchronized; the record information of the synchronized file is used for Record the subnet information of the device that has completed file synchronization and the file information that has completed synchronization;
  • the processing unit is further configured to, if present, send a synchronization control instruction to the second device; the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the file synchronization device further includes:
  • a receiving unit configured to receive a synchronization completion response message returned by the second device
  • the processing unit is also configured to update the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • the receiving unit is further configured to receive a synchronization file request message sent by the device to be synchronized; the synchronization file request message carries subnet information and file information to be synchronized;
  • the processing unit is also configured to send a synchronization file response message to the device to be synchronized;
  • the obtaining unit is specifically configured to obtain the subnet information of the device to be synchronized and the file information to be synchronized from the synchronization file request message.
  • the processing unit is further configured to send a synchronization file notification message to the device to be synchronized;
  • the receiving unit is also configured to receive a synchronization file response message sent by the device to be synchronized; the synchronization file response message carries the file transmission port information of the device to be synchronized.
  • the processing unit is specifically configured to, if there is one, subnet information of at least two second devices and file information that has been synchronized and subnet information of the device to be synchronized. and the file information to be synchronized are the same, then obtain the load information of the at least two second devices;
  • the processing unit is specifically configured to determine, for each of the at least two devices to be synchronized, based on the load information of the at least two second devices, each device to be synchronized.
  • the target second device corresponding to the synchronization device.
  • the processing unit is further configured to, if it does not exist, obtain the file to be synchronized based on the file information to be synchronized, and send the file to be synchronized to the device to be synchronized;
  • the processing unit is also configured to update the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • embodiments of the present application provide a file synchronization device, including:
  • a receiving unit configured to receive a synchronization control instruction; the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized;
  • a processing unit configured to determine the file information to be synchronized and the device to be synchronized according to the synchronization control instruction
  • the processing unit is also configured to obtain the file to be synchronized according to the file information to be synchronized, and send the file to be synchronized to the device to be synchronized.
  • the processing unit is also configured to send a synchronization completion response message to the first device.
  • the processing unit is specifically configured to send the file to be synchronized to the device to be synchronized through a port indicated by the file transfer port information.
  • embodiments of the present application provide a file synchronization device, including:
  • the receiving unit is used to receive files to be synchronized
  • a processing unit configured to update corresponding files according to the files to be synchronized.
  • the processing unit is further configured to send a synchronization file request message to the first device; the synchronization file request message carries subnet information and file information to be synchronized;
  • the receiving unit is also configured to receive a synchronization file response message sent by the first device.
  • the receiving unit is further configured to receive a synchronization file notification message sent by the first device;
  • the processing unit is further configured to send a synchronization file response message to the first device, where the synchronization file response message carries file transfer port information of the device to be synchronized.
  • the processing unit is specifically configured to receive the file to be synchronized through the port indicated by the file transfer port information.
  • embodiments of the present application provide an electronic device, including:
  • a processor and a memory stores a computer program.
  • the electronic device causes the electronic device to execute any one of the first aspect, any one of the second aspect, or any one of the third aspect. method described.
  • inventions of the present application provide a storage medium.
  • the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any one of the first aspect or the second aspect.
  • the first device when the first device needs to synchronize a file to the device to be synchronized, the first device obtains the subnet information of the device to be synchronized and the file information to be synchronized; obtains the record information of the synchronized file, and based on Whether the subnet information of the device to be synchronized and the file information to be synchronized include the subnet information of the second device and the file information that has been synchronized when determining the record information of the synchronized file; among them, the subnet information of the second device and the file information that has been synchronized have been completed.
  • the synchronized file information is the same as the subnet information of the device to be synchronized and the file information to be synchronized; the record information of the synchronized file is used to record the subnet information of the device that has completed file synchronization and the file information that has completed the synchronization. If it exists, a synchronization control instruction is sent to the second device; the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized. That is to say, the record information of the synchronization file records the subnet information of the device that has completed the file synchronization and the file information that has completed the synchronization.
  • the first device can obtain the subnet of the device to be synchronized.
  • Network information and file information to be synchronized and obtain record information of synchronized files.
  • the record information of the synchronized file it is detected whether there is the subnet information of the second device and the file information that has completed synchronization.
  • the subnet information of the second device and The file information that has been synchronized is the same as the subnet information of the device to be synchronized and the file information to be synchronized.
  • the first device can send a synchronization control instruction to the second device, so that the second device The second device transmits the file to be synchronized to the device to be synchronized.
  • the first device needs to synchronize files to the device to be synchronized, if the subnet to which the first device belongs is different from the subnet to which the device to be synchronized belongs, and the subnet to which the second device and the device to be synchronized belong are the same, And the second device has synchronized the files that need to be synchronized by the device to be synchronized, then the first device can schedule the second device to send the files to be synchronized to the device to be synchronized.
  • the speed at which the second device transmits the file to be synchronized to the device to be synchronized is faster. Faster and more efficient.
  • Figure 1 is a schematic diagram of a file synchronization scenario provided by an embodiment of the present application.
  • Figure 2 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application.
  • Figure 3 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application.
  • Figure 4 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application.
  • Figure 5 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application.
  • Figure 6 is a schematic diagram of another file synchronization scenario provided by an embodiment of the present application.
  • Figure 7 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application.
  • Figure 8 is a schematic structural diagram of a file synchronization device provided by an embodiment of the present application.
  • Figure 9 is a schematic structural diagram of another file synchronization device provided by an embodiment of the present application.
  • Figure 10 is a schematic structural diagram of another file synchronization device provided by an embodiment of the present application.
  • Figure 11 is a schematic structural diagram of another file synchronization device provided by an embodiment of the present application.
  • Figure 12 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • P2P Peer-to-Peer
  • P2P network is a peer-to-peer network that does not have a central server and relies on user group nodes for information exchange.
  • each user node in the P2P network is both a client and a server, and can serve as a server to provide services to other nodes at the same time. Data can be shared between any two devices in a P2P network.
  • NAT Network Address Translation
  • NAT traversal involves a common problem in TCP/IP networks, that is, the problem of establishing connections between hosts in a private TCP/IP network using NAT devices.
  • Router It is a hardware device that connects two or more networks. It acts as a gateway between networks. It is a network device that reads the address in each data packet and then decides how to transmit it. It can understand different protocols, such as the Ethernet protocol used by a certain local area network, and the TCP (Transmission Control Protocol)/IP protocol used by the Internet. In this way, the router can analyze the destination addresses of data packets from various types of networks, convert the addresses of non-TCP/IP networks into TCP/IP addresses, or vice versa; and then route each data packet according to the selected routing algorithm. Deliver the best route to the specified location. Therefore, the router can analyze the destination addresses of data packets from various types of networks, convert the addresses of non-TCP/IP networks into TCP/IP addresses, or vice versa; and then route each data packet according to the selected routing algorithm. Deliver the best route to the specified location. Therefore, the router can
  • a TCP/IP network connects to the Internet.
  • Switch means “switch” and is a network device used for forwarding electrical (optical) signals. It can provide an exclusive electrical signal path for any two network nodes connected to the switch. The most common switch is an Ethernet switch.
  • Hydraulic support equipment is a device that uses hydraulic pressure to achieve lifting, forward movement, etc., and perform roof support. It is a key equipment for comprehensive mechanized mining of coal mines and is of great significance to modern coal mine production.
  • the centralized control center equipment can synchronize files to multiple hydraulic support equipment. For example, when a software upgrade package for the hydraulic support equipment is developed or model configuration of the hydraulic support equipment needs to be performed, the centralized control center equipment It is necessary to send software upgrade packages or model configuration files to multiple hydraulic support equipment to realize the upgrade and configuration of multiple hydraulic support equipment.
  • the centralized control center equipment can also synchronize other files to the hydraulic support equipment. For multiple hydraulic support equipment of the same model, the files that need to be synchronized are the same.
  • the coal mine industrial network contains multiple subnets, as shown in Figure 1.
  • the centralized control center equipment and multiple hydraulic support equipment are in different subnets.
  • the centralized control center equipment is in a subnet.
  • multiple hydraulic support equipment are located in subnet 2. Therefore, when the centralized control center equipment synchronizes files to the hydraulic support equipment, it needs to transmit the files that need to be synchronized across subnets to multiple hydraulic support equipment.
  • the transferred data packets (files that need to be synchronized) need to pass through multiple routing nodes.
  • the routing node needs to process the transmitted data packets, for example Addressing, data encapsulation and data Decapsulation, etc., as shown in Figure 1, when the centralized control center device synchronizes files to the hydraulic support device 1, the data packet will arrive from the centralized control center device to the switch in subnet 1, and then to the router, and then the router will forward the data packet to the switch of subnet 2, and the switch of subnet 2 transmits the data packet to hydraulic support device 1. Therefore, file synchronization across subnets takes a long time and is inefficient.
  • the centralized control center equipment needs to synchronize the same file to hydraulic support equipment 1, hydraulic support equipment 2...hydraulic support equipment n, the centralized control center equipment needs to send the files that need to be synchronized to each hydraulic support equipment separately, resulting in centralized control
  • the load on the central device is relatively large, which further increases the time required for file synchronization and reduces the efficiency of file synchronization.
  • file synchronization is achieved through peer-to-peer technology (Peer-to-Peer, P2P).
  • P2P technology can be used to directly share content and distribute data between computers without going through a server, allowing data to be shared between any two machines on the Internet. become possible.
  • the centralized control center equipment and the equipment required for coal mining are all equipment in the P2P network.
  • P2P is usually used for communication between two devices across subnets. Since there is usually NAT between cross-subnet devices, Isolation, so it is necessary to obtain the NAT type through NAT detection, and then implement NAT traversal based on the results of the NAT detection to establish a connection path between devices for file transfer.
  • NAT traversal is complex and time-consuming, resulting in low efficiency in establishing connection paths between devices, thus making file transfer efficiency low.
  • NAT detection may fail, resulting in NAT traversal being unable to be achieved, which in turn causes the connection path between devices to be unable to be established, and thus file transfer cannot be performed.
  • P2P network if the two devices that need to transfer files are in the same subnet, then using P2P technology cannot achieve Layer 2 transmission between the two devices in the same subnet. NAT gateway is still required to intervene, resulting in transmission efficiency reduce.
  • NAT traversal between devices will affect the efficiency of file synchronization, and even cause file transfer failure when NAT detection fails.
  • it is also necessary to perform NAT traversal cannot communicate directly, thus affecting the efficiency of file transfer between devices in the same subnet.
  • embodiments of the present application provide a file synchronization method, which is applied to the first device.
  • the method includes: obtaining the subnet information of the device to be synchronized and the file information to be synchronized; obtaining the record information of the synchronized file, and Determine whether there is subnet information of the second device and completed synchronized file information based on the subnet information of the device to be synchronized and the file information to be synchronized in the synchronized file; wherein, the subnet information of the second device and the completed synchronized file information are
  • the synchronized file information is the same as the subnet information of the device to be synchronized and the file information to be synchronized; the record information of the synchronized file is used to record the subnet information of the device that has completed file synchronization and the file information that has completed the synchronization.
  • a synchronization control instruction is sent to the second device; the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized. That is to say, the record information of the synchronization file records the subnet information of the device that has completed the file synchronization and the file information that has completed the synchronization.
  • the first device can obtain the subnet of the device to be synchronized. Network information and file information to be synchronized, and obtain record information of synchronized files.
  • the subnet information of the device to be synchronized and the file information to be synchronized in the record information of the synchronized file, it is detected whether there is the subnet information of the second device and the file information that has completed synchronization.
  • the subnet of the second device The information and the file information that has been synchronized are the same as the subnet information of the device to be synchronized and the file information to be synchronized. If it exists, it means that the second device and the first device are in the same subnet, and the second device stores files that need to be synchronized by the device to be synchronized. Therefore, the first device can send a synchronization control instruction to the second device, so that the second device can The second device transmits the file to be synchronized to the device to be synchronized.
  • the first device needs to synchronize files with the device to be synchronized, if the subnet to which the first device belongs is the same as the one to be synchronized, If the synchronization device belongs to different subnets, but the second device and the device to be synchronized belong to the same subnet, and the second device has synchronized the files that the device to be synchronized needs to synchronize, then the first device can schedule the second device to send the device to be synchronized. Sync files.
  • the speed at which the second device transmits the file to be synchronized to the device to be synchronized is faster. Faster and more efficient. The details are explained below.
  • FIG. 2 is a schematic flow chart of a file synchronization method provided by an embodiment of the present application. The method is applied to the first device and includes the following steps:
  • Step S201 Obtain the subnet information of the device to be synchronized and the file information to be synchronized.
  • the first device manages the devices in each subnet.
  • the first device manages the files configured in each device in each subnet, and is responsible for upgrading the files configured in each device. Updates etc.
  • When technicians develop update files such as software upgrade packages and device model configuration files, these update files need to be synchronized to the corresponding devices so that the corresponding devices can update the files saved in them.
  • Technical personnel cannot directly synchronize the update files to the corresponding devices.
  • the first device that manages the devices in each subnet needs to be synchronized.
  • a file that needs to be updated by a device can be called a file to be synchronized
  • a device that needs to be updated with a file can be called a device that needs to be synchronized.
  • the first device obtains the update file of the device to be synchronized, it can actively synchronize the update file to each device configured with the update file.
  • Each device configured with the update file may also request the first device to synchronize the update file. That is, when the first device obtains the file to be synchronized, it can actively send the file to be synchronized to each device to be synchronized that is configured with the file to be synchronized.
  • Each device configured with the file to be synchronized may also request the first device to synchronize the file to be synchronized.
  • the first device determines that it needs to synchronize the file to be synchronized with the device to be synchronized, in order to improve the synchronization efficiency, a device that is located in the same subnet as the device to be synchronized and has completed synchronization of the file to be synchronized can perform the synchronization for the device to be synchronized. Synchronize. Based on this, the first device needs to obtain the subnet information of the device to be synchronized and the file information to be synchronized. That is, you need to first obtain the subnet in which the device to be synchronized is located, and which file needs to be synchronized by the device to be synchronized.
  • the other devices when other devices are connected to the first device, the other devices need to report device-related information such as files configured in the other devices, identification information of the other devices, and subnet information to which the other devices belong, to the first device, so that The first device manages other devices.
  • the first device can store device-related information reported by other devices.
  • the first device actively synchronizes files to be synchronized with other devices, first the first device can obtain the files to be synchronized from other devices or can receive files to be synchronized sent by technicians.
  • the file information of the file to be synchronized can be determined, such as the file name, file size and other information of the file to be synchronized.
  • the first device can determine the device to be synchronized corresponding to the file to be synchronized based on the configuration files in other devices recorded in the stored device-related information, and determine the subnet information of the device to be synchronized based on the device-related information. That is, the first device obtains the subnet information of the device to be synchronized and the file information of the file to be synchronized.
  • the other device can carry its subnet information and the file information of the file to be synchronized in the request message, and the first device can obtain the file information of the device to be synchronized from the request message of the other device. Subnet information and file information to be synchronized.
  • the subnet information of the device to be synchronized and the file information to be synchronized can also be obtained through other methods, and this application does not limit this.
  • the first device may obtain the subnet information of the device to be synchronized through the third device based on the obtained file information to be synchronized.
  • the third device may store subnet information of each device, Or the third device can obtain the subnet information from the device to be synchronized and return it to the first device.
  • the first device may actively synchronizing files to the device to be synchronized, assuming that the file to be synchronized is the configuration file of the hydraulic support device.
  • the first device may receive the file of the software configuration upgrade package of the hydraulic support device sent by other devices, and the first device may determine that the file to be synchronized is the hydraulic support.
  • the device's configuration file may be used to determine that the file to be synchronized is the hydraulic support.
  • the first device can determine from the stored device-related information that the device to be synchronized corresponding to the file to be synchronized (software upgrade package of the hydraulic support device) is the hydraulic support device 1, and can also determine the subnet of the hydraulic support device 1 Information, for example, the subnet information of the hydraulic support equipment 1 may be that the subnet to which the hydraulic support equipment belongs is subnet 2. In this way, the first device can obtain the subnet information of the device to be synchronized and the file information to be synchronized.
  • the first device and the device to be synchronized belong to different subnets.
  • a network can be divided into multiple subnets.
  • the first device is a device that centrally manages other devices in each subnet.
  • the subnet to which the first device belongs is different from the subnet to which the device managed by the first device belongs.
  • the first device needs to transmit the files to be synchronized across subnets to the device to be synchronized, resulting in low file synchronization efficiency.
  • the subnet to which the first device belongs is subnet 1
  • the subnet to which device A belongs is subnet 2
  • the subnet to which device B belongs is subnet 3. If the first device directly synchronizes files to device A or device B, it needs to cross Subnet file transfer, but the process of file transfer across subnets is more complicated and the transfer efficiency is low.
  • Step S202 Obtain the record information of the synchronization file, and determine whether there is subnet information of the second device and synchronized file information in the record information of the synchronization file based on the subnet information of the device to be synchronized and the file information to be synchronized.
  • the subnet information of the second device and the file information that has been synchronized are the same as the subnet information of the device to be synchronized and the file information to be synchronized.
  • the record information of synchronized files is used to record the subnet information of the device that has completed file synchronization and the file information that has completed synchronization.
  • each time the first device completes file synchronization it will record the subnet information of the synchronized device and the synchronized file information into the record information of the synchronized file, which is the record of the synchronized file.
  • the information includes the subnet information of the device that has completed file synchronization and the file information that has completed synchronization.
  • the first device can find a second device that is in the same subnet as the device to be synchronized and has completed synchronization of the same file as the file to be synchronized, and the second device performs the file synchronization for the device to be synchronized. synchronization to achieve file synchronization within the same subnet and improve the efficiency of file synchronization. Based on this, the first device can obtain the recorded information of the recorded synchronization file. Among them, the record information of the synchronized file includes the subnet information of the device that has completed the file synchronization and the file information that has completed the synchronization.
  • the first device can obtain the record information of the synchronization file that records the subnet information of the device that has completed file synchronization and the file information of the file that the device has completed synchronization.
  • the first device determines whether the subnet information of the second device and the file information that has been synchronized exist in the record information of the synchronization file based on the subnet information of the device to be synchronized and the file information to be synchronized. That is to say, the first device can determine whether there is subnet information that is the same as the subnet information of the device to be synchronized in the record information of the synchronization file based on the subnet information of the device to be synchronized and the file information to be synchronized, and the synchronization has been completed.
  • the file information of the second device is the same as the file information of the file to be synchronized of the device to be synchronized, and the file information of the second device that has been synchronized has been completed.
  • the subnet information of the second device is the same as the subnet information of the device to be synchronized. If the information is the same, that is, the second device and the device to be synchronized are in the same subnet.
  • Step S203 If it exists, send a synchronization control instruction to the second device.
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the first device determines that the subnet information of the second device and the file information that has completed synchronization exist in the record information of the synchronization file, it means that the subnet to which the second device belongs and the subnet to which the device to be synchronized belong The same means that the second device and the first device are in the same subnet, and the second device has synchronized the files to be synchronized with the device to be synchronized.
  • the first device may send a synchronization control instruction to the second device.
  • the synchronization control instruction may include identification information of the device to be synchronized and file information to be synchronized, so that when the second device receives the synchronization control instruction, Transmit files to be synchronized to the device to be synchronized according to the synchronization control instructions. That is to say, when the first device needs to synchronize a file to be synchronized with the device to be synchronized, if the first device determines through the record information of the synchronization file that the subnet to which the second device belongs is the same as the subnet to which the device to be synchronized belongs, and the second device The file to be synchronized has been synchronized, then the first device can send a synchronization control instruction to the second device.
  • the second device Since the file to be synchronized has been stored in the second device, when the second device receives the synchronization control instruction, it can directly send the synchronization control instruction to the device to be synchronized. Transfer files to be synchronized. In this way, after the first device determines that the subnet to which the second device belongs is the same as the subnet to which the device to be synchronized belongs, and the second device has synchronized the file to be synchronized, it sends a synchronization control instruction to the second device, so that the second device The device transmits the files to be synchronized to the device to be synchronized, thereby completing file synchronization.
  • the subnet information of the second device is the same as the subnet information of the device to be synchronized, that is, the second device and the device to be synchronized are in the same subnet, and files can be transferred directly between devices in the same subnet without going through multiple routes.
  • the transmission speed is faster, and the first device and the device to be synchronized belong to different subnets, and the process of cross-subnet file transfer is more complicated. Therefore, transferring the file to be synchronized from the second device to the device to be synchronized can improve the efficiency of file synchronization.
  • the first device is a centralized control center device, and the subnet to which the first device belongs is subnet 1.
  • the first device obtains the software upgrade package of the hydraulic support equipment.
  • the software upgrade package of the hydraulic support equipment is the file to be synchronized.
  • the file information of the file to be synchronized is file B. Since the device-related information stored by the first device includes identification information of each device, subnet information of the device, identification information of files in the device, etc., for example, hydraulic support device C, the file configured in it is file B, which belongs to The subnet is subnet 2; the file configured in transport machine D is file E, and the subnet it belongs to is subnet 3.
  • the first device can determine that the device to be synchronized corresponding to the file information to be synchronized is the hydraulic support device C, and the subnet information of the hydraulic support device C is subnet 2. In this way, the first device can obtain that the subnet information of the device to be synchronized is subnet 2, and the file information to be synchronized is file B. Then, the first device can obtain the record information of the synchronization file.
  • the record information of the synchronization file contains: hydraulic support equipment F, the subnet to which it belongs is subnet 2, and the file that has completed synchronization is file B; the transport machine G, to which the subnet belongs The network is subnet 3, and the file that has been synchronized is file E.
  • the subnet information of the device to be synchronized and the file information to be synchronized determine whether there is the subnet information of the second device and the file information that has completed synchronization in the record information of the synchronization file. Since the record information of the synchronization file records hydraulic pressure
  • the subnet to which bracket device F belongs is subnet 2, and the file that has been synchronized is file B.
  • the first device can determine that the subnet information of the second device and the file information that has been synchronized exist.
  • the second device is It is hydraulic support equipment F.
  • the first device sends a synchronization control instruction to the second device, so that after receiving the synchronization control instruction, the second device transmits the file to be synchronized to the device to be synchronized.
  • sending a synchronization control instruction to the second device includes:
  • the record information of the synchronization file records the subnet information of the device on which the first device has completed the file and the file information of the completed synchronization. Therefore, the first device searches the record information of the synchronization inquiry based on the subnet information of the device to be synchronized and the file information to be synchronized to see whether there is a second device that is the same as the subnet information of the device to be synchronized and the file information to be synchronized.
  • the subnet information and synchronized file information there may be at least two second devices whose subnet information and synchronized file information are the same as those of the device to be synchronized and the file information to be synchronized.
  • the first device can obtain the load information of the at least two second devices.
  • the first device may respectively send request messages to obtain the load information of the at least two second devices, and the at least two second devices inform the first device of the respective load information of the at least two second devices.
  • the first device can also record the number of synchronization tasks assigned to each other device each time it controls other devices to synchronize files with the device to be synchronized, and obtain the number of synchronization tasks assigned to each second device. Obtain load information of at least two second devices. After obtaining the load information of each second device, the first device can determine the target second device corresponding to the device to be synchronized according to the load balancing principle based on the load information of each second device. That is, after obtaining the load information of each second device, the first device can determine the second device with a smaller number of loads recorded in the load information as the target second device corresponding to the device to be synchronized, realizing each The second device is load balanced to improve synchronization efficiency. After determining the target second device, the first device may send a synchronization control instruction to the target second device to control the target second device to synchronize files to be synchronized for the device to be synchronized.
  • the load information of the second device may be information on the number of synchronization tasks that the second device needs to perform file synchronization for other devices.
  • the devices to be synchronized include at least two.
  • determining the target second device based on the load information of at least two second devices includes:
  • a target second device corresponding to each device to be synchronized is determined based on the load information of the at least two second devices.
  • the first device when the first device needs to synchronize files to be synchronized for at least two devices to be synchronized, and it is determined that at least two second devices can synchronize files to be synchronized for at least two devices to be synchronized. , the first device can determine its corresponding target second device for each file to be synchronized. That is, for each of the at least two devices to be synchronized, the first device determines the target second device corresponding to each device to be synchronized based on the load information of the at least two second devices. In this way, it is possible The at least two second devices are load-balanced to synchronize files to be synchronized for at least two synchronization devices.
  • the first device needs to synchronize files to the device to be synchronized, if the subnet to which the first device belongs is different from the subnet to which the device to be synchronized belongs, and the subnet to which the second device and the device to be synchronized belong are the same, and the second device
  • the files that need to be synchronized by the device to be synchronized have been synchronized, and the first device can schedule the second device to send the files to be synchronized to the device to be synchronized.
  • the file to be synchronized is directly transmitted across the subnet to the device to be synchronized compared to the first device, and the file to be synchronized is transmitted from the second device to the device to be synchronized. It's faster and more efficient.
  • file synchronization between the first device and the device to be synchronized can also be implemented through the above method.
  • the first device directly sends the file to be synchronized to the device to be synchronized without causing the problem of low file synchronization efficiency caused by cross-subnet file transfer.
  • sending the files to be synchronized by the first device to multiple devices to be synchronized will cause the operating load of the first device to increase sharply, resulting in slower file synchronization, and also reducing the file synchronization efficiency to a certain extent.
  • the operating load of the first device can be reduced, thereby improving the efficiency of file synchronization.
  • Figure 3 is a schematic flowchart of another file synchronization method provided by an embodiment of the present application. The method is applied to the second device and specifically includes the following steps:
  • Step S301 Receive synchronization control instructions.
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the first device when the first device determines that the subnet information and synchronized file information of the second device are the same as the subnet information and file information of the device to be synchronized, the first device will send a synchronization control to the second device.
  • the synchronization control instruction may include the identification information of the device to be synchronized and the file information to be synchronized.
  • the second device receives the synchronization control instruction and learns that it needs to transmit the file to be synchronized to the device to be synchronized.
  • Step S302 Determine the file information to be synchronized and the device to be synchronized according to the synchronization control instruction.
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the second device can obtain the file information to be synchronized and the device to be synchronized.
  • Step S303 Obtain the file to be synchronized according to the file information to be synchronized, and send the file to be synchronized to the device to be synchronized.
  • the second device after the second device parses the synchronization control instructions and obtains the file information to be synchronized, it can search for its own files based on the file information to be synchronized, and determine the files whose file information is the same as the file information to be synchronized. Treat it as a file to be synchronized. After obtaining the file to be synchronized, the second device can send the file to be synchronized to the determined device to be synchronized.
  • the second device is a device that has completed the file identified by the file information of the file to be synchronized, and the subnet information of the second device is the same as the subnet information of the device to be synchronized, so the second device and the device to be synchronized are in within the same subnet. Therefore, when the second device transmits the files to be synchronized to the device to be synchronized, the files are synchronized within the same subnet, and the file synchronization efficiency is high.
  • Figure 4 is a schematic flowchart of another file synchronization method provided by an embodiment of the present application. The method is applied to the device to be synchronized, and specifically includes the following steps:
  • Step S401 Receive files to be synchronized.
  • the first device may directly send the file to be synchronized to the device to be synchronized, or it may be a second device that belongs to the same subnet as the device to be synchronized and has already synchronized the file to be synchronized.
  • the device to be synchronized may receive the file to be synchronized sent by the first device or the second device.
  • Step S402 Update the corresponding file according to the file to be synchronized.
  • the device to be synchronized can update the corresponding file in the device to be synchronized according to the file to be synchronized to complete the file synchronization.
  • the first device actively sends files to be synchronized to the device to be synchronized
  • the device to be synchronized actively requests the first device for file synchronization.
  • the first device and the second device and information interaction between devices to be synchronized the first device actively sends a file to be synchronized to the device to be synchronized as an example.
  • Figure 5 is a schematic flow chart of another file synchronization method provided by an embodiment of the present application. . Specifically, it includes the following steps:
  • Step S501 The first device obtains the subnet information of the device to be synchronized and the file information to be synchronized.
  • step S201 For details, reference may be made to step S201, which will not be described again here.
  • the device to be synchronized needs to determine the subnet information of at least two devices to be synchronized and the file information of the file to be synchronized.
  • the file information of the file to be synchronized When at least two devices to be synchronized are of the same type, their files to be synchronized are the same.
  • multiple hydraulic support equipment need to upgrade file 1.
  • the file 1 that needs to be upgraded for multiple hydraulic support equipment is the same, which is File 1 that needs to be updated is the same. Therefore, assuming that the first device obtains the software upgrade package file of file 1 of the hydraulic support device, the first device can determine that file 1 needs to be upgraded to multiple hydraulic support devices. At this time, the first device may determine the hydraulic support device that needs to upgrade file 1 as the device to be synchronized, and determine the software upgrade package file of file 1 as the file to be synchronized. At this time, the first device can determine multiple devices to be synchronized.
  • the first device can determine that the subnet information of the multiple devices to be synchronized belongs to subnet 1, assuming that the file information of the file to be synchronized is the file name of the file to be synchronized. At this time, the first device may determine that the file information of the files to be synchronized in the multiple devices to be synchronized is file 1.
  • Step S502 The first device sends a synchronization file notification message to the device to be synchronized, and the device to be synchronized receives the synchronization file notification message.
  • the first device needs to notify the device to be synchronized to perform file synchronization of file 1.
  • the first device sends a synchronization file notification message to the device to be synchronized to inform the device to be synchronized that it needs to perform file synchronization.
  • the synchronization file notification message carries file information of the files to be synchronized, so as to inform the device to be synchronized which files need to be synchronized.
  • the device to be synchronized receives the synchronization file notification message sent by the first device, thereby learning that the first device needs to perform file synchronization on it, and can learn which files the first device needs to synchronize through the file information of the file to be synchronized carried in the synchronization file notification message. files are synchronized.
  • the first device needs to send synchronization file notification messages to the at least two devices to be synchronized respectively.
  • Step S503 The device to be synchronized sends a synchronization file response message to the first device, and the first device receives the synchronization file response message sent by the device to be synchronized.
  • the synchronization file response message carries the file transfer port information of the device to be synchronized.
  • the device to be synchronized after receiving the synchronization file notification message, the device to be synchronized learns that the file needs to be synchronized. Since the device to be synchronized needs to perform file transmission through a specific port, the device to be synchronized will transfer the file of the device to be synchronized. The transmission port information is added to the synchronization file response message, and the synchronization file response message is sent to the first device. The first device receives the synchronization file response message sent by the device to be synchronized, and by parsing the synchronization file response message, learns the file transfer port information used by the device to be synchronized for file transmission.
  • each device to be synchronized when there are at least two devices to be synchronized, each device to be synchronized will return a synchronization file response message to the first device, and the first device receives the synchronization file response message sent by at least two devices to be synchronized. , and obtain the file transfer port information of each device to be synchronized by respectively parsing the synchronization file response messages sent by at least two devices to be synchronized.
  • Step S504 The first device obtains the record information of the synchronization file, and determines whether there is the subnet information of the second device and the completed synchronization in the record information of the synchronization file based on the subnet information of the device to be synchronized and the file information to be synchronized. File information.
  • step S202 For details, reference may be made to step S202, which will not be described again here.
  • steps S505a to S507a, step S508, step S509a and step S510 are executed; when it is determined that the subnet information of the second device does not exist and the synchronization has been completed.
  • step S505b, step S508 and step S510 are executed.
  • Step S505a If it exists, the first device sends a synchronization control instruction to the second device, and the second device receives the synchronization control instruction.
  • the synchronization control instruction carries file transfer port information of the device to be synchronized.
  • the subnet information of the second device and the file information that has been synchronized exist, it means that the subnet information of the second device and the file information that has been synchronized are the same as the subnet information of the device to be synchronized and the file to be synchronized.
  • the information is the same, that is, the second device has completed synchronization with the device to be synchronized, and the second device and the device to be synchronized belong to the same subnet.
  • the synchronization file can be transmitted from the second device to the device to be synchronized.
  • the first device After the first device receives the synchronization file response message sent by the device to be synchronized, it can learn the file transfer port information of the device to be synchronized by parsing the synchronization file response message, and adds the file transfer port information of the device to be synchronized to the synchronization control instruction. .
  • the first device sends a synchronization control instruction to the second device, and the second device receives the synchronization control instruction.
  • the second device can obtain the file transfer port information of the device to be synchronized by parsing the synchronization control instruction.
  • At least two second devices if there are at least two second devices whose subnet information and synchronized file information are the same as those of the device to be synchronized and file information to be synchronized, then at least two second devices are obtained.
  • Load information of the two devices determine the target second device based on the load information of at least two second devices, and send a synchronization control instruction to the target second device.
  • the subnets of at least two second devices will be recorded in the record information of the synchronization file. information and synchronized file information, so the first device will determine the subnet information and synchronized file information of at least two second devices in the record information of the synchronized file.
  • a target second device needs to be selected among the at least two second devices.
  • the first device may obtain load information of at least two second devices, where the load information of the second device may be the number of file synchronization tasks that the second device needs to perform.
  • the first device may obtain the identification information of at least two second devices from the record information of the synchronization file, and send load information acquisition request messages to the at least two second devices respectively based on the identification information of the at least two second devices,
  • the second device After receiving the load information acquisition request message, the second device sends its own load information to the first device.
  • the devices in each subnet can periodically actively send their own load information to the first device.
  • the first device can record the identification information of each device and the load information corresponding to each device.
  • the first device may determine the load information corresponding to each of the at least two second devices in the recorded device load information based on the identification information of the at least two second devices. Alternatively, the first device may record the load information of each device, and the initial value of the load information of each device is zero. Since the file synchronization tasks of the device are all sent to it by the first device, the first device can Sending a file synchronization task once will update the load information of the device corresponding to the file synchronization task. The first device can obtain the load corresponding to each of at least two second devices from the recorded load information of the device. information. Of course, the load information corresponding to the second device can also be obtained through other methods, and this application does not limit this.
  • the target second device may be determined based on the load information of the at least two second devices.
  • the first device can obtain the number of file synchronization tasks that each second device needs to perform based on the load information of at least two second devices.
  • the required The second device that performs file synchronization with a smaller number is determined as the target second device, thereby achieving load balancing between at least two second devices.
  • one second device may be randomly selected as the target second device from the at least two second devices with the same load information. After the target second device is determined, a synchronization control instruction is sent to the target second device.
  • determining the target second device based on the load information of the at least two second devices includes: for each of the at least two devices to be synchronized, The device determines the target second device corresponding to each device to be synchronized based on the load information of at least two second devices.
  • subnet 2 since there may be multiple devices of the same type in each subnet, for example, subnet 2 includes multiple hydraulic support devices, and multiple devices of the same type need to synchronize the same files, so the first device obtains After the file is synchronized, there will be multiple devices that need to synchronize the file to be synchronized.
  • the first device determines at least two devices to be synchronized based on the stored device-related information. And if the first device determines at least two second devices, for each of the at least two devices to be synchronized, the first device can use load balancing as a criterion based on the load information of the at least two second devices. , determine the target second device corresponding to each device to be synchronized.
  • each device can be determined based on the load information of the at least two second devices.
  • the number of file synchronization tasks that the second device needs to perform is based on the principle of achieving load balancing of at least two second devices, and the target second device corresponding to each device to be synchronized is determined.
  • the load balancing of at least two second devices means that the number of file synchronization tasks to be performed by at least two second devices is relatively balanced.
  • the subnet to which the first device belongs is subnet 1, and there are two devices to be synchronized: device 1 and device 2.
  • the first device determines the two devices based on the subnet information of the device to be synchronized and the file information to be synchronized.
  • Two devices device 3 and device 4.
  • the subnets to which device 1, device 2, device 3 and device 4 belong are all subnet 2.
  • the load information of device 3 obtained by the first device includes the number of file synchronization tasks that need to be executed, which is 2, and the load information of device 4 includes the number of file synchronization tasks that need to be executed, which is 4.
  • the target second device corresponding to the first device to be synchronized (device 1) can be The device is determined as device 3, and the second device to be synchronized (device 2) The corresponding target second device is also determined to be device 3.
  • the number of file synchronization tasks that device 3 needs to perform and the number of file synchronization tasks that device 4 needs to perform are both 4, so that the connection between device 3 and device 4 can be realized. load balancing.
  • the second device can be The target second device corresponding to a device to be synchronized (device 1) is determined to be device 3. At this time, the number of file synchronization tasks that device 3 needs to perform and the number of file synchronization tasks that device 4 needs to perform will both be 3.
  • device 2 When determining the target second device corresponding to the second device to be synchronized (device 2), one of device 3 and device 4 may be randomly selected as the target second device of the second device to be synchronized.
  • Step S505b If it does not exist, the first device obtains the file to be synchronized based on the file information to be synchronized, and sends the file to be synchronized to the device to be synchronized, and the device to be synchronized receives the file to be synchronized.
  • the first device has not synchronized the file to be synchronized with other devices that have the same subnet information as the device to be synchronized.
  • the first device cannot synchronize the file to be synchronized to the device to be synchronized through a device in the same subnet as the device to be synchronized.
  • the first device needs to directly synchronize the file to be synchronized with the device to be synchronized.
  • the first device can obtain the file to be synchronized according to the file information to be synchronized, and send the file to be synchronized to the device to be synchronized.
  • the first device may obtain and store multiple files that need to be synchronized from other devices or through other methods.
  • the first device may determine the files to be synchronized among the multiple files that need to be synchronized based on the file information to be synchronized.
  • the first device can send the file to be synchronized to the device to be synchronized through the file transfer port indicated by the obtained file transfer port information of the device to be synchronized, and the device to be synchronized receives the file to be synchronized through the file transfer port. document.
  • Step S506a The second device determines the file information to be synchronized and the device to be synchronized according to the synchronization control instruction.
  • step S302 which will not be described again here.
  • Step S507a The second device sends the file to be synchronized to the device to be synchronized through the port indicated by the file transfer port information, and the device to be synchronized receives the file to be synchronized through the port indicated by the file transfer port information.
  • the synchronization control command sent by the first device to the second device will carry the file transfer port information of the device to be synchronized.
  • the second device can obtain the device to be synchronized carried in the synchronization control command for file transfer.
  • the port used.
  • the second device sends the file to be synchronized to the device to be synchronized, it can send the file to be synchronized to the device to be synchronized through the port indicated by the file transfer port information, and the device to be synchronized receives the file sent by the second device through the port indicated by the file transfer port information.
  • Files to be synchronized are files to be synchronized.
  • the subnet to which the first device belongs is subnet 1.
  • the first device obtains the file to be synchronized.
  • the file to be synchronized is file 1.
  • file 1 the file information to be synchronized
  • it stores From the device-related information, it is determined that two devices to be synchronized (device 1 and device 2) are configured with file 1, and the subnet information of device 1 and device 2 is both subnet 2. That is to say, the first device can determine that both devices to be synchronized need to synchronize the file to be synchronized.
  • the first device sends synchronization file notification messages to the two devices to be synchronized (device 1 and device 2) respectively to inform device 1 and device 2 that the files to be synchronized need to be transmitted to them.
  • device 1 goes to the first device
  • the device returns a synchronization file response message.
  • the synchronization file response message returned by device 1 carries the file transfer port information of device 1.
  • device 2 returns a synchronization file response message to the first device, and the synchronization file response message returned by device 2 carries the file transfer port information of device 2.
  • the first device determines that there are two second devices (device 3, device 4) in the record information of the synchronization file. ), that is to say, both device 3 and device 4 have completed synchronizing file 1, and both belong to subnet 2, which is the same as the subnet to which the device to be synchronized belongs. Since there are two second devices, the first device can send request messages to obtain their load information to device 3 and device 4 respectively, and receive the respective load information returned by device 3 and device 4.
  • the load information of device 3 includes the number of file synchronization tasks that need to be executed, which is 3, and the load information of device 4 includes that the number of file synchronization tasks that need to be executed is 3. Therefore, in order to achieve load balancing between the two second devices, the target second device corresponding to the first device to be synchronized (device 1) can be determined as device 3, and the target second device corresponding to the second device to be synchronized (device 2) can be determined. The target second device is determined to be device 4. In this way, the number of file synchronization tasks that device 3 needs to perform and the number of file synchronization tasks that device 4 needs to perform are both 4, thus achieving load balancing between device 3 and device 4. .
  • the first device sends a synchronization control instruction to device 3, where the synchronization control instruction includes that the device to be synchronized is device 1, the file transfer port information of device 1, and the file information to be synchronized is file 1; at the same time, the first device sends Device 4 sends a synchronization control instruction, where the synchronization control instruction includes that the device to be synchronized is device 2, the file transmission port information of device 2 and the file information to be synchronized is file 1.
  • device 3 After receiving the synchronization control instruction, device 3 obtains the stored file to be synchronized based on the file information to be synchronized carried in the synchronization control instruction, and transmits the file to the device to be synchronized ( Device 1) transmits the file to be synchronized, and device 1 receives the file to be synchronized through the port indicated by the file transfer port information.
  • device 4 After receiving the synchronization control command, device 4 obtains the stored file to be synchronized based on the file information to be synchronized carried in the synchronization control command, and transmits the file to the file to be synchronized through the file transfer port of device 2 carried in the synchronization control command.
  • the synchronization device (device 2) transmits the file to be synchronized, and device 2 receives the file to be synchronized through the port indicated by the file transfer port information.
  • Step S508 The device to be synchronized updates the corresponding file according to the file to be synchronized.
  • step S402 which will not be described again here.
  • Step S509a The second device sends a synchronization completion response message to the first device, and the first device receives the synchronization completion response message returned by the second device.
  • the second device may return a synchronization completion response message to the first device to inform the first device to complete synchronization of the file to be synchronized to the device to be synchronized.
  • the first device receives the synchronization completion response message, and can learn based on the synchronization completion response message that the second device has completed transmitting the file to be synchronized to the device to be synchronized, and the file synchronization is completed.
  • Step S510 The first device updates the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • the first device will record the subnet information of the device and the file information that has been synchronized each time the file is synchronized, that is, the subnet information of the device and the synchronized file information that has been completed each time the file is synchronized.
  • the record information of the synchronized file can be updated when the file information is obtained.
  • the first device determines that the file synchronization has been completed.
  • the record information of the synchronized file is updated according to the subnet information of the device to be synchronized and the file information to be synchronized. For example, the identification information of the device to be synchronized, the subnet information of the device to be synchronized, and the file information to be synchronized can be added to the record information of the synchronization file.
  • the device to be synchronized actively requests the first device for file synchronization as an example.
  • Figure 7 it is a schematic flow chart of another file synchronization method provided by this embodiment of the present application. Specifically, it includes the following steps:
  • Step S701 The device to be synchronized sends a synchronization file request message to the first device, and the first device receives the synchronization file request message.
  • the synchronization file request message carries subnet information and file information to be synchronized.
  • the device to be synchronized can actively request synchronization files from the first device. At this time, the device to be synchronized can send a synchronization file request message to the first device, and the first device receives the synchronization file request message sent by the device to be synchronized. .
  • the synchronization file request message also carries the file transfer port information of the device to be synchronized.
  • the file transfer port information is used to indicate the port used by the device to be synchronized for file transfer.
  • the device to be synchronized since the device to be synchronized needs to perform file transfer through a specified port, the device to be synchronized can add the file transfer port information to the synchronization file request message and send the synchronization file request message to the first device to Inform the first device of the file transfer port of the device to be synchronized.
  • Step S702 The first device sends a synchronization file response message to the device to be synchronized, and the device to be synchronized receives the synchronization file response message.
  • the first device after receiving the synchronization file response message sent by the device to be synchronized, if the first device can perform file synchronization for the device to be synchronized, it can send the synchronization file response message to the device to be synchronized, and the device to be synchronized receives the synchronization file response message. Synchronize the file response message, thereby learning that the first device agrees to perform file synchronization for it.
  • Step S703 The first device obtains the subnet information of the device to be synchronized and the file information to be synchronized from the synchronization file request message.
  • the synchronization file request message carries subnet information and file information to be synchronized.
  • the first device can learn the subnet information of the device to be synchronized carried in the synchronization file request message. and file information to be synchronized.
  • the first device can learn the device to be synchronized by parsing the synchronization file request message sent by the device to be synchronized.
  • Step S704 The first device obtains the record information of the synchronization file, and determines whether there is the subnet information of the second device and the completed synchronization in the record information of the synchronization file based on the subnet information of the device to be synchronized and the file information to be synchronized. File information.
  • step S202 When it is determined that the subnet information of the second device and the file information that have been synchronized exist, perform steps S705a to S707a, step S708, step S709a and step S710; when it is determined that the subnet information of the second device does not exist and the synchronization has been completed.
  • step S705b, step S708 and step S710 When the file information is obtained, execute step S705b, step S708 and step S710.
  • Step S705a if it exists, send the synchronization control instruction to the second device, and the second device receives the synchronization control instruction.
  • step S505a For details, reference may be made to step S505a, which will not be described again here.
  • step S505a when the device to be synchronized actively requests the first device for file synchronization, there may also be at least two second devices.
  • the specific execution steps may refer to step S505a.
  • Step S705b If it does not exist, the first device obtains the file to be synchronized based on the file information to be synchronized, and sends the file to be synchronized to the device to be synchronized, and the device to be synchronized receives the file to be synchronized.
  • step S505b Please refer to step S505b, which will not be described again here.
  • Step S706a The second device determines the file information to be synchronized and the device to be synchronized according to the synchronization control instruction.
  • step S302 which will not be described again here.
  • Step S707a The second device sends the file to be synchronized to the device to be synchronized through the port indicated by the file transfer port information, and the device to be synchronized receives the file to be synchronized through the port indicated by the file transfer port information.
  • step S507a which will not be described again here.
  • Step S708 The device to be synchronized updates the corresponding file according to the file to be synchronized.
  • step S402 which will not be described again here.
  • Step S709a The second device sends a synchronization completion response message to the first device, and the first device receives the synchronization completion response message returned by the second device.
  • step S509a which will not be described again here.
  • Step S710 The first device updates the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • step S510 which will not be described again here.
  • the first device when the first device needs to synchronize files with the device to be synchronized, if the subnet to which the first device belongs is different from the subnet to which the device to be synchronized belongs, and the second device is different from the subnet to which the device to be synchronized belongs. If the devices to be synchronized belong to the same subnet, and the second device has synchronized the files that the device to be synchronized needs to synchronize, then the first device can schedule the second device to send the files to be synchronized to the device to be synchronized.
  • the speed at which the second device transmits the file to be synchronized to the device to be synchronized is faster. Faster and more efficient.
  • the method described in the above embodiment does not require NAT detection and NAT traversal, and can reduce the complexity of file synchronization.
  • the second device can directly send the file to be synchronized to the device to be synchronized, and file transfer between devices under the same subnet can be realized without NAT traversal.
  • Figure 8 is a schematic structural diagram of a file synchronization device provided by an embodiment of the present application. As shown in Figure 8, the device includes:
  • the obtaining unit 801 is used to obtain the subnet information of the device to be synchronized and the file information to be synchronized.
  • the processing unit 802 is used to obtain the record information of the synchronization file, and determine whether there is subnet information of the second device and the files that have been synchronized based on the subnet information of the device to be synchronized and the file information to be synchronized in the synchronization file. information.
  • the subnet information of the second device and the file information that has completed synchronization are the same as the subnet information and file information of the device to be synchronized.
  • the record information of the synchronization file is used to record the subnet of the device that has completed file synchronization. information and file information that has been synchronized.
  • the processing unit 802 is also configured to, if present, send a synchronization control instruction to the second device.
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the file synchronization device further includes:
  • the receiving unit 803 is configured to receive the synchronization completion response message returned by the second device.
  • the processing unit 802 is also configured to update the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • the receiving unit 803 is also used to receive a synchronization file request message sent by the device to be synchronized; the synchronization file request message carries subnet information and file information to be synchronized;
  • the processing unit 802 is also configured to send a synchronization file response message to the device to be synchronized.
  • the obtaining unit 801 is specifically configured to obtain the subnet information of the device to be synchronized and the file information to be synchronized from the synchronization file request message.
  • the processing unit 802 is also configured to send a synchronization file notification message to the device to be synchronized;
  • the receiving unit 803 is also configured to receive a synchronization file response message sent by the device to be synchronized; the synchronization file response message carries the file transfer port information of the device to be synchronized.
  • the processing unit 802 is specifically configured to, if there is, at least two subnet information and synchronized file information of the second device and subnet information of the device to be synchronized and files to be synchronized. If the information is the same, the load information of at least two second devices is obtained.
  • the processing unit 802 is specifically configured to determine, for each of the at least two devices to be synchronized, a target corresponding to each device to be synchronized based on the load information of at least two second devices. Secondary device.
  • the processing unit 802 is also configured to obtain the file to be synchronized according to the file information to be synchronized if it does not exist, and send the file to be synchronized to the device to be synchronized.
  • the processing unit 802 is also configured to update the record information of the synchronization file according to the subnet information of the device to be synchronized and the file information to be synchronized.
  • Figure 10 is a schematic structural diagram of another file synchronization device provided by an embodiment of the present application. As shown in Figure 10, the device includes:
  • the receiving unit 1001 is used to receive synchronization control instructions.
  • the synchronization control instruction is used to instruct the second device to transmit the file to be synchronized to the device to be synchronized.
  • the processing unit 1002 is configured to determine the file information to be synchronized and the device to be synchronized according to the synchronization control instruction.
  • the processing unit 1002 is also configured to obtain the file to be synchronized according to the file information to be synchronized, and send the file to be synchronized to the device to be synchronized.
  • the processing unit 1002 is also configured to send a synchronization completion response message to the first device.
  • the processing unit 1002 is specifically configured to send the file to be synchronized to the device to be synchronized through the port indicated by the file transfer port information.
  • Figure 11 is a schematic structural diagram of another file synchronization device provided by an embodiment of the present application. As shown in Figure 11, the device includes:
  • the receiving unit 1101 is used to receive files to be synchronized.
  • the processing unit 1102 is used to update the corresponding files according to the files to be synchronized.
  • the processing unit 1102 is also configured to send a synchronization file request message to the first device.
  • the synchronization file request message carries subnet information and file information to be synchronized.
  • the receiving unit 1101 is also configured to receive a synchronization file response message sent by the first device.
  • the receiving unit 1101 is also configured to receive a synchronization file notification message sent by the first device.
  • the processing unit 1102 is also configured to send a synchronization file response message to the first device, where the synchronization file response message carries file transfer port information of the device to be synchronized.
  • the processing unit 1102 is specifically configured to receive the file to be synchronized through the port indicated by the file transfer port information.
  • FIG. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • the electronic device 1200 may include: a processor 1201, a memory 1202, and a communication unit 1703. These components communicate through one or more buses.
  • Those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the embodiment of the present invention. It can be either a bus structure or a star structure. , may also include more or fewer components than shown, or combinations of certain components, or different component arrangements.
  • the communication unit 1203 is used to establish a communication channel so that the electronic device can communicate with other devices. Receive user data from other devices or send user data to other devices.
  • the processor 1201 is the control center of the electronic device, using various interfaces and lines to connect various parts of the entire electronic device, by running or executing software programs and/or modules stored in the memory 1202, and calling the software programs stored in the memory 1202. data to perform various functions of the electronic device and/or process data.
  • the processor may be composed of an integrated circuit (IC), for example, it may be composed of a single packaged IC, or it may be composed of multiple packaged ICs connected with the same function or different functions.
  • the processor 1201 may only include a central processing unit (CPU).
  • the CPU may be a single computing core or may include multiple computing cores.
  • the memory 1202 is used to store execution instructions of the processor 1201.
  • the memory 1202 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM). Erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
  • SRAM static random access memory
  • EEPROM Erasable programmable read-only memory
  • EPROM erasable programmable read-only memory
  • PROM programmable read-only memory
  • ROM read-only memory
  • magnetic memory flash memory
  • flash memory magnetic disk or optical disk.
  • the electronic device 1200 is enabled to execute some or all of the steps in the embodiment shown in FIG. 2 or FIG. 3 or FIG. 4.
  • the present invention also provides a storage medium, wherein the storage medium can store a program, and when executed, the program can include some or all of the steps in each embodiment of the file synchronization method provided by the present invention.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
  • the technology in the embodiments of the present invention can be implemented by means of software plus the necessary general hardware platform. Based on this understanding, the technical solutions in the embodiments of the present invention can be embodied in the form of software products in essence or those that contribute to the existing technology.
  • the computer software products can be stored in storage media, such as ROM/RAM. , magnetic disk, optical disk, etc., including a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例提供的一种文件同步方法、装置、设备及存储介质,所述方法应用于第一设备,包括:获取待同步设备的子网信息及待同步的文件信息;获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息。其中,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同;同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息。若存在,则向第二设备发送同步控制指令;同步控制指令用于指示第二设备向待同步设备传输待同步文件。这样一来,可以提高文件同步的效率。

Description

一种文件同步方法、装置、设备及存储介质
本申请要求于2022年5月30日提交中国专利局、申请号为202210605613.2、申请名称为“一种文件同步方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据同步技术领域,具体地涉及一种文件同步方法、装置、设备及存储介质。
背景技术
目前,在煤矿工业领域,通过集控中心设备对多种煤矿开采所需的设备进行管理。以液压支架设备为例,液压支架设备是以液压为动力实现升降、前移等运动,进行顶板支护的设备,是煤矿综合机械化开采的关键设备,对现代煤矿生产意义重大。在液压支架设备的使用过程中,集控中心设备可以向多台液压支架设备同步文件,例如,当开发出液压支架设备的软件升级包或者需要对液压支架设备进行模型配置时,集控中心设备需要向多台液压支架设备发送软件升级包或者模型配置文件,以实现对多台液压支架设备的升级和配置,当然,集控中心设备还可以向液压支架设备同步其他文件。其中,对于多台相同型号的液压支架设备来说,需同步的文件相同。
现有技术中,煤矿工业组网中包含多个子网,通常情况下集控中心设备与多台液压支架设备处于不同的子网中,例如,集控中心设备处于子网1中、多台液压支架设备处于子网2中。因此,集控中心设备在向液压支架设备同步文件时,需要分别向多台液压支架设备进行跨子网传输需同步的文件。而在跨子网传输需同步的文件过程中,传输的数据包(需同步的文件)需要经过多个路由节点,每经过一个路由节点,该路由节点都需要对传输的数据包进行处理,例如寻址、数据封装和数据解封装等,因此跨子网传输需同步的文件需要耗费的时间较长、效率较低。并且,当集控中心设备需要向多个液压支架设备同步同一份文件时,集控中心设备需要向每台液压支架设备分别发送需同步的文件,导致集控中心设备的负载较大,进一步增加了文件同步的耗时,降低文件同步的效率。
发明内容
有鉴于此,本申请提供一种文件同步方法、装置、设备及存储介质,以利于解决现有技术中文件同步效率低的问题。
第一方面,本申请实施例提供了一种文件同步方法,应用于第一设备,所述方法 包括:
获取待同步设备的子网信息及待同步的文件信息;
获取同步文件的记录信息,并根据所述待同步设备的子网信息及待同步的文件信息在所述同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息;其中,所述第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同;所述同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息;
若存在,则向所述第二设备发送同步控制指令;所述同步控制指令用于指示所述第二设备向所述待同步设备传输待同步文件。
第一方面一种可能的实现方式,还包括:
接收所述第二设备返回的同步完成响应消息;
根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
在第一方面的一种可能的实现方式中,在所述获取待同步设备的子网信息及待同步的文件信息之前,还包括:
接收所述待同步设备发送的同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
向所述待同步设备发送同步文件响应消息;
所述获取待同步设备的子网信息及待同步的文件信息包括:
从所述同步文件请求消息中获取待同步设备的子网信息及待同步的文件信息。
优选地,所述同步文件请求消息还携带有待同步设备的文件传输端口信息;文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口。
第一方面一种可能的实现方式,在所述向所述第二设备发送同步控制指令之前,还包括:
向所述待同步设备发送同步文件通知消息;
接收所述待同步设备发送的同步文件响应消息,所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
第一方面一种可能的实现方式,所述同步控制指令中携带有所述待同步设备的文件传输端口信息。
第一方面一种可能的实现方式,若存在,则向所述第二设备发送同步控制指令包括:
若存在,且存在至少两个第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同,则获取所述至少两个第二设备的负载信息;
根据所述至少两个第二设备的负载信息,确定目标第二设备,向所述目标第二设备发送同步控制指令。
第一方面一种可能的实现方式,所述待同步设备包括至少两个;
所述根据所述至少两个第二设备的负载信息,确定目标第二设备包括:
针对至少两个待同步设备中的每个待同步设备,根据所述至少两个第二设备的负 载信息,确定每个待同步设备对应的目标第二设备。
第一方面一种可能的实现方式,所述第一设备与所述待同步设备所属子网不同。
第一方面一种可能的实现方式,还包括:
若不存在,则根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件;
根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
第二方面,本申请实施例提供了一种文件同步方法,应用于第二设备,所述方法包括:
接收同步控制指令;所述同步控制指令用于指示所述第二设备向待同步设备传输待同步文件;
根据所述同步控制指令,确定待同步的文件信息及待同步设备;
根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件。
第二方面一种可能的实现方式,还包括:
向第一设备发送同步完成响应消息。
第二方面一种可能的实现方式,所述同步控制指令中携带有待同步设备的文件传输端口信息;所述文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口;
所述向所述待同步设备发送所述待同步文件包括:
通过所述文件传输端口信息指示的端口向所述待同步设备发送所述待同步文件。
第三方面,本申请实施例提供了一种文件同步方法,包括:
接收待同步文件;
根据所述待同步文件,更新相应的文件。
第三方面一种可能的实现方式,在所述接收待同步文件之前,还包括:
向第一设备发送同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
接收所述第一设备发送的同步文件响应消息。
第三方面一种可能的实现方式,所述同步文件请求消息中还携带有待同步设备的文件传输端口信息;文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口。
第三方面一种可能的实现方式,在所述接收待同步文件之前,还包括:
接收所述第一设备发送的同步文件通知消息;
向所述第一设备发送同步文件响应消息,所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
第三方面一种可能的实现方式,所述接收待同步文件包括:
通过所述文件传输端口信息指示的端口接收待同步文件。
第四方面,本申请实施例提供了一种文件同步装置,包括:
获取单元,用于获取待同步设备的子网信息及待同步的文件信息;
处理单元,用于获取同步文件的记录信息,并根据所述待同步设备的子网信息及待同步的文件信息在所述同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息;其中,所述第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同;所述同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息;
所述处理单元,还用于,若存在,则向所述第二设备发送同步控制指令;所述同步控制指令用于指示所述第二设备向所述待同步设备传输待同步文件。
第四方面一种可能的实现方式,所述文件同步装置还包括:
接收单元,用于接收所述第二设备返回的同步完成响应消息;
所述处理单元,还用于根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
第四方面一种可能的实现方式,所述接收单元,还用于接收所述待同步设备发送的同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
所述处理单元,还用于向所述待同步设备发送同步文件响应消息;
所述获取单元,具体用于从所述同步文件请求消息中获取待同步设备的子网信息及待同步的文件信息。
第四方面一种可能的实现方式,所述处理单元,还用于向所述待同步设备发送同步文件通知消息;
所述接收单元,还用于接收所述待同步设备发送的同步文件响应消息;所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
第四方面一种可能的实现方式,所述处理单元,具体用于若存在,且存在至少两个第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同,则获取所述至少两个第二设备的负载信息;
根据所述至少两个第二设备的负载信息,确定目标第二设备,向所述目标第二设备发送同步控制指令。
第四方面一种可能的实现方式,所述处理单元,具体用于针对至少两个待同步设备中的每个待同步设备,根据所述至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备。
第四方面一种可能的实现方式,所述处理单元,还用于若不存在,则根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件;
所述处理单元,还用于根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
第五方面,本申请实施例提供了一种文件同步装置,包括:
接收单元,用于接收同步控制指令;所述同步控制指令用于指示第二设备向待同步设备传输待同步文件;
处理单元,用于根据所述同步控制指令,确定待同步的文件信息及待同步设备;
所述处理单元,还用于根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件。
所述处理单元,还用于向第一设备发送同步完成响应消息。
第五方面一种可能的实现方式,所述处理单元,具体用于通过所述文件传输端口信息指示的端口向所述待同步设备发送所述待同步文件。
第六方面,本申请实施例提供了一种文件同步装置,包括:
接收单元,用于接收待同步文件;
处理单元,用于根据所述待同步文件,更新相应的文件。
第六方面一种可能的实现方式,所述处理单元,还用于向第一设备发送同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
所述接收单元,还用于接收所述第一设备发送的同步文件响应消息。
第六方面一种可能的实现方式,所述接收单元,还用于接收所述第一设备发送的同步文件通知消息;
所述处理单元,还用于向所述第一设备发送同步文件响应消息,所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
第六方面一种可能的实现方式,所述处理单元,具体用于通过所述文件传输端口信息指示的端口接收待同步文件。
第七方面,本申请实施例提供了一种电子设备,包括:
处理器和存储器,所述存储器存储有计算机程序,当所述计算机程序被执行时,使得所述电子设备执行上述第一方面任一项或第二方面任一项或第三方面任一项所述的方法。
第八方面,本申请实施例提供了一种存储介质,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行上述第一方面任一项或第二方面任一项或第三方面任一项所述的方法。
采用本申请实施例所提供的方案,在第一设备需要向待同步设备同步文件时,第一设备获取待同步设备的子网信息及待同步的文件信息;获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息确定中是否存在第二设备的子网信息及已完成同步的文件信息;其中,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同;同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息。若存在,则向第二设备发送同步控制指令;同步控制指令用于指示第二设备向待同步设备传输待同步文件。也就是说,同步文件的记录信息中记录有已完成文件同步的设备的子网信息及已完成同步的文件信息,在需要向待同步设备同步文件时,第一设备可以获取待同步设备的子网信息及待同步的文件信息,并获取同步文件的记录信息。然后根据待同步设备的子网信息及待同步的文件信息,在同步文件的记录信息中,检测是否存在第二设备的子网信息及已完成同步的文件信息,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同。若存在,则说明第二设备与待同步设备处于同一子网中,并且第二设备中存储有待同步设备需要同步的文件,因此,第一设备可以向第二设备发送同步控制指令,以使得第二设备向待同步设备传输待同步文件。这样一来,在第一设备需要向待同步设备同步文件时,若第一设备所属子网与待同步设备所属子网不同,而第二设备与待同步设备所属子网相同, 并且第二设备已经同步过待同步设备需要同步的文件,那么第一设备可以调度第二设备向待同步设备发送待同步文件。由于第二设备所属子网与待同步设备所属子网相同,因此相对于第一设备直接对待同步设备进行跨子网传输待同步文件,由第二设备向待同步设备传输待同步文件的速度更快,效率更高。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。
图1为本申请实施例提供的一种文件同步的场景示意图;
图2为本申请实施例提供的另一种文件同步方法的流程示意图;
图3为本申请实施例提供的另一种文件同步方法的流程示意图;
图4为本申请实施例提供的另一种文件同步方法的流程示意图;
图5为本申请实施例提供的另一种文件同步方法的流程示意图;
图6为本申请实施例提供的另一种文件同步的场景示意图;
图7为本申请实施例提供的另一种文件同步方法的流程示意图;
图8为本申请实施例提供的一种文件同步装置的结构示意图;
图9为本申请实施例提供的另一种文件同步装置的结构示意图;
图10为本申请实施例提供的另一种文件同步装置的结构示意图;
图11为本申请实施例提供的另一种文件同步装置的结构示意图;
图12为本申请实施例提供的一种电子设备的结构示意图。
具体实施方式
为了更好的理解本申请的技术方案,下面结合附图对本申请实施例进行详细描述。
应当明确,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
在本申请实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。
应当理解,本文中使用的术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,甲和/或乙,可以表示:单独存在甲,同时存在甲和乙,单独存在乙这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
在对本申请实施例进行具体介绍之前,首先对本申请实施例应用或可能应用的术语进行解释。
点对点技术(Peer-to-Peer,P2P):又称对等互联网络技术,是一种网络新技 术,依赖网络中参与者的计算能力和带宽,而不是把依赖都聚集在较少的几台服务器上。P2P网络是没有中心服务器、依靠用户群节点进行信息交换的对等式网络。区别于传统的中央服务器结构,P2P网络中每一个用户节点既是客户端又是服务端,能同时作为服务器给其他节点提供服务。处于P2P网络中的任意两台设备间都可以共享数据。
网络地址转换(Network Address Translation,NAT):当在专用网内部的一些主机本来已经分配到了本地IP(Internet Protocol,网际互联协议)地址(即仅在本专用网内使用的专用地址),但又想和因特网上的主机通信(并不需要加密)时,可使用NAT方法。这种方法需要在专用网(私网IP)连接到因特网(公网IP)的路由器上安装NAT软件。装有NAT软件的路由器叫做NAT路由器,它至少有一个有效的外部全球IP地址(公网IP地址)。这样,所有使用本地地址(私网IP地址)的主机在和外界通信时,都要在NAT路由器上将其本地地址转换成全球IP地址,才能和因特网连接。
NAT穿越:NAT穿越涉及TCP/IP网络中的一个常见问题,即在处于使用了NAT设备的私有TCP/IP网络中的主机之间建立连接的问题。
路由器(Router):是连接两个或多个网络的硬件设备,在网络间起网关的作用,是读取每一个数据包中的地址然后决定如何传送的网络设备。它能够理解不同的协议,例如某个局域网使用的以太网协议,因特网使用的TCP(Transmission Control Protocol,传输控制协议)/IP协议。这样,路由器可以分析各种不同类型网络传来的数据包的目的地址,把非TCP/IP网络的地址转换成TCP/IP地址,或者反之;再根据选定的路由算法把各数据包按最佳路线传送到指定位置。所以路由器可以把非
TCP/IP网络连接到因特网上。
交换机(Switch):交换机意为“开关”是一种用于电(光)信号转发的网络设备。它可以为接入交换机的任意两个网络节点提供独享的电信号通路。最常见的交换机是以太网交换机。
相关技术中,在煤矿工业领域,通过集控中心设备对多种煤矿开采所需的设备进行管理。以液压支架设备为例,液压支架设备是以液压为动力实现升降、前移等运动,进行顶板支护的设备,是煤矿综合机械化开采的关键设备,对现代煤矿生产意义重大。在液压支架设备的使用过程中,集控中心设备可以向多台液压支架设备同步文件,例如,当开发出液压支架设备的软件升级包或者需要对液压支架设备进行模型配置时,集控中心设备需要向多台液压支架设备发送软件升级包或者模型配置文件,以实现对多台液压支架设备的升级和配置,当然,集控中心设备还可以向液压支架设备同步其他文件。对于多台相同型号的液压支架设备来说,需同步的文件均相同。
现有技术中,煤矿工业组网中包含多个子网,如图1所示,通常情况下集控中心设备与多台液压支架设备处于不同的子网中,例如,集控中心设备处于子网1中、多台液压支架设备处于子网2中。因此,集控中心设备在向液压支架设备同步文件时,需要分别向多台液压支架设备进行跨子网传输需同步的文件。而在跨子网传输需同步的文件过程中,传输的数据包(需同步的文件)需要经过多个路由节点,每经过一个路由节点,该路由节点都需要对传输的数据包进行处理,例如寻址、数据封装和数据 解封装等,如图1所示,集控中心设备向液压支架设备1同步文件时,数据包会从集控中心设备到达子网1中的交换机,然后到达路由器,再由路由器将数据包转发至子网2的交换机,并由子网2的交换机将数据包传输至液压支架设备1,因此跨子网进行文件同步需要耗费的时间较长、效率较低。并且,当集控中心设备需要向液压支架设备1、液压支架设备2…液压支架设备n同步同一份文件时,集控中心设备需要向每台液压支架设备分别发送需同步的文件,导致集控中心设备的负载较大,进一步增加了文件同步的耗时,降低文件同步的效率。
在一些技术中,通过点对点技术(Peer-to-Peer,P2P)实现文件同步,利用P2P技术可以使计算机之间不通过服务器直接进行内容共享和数据分发,使得互联网上任意两台机器间共享数据成为可能。在煤矿工业场景下,假设集控中心设备及进行煤矿开采所需的设备均为P2P网络中的设备,P2P通常用于跨子网的两个设备通信,由于跨子网设备之间通常存在NAT隔离,因此需要经过NAT探测获得NAT的类型,然后根据NAT探测的结果实现NAT穿越,才能建立设备间的连接通路,以进行文件传输。但是NAT穿越的过程复杂、耗时较长,导致设备间建立连接通路的效率较低,从而使得文件传输的效率较低。并且NAT探测可能存在失败的情况,导致无法实现NAT穿越,进而导致设备间的连接通路无法建立,从而无法进行文件传输。并且,在P2P网络中,如果需要进行文件传输的两个设备在同一子网内,那么采用P2P技术无法实现处于同一子网的两个设备的二层传输,仍然需要NAT网关介入,导致传输效率降低。因此,对于采用P2P技术实现文件同步的方法,设备间的NAT穿越会影响文件同步的效率,甚至在NAT探测失败时导致文件传输失败,并且,对于同一子网中的两个设备,也需要进行NAT穿越,无法直接进行通信,从而影响同一子网中设备间的文件传输的效率。
针对上述问题,本申请实施例提供了一种文件同步方法,应用于第一设备,所述方法包括:获取待同步设备的子网信息及待同步的文件信息;获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息;其中,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同;所述同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息。若存在,则向第二设备发送同步控制指令;同步控制指令用于指示第二设备向待同步设备传输待同步文件。也就是说,同步文件的记录信息中记录有已完成文件同步的设备的子网信息及已完成同步的文件信息,在需要向待同步设备同步文件时,第一设备可以获取待同步设备的子网信息及待同步的文件信息,并获取同步文件的记录信息。然后根据待同步设备的子网信息及待同步的文件信息,在同步文件的记录信息中,检测是否存在第二设备的子网信息及已完成同步的文件信息,所述第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同。若存在,则说明第二设备与第一设备处于同一子网中,并且第二设备中存储有待同步设备需要同步的文件,因此,第一设备可以向第二设备发送同步控制指令,以使得第二设备向待同步设备传输待同步文件。
这样一来,在第一设备需要向待同步设备同步文件时,若第一设备所属子网与待 同步设备所属子网不同,而第二设备与待同步设备所属子网相同,并且第二设备已经同步过待同步设备需要同步的文件,那么第一设备可以调度第二设备向待同步设备发送待同步文件。由于第二设备所属子网与待同步设备所属子网相同,因此相对于第一设备直接对待同步设备进行跨子网传输待同步文件,由第二设备向待同步设备传输待同步文件的速度更快,效率更高。以下进行详细说明。
参见图2,为本申请实施例提供的一种文件同步方法的流程示意图。所述方法应用于第一设备,包括如下步骤:
步骤S201、获取待同步设备的子网信息及待同步的文件信息。
在本申请实施例中,第一设备对各个子网中的设备进行管理,例如,第一设备管理各个子网中每个设备内配置的文件,以及负责对每个设备内配置的文件的升级更新等。当技术人员开发出软件升级包、设备的模型配置文件等更新文件时,需要将这些更新文件同步至相应的设备中,以便相应的设备对其内保存的文件进行更新。而技术人员无法直接将更新文件直接同步至相应的设备中,需要由管理各个子网的设备的第一设备进行同步。在本申请实施例中,可以将设备需要更新的文件称为待同步文件,需要进行文件更新的设备称为待同步设备。在第一设备获取到待同步设备的更新文件时,可以主动向各个配置有该更新文件的设备同步该更新文件。也可以由各个配置有该更新文件的设备请求第一设备进行更新文件的同步。即为,在第一设备获取到待同步文件时,可以主动向各个配置有该待同步文件的待同步设备发送待同步文件。也可以由各个配置有该待同步文件的设备请求第一设备进行待同步文件的同步。
在第一设备确定需要向待同步设备进行待同步文件的同步时,为了提高同步效率,可以通过与待同步设备位于相同子网,且已经同步完成了该待同步文件的设备为待同步设备进行同步。基于此,第一设备需要获取待同步设备的子网信息及待同步的文件信息。即为,需要先获取待同步设备位于哪个子网,及待同步设备需要同步哪个文件。
在一些实施例中,当其他设备连接至第一设备时,其他设备需要向第一设备上报其他设备内配置的文件,其他设备的标识信息,以及其他设备所属子网信息等设备相关信息,以便第一设备对其他设备的管理。此时,第一设备可以存储其他设备上报的设备相关信息。当第一设备主动向其他设备同步待同步文件时,首先第一设备可以从其他设备中获取待同步文件或者可以接收技术人员发送的待同步文件。根据该待同步文件可以确定出其文件信息,例如待同步文件的文件名称,文件大小等信息。其次,第一设备可以根据存储的设备相关信息中记录的其他设备内的配置文件,确定出待同步文件对应的待同步设备,并根据设备相关信息确定出待同步设备的子网信息。即为,第一设备获取待同步设备的子网信息及待同步文件的文件信息。
当其他设备请求第一设备同步待同步文件时,其他设备可以在请求消息中携带其子网信息及待同步文件的文件信息,第一设备可以从其他设备的请求消息中获取到待同步设备的子网信息及待同步的文件信息。
当然,还可以通过其他方式获取待同步设备的子网信息及待同步的文件信息,本申请对此不作限制。例如,第一设备可以根据获取的待同步的文件信息,通过第三设备获取待同步设备的子网信息。其中,第三设备中可以存储有各个设备的子网信息, 或者第三设备可以从待同步设备中获取子网信息并返回给第一设备。
示例性的,以第一设备主动向待同步设备同步文件为例,假设待同步文件为液压支架设备的配置文件。在第一设备获取到液压支架设备的软件配置升级包的文件时,例如第一设备可以接收其他设备发送的液压支架设备的软件配置升级包的文件,第一设备可以确定待同步文件为液压支架设备的的配置文件。此时,第一设备可以从存储的设备相关信息中确定出待同步文件(液压支架设备的软件升级包)对应的待同步设备为液压支架设备1,还可以确定出液压支架设备1的子网信息,例如,液压支架设备1的子网信息可以是液压支架设备所属子网为子网2。这样一来,第一设备便可以获取到待同步设备的子网信息及待同步的文件信息。
作为一种可能的实现方式,第一设备与待同步设备所属子网不同。
具体的,一个网络可以被划分为多个子网,第一设备是对各个子网中的其他设备进行集中管理的设备,在第一设备所属子网与第一设备管理的设备的所属子网不同时,第一设备需要向待同步设备进行跨子网传输待同步文件,导致文件同步效率较低。例如,第一设备所属子网为子网1,设备A所属子网为子网2、设备B所属子网为子网3,若第一设备直接向设备A或者设备B进行文件同步,需要跨子网文件传输,但是跨子网进行文件传输的过程较为复杂,传输效率较低。
步骤S202、获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息。
其中,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同。同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息。
在本申请实施例中,第一设备在每次完成文件同步时,会将完成同步的设备的子网信息及已完成同步的文件信息记录至同步文件的记录信息中,即为同步文件的记录信息中包括已完成文件同步的设备的子网信息及已完成同步的文件信息。在第一设备需要向待同步设备同步文件时,由于第一设备与待同步设备所属子网不同,因此,如果由第一设备直接将待同步文件发送至待同步设备,需要进行跨子网文件传输,跨子网传输过程较为复杂,效率较低。在本申请实施例中,第一设备可以查找出与该待同步设备处于相同子网且已完成与待同步文件相同的文件同步的第二设备,由第二设备为待同步设备进行待同步文件的同步,实现同一个子网内文件同步,提高文件同步的效率。基于此,第一设备可以获取记录的同步文件的记录信息。其中,同步文件的记录信息中包括已完成文件同步的设备的子网信息及已完成同步的文件信息。即为,第一设备可以获取记录有已完成文件同步的设备的子网信息及该设备完成同步的文件的文件信息的同步文件的记录信息。第一设备根据待同步设备的子网信息及待同步的文件信息,在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息。也就是说,第一设备可以根据待同步设备的子网信息及待同步的文件信息,在同步文件的记录信息中确定是否存在子网信息与待同步设备的子网信息相同、且已完成同步的文件信息与待同步设备的待同步文件的文件信息相同的第二设备的子网信息及已完成同步的文件信息。其中,第二设备的子网信息与待同步设备的子网信 息相同即为,第二设备与待同步设备处于同一子网。
步骤S203、若存在,则向第二设备发送同步控制指令。
其中,同步控制指令用于指示第二设备向待同步设备传输待同步文件。
在本申请实施例中,若第一设备在同步文件的记录信息中确定出存在第二设备的子网信息及已完成同步的文件信息,说明第二设备所属子网与待同步设备所属子网相同,即为第二设备与第一设备处于同一子网中,并且第二设备已经同步过待同步设备的待同步文件。此时,第一设备可以向第二设备发送同步控制指令,例如,同步控制指令中可以包括待同步设备的标识信息及待同步的文件信息,以使得第二设备在接收到同步控制指令时,根据同步控制指令向待同步设备传输待同步文件。也就是说,在第一设备需要向待同步设备同步待同步文件时,第一设备通过同步文件的记录信息若确定出第二设备所属子网与待同步设备所属子网相同,且第二设备已经同步过待同步文件,那么第一设备可以向第二设备发送同步控制指令,由于第二设备中已经存储有待同步文件,因此第二设备在接收到同步控制指令时,可以直接向待同步设备传输待同步文件。这样一来,在第一设备确定出第二设备所属子网与待同步设备所属子网相同,且第二设备已经同步过待同步文件后,向第二设备发送同步控制指令,以使得第二设备向待同步设备传输待同步文件,从而完成文件同步。由于第二设备的子网信息与待同步设备的子网信息相同,即为第二设备与待同步设备处于同一子网中,同子网的设备间可以直接进行文件传输,无需经过多次路由,传输速度较快,而第一设备与待同步设备所属子网不同,跨子网文件传输的过程比较复杂,因此由第二设备向待同步设备传输待同步文件可以提高文件同步的效率。
示例性的,假设在煤矿工业场景下,第一设备为集控中心设备,第一设备所属子网为子网1。此时,第一设备获取到液压支架设备的软件升级包,液压支架设备的软件升级包即为待同步文件,假设待同步文件的文件信息为文件B。由于第一设备存储的设备相关信息中包括每个设备的标识信息、设备的子网信息、设备中的文件的标识信息等,例如,液压支架设备C,其内配置的文件为文件B,所属子网为子网2;运输机D,其内配置的文件为文件E,所属子网为子网3。因此,第一设备根据存储的设备相关信息及待同步的文件信息,可以确定待同步的文件信息对应的待同步设备为液压支架设备C,液压支架设备C的子网信息为子网2。这样一来,第一设备可以获取到待同步设备的子网信息为子网2,待同步的文件信息为文件B。然后,第一设备可以获取同步文件的记录信息,假设同步文件的记录信息中记录有:液压支架设备F,所属子网为子网2,已完成同步的文件为文件B;运输机G,所属子网为子网3,已完成同步的文件为文件E。根据待同步设备的子网信息及待同步的文件信息,在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息,由于同步文件的记录信息中记录有液压支架设备F,所属子网为子网2,已完成同步的文件为文件B,那么此时,第一设备可以确定存在第二设备的子网信息及已完成同步的文件信息,第二设备即为液压支架设备F。第一设备向第二设备发送同步控制指令,以使得第二设备在接收到同步控制指令之后,向待同步设备传输待同步文件。
作为一种可能的实现方式,上述若存在,则向第二设备发送同步控制指令包括:
若存在,且存在至少两个第二设备的子网信息及已完成同步的文件信息与待同步 设备的子网信息及待同步的文件信息相同,则获取至少两个第二设备的负载信息;
根据至少两个第二设备的负载信息,确定目标第二设备,向目标第二设备发送同步控制指令。
在本申请实施例中,由于同步文件的记录信息中记录了第一设备已经完成文件的设备的子网信息及已完成同步的文件信息。因此,在第一设备根据待同步设备的子网信息及待同步的文件信息在同步问价的记录信息中查找是否有与待同步设备的子网信息及待同步的文件信息相同的第二设备的子网信息及已完成同步的文件信息时,可能有至少两个第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同。此时,在存在第二设备的子网信息及已完成同步的文件信息,且存在至少两个时,即为存在至少两个第二设备的子网信息与待同步设备的子网信息相同,且至少两个第二设备已完成的同步文件信息与待同步设备的待同步文件的文件信息相同时,则第一设备可以获取至少两个第二设备的负载信息。此时,第一设备可以分别向至少两个第二设备发送获取其负载信息的请求消息,由至少两个第二设备告知第一设备至少两个第二设备各自的负载信息。第一设备也可以在每次控制其他设备向待同步设备进行文件同步时,记录为每个其他设备分配的同步任务的个数,通过获取为每个第二设备分配的同步任务的个数来获取至少两个第二设备的负载信息。第一设备在获取了每个第二设备的负载信息后,可以根据每个第二设备的负载信息,通过负载均衡原则确定该待同步设备对应的目标第二设备。即为,第一设备在获取了每个第二设备的负载信息后,可以将负载信息中记录的负载个数较少的第二设备确定为待同步设备对应的目标第二设备,实现每个第二设备负载均衡,提高同步效率。第一设备在确定出目标第二设备后,可以向目标第二设备发送同步控制指令,以控制目标第二设备为待同步设备进行待同步文件的同步。
应理解,第二设备的负载信息可以是第二设备需为其他设备进行文件同步的同步任务的个数的信息。
作为一种可能的实现方式中,待同步设备包括至少两个。此时,上述根据至少两个第二设备的负载信息,确定目标第二设备包括:
针对至少两个待同步设备中的每个待同步设备,根据至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备。
在本申请实施例中,当第一设备需要为至少两个待同步设备进行待同步文件的同步,且确定出至少两个第二设备可以为至少两个待同步设备进行待同步文件的同步时,第一设备可以针对每个待同步文件确定出其对应的目标第二设备。即为,针对至少两个待同步设备中的每个待同步设备,第一设备根据至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备,这样一来,可以将至少两个第二设备负载均衡的为至少两个同步设备进行待同步文件的同步。
这样一来,在第一设备需要向待同步设备同步文件时,若第一设备所属子网与待同步设备所属子网不同,而第二设备与待同步设备所属子网相同,并且第二设备已经同步过待同步设备需要同步的文件,那么第一设备可以调度第二设备向待同步设备发送待同步文件。由于第二设备与待同步设备所属子网相同,因此相对于第一设备直接对待同步设备进行跨子网传输待同步文件,由第二设备向待同步设备传输待同步文件 的速度更快,效率更高。
作为一种可能的实现方式,当第一设备与待同步设备的子网信息相同时,也可以通过上述方法实现第一设备与待同步设备间的文件同步。虽然在第一设备与待同步设备的子网信息相同时,由第一设备直接向待同步设备发送待同步文件不会存在跨子网文件传输导致的文件同步效率低的问题,但是,当存在多个待同步设备时,第一设备向多个待同步设备发送待同步文件会导致第一设备的运行负载急剧增大,导致文件同步较慢,也会在一定程度上降低文件同步效率,此时采用上述文件同步方法,可以减轻第一设备的运行负载,从而提高文件同步的效率。
图3为本申请实施例提供的另一种文件同步方法的流程示意图。所述方法应用于第二设备,具体包括如下步骤:
步骤S301、接收同步控制指令。
其中,同步控制指令用于指示第二设备向待同步设备传输待同步文件。
具体的,在第一设备确定第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同时,第一设备会向第二设备发送同步控制指令,同步控制指令中可以包括待同步设备的标识信息及待同步的文件信息,第二设备接收同步控制指令,获知需要向待同步设备传输待同步文件。
步骤S302、根据同步控制指令,确定待同步的文件信息及待同步设备。
在本申请实施例中,同步控制指令用于指示第二设备向待同步设备传输待同步文件,第二设备通过解析同步控制指令,可以获知待同步的文件信息及待同步设备。
步骤S303、根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件。
在本申请实施例中,第二设备解析同步控制指令,得到待同步的文件信息后,可以根据待同步的文件信息,查找自身的文件,确定出文件信息与待同步的文件信息相同的文件,将其作为待同步文件,第二设备在获取了待同步文件后,可以向确定出的待同步设备发送待同步文件。
应理解的,第二设备是已完成待同步文件的文件信息标识出的文件的设备,且第二设备的子网信息与待同步设备的子网信息相同,因此第二设备与待同步设备处于相同的子网内。因此,第二设备向待同步设备传输待同步文件时,是在同一子网内进行文件同步,文件同步效率较高。
图4为本申请实施例提供的另一种文件同步方法的流程示意图。所述方法应用于待同步设备,具体包括如下步骤:
步骤S401、接收待同步文件。
具体的,待同步设备需要同步文件时,可能会由第一设备直接向待同步设备发送待同步文件,也可能是与待同步设备所属子网相同,并且已同步过待同步文件的第二设备向待同步设备发送待同步文件,此时,待同步设备可以接收由第一设备或第二设备发送的待同步文件。
步骤S402、根据待同步文件,更新相应的文件。
具体的,待同步设备在接收到待同步文件之后,可以根据待同步文件,更新待同步设备中相应的文件,以完成文件同步。
在本申请实施例中,存在第一设备主动向待同步设备发送待同步文件,和待同步设备主动向第一设备请求进行文件同步两种方式,为更清楚的说明第一设备、第二设备及待同步设备间的信息交互,在本实施例中以第一设备主动向待同步设备发送待同步文件为例进行说明,图5为本申请实施例提供的另一种文件同步方法的流程示意图。具体包括如下步骤:
步骤S501、第一设备获取待同步设备的子网信息及待同步的文件信息。
具体可参考步骤S201,在此不再赘述。
作为一种可能的实现方式,由于可能存在至少两个待同步设备进行文件同步的情况。待同步设备需要确定出至少两个待同步设备的子网信息及待同步文件的文件信息。在至少两个待同步设备的类型相同时,其待同步文件相同。
以煤矿工业场景中的液压支架设备为例,多个液压支架设备需要进行文件1的升级,在多个液压支架设备的类型相同时,则多个液压支架设备需要升级的文件1相同,即为需要更新的文件1相同。因此,假设第一设备获取到液压支架设备的文件1的软件升级包文件,第一设备可以确定需要向多个液压支架设备进行文件1的升级。此时,第一设备可以将需要升级文件1的液压支架设备确定为待同步设备,将文件1的软件升级包文件确定为待同步文件。第一设备此时可以确定出多个待同步设备。通过检测记录的设备相关信息,可以分别确定出待同步设备的子网信息。假设,多个液压支架设备的子网信息相同,均为属于子网1。此时,第一设备可以确定出多个待同步设备的子网信息为属于子网1,假设待同步文件的文件信为待同步文件的文件名称。此时,第一设备可以确定出多个待同步设备的待同步文件的文件信息为文件1。
步骤S502、第一设备向待同步设备发送同步文件通知消息,待同步设备接收同步文件通知消息。
具体的,在进行文件同步之前,第一设备需向告知待同步设备进行文件1的文件同步。此时,第一设备向待同步设备发送同步文件通知消息,以告知待同步设备需要对其进行文件同步。一种可能的实现方式中,同步文件通知消息中携带有待同步文件的文件信息,以便告知待同步设备需要同步哪些文件。待同步设备接收第一设备发送的同步文件通知消息,从而获知第一设备需要对其进行文件同步,并通过同步文件通知消息中携带的待同步文件的文件信息,可以获知第一设备需要对哪些文件进行同步。
作为一种可能的实现方式,若存在至少两个待同步设备,那么第一设备需要向至少两个待同步设备分别发送同步文件通知消息。
步骤S503、待同步设备向第一设备发送同步文件响应消息,第一设备接收待同步设备发送的同步文件响应消息。
其中,同步文件响应消息中携带有待同步设备的文件传输端口信息。
在本申请实施例中,待同步设备在接收到同步文件通知消息之后,获知需要进行文件的同步,由于待同步设备需要通过特定的端口进行文件传输,因此待同步设备会将待同步设备的文件传输端口信息添加至同步文件响应消息中,并向第一设备发送同步文件响应消息。第一设备接收待同步设备发送的同步文件响应消息,并通过解析同步文件响应消息,获知待同步设备进行文件传输时所使用的文件传输端口信息。
作为一种可能的实现方式,当存在至少两个待同步设备时,每个待同步设备都会向第一设备返回同步文件响应消息,第一设备接收至少两个待同步设备发送的同步文件响应消息,并通过分别解析至少两个待同步设备发送的同步文件响应消息,获知每个待同步设备的文件传输端口信息。
步骤S504、第一设备获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息。
具体可参考步骤S202,在此不再赘述。
需要说明的是,第一设备在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息时,根据确定的结果不同,下述执行的步骤不同。在确定存在第二设备的子网信息及已完成同步的文件信息时,执行步骤S505a至步骤S507a,步骤S508,步骤S509a及步骤S510;当确定不存在第二设备的子网信息及已完成同步的文件信息时,执行步骤S505b、步骤S508及步骤S510。
步骤S505a、若存在,第一设备向第二设备发送同步控制指令,第二设备接收同步控制指令。
其中,同步控制指令中携带有待同步设备的文件传输端口信息。
具体的,若确定存在第二设备的子网信息及已完成同步的文件信息,则说明第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同,即为,第二设备已经同步完成了待同步设备,且第二设备与待同步设备属于相同的子网。此时可以由第二设备向待同步设备传输同步文件。当第一设备接收到待同步设备发送的同步文件响应消息之后,通过解析同步文件响应消息可以获知待同步设备的文件传输端口信息,并将待同步设备的文件传输端口信息添加至同步控制指令中。第一设备向第二设备发送同步控制指令,第二设备接收同步控制指令,第二设备可以通过解析同步控制指令,获取到待同步设备的文件传输端口信息。
作为一种可能的实现方式,上述若存在至少两个第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同,则获取至少两个第二设备的负载信息;根据至少两个第二设备的负载信息,确定目标第二设备,向目标第二设备发送同步控制指令。
具体的,由于可能存在至少两个第二设备与待同步设备所属子网相同,且已完成待同步文件的同步,那么在同步文件的记录信息中会记录有至少两个第二设备的子网信息及已完成同步的文件信息,因此第一设备在同步文件的记录信息中会确定出至少两个第二设备的子网信息及已完成同步的文件信息。当存在至少两个第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同时,需要在至少两个第二设备中选择一个目标第二设备,用于向待同步设备同步待同步文件。
此时,第一设备可以获取至少两个第二设备的负载信息,其中,第二设备的负载信息可以是第二设备需执行的文件同步任务的数量。例如,第一设备可以在同步文件的记录信息中获取至少两个第二设备的标识信息,根据至少两个第二设备的标识信息,向至少两个第二设备分别发送负载信息获取请求消息,至少两个第二设备中的每 个第二设备在接收到负载信息获取请求消息之后,向第一设备发送自身的负载信息。还可以是,各个子网中的设备可以周期性向第一设备主动发送自身的负载信息,第一设备在接收到设备负载信息时,可以记录每个设备的标识信息及每个设备对应的负载信息,第一设备可以根据至少两个第二设备的标识信息,在记录的设备负载信息中,确定至少两个第二设备中的每个第二设备对应的负载信息。还可以是,第一设备可以记录每个设备的负载信息,每个设备的负载信息的初始值均为零,由于设备的文件同步任务均为第一设备向其发送的,因此第一设备每发送一次文件同步任务,便更新一次该文件同步任务对应的设备的负载信息,第一设备可以在记录的设备的负载信息中获取到至少两个第二设备中的每个第二设备对应的负载信息。当然,还可以通过其他方式获取第二设备对应的负载信息,本申请对此不作限制。
当获取到至少两个第二设备的负载信息之后,可以根据至少两个第二设备的负载信息,确定目标第二设备。此时,第一设备根据至少两个第二设备的负载信息,可以获取到每个第二设备需执行的文件同步任务的数量,为实现至少两个第二设备间的负载均衡,可以将需执行的文件同步的数量较少的第二设备确定为目标第二设备,从而实现至少两个第二设备间的负载均衡。当至少两个第二设备的负载信息相同时,可以在负载信息相同的至少两个第二设备中随机选取一个第二设备作为目标第二设备。在确定出目标第二设备之后,向目标第二设备发送同步控制指令。
作为一种可能的实现方式,当存在至少两个待同步设备时,上述根据至少两个第二设备的负载信息,确定目标第二设备包括:针对至少两个待同步设备中的每个待同步设备,根据至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备。
在本申请实施例中,由于每个子网中可能存在多个同类型的设备,例如子网2中包括多个液压支架设备,多个同类型设备需要同步的文件相同,因此第一设备获取到待同步文件后,会存在多个设备都需要同步该待同步文件。第一设备根据存储的设备相关信息,会确定出至少两个待同步设备。并且第一设备若确定出至少两个第二设备时,针对至少两个待同步设备中的每个待同步设备,第一设备可以根据至少两个第二设备的负载信息,以负载均衡为准则,确定每个待同步设备对应的目标第二设备。即为,若存在至少两个待同步设备及至少两个第二设备,则针对至少两个待同步设备中的每个待同步设备,根据至少两个第二设备的负载信息,可以确定每个第二设备需执行的文件同步任务的数量,以实现至少两个第二设备的负载均衡为原则,确定每个待同步设备对应的目标第二设备。其中,至少两个第二设备负载均衡即为至少两个第二设备需执行的文件同步任务的数量相对均衡。
例如,假设第一设备所属子网为子网1,并且存在两个待同步设备:设备1、设备2,第一设备根据待同步设备的子网信息及待同步的文件信息确定出两个第二设备:设备3、设备4,设备1、设备2、设备3及设备4所属子网均为子网2。第一设备获取到的设备3的负载信息包括需执行的文件同步任务的数量为2,设备4的负载信息包括需执行的文件同步任务的数量为4。在确定两个待同步设备:设备1、设备2对应的目标第二设备时,为实现两个第二设备间的负载均衡,可以将第一个待同步设备(设备1)对应的目标第二设备确定为设备3,将第二个待同步设备(设备2) 对应的目标第二设备也确定为设备3,这样一来,设备3需执行的文件同步任务的数量及设备4需执行的文件同步任务的数量均为4,从而可以实现设备3和设备4间的负载均衡。假设设备3的负载信息包括需执行的文件同步任务的数量为2,设备4的负载信息包括需执行的文件同步任务的数量为3,为实现两个第二设备间的负载均衡,可以将第一个待同步设备(设备1)对应的目标第二设备确定为设备3,此时,设备3需执行的文件同步任务的数量及设备4需执行的文件同步任务的数量将均为3,在确定第二个待同步设备(设备2)对应的目标第二设备时,可以随机选取设备3及设备4中的一个设备作为第二个待同步设备的目标第二设备。
步骤S505b、若不存在,第一设备根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件,待同步设备接收待同步文件。
具体的,若同步文件的记录信息中不存在第二设备的子网信息及已完成同步的文件信息,说明第一设备未向与待同步设备的子网信息相同的其他设备同步过待同步文件,第一设备无法通过与待同步设备处于同一子网中的设备向待同步设备同步待同步文件。此时第一设备需要直接向待同步设备同步待同步文件。第一设备可以根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件。
例如,第一设备可能从其他设备或者通过其他方式获取到多个需同步的文件并存储,第一设备可以根据待同步的文件信息,在多个需同步的文件中确定出待同步文件。
作为一种可能的实现方式,由于待同步设备向第一设备返回的同步文件响应消息中携带有待同步设备的文件传输端口信息,因此,在确定同步文件的记录信息中不存在第二设备的子网信息及已完成同步的文件信息时,第一设备可以通过获取的待同步设备的文件传输端口信息指示的文件传输端口向待同步设备发送待同步文件,待同步设备通过文件传输端口接收待同步文件。
步骤S506a、第二设备根据同步控制指令,确定待同步的文件信息及待同步设备。
具体可参考步骤S302,在此不再赘述。
步骤S507a、第二设备通过文件传输端口信息指示的端口向待同步设备发送待同步文件,待同步设备通过文件传输端口信息指示的端口接收待同步文件。
具体的,第一设备向第二设备发送的同步控制指令中会携带有待同步设备的文件传输端口信息,第二设备通过解析同步控制指令,可以得到同步控制指令中携带的待同步设备进行文件传输时使用的端口。第二设备在向待同步设备发送待同步文件时,便可以通过文件传输端口信息指示的端口向待同步设备发送待同步文件,待同步设备通过文件传输端口信息指示的端口接收第二设备发送的待同步文件。
假设,如图6所示,第一设备所属子网为子网1,第一设备获取到待同步文件,例如待同步文件为文件1,根据待同步的文件信息(文件1),在其存储的设备相关信息中确定出有两个待同步设备(设备1、设备2)中配置有文件1,其中设备1及设备2的子网信息均为子网2。也就是说,第一设备可以确定两个待同步设备都需要同步该待同步文件。第一设备向两个待同步设备(设备1、设备2)分别发送同步文件通知消息,以告知设备1、设备2需要向其传输待同步文件。然后设备1向第一设 备返回同步文件响应消息,设备1返回的同步文件响应消息中携带有设备1的文件传输端口信息。同时,设备2向第一设备返回同步文件响应消息,设备2返回的同步文件响应消息中携带有设备2的文件传输端口信息。第一设备通过解析接收到的两个待同步设备返回的同步文件响应消息,可以获知两个待同步设备进行文件传输使用的端口。
然后,第一设备根据待同步设备的子网信息(子网2)及待同步的文件信息(文件1),在同步文件的记录信息中确定出存在两个第二设备(设备3、设备4),也就是说,设备3及设备4都已经同步完成文件1,并且所属子网均为子网2,与待同步设备所属子网相同。由于存在两个第二设备,因此第一设备可以向设备3和设备4分别发送获取其负载信息的请求消息,并接收设备3、设备4返回的各自的负载信息。假设设备3的负载信息包括需执行的文件同步任务的数量为3,设备4的负载信息包括需执行的文件同步任务的数量为3。因此,为实现两个第二设备间的负载均衡,可以将第一个待同步设备(设备1)对应的目标第二设备确定为设备3,将第二个待同步设备(设备2)对应的目标第二设备确定为设备4,这样一来,设备3需执行的文件同步任务的数量及设备4需执行的文件同步任务的数量均为4,从而可以实现设备3和设备4间的负载均衡。然后,第一设备向设备3发送同步控制指令,其中,同步控制指令中包括待同步设备为设备1、设备1的文件传输端口信息及待同步的文件信息为文件1;同时,第一设备向设备4发送同步控制指令,其中,同步控制指令中包括待同步设备为设备2、设备2的文件传输端口信息及待同步的文件信息为文件1。设备3接收到同步控制指令之后,根据同步控制指令中携带的待同步的文件信息,获取到已存储的待同步文件,并通过同步控制指令中携带的设备1的文件传输端口向待同步设备(设备1)传输待同步文件,设备1通过文件传输端口信息指示的端口接收待同步文件。同理,设备4接收到同步控制指令之后,根据同步控制指令中携带的待同步的文件信息,获取到已存储的待同步文件,并通过同步控制指令中携带的设备2的文件传输端口向待同步设备(设备2)传输待同步文件,设备2通过文件传输端口信息指示的端口接收待同步文件。
步骤S508、待同步设备根据待同步文件,更新相应的文件。
具体可参考步骤S402,在此不再赘述。
步骤S509a、第二设备向第一设备发送同步完成响应消息,第一设备接收第二设备返回的同步完成响应消息。
具体的,当第二设备向待同步设备传输完待同步文件之后,可以向第一设备返回同步完成响应消息,以告知第一设备以完成向待同步设备进行待同步文件的同步。第一设备接收同步完成响应消息,可以根据同步完成响应消息获知第二设备已经向待同步设备传输完待同步文件,文件同步完成。
步骤S510、第一设备根据待同步设备的子网信息及待同步的文件信息,更新同步文件的记录信息。
在本申请实施例中,第一设备会记录每次完成同步文件时的设备的子网信息及已完成同步的文件信息,即为每次完成同步文件时的设备的子网信息及已完成同步的文件信息时可以更新同步文件的记录信息。在接收到第二设备返回的同步完成响应消息 之后,第一设备确定已经完成文件同步,此时根据待同步设备的子网信息及待同步的文件信息,更新同步文件的记录信息。例如,可以将待同步设备的标识信息、待同步设备的子网信息及待同步的文件信息添加至同步文件的记录信息中。
本申请实施例中以待同步设备主动向第一设备请求进行文件同步为例进行说明,如图7所示,为本申请实施例提供的另一种文件同步方法的流程示意图。具体包括如下步骤:
步骤S701、待同步设备向第一设备发送同步文件请求消息,第一设备接收同步文件请求消息。
其中,同步文件请求消息中携带有子网信息及待同步的文件信息。
在本申请实施例中,待同步设备可以主动向第一设备请求同步文件,此时,待同步设备可以向第一设备发送同步文件请求消息,第一设备接收待同步设备发送的同步文件请求消息。
作为一种可能的实现方式,同步文件请求消息还携带有待同步设备的文件传输端口信息。
其中,文件传输端口信息用于指示待同步设备进行文件传输时使用的端口。
在一些实施例中,由于待同步设备需要通过指定的端口进行文件传输,因此,待同步设备可以将文件传输端口信息添加至同步文件请求消息中,并向第一设备发送同步文件请求消息,以告知第一设备待同步设备的文件传输端口。
步骤S702、第一设备向待同步设备发送同步文件响应消息,待同步设备接收同步文件响应消息。
在本申请实施例中,第一设备在接收到待同步设备发送的同步文件响应消息之后,若可以为待同步设备进行文件同步,则可以向待同步设备发送同步文件响应消息,待同步设备接收同步文件响应消息,从而获知第一设备同意为其进行文件同步。
步骤S703、第一设备从同步文件请求消息中获取待同步设备的子网信息及待同步的文件信息。
在本申请实施例中,同步文件请求消息中携带有子网信息及待同步的文件信息,第一设备通过解析同步文件请求消息,可以获知同步文件请求消息中携带的待同步设备的子网信息及待同步的文件信息。
作为一种可能的实现方式,当待同步设备发送的同步文件请求消息还携带有待同步设备的文件传输端口信息时,第一设备通过解析待同步设备发送的同步文件请求消息,可以获知待同步设备进行文件传输时使用的端口。
步骤S704、第一设备获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息。
具体可参考步骤S202,在此不再赘述。当确定存在第二设备的子网信息及已完成同步的文件信息时,执行步骤S705a至步骤S707a,步骤S708,步骤S709a及步骤S710;当确定不存在第二设备的子网信息及已完成同步的文件信息时,执行步骤S705b、步骤S708及步骤S710。
步骤S705a、若存在,则向第二设备发送同步控制指令,第二设备接收同步控制 指令。
具体可参考步骤S505a,在此不再赘述。
需要说明的是,在待同步设备主动向第一设备请求进行文件同步时,也可能存在至少两个第二设备,在存在至少两个第二设备时,具体执行步骤可参考步骤S505a。
步骤S705b、若不存在,第一设备根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件,待同步设备接收待同步文件。
具体可参考步骤S505b,在此不再赘述。
步骤S706a、第二设备根据同步控制指令,确定待同步的文件信息及待同步设备。
具体可参考步骤S302,在此不再赘述。
步骤S707a、第二设备通过文件传输端口信息指示的端口向待同步设备发送待同步文件,待同步设备通过文件传输端口信息指示的端口接收待同步文件。
具体可参考步骤S507a,在此不再赘述。
步骤S708、待同步设备根据待同步文件,更新相应的文件。
具体可参考步骤S402,在此不再赘述。
步骤S709a、第二设备向第一设备发送同步完成响应消息,第一设备接收第二设备返回的同步完成响应消息。
具体可参考步骤S509a,在此不再赘述。
步骤S710、第一设备根据待同步设备的子网信息及待同步的文件信息,更新同步文件的记录信息。
具体可参考步骤S510,在此不再赘述。
这样一来,根据上述图5或图7所述的方法,在第一设备需要向待同步设备同步文件时,若第一设备所属子网与待同步设备所属子网不同,而第二设备与待同步设备所属子网相同,并且第二设备已经同步过待同步设备需要同步的文件,那么第一设备可以调度第二设备向待同步设备发送待同步文件。由于第二设备所属子网与待同步设备所属子网相同,因此相对于第一设备直接对待同步设备进行跨子网传输待同步文件,由第二设备向待同步设备传输待同步文件的速度更快,效率更高。并且,相对于P2P技术,采用上述实施例所述方法无需进行NAT探测和NAT穿越,可以降低文件同步的复杂度。同时,对于同一子网下的第二设备及待同步设备,第二设备可以直接向待同步设备发送待同步文件,无需NAT穿越便可以实现同一子网下的设备间的文件传输。
图8为本申请实施例提供的一种文件同步装置的结构示意图。如图8所示,该装置包括:
获取单元801,用于获取待同步设备的子网信息及待同步的文件信息。
处理单元802,用于获取同步文件的记录信息,并根据待同步设备的子网信息及待同步的文件信息在同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息。
其中,第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同,同步文件的记录信息用于记录已完成文件同步的设备的子网 信息及已完成同步的文件信息。
处理单元802,还用于,若存在,则向第二设备发送同步控制指令。同步控制指令用于指示第二设备向待同步设备传输待同步文件。
作为一种可能的实现方式,如图9所示,所述文件同步装置还包括:
接收单元803,用于接收第二设备返回的同步完成响应消息。
处理单元802,还用于根据待同步设备的子网信息及待同步的文件信息,更新同步文件的记录信息。
作为一种可能的实现方式,接收单元803,还用于接收待同步设备发送的同步文件请求消息;同步文件请求消息中携带有子网信息及待同步的文件信息;
处理单元802,还用于向待同步设备发送同步文件响应消息。
获取单元801,具体用于从同步文件请求消息中获取待同步设备的子网信息及待同步的文件信息。
作为一种可能的实现方式,处理单元802,还用于向待同步设备发送同步文件通知消息;
接收单元803,还用于接收待同步设备发送的同步文件响应消息;同步文件响应消息中携带有待同步设备的文件传输端口信息。
作为一种可能的实现方式,处理单元802,具体用于若存在,且存在至少两个第二设备的子网信息及已完成同步的文件信息与待同步设备的子网信息及待同步的文件信息相同,则获取至少两个第二设备的负载信息。
根据所述至少两个第二设备的负载信息,确定目标第二设备,向所述目标第二设备发送同步控制指令。
作为一种可能的实现方式,处理单元802,具体用于针对至少两个待同步设备中的每个待同步设备,根据至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备。
作为一种可能的实现方式,处理单元802,还用于若不存在,则根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件。
处理单元802,还用于根据待同步设备的子网信息及待同步的文件信息,更新同步文件的记录信息。
图10为本申请实施例提供的另一种文件同步装置的结构示意图。如图10所示,该装置包括:
接收单元1001,用于接收同步控制指令。同步控制指令用于指示第二设备向待同步设备传输待同步文件。
处理单元1002,用于根据同步控制指令,确定待同步的文件信息及待同步设备。
处理单元1002,还用于根据待同步的文件信息获取待同步文件,并向待同步设备发送待同步文件。
处理单元1002,还用于向第一设备发送同步完成响应消息。
作为一种可能的实现方式,处理单元1002,具体用于通过文件传输端口信息指示的端口向待同步设备发送待同步文件。
图11为本申请实施例提供的另一种文件同步装置的结构示意图。如图11所示,该装置包括:
接收单元1101,用于接收待同步文件。
处理单元1102,用于根据待同步文件,更新相应的文件。
作为一种可能的实现方式,处理单元1102,还用于向第一设备发送同步文件请求消息。同步文件请求消息中携带有子网信息及待同步的文件信息。
接收单元1101,还用于接收第一设备发送的同步文件响应消息。
作为一种可能的实现方式,接收单元1101,还用于接收第一设备发送的同步文件通知消息。
处理单元1102,还用于向第一设备发送同步文件响应消息,同步文件响应消息中携带有待同步设备的文件传输端口信息。
作为一种可能的实现方式,处理单元1102,具体用于通过文件传输端口信息指示的端口接收待同步文件。
与上述实施例相对应,本申请还提供了一种电子设备。图12为本发明实施例提供的一种电子设备的结构示意图,所述电子设备1200可以包括:处理器1201、存储器1202及通信单元1703。这些组件通过一条或多条总线进行通信,本领域技术人员可以理解,图中示出的服务器的结构并不构成对本发明实施例的限定,它既可以是总线形结构,也可以是星型结构,还可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
其中,所述通信单元1203,用于建立通信信道,从而使所述电子设备可以与其它设备进行通信。接收其他设备发送的用户数据或者向其他设备发送用户数据。
所述处理器1201,为电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器1202内的软件程序和/或模块,以及调用存储在存储器内的数据,以执行电子设备的各种功能和/或处理数据。所述处理器可以由集成电路(integrated circuit,IC)组成,例如可以由单颗封装的IC所组成,也可以由连接多颗相同功能或不同功能的封装IC而组成。举例来说,处理器1201可以仅包括中央处理器(central processing unit,CPU)。在本发明实施方式中,CPU可以是单运算核心,也可以包括多运算核心。
所述存储器1202,用于存储处理器1201的执行指令,存储器1202可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
当存储器1202中的执行指令由处理器1201执行时,使得电子设备1200能够执行图2或图3或图4所示实施例中的部分或全部步骤。
具体实现中,本发明还提供一种存储介质,其中,该存储介质可存储有程序,该程序执行时可包括本发明提供的文件同步方法的各实施例中的部分或全部步骤。所述的存储介质可为磁碟、光盘、只读存储记忆体(read-only memory,ROM)或随机存储记忆体(random access memory,RAM)等。
本领域的技术人员可以清楚地了解到本发明实施例中的技术可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本发明实施例中的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例或者实施例的某些部分所述的方法。
本说明书中各个实施例之间相同相似的部分互相参见即可。尤其,对于装置实施例和终端实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例中的说明即可。

Claims (23)

  1. 一种文件同步方法,其特征在于,应用于第一设备,所述方法包括:
    获取待同步设备的子网信息及待同步的文件信息;
    获取同步文件的记录信息,并根据所述待同步设备的子网信息及待同步的文件信息在所述同步文件的记录信息中确定是否存在第二设备的子网信息及已完成同步的文件信息;其中,所述第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同;所述同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息;
    若存在,则向所述第二设备发送同步控制指令;所述同步控制指令用于指示所述第二设备向所述待同步设备传输待同步文件。
  2. 根据权利要求1所述的方法,其特征在于,还包括:
    接收所述第二设备返回的同步完成响应消息;
    根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
  3. 根据权利要求1所述的方法,其特征在于,在所述获取待同步设备的子网信息及待同步的文件信息之前,还包括:
    接收所述待同步设备发送的同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
    向所述待同步设备发送同步文件响应消息;
    所述获取待同步设备的子网信息及待同步的文件信息包括:
    从所述同步文件请求消息中获取待同步设备的子网信息及待同步的文件信息。
  4. 根据权利要求3所述的方法,其特征在于,所述同步文件请求消息还携带有待同步设备的文件传输端口信息;文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口。
  5. 根据权利要求1所述的方法,其特征在于,在所述向所述第二设备发送同步控制指令之前,还包括:
    向所述待同步设备发送同步文件通知消息;
    接收所述待同步设备发送的同步文件响应消息;所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
  6. 根据权利要求3或4所述的方法,其特征在于,所述同步控制指令中携带有所述待同步设备的文件传输端口信息。
  7. 根据权利要求1所述的方法,其特征在于,所述若存在,则向所述第二设备发送同步控制指令包括:
    若存在,且存在至少两个第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同,则获取所述至少两个第二设备的负载信息;
    根据所述至少两个第二设备的负载信息,确定目标第二设备,向所述目标第二设备发送同步控制指令。
  8. 根据权利要求7所述的方法,其特征在于,所述待同步设备包括至少两个;
    所述根据所述至少两个第二设备的负载信息,确定目标第二设备包括:
    针对至少两个待同步设备中的每个待同步设备,根据所述至少两个第二设备的负载信息,确定每个待同步设备对应的目标第二设备。
  9. 根据权利要求1所述的方法,其特征在于,所述第一设备与所述待同步设备所属子网不同。
  10. 根据权利要求1所述的方法,其特征在于,还包括:
    若不存在,则根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件;
    根据所述待同步设备的子网信息及待同步的文件信息,更新所述同步文件的记录信息。
  11. 一种文件同步方法,其特征在于,应用于第二设备,所述方法包括:
    接收同步控制指令;所述同步控制指令用于指示所述第二设备向待同步设备传输待同步文件;
    根据所述同步控制指令,确定待同步的文件信息及待同步设备;
    根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件。
  12. 根据权利要求11所述的方法,其特征在于,还包括:
    向第一设备发送同步完成响应消息。
  13. 根据权利要求11所述的方法,其特征在于,所述同步控制指令中携带有待同步设备的文件传输端口信息;所述文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口;
    所述向所述待同步设备发送所述待同步文件包括:
    通过所述文件传输端口信息指示的端口向所述待同步设备发送所述待同步文件。
  14. 一种文件同步方法,其特征在于,包括:
    接收待同步文件;
    根据所述待同步文件,更新相应的文件。
  15. 根据权利要求14所述的方法,其特征在于,在所述接收待同步文件之前,还包括:
    向第一设备发送同步文件请求消息;所述同步文件请求消息中携带有子网信息及待同步的文件信息;
    接收所述第一设备发送的同步文件响应消息。
  16. 根据权利要求15所述的方法,其特征在于,所述同步文件请求消息中还携带有待同步设备的文件传输端口信息;文件传输端口信息用于指示所述待同步设备进行文件传输时使用的端口。
  17. 根据权利要求14所述的方法,其特征在于,在所述接收待同步文件之前,还包括:
    接收第一设备发送的同步文件通知消息;
    向所述第一设备发送同步文件响应消息,所述同步文件响应消息中携带有所述待同步设备的文件传输端口信息。
  18. 根据权利要求16或17所述的方法,其特征在于,所述接收待同步文件包括:
    通过所述文件传输端口信息指示的端口接收待同步文件。
  19. 一种文件同步装置,其特征在于,包括:
    获取单元,用于获取待同步设备的子网信息及待同步的文件信息;
    处理单元,用于获取同步文件的记录信息,并根据所述待同步设备的子网信息及待同步的文件信息在所述同步文件的记录信息确定是否存在第二设备的子网信息及已完成同步的文件信息;其中,所述第二设备的子网信息及已完成同步的文件信息与所述待同步设备的子网信息及待同步的文件信息相同;所述同步文件的记录信息用于记录已完成文件同步的设备的子网信息及已完成同步的文件信息;
    所述处理单元,还用于,若存在,则向所述第二设备发送同步控制指令;所述同步控制指令用于指示所述第二设备向所述待同步设备传输待同步文件。
  20. 一种文件同步装置,其特征在于,包括:
    接收单元,用于接收同步控制指令;所述同步控制指令用于指示第二设备向待同步设备传输待同步文件;
    处理单元,用于根据所述同步控制指令,确定待同步的文件信息及待同步设备;
    所述处理单元,还用于根据所述待同步的文件信息获取待同步文件,并向所述待同步设备发送所述待同步文件。
  21. 一种文件同步装置,其特征在于,包括:
    获取单元,用于接收待同步文件;
    处理单元,用于根据所述待同步文件,更新相应的文件。
  22. 一种电子设备,其特征在于,包括:处理器和存储器,所述存储器存储有计算机程序,当所述计算机程序被执行时,使得所述电子设备执行权利要求1-10任一项或11-13任一项或14-18任一项所述的方法。
  23. 一种存储介质,其特征在于,所述存储介质包括存储的程序,其中,在所述程序运行时控制所述存储介质所在设备执行权利要求1-10任一项或11-13任一项或14-18任一项所述的方法。
PCT/CN2023/095772 2022-05-30 2023-05-23 一种文件同步方法、装置、设备及存储介质 WO2023231836A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210605613.2 2022-05-30
CN202210605613.2A CN117201510A (zh) 2022-05-30 2022-05-30 一种文件同步方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2023231836A1 true WO2023231836A1 (zh) 2023-12-07

Family

ID=89002162

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/095772 WO2023231836A1 (zh) 2022-05-30 2023-05-23 一种文件同步方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN117201510A (zh)
WO (1) WO2023231836A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103986738A (zh) * 2013-02-07 2014-08-13 百度在线网络技术(北京)有限公司 一种多终端间的同步方法及系统
US8959242B1 (en) * 2014-07-02 2015-02-17 Connected Data, Inc. Method of reducing bandwidth required for sharing of files on a server
CN105933393A (zh) * 2016-04-12 2016-09-07 乐视控股(北京)有限公司 一种局域网内数据同步方法及其装置、用户终端
CN109358876A (zh) * 2018-09-28 2019-02-19 联想(北京)有限公司 一种版本同步方法及装置、设备、存储介质
CN112118322A (zh) * 2020-09-24 2020-12-22 杭州海康威视数字技术股份有限公司 一种网络设备的数据同步方法、网络设备及系统

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103906087A (zh) * 2012-12-28 2014-07-02 华为技术有限公司 升级接入点的方法、装置和系统
CN104244306A (zh) * 2014-09-15 2014-12-24 杭州华三通信技术有限公司 一种接入点固件升级方法和装置
CN106060135B (zh) * 2016-05-31 2019-08-06 新华三技术有限公司 一种版本更新方法和装置
CN109218359A (zh) * 2017-07-03 2019-01-15 深圳市中兴微电子技术有限公司 一种物联网设备软件更新的方法及服务器端
CN108809468B (zh) * 2018-05-25 2020-11-10 东软集团股份有限公司 时间同步的方法、装置和存储介质以及电子设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103986738A (zh) * 2013-02-07 2014-08-13 百度在线网络技术(北京)有限公司 一种多终端间的同步方法及系统
US8959242B1 (en) * 2014-07-02 2015-02-17 Connected Data, Inc. Method of reducing bandwidth required for sharing of files on a server
CN105933393A (zh) * 2016-04-12 2016-09-07 乐视控股(北京)有限公司 一种局域网内数据同步方法及其装置、用户终端
CN109358876A (zh) * 2018-09-28 2019-02-19 联想(北京)有限公司 一种版本同步方法及装置、设备、存储介质
CN112118322A (zh) * 2020-09-24 2020-12-22 杭州海康威视数字技术股份有限公司 一种网络设备的数据同步方法、网络设备及系统

Also Published As

Publication number Publication date
CN117201510A (zh) 2023-12-08

Similar Documents

Publication Publication Date Title
CN108768817B (zh) 一种虚拟化网络组网系统、数据包发送方法
US11398956B2 (en) Multi-Edge EtherChannel (MEEC) creation and management
EP3225014B1 (en) Source ip address transparency systems and methods
CN111736958B (zh) 虚拟机迁移方法、系统、计算机设备及存储介质
CN103118148B (zh) 一种arp缓存更新方法和设备
US10574570B2 (en) Communication processing method and apparatus
JP5861772B2 (ja) ネットワークアプライアンス冗長化システム、制御装置、ネットワークアプライアンス冗長化方法及びプログラム
WO2014154087A1 (en) A gateway and its method of transfering data
CN115225634B (zh) 虚拟网络下的数据转发方法、装置及计算机程序产品
US12052171B2 (en) Communication system and communication method
CN111193773A (zh) 负载均衡方法、装置、设备及存储介质
WO2021098727A1 (zh) 网络部署的方法及系统
WO2021008591A1 (zh) 数据传输方法、装置及系统
CN101631075A (zh) 一种报文处理方法和设备
CN117083843A (zh) 利用多播侦听者发现来发现主机
WO2012120474A1 (en) Sctp association endpoint relocation in a load balancing system
CN109120556B (zh) 一种云主机访问对象存储服务器的方法及系统
US10924397B2 (en) Multi-VRF and multi-service insertion on edge gateway virtual machines
WO2023231836A1 (zh) 一种文件同步方法、装置、设备及存储介质
US12088493B2 (en) Multi-VRF and multi-service insertion on edge gateway virtual machines
JP6718739B2 (ja) 通信装置および通信方法
JP2017184195A (ja) 通信管理装置、通信管理方法及びプログラム
JP6362424B2 (ja) 中継装置および中継方法
JP6062394B2 (ja) 中継装置および中継方法
CN114745393B (zh) 会话同步系统及其方法、云计算中心和云计算设备

Legal Events

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

Ref document number: 23815020

Country of ref document: EP

Kind code of ref document: A1