Data synchronization Scheme (Java source code included)

Source: Internet
Author: User

I. Background to the issue
Often encountered to synchronize data, and the system comes with the replication function can not achieve incremental synchronization, each time to do the full amount of replication, the abnormal situation can only start again, very troublesome, excellent it is the kind of large file processing, it is time-consuming.
Two. Solution
1. Calculate the source directory data fingerprint
2. Calculating the target directory data fingerprint
3. Compare fingerprint data, find out the difference, get a list of files that need to be added, deleted or updated, and calculate the size of the data that needs to be updated
4. Synchronize the differences each time, if you encounter large files, then cache their fingerprint data to the target folder for the next synchronization of data to use
Three. Data fingerprint description
The data fingerprint, as its name implies, is a unique identifier for a folder or file, in the form of:
File relative path +:(delimiter) + Modified date +:+ data length +:+ internal fingerprint
The internal fingerprint is made up of MD5 of multiple content blocks.
Content block is to partition large files, each time comparing data, the smallest synchronization object is the content block, to avoid processing the entire file, but also to achieve incremental synchronization of the key point
Four. Source code download
Source: Https://github.com/xxonehjh/file-sync
Executable file: Filesync.jar
Instruction for use: Java-jar Filesync.jar source Directory destination Directory

Data synchronization Scheme (Java source code included)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.