Naanou.ResourceExchange
Class Source

Source

Field Summary
string baseUrl
int DOWNLOAD_IDEAL_TIME_RANGE
         Range to keep download times within (seconds)
Naanou.ResourceExchange.Source.Manifest FilledMarker
int generation
Naanou.Common.Hash id
string[] metaContacts
int metaMaxSimul
string metaName
long metaThrottle
string metaUser
System.Threading.ManualResetEvent mutex
System.Threading.ReaderWriterLock rwl
int simul
int simulMax
         The maximum simulatanous connections for this source

Constructor Summary
Source(Naanou.Common.Hash id, string baseUrl)
         Constructor. Do not use, instead use DownloadManager.

Property Summary
string BaseUrl
         Gets the base url for the source e.g. http://localhost:80/direct/
string ContactEmail
         Gets Email address
string ContactIM
         Gets Instant message address
string[] Contacts
         Gets contacts listed for server, if any. (e-mail, im, web ordering)
string ContactWeb
         Gets web contact address
int Generation
         Gets the generation (0...n)
bool IsAcquirable
         Gives a rough indication of whether a source is available (i.e. the simulatenous transfers on it are not exceeding limit)
int MaximumSimul
         Maximum number of simulataneous connections the source supports (advertised)
int SimultaneousDownloads
         Gets the number of simul downloads happening on source
long Throttle
         Gets the advertised throttling rate for this source
string Title
         Gets a string suitable for UI to give the source a name
string User
         Gets user id (serial)

Method Summary
void Acquire()
         Acquire source. If source is being overloaded by us, this call will block until its ready
Naanou.ResourceExchange.Source.Manifest Create(string resource, string discoveryMethod)
         Create a manifest for a resource without any known bytes ranges
Naanou.ResourceExchange.Source.Manifest Create(string resource, Naanou.ResourceExchange.ByteRange[] ranges, string discoveryMethod)
         Create a manifest for a resource, and known byte ranges
void DecrementGeneration()
int GetHashCode()
void IncrementGeneration()
void LastDownloadSpeed(double bytesPerSec)
         A notification by of the last speed that was attained for this host
void Release()
         Releases sources
void SetMetadata(string[] contacts, long throttle, string name, int maxSimul, string user)

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


Field Detail

baseUrl

private string baseUrl


DOWNLOAD_IDEAL_TIME_RANGE

public int DOWNLOAD_IDEAL_TIME_RANGE

Range to keep download times within (seconds)


FilledMarker

public Naanou.ResourceExchange.Source.Manifest FilledMarker


generation

private int generation


id

private Naanou.Common.Hash id


metaContacts

private string[] metaContacts


metaMaxSimul

private int metaMaxSimul


metaName

private string metaName


metaThrottle

private long metaThrottle


metaUser

private string metaUser


mutex

private System.Threading.ManualResetEvent mutex


rwl

private System.Threading.ReaderWriterLock rwl


simul

private int simul


simulMax

private int simulMax

The maximum simulatanous connections for this source

Constructor Detail

Source

internal Source(Naanou.Common.Hash id,
                string baseUrl)

Constructor. Do not use, instead use DownloadManager.

Parameters:
baseUrl - Base Url for downloading via hash, e.g. http://localhost:80/direct/
id - Id
Property Detail

BaseUrl

public string BaseUrl

Gets the base url for the source e.g. http://localhost:80/direct/


ContactEmail

public string ContactEmail

Gets Email address


ContactIM

public string ContactIM

Gets Instant message address


Contacts

public string[] Contacts

Gets contacts listed for server, if any. (e-mail, im, web ordering)


ContactWeb

public string ContactWeb

Gets web contact address


Generation

public int Generation

Gets the generation (0...n)


IsAcquirable

public bool IsAcquirable

Gives a rough indication of whether a source is available (i.e. the simulatenous transfers on it are not exceeding limit)


MaximumSimul

public int MaximumSimul

Maximum number of simulataneous connections the source supports (advertised)


SimultaneousDownloads

public int SimultaneousDownloads

Gets the number of simul downloads happening on source


Throttle

public long Throttle

Gets the advertised throttling rate for this source


Title

public string Title

Gets a string suitable for UI to give the source a name


User

public string User

Gets user id (serial)

Method Detail

Acquire

public void Acquire()

Acquire source. If source is being overloaded by us, this call will block until its ready


Create

public Naanou.ResourceExchange.Source.Manifest Create(string resource,
                                                      string discoveryMethod)

Create a manifest for a resource without any known bytes ranges

Parameters:
resource - Hash serial
Returns:
Manifest

Create

public Naanou.ResourceExchange.Source.Manifest Create(string resource,
                                                      Naanou.ResourceExchange.ByteRange[] ranges,
                                                      string discoveryMethod)

Create a manifest for a resource, and known byte ranges

Parameters:
resource - Hash serial
ranges - Ranges
Returns:
Manifest

DecrementGeneration

private void DecrementGeneration()


GetHashCode

public int GetHashCode()


IncrementGeneration

private void IncrementGeneration()


LastDownloadSpeed

public void LastDownloadSpeed(double bytesPerSec)

A notification by of the last speed that was attained for this host

Parameters:
bytesPerSec -

Release

public void Release()

Releases sources


SetMetadata

protected void SetMetadata(string[] contacts,
                           long throttle,
                           string name,
                           int maxSimul,
                           string user)