apt @VERSION@
|
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 | |
enum | RunResult { Continue, Failed, Cancelled } |
Provides information on how a download terminated. More... | |
typedef vector< Item * >::iterator | ItemIterator |
typedef vector< Item * > ::const_iterator | ItemCIterator |
Public Member Functions | |
MethodConfig * | GetConfig (string Access) |
Retrieve information about a fetch method by name. | |
RunResult | Run (int PulseInterval=500000) |
Download all the items that have been Add()ed to this download process. | |
void | Shutdown () |
Remove all items from this download process, terminate all download workers, and empty all queues. | |
Worker * | WorkersBegin () |
Get the first #Worker object. | |
Worker * | WorkerStep (Worker *I) |
Advance to the next #Worker object. | |
ItemIterator | ItemsBegin () |
Get the head of the list of items. | |
ItemIterator | ItemsEnd () |
Get the end iterator of the list of items. | |
UriIterator | UriBegin () |
Get the head of the list of enqueued item URIs. | |
UriIterator | UriEnd () |
Get the end iterator of the list of enqueued item URIs. | |
bool | Clean (string Dir) |
unsigned long long | TotalNeeded () |
unsigned long long | FetchNeeded () |
unsigned long long | PartialPresent () |
bool | Setup (pkgAcquireStatus *Progress=NULL, string const &Lock="") |
Delayed constructor. | |
pkgAcquire (pkgAcquireStatus *Log) __deprecated | |
Construct a new pkgAcquire. | |
virtual | ~pkgAcquire () |
Destroy this pkgAcquire object. | |
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. | |
void | Remove (Item *Item) |
Remove the given item from the list of items. | |
void | Add (Worker *Work) |
Add the given worker to the list of workers. | |
void | Remove (Worker *Work) |
Remove the given worker from the list of workers. | |
void | Enqueue (ItemDesc &Item) |
Insert the given fetch request into the appropriate queue. | |
void | Dequeue (Item *Item) |
Remove all fetch requests for this item from all queues. | |
string | QueueName (string URI, MethodConfig const *&Config) |
Determine the fetch method and queue of a URI. | |
virtual void | SetFds (int &Fd, fd_set *RSet, fd_set *WSet) |
Build up the set of file descriptors upon which select() should block. | |
virtual void | RunFds (fd_set *RSet, fd_set *WSet) |
void | Bump () |
Check for idle queues with ready-to-fetch items. | |
Protected Attributes | |
vector< Item * > | Items |
A list of items to download. | |
Queue * | Queues |
The head of the list of active queues. | |
Worker * | Workers |
The head of the list of active workers. | |
MethodConfig * | Configs |
The head of the list of acquire method configurations. | |
pkgAcquireStatus * | Log |
The progress indicator for this download. | |
unsigned long | ToFetch |
The total size of the files which are to be fetched. | |
enum pkgAcquire::QueueStrategy | QueueMode |
bool const | Debug |
If true, debugging information will be dumped to std::clog. | |
bool | Running |
If true, a download is currently in progress. | |
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.
enum QueueStrategy [protected] |
enum RunResult |
Provides information on how a download terminated.
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 | ( | ) | [virtual] |
Destroy this pkgAcquire object.
Destroys all queue, method, and item objects associated with this download.
References Configs, pkgAcquire::MethodConfig::Next, and Shutdown().
void Bump | ( | ) | [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.
References Queues.
bool Clean | ( | string | Dir | ) |
void Enqueue | ( | ItemDesc & | Item | ) | [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. |
References pkgAcquire::Item::Complete, Debug, pkgAcquire::Item::DestFile, pkgAcquire::Queue::Enqueue(), pkgAcquire::Item::Local, pkgAcquire::MethodConfig::LocalOnly, pkgAcquire::Queue::Name, pkgAcquire::ItemDesc::Owner, QueueName(), Queues, Running, pkgAcquire::Queue::Startup(), pkgAcquire::Item::StatIdle, ToFetch, and pkgAcquire::ItemDesc::URI.
Referenced by pkgAcquire::Item::QueueURI().
unsigned long long FetchNeeded | ( | ) |
References ItemsBegin(), and ItemsEnd().
pkgAcquire::MethodConfig * GetConfig | ( | string | Access | ) |
Retrieve information about a fetch method by name.
Access | The name of the method to look up. |
References pkgAcquire::MethodConfig::Access, Configs, pkgAcquire::MethodConfig::Next, pkgAcquire::MethodConfig::SingleInstance, and pkgAcquire::Worker::Start().
Referenced by QueueName().
unsigned long long PartialPresent | ( | ) |
References ItemsBegin(), and ItemsEnd().
string QueueName | ( | string | URI, |
MethodConfig const *& | Config | ||
) | [protected] |
Determine the fetch method and queue of a URI.
URI | The URI to fetch. | |
[out] | Config | A location in which to place the method via which the URI is to be fetched. |
References GetConfig(), QueueAccess, and pkgAcquire::MethodConfig::SingleInstance.
Referenced by Enqueue().
pkgAcquire::RunResult 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. |
References Cancelled, Continue, Failed, Items, Log, pkgAcquire::Worker::NextAcquire, pkgAcquireStatus::Pulse(), Queues, RunFds(), Running, SetFds(), pkgAcquireStatus::Start(), pkgAcquireStatus::Stop(), ToFetch, pkgAcquireStatus::Update, and Workers.
void RunFds | ( | fd_set * | RSet, |
fd_set * | WSet | ||
) | [protected, virtual] |
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. |
References pkgAcquire::Worker::NextAcquire, and Workers.
Referenced by Run().
void SetFds | ( | int & | Fd, |
fd_set * | RSet, | ||
fd_set * | WSet | ||
) | [protected, virtual] |
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. |
References pkgAcquire::Worker::NextAcquire, and Workers.
Referenced by Run().
bool Setup | ( | pkgAcquireStatus * | Progress = NULL , |
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. |
References Log.
Referenced by pkgAcquire().
unsigned long long TotalNeeded | ( | ) |
References ItemsBegin(), and ItemsEnd().
pkgAcquire::UriIterator UriBegin | ( | ) |
Get the head of the list of enqueued item URIs.
This iterator will step over every element of every active queue.
References Queues.
Worker* WorkersBegin | ( | ) | [inline] |
Get the first #Worker object.
References Workers.
Referenced by pkgAcquireStatus::Pulse().
pkgAcquire::Worker * WorkerStep | ( | Worker * | I | ) |
Advance to the next #Worker object.
References pkgAcquire::Worker::NextAcquire.
Referenced by pkgAcquireStatus::Pulse().
MethodConfig* Configs [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).
Referenced by GetConfig(), and ~pkgAcquire().
A list of items to download.
This is built monotonically as items are created and only emptied when the download shuts down.
Referenced by Add(), Clean(), pkgAcquire::Queue::Cycle(), pkgAcquire::Queue::Dequeue(), pkgAcquire::Queue::Enqueue(), pkgAcquire::Queue::FindItem(), ItemsBegin(), ItemsEnd(), Remove(), Run(), Shutdown(), and pkgAcquire::Queue::~Queue().
The head of the list of active queues.
Referenced by Bump(), Dequeue(), Enqueue(), Run(), Shutdown(), and UriBegin().
unsigned long ToFetch [protected] |
The head of the list of active workers.
Referenced by Add(), pkgAcquire::Queue::Cycle(), Remove(), Run(), RunFds(), SetFds(), pkgAcquire::Queue::Shutdown(), pkgAcquire::Queue::Startup(), and WorkersBegin().