CN107948316B - File synchronization method, device and equipment - Google Patents

File synchronization method, device and equipment Download PDF

Info

Publication number
CN107948316B
CN107948316B CN201711422487.2A CN201711422487A CN107948316B CN 107948316 B CN107948316 B CN 107948316B CN 201711422487 A CN201711422487 A CN 201711422487A CN 107948316 B CN107948316 B CN 107948316B
Authority
CN
China
Prior art keywords
command message
file
message queue
distinguishing
updated
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201711422487.2A
Other languages
Chinese (zh)
Other versions
CN107948316A (en
Inventor
黄飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sohu New Media Information Technology Co Ltd
Original Assignee
Beijing Sohu New Media Information Technology Co Ltd
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 Beijing Sohu New Media Information Technology Co Ltd filed Critical Beijing Sohu New Media Information Technology Co Ltd
Priority to CN201711422487.2A priority Critical patent/CN107948316B/en
Publication of CN107948316A publication Critical patent/CN107948316A/en
Application granted granted Critical
Publication of CN107948316B publication Critical patent/CN107948316B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • 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/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Abstract

The invention provides a file synchronization method, a device and equipment, wherein receiving equipment can determine a distinguishing command message queue according to a command message queue and a local command message queue locally stored by the receiving equipment, and updates according to any type of sub distinguishing command message queue in the distinguishing command message queue. Because the contents in the command message queue and the local command message queue only need to be compared, compared with the processes of segmenting data, calculating check codes and comparing, the method has the advantages of simple operation and no occupation of more resources.

Description

File synchronization method, device and equipment
Technical Field
The present invention relates to the field of file synchronization, and in particular, to a file synchronization method, device and facility.
Background
Today, content delivery network CDN servers are employed to serve users. The files in each CDN server are realized by synchronizing the files in the server to the CDN servers. In order to guarantee the service quality, new files or modified files in the server need to be synchronized to the CDN server in real time.
The synchronization process includes that each CDN server segments a file stored locally to obtain a plurality of data blocks with fixed sizes, calculates check codes of each data block, and summarizes the check codes of each data block to obtain a check code set.
And then, the server segments the file stored locally to obtain a plurality of data blocks with the same size as the data blocks obtained by the segmentation of the CDN server, calculates the check code of each data block obtained by the segmentation, compares the check code with a check code set, and does not synchronize the data block into the CDN server if the check code exists in the check code set. And if the check code does not exist in the check code set, synchronizing the data block to the CDN server.
The synchronization method needs to perform the processes of data segmentation, check code calculation and check code comparison, is complex to operate, occupies more resources and increases the workload of the server.
Disclosure of Invention
In view of this, the present invention provides a file synchronization method, device and apparatus, so as to solve the problems that the synchronization method in the prior art is complex in operation and occupies more resources.
In order to solve the technical problems, the invention adopts the following technical scheme:
a file synchronization method is applied to a receiving device and comprises the following steps:
after the communication connection with the sending equipment, acquiring a command message queue in the sending equipment;
determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
Preferably, determining a differentiated command message queue according to the command message queue and a local command message queue locally stored by the receiving device includes:
acquiring different statistical dimensions in the local command message queue;
for each statistical dimension, sequentially comparing the difference points of the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generating a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained by comparison;
and generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
Preferably, the file attribute information includes a file editing instruction, a file name, a file storage address, and a timestamp when the file is generated;
correspondingly, when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained, updating the file in the receiving device according to the sub distinguishing command message queue, including:
and acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub distinguishing command message queue, and updating the files to be updated according to corresponding file editing instructions.
A file synchronization method is applied to a sending device and comprises the following steps:
when the file attribute information of a file to be updated is newly added in a preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory;
monitoring a preset port in real time, and judging whether a connection instruction sent by at least one receiving device is received;
when judging that a connection instruction sent by at least one receiving device is received, connecting with the receiving device sending the connection instruction;
a new communication thread is initiated to communicate with the receiving device connected to the sending device.
Preferably, when the file attribute information of the file to be updated is newly added to the preset file, format conversion is performed on the file attribute information of the file to be updated to obtain a command message queue, including:
when the file attribute information of the file to be updated is newly added in the preset file, a multithreading working mode is adopted to convert the format of the file attribute information of the file to be updated, and a command message queue is obtained.
A file synchronization device applied to a receiving device comprises:
the acquisition module is used for acquiring a command message queue in the sending equipment after the communication connection with the sending equipment is realized;
the comparison module is used for determining a difference command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and the updating module is used for updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues.
Preferably, the comparison module comprises:
the obtaining submodule is used for obtaining different statistical dimensions in the local command message queue;
a comparison submodule, configured to, for each statistical dimension, sequentially compare difference points between the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generate a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained through comparison;
and the generating submodule is used for generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
Preferably, the file attribute information includes a file editing instruction, a file name, a file storage address, and a timestamp when the file is generated;
correspondingly, the update module comprises:
and the updating submodule is used for acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub-discrimination command message queue, and updating the files to be updated according to the corresponding file editing instructions.
A file synchronization device applied to a sending device comprises:
the analysis module is used for carrying out format conversion on the file attribute information of the file to be updated when the file attribute information of the file to be updated is newly added in the preset file to obtain a command message queue and storing the command message queue in the memory;
the judging module is used for monitoring the preset port in real time and judging whether a connection instruction sent by at least one receiving device is received;
the connection module is used for connecting with the receiving equipment for sending the connection instruction when the judgment module judges that the connection instruction sent by at least one receiving equipment is received;
and the thread starting module is used for starting a new communication thread to communicate with the receiving equipment connected to the sending equipment after the connection module is connected with the receiving equipment sending the connection instruction.
Preferably, the parsing module includes:
and the analysis submodule is used for performing format conversion on the file attribute information of the file to be updated by adopting a multi-thread working mode when the file attribute information of the file to be updated is newly added in the preset file to obtain a command message queue.
A receiving device, comprising: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
after the communication connection with the sending equipment, acquiring a command message queue in the sending equipment;
determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues.
A transmitting device, comprising: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
when the file attribute information of a file to be updated is newly added in a preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory;
monitoring a preset port in real time, and judging whether a connection instruction sent by at least one receiving device is received;
when judging that a connection instruction sent by at least one receiving device is received, connecting with the receiving device sending the connection instruction;
a new communication thread is initiated to communicate with the receiving device connected to the sending device.
Compared with the prior art, the invention has the following beneficial effects:
the invention provides a file synchronization method, a device and equipment, wherein receiving equipment can determine a distinguishing command message queue according to a command message queue and a local command message queue locally stored by the receiving equipment, and updates according to any type of sub distinguishing command message queue in the distinguishing command message queue. Because the contents in the command message queue and the local command message queue only need to be compared, compared with the processes of segmenting data, calculating check codes and comparing, the method has the advantages of simple operation and no occupation of more resources.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flowchart of a method for synchronizing files according to the present invention;
FIG. 2 is a flow chart of another method for synchronizing files according to the present invention;
FIG. 3 is a flowchart of a method of another file synchronization method according to the present invention;
FIG. 4 is a schematic structural diagram of a file synchronization apparatus according to the present invention;
FIG. 5 is a schematic structural diagram of another file synchronization apparatus provided in the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a file synchronization method which is applied to receiving equipment, wherein the receiving equipment is equipment at a receiving end. It should be noted that the receiving device and the transmitting device communicate and the execution of the file synchronization method is dependent on the file synchronization system Csync in the receiving device and the transmitting device.
Before communication is performed, the file synchronization system in the receiving device and the transmitting device needs to be configured. The specific configuration process is as follows:
reading and analyzing the configuration file through a module interface of the Csync, and setting required parameter variables during the operation of the Csync, wherein the parameter variables comprise:
the software running mode (running in a client or server mode), whether the software is a daemon process, a user identification number ID, a user group ID, an occupied network port, timeout time, the maximum length of a command message queue command list, a monitored directory, an archived directory, a log-stored directory and each channel needing synchronization.
After configuration is completed, the Csync is started according to the analyzed configuration file, the environment is initialized, and the main thread monitors whether each sub-thread is deadlocked or not in a circulating mode.
The initialization environment means that parameters analyzed from the configuration file are stored in a memory, each sub-thread is started, the parameters stored in the memory are transmitted to each sub-thread, standard input and output are closed, and a working directory is switched to be under "/".
dead lock refers to a phenomenon that two or more processes are blocked in the process of executing due to resource competition or due to mutual communication, and cannot advance without external force. At this time, the system is said to be in a deadlock state or the system is deadlock. When the file is in the deadlock state, the deadlock state needs to be firstly removed, and then the file can be normally transmitted synchronously.
Referring to fig. 1, the file synchronization method applied to a receiving device may include:
s11, after the communication connection with the sending equipment, acquiring a command message queue in the sending equipment;
the command message queue in the sending device may be retrieved at regular intervals for updating.
When the file attribute information of a file to be updated is newly added in a preset file, format conversion is carried out on the file attribute information of the file to be updated by sending equipment to obtain a command message queue, and the command message queue is stored in a memory;
the preset file may be a synchronization list file listfile/conversion file list switchfile.
Specifically, when new content is released or some content is modified in the content management system cms/video management system vms, file attribute information of a file to be updated is added to the listfile/switchfile. The file attribute information comprises a file editing instruction, a file name, a file storage address and a timestamp when the file is generated.
The file editing command refers to an add or modify command, and the file name is the name of the file to be added or modified. The file storage address refers to where the file is stored. The time stamp at the time of file generation refers to the time at the time of file generation. The purpose of the time stamp is to know the time of generation of the file and to represent that the file is the most recent file.
In addition, the sending equipment carries out format conversion on the file attribute information of the file to be updated to obtain a command message queue. The method specifically comprises the following steps:
since the file attribute information of the file to be updated cannot be identified in the memory, the file attribute information of the file to be updated needs to be subjected to format conversion and converted into the content in the recognizable command message queue. The command message queue may be a command list message queue.
The listfile/switchfile file needs to be monitored by the monitoring thread list _ server in real time, and the listfile/switchfile file can be analyzed to the memory in time when data is newly added to the listfile/switchfile file.
S12, determining a difference command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment;
the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
in addition, when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained, the file in the receiving device is updated according to the sub distinguishing command message queues.
Specifically, the receiving device compares the command message queue with the local command message queue to obtain a differential command message queue. And when any type of sub distinguishing command message queue in the distinguishing command message queues is generated, updating the file in the receiving equipment according to the sub distinguishing command message queues.
In this embodiment, the receiving device may determine the distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving device, and update according to any one of the sub distinguishing command message queues in the distinguishing command message queue. Because the contents in the command message queue and the local command message queue only need to be compared, compared with the processes of segmenting data, calculating check codes and comparing, the method has the advantages of simple operation and no occupation of more resources.
Alternatively, on the basis of the foregoing embodiment, referring to fig. 2, step S12 may include:
s21, acquiring different statistical dimensions in the local command message queue;
wherein, the statistical dimension can be the dimension of finance, video, entertainment and the like.
Specifically, the contents stored in the sending device and the receiving device are classified and stored according to the statistical dimension. Thus, when updating, updating can be performed according to the type.
S22, for each statistical dimension, sequentially comparing the difference points of the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generating a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained by comparison;
specifically, the file attribute information of the file to be updated, which needs to be updated in different statistical dimensions, is stored in the command message queue. The local command message queue stores the file attribute information of the files which are updated.
After the statistical dimensions are determined, for each statistical dimension, comparing whether the contents of the local command message queue and the command message queue in the statistical dimension are the same.
Specifically, whether timestamps when the files are generated are the same or not may be compared, or whether the file names are the same or not may be compared, and when the file names are the same, whether the timestamps are the same or not may be further compared. When the file names are different or the time stamps are different, the file is indicated to be the file needing to be updated.
At this time, the file attribute information of the file to be updated is analyzed to the statistical dimension in the distinguishing command message queue, and the sub-distinguishing command message queue corresponding to the statistical dimension is obtained.
S23, generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
And after the sub-differential command message queues corresponding to each statistical dimension are obtained, summarizing all the sub-differential command message queues to obtain the differential command message queues.
It should be noted that, when the sub-difference command message queues are obtained through comparison, the accuracy of the contents in the sub-difference command message queues is ensured. At this time, the locking is performed by using a mutual exclusive lock mutex.
Specifically, when a thread compares the difference between the command message queue in a statistical dimension and the local command message queue, the local command message queue does not allow other threads to edit.
Optionally, on the basis of this embodiment, when the file attribute information includes a file editing instruction, a file name, a file storage address, and a timestamp when the file is generated, and when any type of sub differentiation command message queue in the differentiation command message queue is obtained, updating is performed according to the sub differentiation command message queue, including:
and acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub distinguishing command message queue, and updating the files to be updated according to corresponding file editing instructions.
Specifically, a file is found according to a file storage address, and when the file editing instruction is updated, the file is replaced with a file having the same file name in the receiving device. When the file editing instruction is newly added, the file is directly stored.
It should be noted that, after each sub-differential command message queue is determined, at least one thread may be enabled to perform a file update operation.
In addition, after the file is updated, a timestamp when the update is completed is written into the file attribute information of the corresponding file in the command message queue, so that the file is ensured to be successfully updated.
Third, updating according to the sub-distinguished command message queue may be performed by multiple file synchronization client threads sync _ client simultaneously.
Fourthly, after the receiving device completes updating according to the sub-differential command message queues, writing the file attribute information of the file to be updated in the corresponding local command message queues, and writing the time stamp of the file updating completion time into the file attribute information of the file to be updated.
Fifthly, when a thread finishes its update task, the receiving device will reclaim the resources of the thread to make the thread execute other tasks.
Sixthly, after the client times out or crashes the dead, the Csync monitoring thread watchdog _ server kills the sync _ client thread, releases the resource of the sync _ client thread, starts a new sync _ client, and synchronizes new data from the sync _ server end of the file synchronization server thread.
In this embodiment, after obtaining one sub distinguishing command message queue, the file to be updated in the sub distinguishing command message queue is updated, so that the file updating speed can be increased.
Optionally, corresponding to the file synchronization method applied to the receiving device, another embodiment of the present invention provides a file synchronization method applied to the sending device. The sending device may be a device of a server, such as a server.
Referring to fig. 3, the file synchronization method applied to the transmitting device may include:
s31, when the file attribute information of the file to be updated is newly added in the preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory;
for a detailed explanation in step S31, please refer to the corresponding contents in the above embodiments, which are not described herein again.
S32, judging whether a connection instruction sent by at least one receiving device is received; when judging that the connection instruction sent by at least one receiving device is received, executing step S33; when it is determined that the connection instruction transmitted by the at least one receiving apparatus is not received, step S34 is performed.
The preset port can be monitored in real time, and whether a connection instruction sent by at least one receiving device is received or not is judged. The predetermined port may be a transmission control protocol (tcp) port.
Specifically, the listening server sync _ server _ listener may listen to the TCP port, and when there is sync _ client connection, it considers that the connection instruction sent by the receiving device is received. When no sync _ client is connected, it is considered that the connection instruction transmitted by the receiving apparatus is not received.
S33, connecting with the receiving equipment sending the connection instruction;
s34, starting a new communication thread to communicate with the receiving device connected to the sending device.
Specifically, after connecting with the receiving device that sends the connection instruction, the sending device may start a new file synchronization server thread sync _ server to communicate with the receiving device.
And S35, monitoring the preset port in real time.
Specifically, when a sync _ client is connected, the sync _ client is connected. When no sync _ client is connected, the preset port is monitored continuously to judge whether the sync _ client is connected.
Optionally, on the basis of this embodiment, when the file attribute information of the file to be updated is newly added to the preset file, format conversion is performed on the file attribute information of the file to be updated to obtain a command message queue, which includes:
when the file attribute information of the file to be updated is newly added in the preset file, a multithreading working mode is adopted to convert the format of the file attribute information of the file to be updated, and a command message queue is obtained.
Specifically, file attribute information of a plurality of files to be updated may exist, and at this time, a multi-thread working mode may be adopted, and the file attribute information of the plurality of files to be updated is analyzed into a command message queue, so that the working efficiency is improved.
In the embodiment, the file attribute information of the files to be updated can be analyzed into the command message queue by adopting a multi-thread working mode, so that the working efficiency is improved, and the receiving equipment can be ensured to timely synchronize the files.
Optionally, on the basis of the above embodiment of the file synchronization method applied to the receiving device, another embodiment of the present invention provides a file synchronization apparatus applied to the receiving device, and with reference to fig. 4, the file synchronization apparatus may include:
an obtaining module 101, configured to obtain a command message queue in a sending device after being in communication connection with the sending device;
a comparing module 102, configured to determine a difference command message queue according to the command message queue and a local command message queue locally stored by the receiving device; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
an updating module 103, configured to update a file in the receiving device according to a sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queue is obtained.
In this embodiment, the receiving device may determine the distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving device, and update according to any one of the sub distinguishing command message queues in the distinguishing command message queue. Because the contents in the command message queue and the local command message queue only need to be compared, compared with the processes of segmenting data, calculating check codes and comparing, the method has the advantages of simple operation and no occupation of more resources.
It should be noted that, for the working process of each module in this embodiment, please refer to the corresponding description in the above embodiments, which is not described herein again.
Optionally, on the basis of the above embodiment of the file synchronization apparatus applied to the receiving device, the comparing module includes:
the obtaining submodule is used for obtaining different statistical dimensions in the local command message queue;
a comparison submodule, configured to, for each statistical dimension, sequentially compare difference points between the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generate a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained through comparison;
and the generating submodule is used for generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
Further, the file attribute information includes a file editing instruction, a file name, a file storage address and a timestamp when the file is generated;
correspondingly, the update module comprises:
and the updating submodule is used for acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub-discrimination command message queue, and updating the files to be updated according to the corresponding file editing instructions.
In this embodiment, after obtaining one sub distinguishing command message queue, the file to be updated in the sub distinguishing command message queue is updated, so that the file updating speed can be increased.
It should be noted that, for the working processes of each module and sub-module in this embodiment, please refer to the corresponding description in the above embodiments, which is not described herein again.
Optionally, on the basis of the above embodiment of the file synchronization method applied to the sending device, another embodiment of the present invention provides a file synchronization apparatus applied to the sending device, and with reference to fig. 5, the file synchronization apparatus may include:
the analysis module 201 is configured to, when file attribute information of a file to be updated is newly added to a preset file, perform format conversion on the file attribute information of the file to be updated to obtain a command message queue, and store the command message queue in a memory;
the judging module 202 is configured to monitor a preset port in real time, and judge whether a connection instruction sent by at least one receiving device is received;
the connection module 203 is configured to connect with the receiving device that sends the connection instruction when the determining module determines that the connection instruction sent by at least one receiving device is received;
a thread starting module 204, configured to start a new communication thread to communicate with the receiving device connected to the sending device after the connection module connects to the receiving device that sends the connection instruction.
Further, the parsing module comprises:
and the analysis submodule is used for performing format conversion on the file attribute information of the file to be updated by adopting a multi-thread working mode when the file attribute information of the file to be updated is newly added in the preset file to obtain a command message queue.
In the embodiment, the file attribute information of the files to be updated can be analyzed into the command message queue by adopting a multi-thread working mode, so that the working efficiency is improved, and the receiving equipment can be ensured to timely synchronize the files.
It should be noted that, for the working processes of each module and sub-module in this embodiment, please refer to the corresponding description in the above embodiments, which is not described herein again.
Optionally, on the basis of the above embodiments of the file synchronization method and apparatus applied to the receiving device, another embodiment of the present invention provides a receiving device, including: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
after the communication connection with the sending equipment, acquiring a command message queue in the sending equipment;
determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
In this embodiment, the receiving device may determine the distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving device, and update according to any one of the sub distinguishing command message queues in the distinguishing command message queue. Because the contents in the command message queue and the local command message queue only need to be compared, compared with the processes of segmenting data, calculating check codes and comparing, the method has the advantages of simple operation and no occupation of more resources.
Optionally, on the basis of the above embodiments of the file synchronization method and apparatus applied to the sending device, another embodiment of the present invention provides a sending device, including: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
when the file attribute information of a file to be updated is newly added in a preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory;
monitoring a preset port in real time, and judging whether a connection instruction sent by at least one receiving device is received;
when judging that a connection instruction sent by at least one receiving device is received, connecting with the receiving device sending the connection instruction;
a new communication thread is initiated to communicate with the receiving device connected to the sending device.
In the embodiment, the file attribute information of a plurality of files to be updated can be analyzed into the command message queue, so that the receiving equipment can be ensured to perform file synchronization in time.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (12)

1. A file synchronization method is applied to a receiving device and comprises the following steps:
after the communication connection with the sending equipment, acquiring a command message queue used for storing the file attribute information of the file to be updated in the sending equipment;
determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
2. The file synchronization method of claim 1, wherein determining a distinct command message queue based on the command message queue and a local command message queue stored locally by the receiving device comprises:
acquiring different statistical dimensions in the local command message queue;
for each statistical dimension, sequentially comparing the difference points of the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generating a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained by comparison;
and generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
3. The file synchronization method according to claim 1, wherein the file attribute information includes a file edit instruction, a file name, a file storage address, and a time stamp at the time of file generation;
correspondingly, when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained, updating the file in the receiving device according to the sub distinguishing command message queue, including:
and acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub distinguishing command message queue, and updating the files to be updated according to corresponding file editing instructions.
4. A file synchronization method is applied to a sending device and comprises the following steps:
when the file attribute information of a file to be updated is newly added in a preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory; the command message queue is used for storing file attribute information of a file to be updated;
monitoring a preset port in real time, and judging whether a connection instruction sent by at least one receiving device is received;
when judging that a connection instruction sent by at least one receiving device is received, connecting with the receiving device sending the connection instruction;
starting a new communication thread to communicate with the receiving equipment connected to the sending equipment, so that the receiving equipment obtains a command message queue used for storing file attribute information of a file to be updated in the sending equipment after the receiving equipment is in communication connection with the sending equipment; determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue; and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
5. The method of claim 4, wherein when the file attribute information of the file to be updated is newly added to the preset file, performing format conversion on the file attribute information of the file to be updated to obtain the command message queue, the method comprises:
when the file attribute information of the file to be updated is newly added in the preset file, a multithreading working mode is adopted to convert the format of the file attribute information of the file to be updated, and a command message queue is obtained.
6. A file synchronization device applied to a receiving device includes:
the acquisition module is used for acquiring a command message queue used for storing file attribute information of a file to be updated in sending equipment after the communication connection with the sending equipment is carried out;
the comparison module is used for determining a difference command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and the updating module is used for updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
7. The file synchronization apparatus according to claim 6, wherein the comparison module comprises:
the obtaining submodule is used for obtaining different statistical dimensions in the local command message queue;
a comparison submodule, configured to, for each statistical dimension, sequentially compare difference points between the content stored in the statistical dimension in the local command message queue and the content stored in the statistical dimension in the command message queue, and generate a sub-differential command message queue corresponding to the statistical dimension according to the difference points obtained through comparison;
and the generating submodule is used for generating the distinguishing command message queue according to all the generated sub distinguishing command message queues.
8. The file synchronizing apparatus according to claim 6, wherein the file attribute information includes a file edit instruction, a file name, a file storage address, and a time stamp at the time of file generation;
correspondingly, the update module comprises:
and the updating submodule is used for acquiring the files to be updated named as corresponding file names from the corresponding file storage addresses according to the file storage addresses in the file attribute information of each file to be updated, which are included in the sub-discrimination command message queue, and updating the files to be updated according to the corresponding file editing instructions.
9. A file synchronization apparatus applied to a transmission device includes:
the analysis module is used for carrying out format conversion on the file attribute information of the file to be updated when the file attribute information of the file to be updated is newly added in the preset file to obtain a command message queue and storing the command message queue in the memory; the command message queue is used for storing file attribute information of a file to be updated;
the judging module is used for monitoring the preset port in real time and judging whether a connection instruction sent by at least one receiving device is received;
the connection module is used for connecting with the receiving equipment for sending the connection instruction when the judgment module judges that the connection instruction sent by at least one receiving equipment is received;
the thread starting module is used for starting a new communication thread to communicate with the receiving equipment connected to the sending equipment after the connection module is connected with the receiving equipment sending the connection instruction, so that the receiving equipment obtains a command message queue used for storing the file attribute information of the file to be updated in the sending equipment after the receiving equipment is in communication connection with the sending equipment; determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue; and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
10. The file synchronization apparatus according to claim 9, wherein the parsing module comprises:
and the analysis submodule is used for performing format conversion on the file attribute information of the file to be updated by adopting a multi-thread working mode when the file attribute information of the file to be updated is newly added in the preset file to obtain a command message queue.
11. A receiving device, comprising: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
after the communication connection with the sending equipment, acquiring a command message queue used for storing the file attribute information of the file to be updated in the sending equipment;
determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue;
and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
12. A transmitting device, comprising: a memory and a processor;
wherein the memory is used for storing programs;
the processor is configured to invoke a program, wherein the program is configured to:
when the file attribute information of a file to be updated is newly added in a preset file, carrying out format conversion on the file attribute information of the file to be updated to obtain a command message queue, and storing the command message queue in a memory; the command message queue is used for storing file attribute information of a file to be updated;
monitoring a preset port in real time, and judging whether a connection instruction sent by at least one receiving device is received;
when judging that a connection instruction sent by at least one receiving device is received, connecting with the receiving device sending the connection instruction;
starting a new communication thread to communicate with the receiving equipment connected to the sending equipment, so that the receiving equipment obtains a command message queue used for storing file attribute information of a file to be updated in the sending equipment after the receiving equipment is in communication connection with the sending equipment; determining a distinguishing command message queue according to the command message queue and a local command message queue locally stored by the receiving equipment; the distinguishing command message queue comprises a plurality of types of sub distinguishing command message queues, and file attribute information of at least one file to be updated is stored in each sub distinguishing command message queue; and updating the file in the receiving equipment according to the sub distinguishing command message queue when any type of sub distinguishing command message queue in the distinguishing command message queues is obtained.
CN201711422487.2A 2017-12-25 2017-12-25 File synchronization method, device and equipment Active CN107948316B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711422487.2A CN107948316B (en) 2017-12-25 2017-12-25 File synchronization method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711422487.2A CN107948316B (en) 2017-12-25 2017-12-25 File synchronization method, device and equipment

Publications (2)

Publication Number Publication Date
CN107948316A CN107948316A (en) 2018-04-20
CN107948316B true CN107948316B (en) 2020-11-03

Family

ID=61938994

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711422487.2A Active CN107948316B (en) 2017-12-25 2017-12-25 File synchronization method, device and equipment

Country Status (1)

Country Link
CN (1) CN107948316B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434600B (en) * 2021-06-30 2023-06-09 青岛海尔科技有限公司 Data synchronization method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101326492A (en) * 2005-10-06 2008-12-17 雷德本德有限公司 Methods and systems for updating content including a compressed version
US7747999B1 (en) * 2005-09-26 2010-06-29 Juniper Networks, Inc. Software installation in a multi-chassis network device
CN102682178A (en) * 2012-05-22 2012-09-19 武汉大学 Consistency maintenance method in heterogeneous computer aided design (CAD) on-line integration
US9088491B2 (en) * 2012-03-07 2015-07-21 Citrix Systems, Inc. Systems and methods for comparing configuration files and generating corrective commands
CN105843871A (en) * 2016-03-18 2016-08-10 中国银联股份有限公司 Control and management system of distributed application file
CN106909128A (en) * 2015-12-23 2017-06-30 中国科学院沈阳自动化研究所 A kind of motion control method for supporting motion-control module online upgrading

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7747999B1 (en) * 2005-09-26 2010-06-29 Juniper Networks, Inc. Software installation in a multi-chassis network device
CN101326492A (en) * 2005-10-06 2008-12-17 雷德本德有限公司 Methods and systems for updating content including a compressed version
US9088491B2 (en) * 2012-03-07 2015-07-21 Citrix Systems, Inc. Systems and methods for comparing configuration files and generating corrective commands
CN102682178A (en) * 2012-05-22 2012-09-19 武汉大学 Consistency maintenance method in heterogeneous computer aided design (CAD) on-line integration
CN106909128A (en) * 2015-12-23 2017-06-30 中国科学院沈阳自动化研究所 A kind of motion control method for supporting motion-control module online upgrading
CN105843871A (en) * 2016-03-18 2016-08-10 中国银联股份有限公司 Control and management system of distributed application file

Also Published As

Publication number Publication date
CN107948316A (en) 2018-04-20

Similar Documents

Publication Publication Date Title
CN110309161B (en) Data synchronization method and device and server
US10824537B2 (en) Method, device, and computer readable medium for tracing computing system
CN112380093A (en) Operation and maintenance processing method and device and computer equipment
CN113220715B (en) Data processing method, system, computer and readable storage medium
WO2021169275A1 (en) Sdn network device access method and apparatus, computer device, and storage medium
CN105357273A (en) Universal SOCKET communication and process management platform and method in asynchronous communication mode
CN109218054B (en) Terminal dynamic configuration, corresponding server implementation method, device and storage medium
US10067862B2 (en) Tracking asynchronous entry points for an application
CN105338564B (en) A kind of client adaptation method, client, server and system
CN111984505B (en) Fortune dimension data acquisition device and acquisition method
CN116319790A (en) Rendering method, device, equipment and storage medium of full-true scene
CN115357662A (en) Data synchronization method, device and medium
CN109788251B (en) Video processing method, device and storage medium
CN107948316B (en) File synchronization method, device and equipment
CN109600423B (en) Data synchronization method and device, electronic equipment and storage medium
CN107566881B (en) VR equipment control method, device and system
CN107239272B (en) Video capture equipment redirection method and device
CN111327680A (en) Authentication data synchronization method, device, system, computer equipment and storage medium
CN112667393B (en) Method and device for building distributed task computing scheduling framework and computer equipment
CN115269719A (en) Data synchronization method and device
CN113778856B (en) APP detection method and system based on stream media semantic server
WO2011118048A1 (en) Program execution method, computing system, and program execution control program
CN111654410B (en) Gateway request monitoring method, device, equipment and medium
CN108449343B (en) SSH protocol text data acquisition method, acquisition device and computer equipment
US20240127111A1 (en) Internet-of-things-oriented machine learning container image download method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant