正在加载图片...
5 Example Assume you have two images A gif and B. gif you want to share. These two files are available in the example subdirectory of the code. We strongly suggest that you walk through these steps as you read them in order to get a better understanding of what each file contains(the hash values in this document are not the actual hash values, to mprove readability) First, create two files whose sizes are multiple of 512K, using tar cf- A gif I dd of=/tmp/A tar bs=512K conv=sync count=2 tar cf -B. gif i dd of=/tmp/B tar bs=512K conv=sync count=2 With padding, A tar and B tar are exactly IMB big(ie: 2 chunks long) Lets run two nodes, one on port 1111 and one on port 2222 Suppose that the SHA-I hash of the first 512KB of A tar is OxDE and the second 512KB is OxAD. Similarly, for B tar the 0-512KB chunk hash is ox 15 and the 512KB-I MB chunk hash is 0x44 1 First. do the follow cat /tmp/A tar /tmp/B tar >/tmp/ctar make-chunks /tmp/c tar >/tmp/c chunks make-chunks /tmp/A tar >/tmp/A chunks make-chunks /tmp/B tar >/tmp/B chunk This will create the master data file at /tmp/C. tar. The contents of C chunks will be 000000000000000000000000000000000000000de 10000000000000000000000000000000000000 20000000000000000000000000000000000000015 30000000000000000000000000000000000000441 Recall that ids are in decimal format, while the hash is in hexadecimal. The contents of A chunks will be 100000000000000000000000000000000000000ad The contents of b chunks will be 00000000000000000000000000000000000000015 10000000000000000000000000000000000000441 Next. edit the c chunks file to add two lines and save this as c. masterchunks File: /tmp/ctar chunks 000000000000000000000000000000000000000de 100000000000000000000000000000000000000ad 000000000000000000000000000000000015 30000000000000000000000000000000000000441 lext create a peer file called/tmp/nodes.map It should contain 1127.0.0.11111 Finally, you need to create files that describe the initial content of each node. Let node I have all of file A tar and none of file b tar. Let node 2 have all of file B tar and none of A tar Create a file/tmp/A. haschunks whose contents are5 Example Assume you have two images A.gif and B.gif you want to share. These two files are available in the ‗example‘ subdirectory of the code. We strongly suggest that you walk through these steps as you read them in order to get a better understanding of what each file contains (the hash values in this document are not the actual hash values, to improve readability). First, create two files whose sizes are multiple of 512K, using: tar cf - A.gif | dd of=/tmp/A.tar bs=512K conv=sync count=2 tar cf - B.gif | dd of=/tmp/B.tar bs=512K conv=sync count=2 With padding, A.tar and B.tar are exactly 1MB big (ie: 2 chunks long). Let‘s run two nodes, one on port 1111 and one on port 2222 Suppose that the SHA-1 hash of the first 512KB of A.tar is 0xDE and the second 512KB is 0xAD. Similarly, for B.tar the 0-512KB chunk hash is 0x15 and the 512KB-1MB chunk hash is 0x441. First, do the following: cat /tmp/A.tar /tmp/B.tar > /tmp/C.tar make-chunks /tmp/C.tar > /tmp/C.chunks make-chunks /tmp/A.tar > /tmp/A.chunks make-chunks /tmp/B.tar > /tmp/B.chunks This will create the master data file at /tmp/C.tar. The contents of C.chunks will be: 0 00000000000000000000000000000000000000de 1 00000000000000000000000000000000000000ad 2 0000000000000000000000000000000000000015 3 0000000000000000000000000000000000000441 Recall that ids are in decimal format, while the hash is in hexadecimal. The contents of A.chunks will be: 0 00000000000000000000000000000000000000de 1 00000000000000000000000000000000000000ad The contents of B.chunks will be: 0 0000000000000000000000000000000000000015 1 0000000000000000000000000000000000000441 Next, edit the C.chunks file to add two lines and save this as C.masterchunks: File: /tmp/C.tar Chunks: 0 00000000000000000000000000000000000000de 1 00000000000000000000000000000000000000ad 2 0000000000000000000000000000000000000015 3 0000000000000000000000000000000000000441 Next create a peer file called /tmp/nodes.map It should contain 1 127.0.0.1 1111 2 127.0.0.1 2222 Finally, you need to create filesthat describe the initial content of each node. Let node 1 have all of file A.tar and none of file B.tar. Let node 2 have all of file B.tar and none of A.tar. Create a file /tmp/A.haschunks whose contents are: 8
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有