In CET, there is a background downloading system where downloading does not stop the user from doing anything in CET called BITS, abbreviated from Background Intelligent Transfer Service. It is a component of Microsoft (Wikipedia page).
By using BITS, this system can update Extensions in the background and also allow background download of new Extensions that have been manually selected by the user.
BITS creates a “job” on what files to download and periodically check the status. When finished, it then saves a copy of the file.
Advantages
- Works everywhere
- Asynchronous
- Downloads even if CET is turned off
- Uses idle network bandwidth
Disadvantages
- Very slow response time (10-300 ms)
- Very sensitive to workload (jobs*files)
Microsoft recommends to not exceed a total of 10 jobs, and each job not exceed 10 files. This recommendation applies to ALL applications in the computer using BITS. - No support for directory listings (!)
- No peer caching (in version < 4)
4 end users in a dealership would only require one single download (like workgroup extension storage) - Slow downloads
One file at a time feeling, Windows Update might interfere as it takes higher priority, and if the internet connection is slow might not have anything downloaded.
Dealing with the Disadvantages
- Try to limit the job queue to 5 jobs
- Use webdirectory.exe (automatically done in extensions)
- Defensive polling (only when idle)
Uses of BITS
- Marbodal uses BITS for pricelist updates
- BITS can also do uploads (like issue reports)
- Easy to sync all files in a directory (*.db)
- OO – you can subclass and customize
Usage Examples
The example can be found in cet/runtime/rtBitsTest.cm, in the rtBitsTestInit()
function. This part of the function shows how to download one file:
// Setup a handler UpdateHandler handler = createUpdateHandler("cet-test-bits", "CET Test Handler"); handler.updateInterval = 3 minutes; handler.jobInterval = 30 s; handler.idleThreshold = 5 s; // Setup an update group str remoteDir = configuraWebRoot # relativeDir; Url localDir = cmWritable("data/"); RtBitsTestGroup group("cet-test-bits-group", "Test Group", remoteDir, localDir, waitForAll=true); handler << group; // Setup a single file to keep updated RtBitsTestUpdate update(fileToDownload); group << update; // Start the timers handler.startTimers();
And if you want to download a folder, change replace the code as such with the bolded code :
// Setup a handler UpdateHandler handler = createUpdateHandler("cet-test-bits", "CET Test Handler"); handler.updateInterval = 3 minutes; handler.jobInterval = 30 s; handler.idleThreshold = 5 s; // Setup an update group str remoteDir = configuraWebRoot # relativeDir; Url localDir = cmWritable("data/"); UpdateDirectoryGroup syncMyStuff("my-pricelists-sync", "Sync the pricelists directory", remoteDir, localDir, waitForAll=true); // Start the timers handler.startTimers();
Comments
0 comments
Please sign in to leave a comment.