Naanou.ResourceExchange
Class DownloadManager

Field Summary
System.Collections.Hashtable cachedSources
System.Collections.ArrayList downloadsInProgress
         ArrayList of Downloaders
Naanou.Common.Hash localUser
int SOURCE_CACHE_MAX

Constructor Summary
DownloadManager()
         Prevent instanciations

Property Summary
Naanou.Common.Hash LocalUser
string UserId

Method Summary
void Close()
Naanou.ResourceExchange.Downloader Download(string resource, Naanou.ResourceExchange.Source.Manifest[] likelySources, Naanou.ResourceExchange.Downloader.Priority priority)
         Downloads a resource for which we have a few sources for
Naanou.ResourceExchange.Downloader Download(ClintHeyer.Httpd.URI uri)
         Downloads a resource for which we have a Naanou Url
Naanou.ResourceExchange.Downloader Download(string resource, Naanou.ResourceExchange.Downloader.Priority priority)
         Downloads a resource for which we aren't too sure where to get it from
Naanou.ResourceExchange.Downloader[] DownloadsInProgress()
         Gets all downloads in progress
Naanou.ResourceExchange.Source GetSource(Naanou.Common.Hash id, string baseUrl)
         Looks up an existing source, or creates a new one.
void LocateSources(string contentHash, Naanou.Common.QueryProgressDelegate progressDelegate)
         Locates download sources for a resource (async)
void NotifyDownloadCompleted(Naanou.ResourceExchange.Downloader d, bool wasAborted, bool wasError)
void NotifyDownloadStarted(Naanou.ResourceExchange.Downloader d)

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString

Event Summary
Naanou.ResourceExchange.DownloadCompletedEventHandler DownloadCompleted
         A download has been completed
Naanou.ResourceExchange.DownloadStartedEventHandler DownloadStarted
         A download has started


Field Detail

cachedSources

private System.Collections.Hashtable cachedSources


downloadsInProgress

private System.Collections.ArrayList downloadsInProgress

ArrayList of Downloaders


localUser

private Naanou.Common.Hash localUser


SOURCE_CACHE_MAX

public int SOURCE_CACHE_MAX

Constructor Detail

DownloadManager

private DownloadManager()

Prevent instanciations

Property Detail

LocalUser

public Naanou.Common.Hash LocalUser


UserId

public string UserId

Method Detail

Close

public void Close()


Download

public Naanou.ResourceExchange.Downloader Download(string resource,
                                                   Naanou.ResourceExchange.Source.Manifest[] likelySources,
                                                   Naanou.ResourceExchange.Downloader.Priority priority)

Downloads a resource for which we have a few sources for

Parameters:
likelyBaseUrls -
priority -
Returns:

Download

public Naanou.ResourceExchange.Downloader Download(ClintHeyer.Httpd.URI uri)

Downloads a resource for which we have a Naanou Url

Parameters:
url - Nanaou Url for resource naanou://nodeId@localhost:8080/direct/1238dfg34rnsdf3
Returns:

Download

public Naanou.ResourceExchange.Downloader Download(string resource,
                                                   Naanou.ResourceExchange.Downloader.Priority priority)

Downloads a resource for which we aren't too sure where to get it from

Parameters:
likelyBaseUrls -
priority -
Returns:

DownloadsInProgress

public Naanou.ResourceExchange.Downloader[] DownloadsInProgress()

Gets all downloads in progress

Returns:

GetSource

public Naanou.ResourceExchange.Source GetSource(Naanou.Common.Hash id,
                                                string baseUrl)

Looks up an existing source, or creates a new one.

Caches up to Naanou.ResourceExchange.DownloadManager.SOURCE_CACHE_MAX entries before purging entire cache. Does not matter too much if in-use sources are removed - we just lose the acquired history data such as simultaneous downloads, generation# etc.

Parameters:
id - Id of source
baseUrl - Base url of source
Returns:
Source

LocateSources

public void LocateSources(string contentHash,
                          Naanou.Common.QueryProgressDelegate progressDelegate)

Locates download sources for a resource (async)

Parameters:
contentHash -

NotifyDownloadCompleted

public void NotifyDownloadCompleted(Naanou.ResourceExchange.Downloader d,
                                    bool wasAborted,
                                    bool wasError)


NotifyDownloadStarted

public void NotifyDownloadStarted(Naanou.ResourceExchange.Downloader d)

Event Detail

DownloadCompleted

public Naanou.ResourceExchange.DownloadCompletedEventHandler DownloadCompleted

A download has been completed


DownloadStarted

public Naanou.ResourceExchange.DownloadStartedEventHandler DownloadStarted

A download has started