The core download scheduler. More...
#include <acquire.h>
Classes | |
class | Item |
Represents the process by which a pkgAcquire object should {{{ retrieve a file or a collection of files. More... | |
struct | ItemDesc |
Represents a single download source from which an item should be downloaded. More... | |
struct | MethodConfig |
Information about the properties of a single acquire method. More... | |
class | Queue |
A single download queue in a pkgAcquire object. More... | |
class | UriIterator |
Iterates over all the URIs being fetched by a pkgAcquire object. More... | |
class | Worker |
A fetch subprocess. More... | |
Public Types | |
typedef std::vector< Item * > ::const_iterator | ItemCIterator |
typedef std::vector< Item * > ::iterator | ItemIterator |
enum | RunResult { Continue, Failed, Cancelled } |
Provides information on how a download terminated. More... | |
Public Member Functions | |
pkgAcquire (pkgAcquireStatus *Log) __deprecated | |
Construct a new pkgAcquire. More... | |
pkgAcquire () | |
virtual | ~pkgAcquire () |
Destroy this pkgAcquire object. More... | |
bool | Clean (std::string Dir) |
Deletes each entry in the given directory that is not being downloaded by this object. More... | |
unsigned long long | FetchNeeded () |
MethodConfig * | GetConfig (std::string Access) |
Retrieve information about a fetch method by name. More... | |
ItemIterator | ItemsBegin () |
Get the head of the list of items. More... | |
ItemIterator | ItemsEnd () |
Get the end iterator of the list of items. More... | |
unsigned long long | PartialPresent () |
RunResult | Run (int PulseInterval=500000) |
Download all the items that have been Add()ed to this download process. More... | |
void | SetLog (pkgAcquireStatus *Progress) |
bool | Setup (pkgAcquireStatus *Progress=NULL, std::string const &Lock="") |
Delayed constructor. More... | |
void | Shutdown () |
Remove all items from this download process, terminate all download workers, and empty all queues. More... | |
unsigned long long | TotalNeeded () |
UriIterator | UriBegin () |
Get the head of the list of enqueued item URIs. More... | |
UriIterator | UriEnd () |
Get the end iterator of the list of enqueued item URIs. More... | |
Worker * | WorkersBegin () |
Get the first #Worker object. More... | |
Worker * | WorkerStep (Worker *I) |
Advance to the next #Worker object. More... | |
Protected Types | |
enum | QueueStrategy { QueueHost, QueueAccess } |
Represents the queuing strategy for remote URIs. More... | |
Protected Member Functions | |
void | Add (Item *Item) |
Add the given item to the list of items. More... | |
void | Add (Worker *Work) |
Add the given worker to the list of workers. More... | |
void | Bump () |
Check for idle queues with ready-to-fetch items. More... | |
void | Dequeue (Item *Item) |
Remove all fetch requests for this item from all queues. More... | |
void | Enqueue (ItemDesc &Item) |
Insert the given fetch request into the appropriate queue. More... | |
std::string | QueueName (std::string URI, MethodConfig const *&Config) |
Determine the fetch method and queue of a URI. More... | |
void | Remove (Item *Item) |
Remove the given item from the list of items. More... | |
void | Remove (Worker *Work) |
Remove the given worker from the list of workers. More... | |
virtual void | RunFds (fd_set *RSet, fd_set *WSet) |
Handle input from and output to file descriptors which select() has determined are ready. More... | |
virtual void | SetFds (int &Fd, fd_set *RSet, fd_set *WSet) |
Build up the set of file descriptors upon which select() should block. More... | |
Protected Attributes | |
MethodConfig * | Configs |
The head of the list of acquire method configurations. More... | |
bool const | Debug |
If true, debugging information will be dumped to std::clog. More... | |
std::vector< Item * > | Items |
A list of items to download. More... | |
pkgAcquireStatus * | Log |
The progress indicator for this download. More... | |
enum pkgAcquire::QueueStrategy | QueueMode |
Queue * | Queues |
The head of the list of active queues. More... | |
bool | Running |
If true, a download is currently in progress. More... | |
unsigned long | ToFetch |
The number of files which are to be fetched. More... | |
Worker * | Workers |
The head of the list of active workers. More... | |
Private Attributes | |
void * | d |
dpointer placeholder (for later in case we need it) More... | |
int | LockFD |
FD of the Lock file we acquire in Setup (if any) More... | |
Friends | |
class | Item |
class | Queue |
The core download scheduler.
{{{
This class represents an ongoing download. It manages the lists of active and pending downloads and handles setting up and tearing down download-related structures.
typedef std::vector<Item *>::const_iterator pkgAcquire::ItemCIterator |
typedef std::vector<Item *>::iterator pkgAcquire::ItemIterator |
|
protected |
Provides information on how a download terminated.
Enumerator | |
---|---|
Continue |
All files were fetched successfully. |
Failed |
Some files failed to download. |
Cancelled |
The download was cancelled by the user (i.e., Log's pkgAcquireStatus::Pulse() method returned false). |
pkgAcquire::pkgAcquire | ( | pkgAcquireStatus * | Log | ) |
Construct a new pkgAcquire.
pkgAcquire::pkgAcquire | ( | ) |
|
virtual |
Destroy this pkgAcquire object.
Destroys all queue, method, and item objects associated with this download.
|
protected |
Add the given item to the list of items.
|
protected |
Add the given worker to the list of workers.
|
protected |
Check for idle queues with ready-to-fetch items.
Called by pkgAcquire::Queue::Done each time an item is dequeued but remains on some queues; i.e., another queue should start fetching it.
bool pkgAcquire::Clean | ( | std::string | Dir | ) |
Deletes each entry in the given directory that is not being downloaded by this object.
For instance, when downloading new list files, calling Clean() will delete the old ones.
Dir | The directory to be cleaned out. |
|
protected |
Remove all fetch requests for this item from all queues.
Referenced by pkgAcquire::Item::Dequeue().
|
protected |
Insert the given fetch request into the appropriate queue.
Item | The URI to download and the item to download it for. Copied by value into the queue; no reference to Item is retained. |
Referenced by pkgAcquire::Item::QueueURI().
unsigned long long pkgAcquire::FetchNeeded | ( | ) |
MethodConfig* pkgAcquire::GetConfig | ( | std::string | Access | ) |
Retrieve information about a fetch method by name.
Access | The name of the method to look up. |
|
inline |
Get the head of the list of items.
References Items.
|
inline |
Get the end iterator of the list of items.
References Items.
unsigned long long pkgAcquire::PartialPresent | ( | ) |
|
protected |
|
protected |
Remove the given item from the list of items.
|
protected |
Remove the given worker from the list of workers.
RunResult pkgAcquire::Run | ( | int | PulseInterval = 500000 | ) |
Download all the items that have been Add()ed to this download process.
This method will block until the download completes, invoking methods on Log to report on the progress of the download.
PulseInterval | The method pkgAcquireStatus::Pulse will be invoked on Log at intervals of PulseInterval milliseconds. |
|
protectedvirtual |
Handle input from and output to file descriptors which select() has determined are ready.
The default implementation dispatches to all active downloads.
RSet | The set of file descriptors that are ready for input. |
WSet | The set of file descriptors that are ready for output. |
|
protectedvirtual |
Build up the set of file descriptors upon which select() should block.
The default implementation inserts the file descriptors corresponding to active downloads.
[out] | Fd | The largest file descriptor in the generated sets. |
[out] | RSet | The set of file descriptors that should be watched for input. |
[out] | WSet | The set of file descriptors that should be watched for output. |
|
inline |
References Log.
bool pkgAcquire::Setup | ( | pkgAcquireStatus * | Progress = NULL , |
std::string const & | Lock = "" |
||
) |
Delayed constructor.
Progress | indicator associated with this download or NULL for none. This object is not owned by the download process and will not be deleted when the pkgAcquire object is destroyed. Naturally, it should live for at least as long as the pkgAcquire object does. |
Lock | defines a lock file that should be acquired to ensure only one Acquire class is in action at the time or an empty string if no lock file should be used. |
void pkgAcquire::Shutdown | ( | ) |
Remove all items from this download process, terminate all download workers, and empty all queues.
unsigned long long pkgAcquire::TotalNeeded | ( | ) |
UriIterator pkgAcquire::UriBegin | ( | ) |
Get the head of the list of enqueued item URIs.
This iterator will step over every element of every active queue.
UriIterator pkgAcquire::UriEnd | ( | ) |
Get the end iterator of the list of enqueued item URIs.
|
inline |
Get the first #Worker object.
References Workers.
Advance to the next #Worker object.
|
friend |
|
friend |
|
protected |
The head of the list of acquire method configurations.
Each protocol (http, ftp, gzip, etc) via which files can be fetched can have a representation in this list. The configuration data is filled in by parsing the 100 Capabilities string output by a method on startup (see pkgAcqMethod::pkgAcqMethod and pkgAcquire::GetConfig).
|
private |
dpointer placeholder (for later in case we need it)
|
protected |
If true, debugging information will be dumped to std::clog.
|
protected |
A list of items to download.
This is built monotonically as items are created and only emptied when the download shuts down.
Referenced by ItemsBegin(), and ItemsEnd().
|
private |
FD of the Lock file we acquire in Setup (if any)
|
protected |
The progress indicator for this download.
Referenced by SetLog().
|
protected |
|
protected |
The head of the list of active queues.
|
protected |
If true, a download is currently in progress.
|
protected |
The number of files which are to be fetched.
|
protected |
The head of the list of active workers.
Referenced by WorkersBegin().