From d64c8e75f6c3b6895f51036e5d16ad696dfe0f66 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 4 Aug 2008 17:06:47 +0000 Subject: 2008-08-05 Tatsuhiro Tsujikawa Implemented download speed based URI selection algorithm. Introduced new option --uri-selector. If --uri-selector=feedback is given, aria2 uses download speed observed in the previous downloads and chooses fastest server in the URI list. Currently at most 10 URIs are considered to introduce randomeness for finding better servers. The speed is average download speed in the downloads. On the other hand, if --uri-selector=inorder is given, which is default, URI is tried in order in URI list. The usage text for the new option has not been written yet. * src/AbstractCommand.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/DownloadEngineFactory.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/OptionHandlerFactory.cc * src/PeerStat.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/SegmentMan.cc * src/SegmentMan.h * src/ServerStat.cc * src/ServerStat.h * src/ServerStatMan.cc * src/ServerStatMan.h * src/ServerStatURISelector.cc * src/ServerStatURISelector.h * src/URISelector.h * src/option_processing.cc * src/prefs.cc * src/prefs.h * test/InOrderURISelectorTest.cc * test/RequestGroupManTest.cc * test/ServerStatManTest.cc * test/ServerStatURISelectorTest.cc --- src/ServerStat.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/ServerStat.h (limited to 'src/ServerStat.h') diff --git a/src/ServerStat.h b/src/ServerStat.h new file mode 100644 index 00000000..7f31ea93 --- /dev/null +++ b/src/ServerStat.h @@ -0,0 +1,108 @@ +/* */ +#ifndef _D_SERVER_STAT_H_ +#define _D_SERVER_STAT_H_ +#include "common.h" +#include "TimeA2.h" +#include +#include + +namespace aria2 { + +// ServerStatMan: has many ServerStat +// URISelector: interface +// ServerStatURISelector: Has a reference of ServerStatMan +// InOrderURISelector: this is default. +class ServerStat { +public: + enum STATUS { + OK, + ERROR + }; + + ServerStat(const std::string& hostname, const std::string& protocol); + + ~ServerStat(); + + const std::string& getHostname() const; + + const std::string& getProtocol() const; + + Time getLastUpdated() const; + + void setLastUpdated(const Time& time); + + unsigned int getDownloadSpeed() const; + + // update download speed and update _lastUpdated + void updateDownloadSpeed(unsigned int downloadSpeed); + + // set download speed. This method doesn't update _lastUpdate. + void setDownloadSpeed(unsigned int downloadSpeed); + + void setStatus(STATUS status); + + STATUS getStatus() const; + + bool isOK() const; + + // set status OK and update _lastUpdated + void setOK(); + + bool isError() const; + + // set status ERROR and update _lastUpdated + void setError(); + + bool operator<(const ServerStat& serverStat) const; + + bool operator==(const ServerStat& serverStat) const; +private: + std::string _hostname; + + std::string _protocol; + + unsigned int _downloadSpeed; + + STATUS _status; + + Time _lastUpdated; +}; + +std::ostream& operator<<(std::ostream& o, const ServerStat& serverStat); + +} // namespace aria2 + +#endif // _D_SERVER_STAT_H_ -- cgit