public class UploadMakerEx extends Object
UploadMaker that accommodates updating of potentially
redundant files, ie files containing blocks that repeat at multiple offsets.
It is not necessary to use this class rather than UploadMaker. This class simply
decreases the amount of data that needs to be transmitted for certain cases of redundant files. The
sole difference from UploadMaker is that this class uses methods that expect a reverse block-matching in the
form of an array where f[serverIndex] = localOffset (actually implemented as a List of OffsetPairs),
whereas UploadMaker expects f[localOffset] = serverIndex.
The main advantage of the reverse mapping is that it allows multiple identical block ranges in the local
file to be mapped to a single range in the server file. If a given block occurs more times on the local file than
on the server file, the f[serverIndex] array will not identify all of those local occurences, and the unmatched ones
will be transmitted needlessly.| Modifier and Type | Field and Description |
|---|---|
File |
localCopy
The local file that will replace the server file
|
File |
serversMetafile
The .zsync of the server file to be replaced
|
| Constructor and Description |
|---|
UploadMakerEx(File sourceFile,
File zsFile)
Constructor that initializes an Upload object and invokes methods to parse
the zsync file.
|
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
getDataRanges(List<Range> ranges,
File local)
Constructs the List of DataRange objects containing the portions of the client file
to be uploaded to the server.
|
File |
getUploadFile()
Generates the upload content to a temp file.
|
InputStream |
makeUpload()
Returns the stream of bytes to be used as the body of a ZSync PUT.
|
static InputStream |
serversMissingRangesEx(List<OffsetPair> reverseMap,
File local,
int blockSize)
Determines the byte ranges from the client file that need to be uploaded to the server.
|
static InputStream |
serversRelocationRangesEx(List<OffsetPair> reverseMap,
int blockSize,
long fileLength,
boolean combineRanges)
Determines the instructions needed by the server to relocate blocks of data already contained
in its version of the file.
|
public final File localCopy
public final File serversMetafile
public UploadMakerEx(File sourceFile, File zsFile) throws IOException
sourceFile - The client file to be uploadedzsFile - The zsync of the server's fileIOExceptionpublic static InputStream serversMissingRangesEx(List<OffsetPair> reverseMap, File local, int blockSize) throws UnsupportedEncodingException, IOException
reverseMap - The List of block-matches obtained from MakeContextExlocal - The local file being uploadedblockSize - The block size used in reverseMapIOExceptionUnsupportedEncodingExceptionUploadMaker.serversMissingRanges(long[], java.io.File, int)public static InputStream serversRelocationRangesEx(List<OffsetPair> reverseMap, int blockSize, long fileLength, boolean combineRanges) throws UnsupportedEncodingException, IOException
reverseMap - The List of block-matches obtained from MakeContextExblockSize - The block size used to generate reverseMapfileLength - The length of the client file being uploadedcombineRanges - Whether to combine consecutive block matches into a single RelocateRangeIOExceptionUnsupportedEncodingExceptionUploadMaker#serversRelocationRanges}public static InputStream getDataRanges(List<Range> ranges, File local) throws IOException
ranges - The List of Ranges from the client file needed by the server, which can be
obtained from #serversMissingRangesEx(List, long, int)local - The client file to be uploadedIOExceptionpublic InputStream makeUpload() throws IOException
UnsupportedEncodingExceptionIOExceptionpublic File getUploadFile() throws IOException
IOExceptionCopyright © 2021 McEvoy Software Ltd. All rights reserved.