Creating an RDC Application
This section describes the basic tasks for creating a Remote Differential Compression (RDC) application.
Implementing the IRdcFileReader Interface
Because the files to be compared might not be actual files on disk, RDC does not perform file I/O directly. Thus, your application must implement the IRdcFileReader interface and its methods for the IRdcComparator::Process method to use for reading signatures sequentially from the seed signature file. Your client application can also use your IRdcFileReader methods for copying chunks of file data from the source and seed files.
The IRdcFileReader interface is used by the following:
- The client application uses the IRdcFileReader::Read method for reading signatures from the source signature file and for reading the needed chunks of file data from the source and seed files.
- The IRdcComparator::Process method uses the Read method for reading signatures from the seed signature file.
- The IRdcLibrary::CreateComparator method uses the IRdcFileReader::GetFileSize method to obtain the size of the seed signature file.
- The IRdcSignatureReader::ReadHeader and IRdcSignatureReader::ReadSignatures methods, which are used for debugging, use the Read method for reading signature and header information from the seed and source signature files.
You are not required to implement the IRdcFileReader::GetFilePosition method, because it is not used.
Creating the Signature Generator
Your application must create a signature generator. The client and server use the generator to create signatures for the data in the source and seed files.
To create a signature generator
- Compute the default recursion depth for the generator by calling the IRdcLibrary::ComputeDefaultRecursionDepth method. Note that RDC supports a maximum recursion depth of eight levels. Most applications will need no more than one or two levels.
- After you have chosen an appropriate recursion depth for your application, you can create the generator parameters by calling the IRdcLibrary::CreateGeneratorParameters method. You will need to call this method once for each level of recursion depth.
- Most applications should use the default generator parameter values. If necessary, you can change the default values by calling the IRdcGeneratorFilterMaxParameters::SetHashWindowSize and IRdcGeneratorFilterMaxParameters::SetHorizonSize methods for each of the parameter blocks.
- Create the generator by calling the IRdcLibrary::CreateGenerator method, passing a pointer to the array of parameter blocks in the iGeneratorParametersArray parameter.
Generating the Signatures
After your application has created the signature generator, the server and client can generate signatures by calling the IRdcGenerator::Process method.
Creating the Signature Comparators
Your RDC application must create a set of signature comparators, one for each level of recursion depth. (See "Creating the Signature Generator.") Each comparator compares the contents of the seed and source signature files for a given level of recursion and stores the results into a needs list.
Comparing the Signatures
After your application has created the signature comparators, it can use them to compare the source and seed signatures by calling the IRdcComparator::Process method. This method produces a needs list, which the client then uses to construct the target file.
Constructing the Target File
After your application has created the needs list, the client can use that list to construct the target file using chunks of file data from the seed and source files.
- If the m_BlockType value is RDCNEED_SEED, this means that the chunk is common to the source and seed files. The client copies the chunk locally from the seed file to the target file.
- If the m_BlockType value is RDCNEED_SOURCE, this means that the client must download the chunk from the server's source file and copy it to the target file.
Validating the Target File
Your RDC application should verify that the target file created by the client matches the source file on the server. You can do this by computing SHA-1 hash values for the entire source and target files and comparing them. This check can help to detect problems such as signature collisions, cached signature files that might be out of sync with the source or seed files, or other application bugs.
If the target file verification fails, the application must delete the client's target file and copy the source file from the server to the client.