mirror of
https://github.com/aria2/aria2.git
synced 2025-02-26 08:22:11 +00:00
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
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#include "ServerStatMan.h"
|
|
#include "ServerStat.h"
|
|
#include "Exception.h"
|
|
#include "Util.h"
|
|
#include <iostream>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
namespace aria2 {
|
|
|
|
class ServerStatManTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(ServerStatManTest);
|
|
CPPUNIT_TEST(testAddAndFind);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
public:
|
|
void setUp() {}
|
|
|
|
void tearDown() {}
|
|
|
|
void testAddAndFind();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(ServerStatManTest);
|
|
|
|
void ServerStatManTest::testAddAndFind()
|
|
{
|
|
SharedHandle<ServerStat> localhost_http(new ServerStat("localhost", "http"));
|
|
SharedHandle<ServerStat> localhost_ftp(new ServerStat("localhost", "ftp"));
|
|
SharedHandle<ServerStat> mirror(new ServerStat("mirror", "http"));
|
|
|
|
ServerStatMan ssm;
|
|
CPPUNIT_ASSERT(ssm.add(localhost_http));
|
|
CPPUNIT_ASSERT(!ssm.add(localhost_http));
|
|
CPPUNIT_ASSERT(ssm.add(localhost_ftp));
|
|
CPPUNIT_ASSERT(ssm.add(mirror));
|
|
|
|
{
|
|
SharedHandle<ServerStat> r = ssm.find("localhost", "http");
|
|
CPPUNIT_ASSERT(!r.isNull());
|
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), r->getHostname());
|
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), r->getProtocol());
|
|
}
|
|
{
|
|
SharedHandle<ServerStat> r = ssm.find("mirror", "ftp");
|
|
CPPUNIT_ASSERT(r.isNull());
|
|
}
|
|
}
|
|
|
|
} // namespace aria2
|