mirror of https://github.com/aria2/aria2
2009-06-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed ServerHost. Same functionality is implemented using FileEntry's in-flight Request objects. * src/AbstractCommand.cc * src/BtDependency.cc * src/CreateRequestCommand.cc * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.cc * src/Makefile.am * src/Metalink2RequestGroup.cc * src/RequestGroup.cc * src/RequestGroup.h * src/ServerHost.cc: Removed * src/ServerHost.h: Removed * test/BtDependencyTest.cc * test/FileEntryTest.cc * test/RequestGroupTest.ccpull/1/head
parent
c4d79d7160
commit
cece2bc896
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
||||||
|
2009-06-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Removed ServerHost. Same functionality is implemented using
|
||||||
|
FileEntry's in-flight Request objects.
|
||||||
|
* src/AbstractCommand.cc
|
||||||
|
* src/BtDependency.cc
|
||||||
|
* src/CreateRequestCommand.cc
|
||||||
|
* src/FileEntry.cc
|
||||||
|
* src/FileEntry.h
|
||||||
|
* src/FtpNegotiationCommand.cc
|
||||||
|
* src/HttpResponseCommand.cc
|
||||||
|
* src/Makefile.am
|
||||||
|
* src/Metalink2RequestGroup.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroup.h
|
||||||
|
* src/ServerHost.cc: Removed
|
||||||
|
* src/ServerHost.h: Removed
|
||||||
|
* test/BtDependencyTest.cc
|
||||||
|
* test/FileEntryTest.cc
|
||||||
|
* test/RequestGroupTest.cc
|
||||||
|
|
||||||
2009-06-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-06-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Rewritten PeerStat handling. In the previous implementation,
|
Rewritten PeerStat handling. In the previous implementation,
|
||||||
|
|
|
@ -140,10 +140,6 @@ bool AbstractCommand::execute() {
|
||||||
Command* command =
|
Command* command =
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
||||||
// TODO1.5 Here is ServerHost stuff
|
|
||||||
//ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
|
||||||
//registerServerHost(sv);
|
|
||||||
|
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
return true;
|
return true;
|
||||||
|
@ -248,7 +244,6 @@ bool AbstractCommand::execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCommand::tryReserved() {
|
void AbstractCommand::tryReserved() {
|
||||||
_requestGroup->removeServerHost(cuid);
|
|
||||||
if(_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
if(_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
||||||
const SharedHandle<FileEntry>& entry =
|
const SharedHandle<FileEntry>& entry =
|
||||||
_requestGroup->getDownloadContext()->getFirstFileEntry();
|
_requestGroup->getDownloadContext()->getFirstFileEntry();
|
||||||
|
|
|
@ -80,12 +80,17 @@ bool BtDependency::resolve()
|
||||||
}
|
}
|
||||||
// Copy file path in _dependant's FileEntries to newly created
|
// Copy file path in _dependant's FileEntries to newly created
|
||||||
// context's FileEntries to endorse the path structure of
|
// context's FileEntries to endorse the path structure of
|
||||||
// _dependant.
|
// _dependant. URIs and singleHostMultiConnection are also copied.
|
||||||
for(std::vector<SharedHandle<FileEntry> >::const_iterator s =
|
for(std::vector<SharedHandle<FileEntry> >::const_iterator s =
|
||||||
_dependant->getDownloadContext()->getFileEntries().begin(),
|
_dependant->getDownloadContext()->getFileEntries().begin(),
|
||||||
d = context->getFileEntries().begin();
|
d = context->getFileEntries().begin();
|
||||||
d != context->getFileEntries().end(); ++s, ++d) {
|
d != context->getFileEntries().end(); ++s, ++d) {
|
||||||
(*d)->setPath((*s)->getPath());
|
(*d)->setPath((*s)->getPath());
|
||||||
|
(*d)->addUris((*s)->getRemainingUris().begin(),
|
||||||
|
(*s)->getRemainingUris().end());
|
||||||
|
if(!(*s)->isSingleHostMultiConnectionEnabled()) {
|
||||||
|
(*d)->disableSingleHostMultiConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
_logger->error(EX_EXCEPTION_CAUGHT, e);
|
||||||
|
|
|
@ -75,8 +75,6 @@ bool CreateRequestCommand::executeInternal()
|
||||||
Command* command =
|
Command* command =
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, req, _fileEntry, _requestGroup, e);
|
(cuid, req, _fileEntry, _requestGroup, e);
|
||||||
//ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
|
||||||
//registerServerHost(sv);
|
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -49,10 +49,12 @@ FileEntry::FileEntry(const std::string& path,
|
||||||
const std::deque<std::string>& uris):
|
const std::deque<std::string>& uris):
|
||||||
path(path), _uris(uris), length(length), offset(offset),
|
path(path), _uris(uris), length(length), offset(offset),
|
||||||
extracted(false), requested(true),
|
extracted(false), requested(true),
|
||||||
|
_singleHostMultiConnection(true),
|
||||||
_logger(LogFactory::getInstance()) {}
|
_logger(LogFactory::getInstance()) {}
|
||||||
|
|
||||||
FileEntry::FileEntry():
|
FileEntry::FileEntry():
|
||||||
length(0), offset(0), extracted(false), requested(false),
|
length(0), offset(0), extracted(false), requested(false),
|
||||||
|
_singleHostMultiConnection(true),
|
||||||
_logger(LogFactory::getInstance()) {}
|
_logger(LogFactory::getInstance()) {}
|
||||||
|
|
||||||
FileEntry::~FileEntry() {}
|
FileEntry::~FileEntry() {}
|
||||||
|
@ -101,11 +103,26 @@ std::string FileEntry::selectUri(const SharedHandle<URISelector>& uriSelector)
|
||||||
return uriSelector->select(this);
|
return uriSelector->select(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename InputIterator>
|
||||||
|
static bool inFlightHost(InputIterator first, InputIterator last,
|
||||||
|
const std::string& hostname)
|
||||||
|
{
|
||||||
|
// TODO1.5 redirection should be considered here. We need to parse
|
||||||
|
// original URI to get hostname.
|
||||||
|
for(; first != last; ++first) {
|
||||||
|
if((*first)->getHost() == hostname) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<Request>
|
SharedHandle<Request>
|
||||||
FileEntry::getRequest(const SharedHandle<URISelector>& selector)
|
FileEntry::getRequest(const SharedHandle<URISelector>& selector)
|
||||||
{
|
{
|
||||||
SharedHandle<Request> req;
|
SharedHandle<Request> req;
|
||||||
if(_requestPool.empty()) {
|
if(_requestPool.empty()) {
|
||||||
|
std::deque<std::string> pending;
|
||||||
while(1) {
|
while(1) {
|
||||||
std::string uri = selector->select(this);
|
std::string uri = selector->select(this);
|
||||||
if(uri.empty()) {
|
if(uri.empty()) {
|
||||||
|
@ -113,19 +130,28 @@ FileEntry::getRequest(const SharedHandle<URISelector>& selector)
|
||||||
}
|
}
|
||||||
req.reset(new Request());
|
req.reset(new Request());
|
||||||
if(req->setUrl(uri)) {
|
if(req->setUrl(uri)) {
|
||||||
|
if(!_singleHostMultiConnection) {
|
||||||
|
if(inFlightHost(_inFlightRequests.begin(), _inFlightRequests.end(),
|
||||||
|
req->getHost())) {
|
||||||
|
pending.push_back(uri);
|
||||||
|
req.reset();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
_spentUris.push_back(uri);
|
_spentUris.push_back(uri);
|
||||||
_inFlightRequests.push_back(req);
|
_inFlightRequests.push_back(req);
|
||||||
return req;
|
break;
|
||||||
} else {
|
} else {
|
||||||
req.reset();
|
req.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_uris.insert(_uris.begin(), pending.begin(), pending.end());
|
||||||
} else {
|
} else {
|
||||||
req = _requestPool.front();
|
req = _requestPool.front();
|
||||||
_requestPool.pop_front();
|
_requestPool.pop_front();
|
||||||
_inFlightRequests.push_back(req);
|
_inFlightRequests.push_back(req);
|
||||||
return req;
|
|
||||||
}
|
}
|
||||||
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<Request>
|
SharedHandle<Request>
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
// URIResult is stored in the ascending order of the time when its result is
|
// URIResult is stored in the ascending order of the time when its result is
|
||||||
// available.
|
// available.
|
||||||
std::deque<URIResult> _uriResults;
|
std::deque<URIResult> _uriResults;
|
||||||
|
bool _singleHostMultiConnection;
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
void storePool(const SharedHandle<Request>& request);
|
void storePool(const SharedHandle<Request>& request);
|
||||||
|
@ -142,6 +142,12 @@ public:
|
||||||
_uris = uris;
|
_uris = uris;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename InputIterator>
|
||||||
|
void addUris(InputIterator first, InputIterator last)
|
||||||
|
{
|
||||||
|
_uris.insert(_uris.end(), first, last);
|
||||||
|
}
|
||||||
|
|
||||||
// Inserts _uris and _spentUris into uris.
|
// Inserts _uris and _spentUris into uris.
|
||||||
void getUris(std::deque<std::string>& uris) const;
|
void getUris(std::deque<std::string>& uris) const;
|
||||||
|
|
||||||
|
@ -201,6 +207,16 @@ public:
|
||||||
// The extracted URIResults are removed from _uriResults.
|
// The extracted URIResults are removed from _uriResults.
|
||||||
void extractURIResult
|
void extractURIResult
|
||||||
(std::deque<URIResult>& res, downloadresultcode::RESULT r);
|
(std::deque<URIResult>& res, downloadresultcode::RESULT r);
|
||||||
|
|
||||||
|
void disableSingleHostMultiConnection()
|
||||||
|
{
|
||||||
|
_singleHostMultiConnection = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSingleHostMultiConnectionEnabled() const
|
||||||
|
{
|
||||||
|
return _singleHostMultiConnection;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<FileEntry> FileEntryHandle;
|
typedef SharedHandle<FileEntry> FileEntryHandle;
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "DefaultBtProgressInfoFile.h"
|
#include "DefaultBtProgressInfoFile.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "DownloadFailureException.h"
|
#include "DownloadFailureException.h"
|
||||||
#include "ServerHost.h"
|
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
|
@ -103,12 +102,8 @@ bool FtpNegotiationCommand::executeInternal() {
|
||||||
(cuid, req, _fileEntry, _requestGroup, ftp, e, dataSocket, socket);
|
(cuid, req, _fileEntry, _requestGroup, ftp, e, dataSocket, socket);
|
||||||
command->setStartupIdleTime(getOption()->getAsInt(PREF_STARTUP_IDLE_TIME));
|
command->setStartupIdleTime(getOption()->getAsInt(PREF_STARTUP_IDLE_TIME));
|
||||||
command->setLowestDownloadSpeedLimit(getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
command->setLowestDownloadSpeedLimit(getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
||||||
if(!_requestGroup->isSingleHostMultiConnectionEnabled()) {
|
if(!_fileEntry->isSingleHostMultiConnectionEnabled()) {
|
||||||
SharedHandle<ServerHost> sv =
|
_fileEntry->removeURIWhoseHostnameIs(req->getHost());
|
||||||
_requestGroup->searchServerHost(req->getHost());
|
|
||||||
if(!sv.isNull()) {
|
|
||||||
_fileEntry->removeURIWhoseHostnameIs(sv->getHostname());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_requestGroup->getURISelector()->tuneDownloadCommand
|
_requestGroup->getURISelector()->tuneDownloadCommand
|
||||||
(_fileEntry->getRemainingUris(), command);
|
(_fileEntry->getRemainingUris(), command);
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "ServerHost.h"
|
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "HttpRequest.h"
|
#include "HttpRequest.h"
|
||||||
|
@ -122,18 +121,10 @@ bool HttpResponseCommand::executeInternal()
|
||||||
}
|
}
|
||||||
return skipResponseBody(httpResponse);
|
return skipResponseBody(httpResponse);
|
||||||
}
|
}
|
||||||
if(!_requestGroup->isSingleHostMultiConnectionEnabled()) {
|
if(!_fileEntry->isSingleHostMultiConnectionEnabled()) {
|
||||||
// Query by hostname. Searching by CUID may returns NULL. In case
|
// TODO1.5 redirection should be considered here. We need to parse
|
||||||
// when resuming download, ServerHost is registered with CUID A.
|
// original URI to get hostname.
|
||||||
// Then if requested range is not equal to saved one,
|
_fileEntry->removeURIWhoseHostnameIs(req->getHost());
|
||||||
// StreamFileAllocationEntry is created with _nextCommand NULL.
|
|
||||||
// This results creating new command CUID, say B and same URI. So
|
|
||||||
// searching ServerHost by CUID B fails.
|
|
||||||
SharedHandle<ServerHost> sv =
|
|
||||||
_requestGroup->searchServerHost(req->getHost());
|
|
||||||
if(!sv.isNull()) {
|
|
||||||
_fileEntry->removeURIWhoseHostnameIs(sv->getHostname());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(_requestGroup->getPieceStorage().isNull()) {
|
if(_requestGroup->getPieceStorage().isNull()) {
|
||||||
uint64_t totalLength = httpResponse->getEntityLength();
|
uint64_t totalLength = httpResponse->getEntityLength();
|
||||||
|
|
|
@ -150,7 +150,6 @@ SRCS = Socket.h\
|
||||||
PeerConnection.cc PeerConnection.h\
|
PeerConnection.cc PeerConnection.h\
|
||||||
ByteArrayDiskWriter.cc ByteArrayDiskWriter.h\
|
ByteArrayDiskWriter.cc ByteArrayDiskWriter.h\
|
||||||
ByteArrayDiskWriterFactory.cc ByteArrayDiskWriterFactory.h\
|
ByteArrayDiskWriterFactory.cc ByteArrayDiskWriterFactory.h\
|
||||||
ServerHost.cc ServerHost.h\
|
|
||||||
DownloadContext.cc DownloadContext.h\
|
DownloadContext.cc DownloadContext.h\
|
||||||
TimedHaltCommand.cc TimedHaltCommand.h\
|
TimedHaltCommand.cc TimedHaltCommand.h\
|
||||||
CUIDCounter.h\
|
CUIDCounter.h\
|
||||||
|
|
|
@ -398,27 +398,26 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
|
MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
|
||||||
PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
|
PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
|
||||||
ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
|
ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
|
||||||
ByteArrayDiskWriterFactory.h ServerHost.cc ServerHost.h \
|
ByteArrayDiskWriterFactory.h DownloadContext.cc \
|
||||||
DownloadContext.cc DownloadContext.h TimedHaltCommand.cc \
|
DownloadContext.h TimedHaltCommand.cc TimedHaltCommand.h \
|
||||||
TimedHaltCommand.h CUIDCounter.h DNSCache.h DownloadResult.h \
|
CUIDCounter.h DNSCache.h DownloadResult.h Sequence.h \
|
||||||
Sequence.h IntSequence.h PostDownloadHandler.h \
|
IntSequence.h PostDownloadHandler.h PreDownloadHandler.h \
|
||||||
PreDownloadHandler.h SingletonHolder.h \
|
SingletonHolder.h TrueRequestGroupCriteria.h a2algo.h \
|
||||||
TrueRequestGroupCriteria.h a2algo.h a2functional.h a2io.h \
|
a2functional.h a2io.h a2netcompat.h a2time.h array_fun.h \
|
||||||
a2netcompat.h a2time.h array_fun.h help_tags.h prefs.cc \
|
help_tags.h prefs.cc prefs.h usage_text.h ProtocolDetector.cc \
|
||||||
prefs.h usage_text.h ProtocolDetector.cc ProtocolDetector.h \
|
ProtocolDetector.h NullStatCalc.h StringFormat.cc \
|
||||||
NullStatCalc.h StringFormat.cc StringFormat.h \
|
StringFormat.h HttpSkipResponseCommand.cc \
|
||||||
HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
|
HttpSkipResponseCommand.h InitiateConnectionCommand.cc \
|
||||||
InitiateConnectionCommand.cc InitiateConnectionCommand.h \
|
InitiateConnectionCommand.h FtpFinishDownloadCommand.cc \
|
||||||
FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
|
FtpFinishDownloadCommand.h A2STR.cc A2STR.h \
|
||||||
A2STR.cc A2STR.h RarestPieceSelector.cc RarestPieceSelector.h \
|
RarestPieceSelector.cc RarestPieceSelector.h Decoder.h \
|
||||||
Decoder.h ChunkedDecoder.cc ChunkedDecoder.h Signature.cc \
|
ChunkedDecoder.cc ChunkedDecoder.h Signature.cc Signature.h \
|
||||||
Signature.h ServerStat.cc ServerStat.h ServerStatMan.cc \
|
ServerStat.cc ServerStat.h ServerStatMan.cc ServerStatMan.h \
|
||||||
ServerStatMan.h URISelector.h AdaptiveURISelector.cc \
|
URISelector.h AdaptiveURISelector.cc AdaptiveURISelector.h \
|
||||||
AdaptiveURISelector.h InOrderURISelector.cc \
|
InOrderURISelector.cc InOrderURISelector.h \
|
||||||
InOrderURISelector.h FeedbackURISelector.cc \
|
FeedbackURISelector.cc FeedbackURISelector.h NsCookieParser.cc \
|
||||||
FeedbackURISelector.h NsCookieParser.cc NsCookieParser.h \
|
NsCookieParser.h CookieStorage.cc CookieStorage.h \
|
||||||
CookieStorage.cc CookieStorage.h SocketBuffer.cc \
|
SocketBuffer.cc SocketBuffer.h OptionHandlerException.cc \
|
||||||
SocketBuffer.h OptionHandlerException.cc \
|
|
||||||
OptionHandlerException.h URIResult.cc URIResult.h EventPoll.h \
|
OptionHandlerException.h URIResult.cc URIResult.h EventPoll.h \
|
||||||
SelectEventPoll.cc SelectEventPoll.h SequentialPicker.h \
|
SelectEventPoll.cc SelectEventPoll.h SequentialPicker.h \
|
||||||
SequentialDispatcherCommand.h PieceSelector.h \
|
SequentialDispatcherCommand.h PieceSelector.h \
|
||||||
|
@ -830,10 +829,10 @@ am__objects_26 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
|
||||||
PeerSessionResource.$(OBJEXT) BtRegistry.$(OBJEXT) \
|
PeerSessionResource.$(OBJEXT) BtRegistry.$(OBJEXT) \
|
||||||
MultiFileAllocationIterator.$(OBJEXT) PeerConnection.$(OBJEXT) \
|
MultiFileAllocationIterator.$(OBJEXT) PeerConnection.$(OBJEXT) \
|
||||||
ByteArrayDiskWriter.$(OBJEXT) \
|
ByteArrayDiskWriter.$(OBJEXT) \
|
||||||
ByteArrayDiskWriterFactory.$(OBJEXT) ServerHost.$(OBJEXT) \
|
ByteArrayDiskWriterFactory.$(OBJEXT) DownloadContext.$(OBJEXT) \
|
||||||
DownloadContext.$(OBJEXT) TimedHaltCommand.$(OBJEXT) \
|
TimedHaltCommand.$(OBJEXT) prefs.$(OBJEXT) \
|
||||||
prefs.$(OBJEXT) ProtocolDetector.$(OBJEXT) \
|
ProtocolDetector.$(OBJEXT) StringFormat.$(OBJEXT) \
|
||||||
StringFormat.$(OBJEXT) HttpSkipResponseCommand.$(OBJEXT) \
|
HttpSkipResponseCommand.$(OBJEXT) \
|
||||||
InitiateConnectionCommand.$(OBJEXT) \
|
InitiateConnectionCommand.$(OBJEXT) \
|
||||||
FtpFinishDownloadCommand.$(OBJEXT) A2STR.$(OBJEXT) \
|
FtpFinishDownloadCommand.$(OBJEXT) A2STR.$(OBJEXT) \
|
||||||
RarestPieceSelector.$(OBJEXT) ChunkedDecoder.$(OBJEXT) \
|
RarestPieceSelector.$(OBJEXT) ChunkedDecoder.$(OBJEXT) \
|
||||||
|
@ -1153,27 +1152,26 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
|
||||||
MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
|
MultiFileAllocationIterator.cc MultiFileAllocationIterator.h \
|
||||||
PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
|
PeerConnection.cc PeerConnection.h ByteArrayDiskWriter.cc \
|
||||||
ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
|
ByteArrayDiskWriter.h ByteArrayDiskWriterFactory.cc \
|
||||||
ByteArrayDiskWriterFactory.h ServerHost.cc ServerHost.h \
|
ByteArrayDiskWriterFactory.h DownloadContext.cc \
|
||||||
DownloadContext.cc DownloadContext.h TimedHaltCommand.cc \
|
DownloadContext.h TimedHaltCommand.cc TimedHaltCommand.h \
|
||||||
TimedHaltCommand.h CUIDCounter.h DNSCache.h DownloadResult.h \
|
CUIDCounter.h DNSCache.h DownloadResult.h Sequence.h \
|
||||||
Sequence.h IntSequence.h PostDownloadHandler.h \
|
IntSequence.h PostDownloadHandler.h PreDownloadHandler.h \
|
||||||
PreDownloadHandler.h SingletonHolder.h \
|
SingletonHolder.h TrueRequestGroupCriteria.h a2algo.h \
|
||||||
TrueRequestGroupCriteria.h a2algo.h a2functional.h a2io.h \
|
a2functional.h a2io.h a2netcompat.h a2time.h array_fun.h \
|
||||||
a2netcompat.h a2time.h array_fun.h help_tags.h prefs.cc \
|
help_tags.h prefs.cc prefs.h usage_text.h ProtocolDetector.cc \
|
||||||
prefs.h usage_text.h ProtocolDetector.cc ProtocolDetector.h \
|
ProtocolDetector.h NullStatCalc.h StringFormat.cc \
|
||||||
NullStatCalc.h StringFormat.cc StringFormat.h \
|
StringFormat.h HttpSkipResponseCommand.cc \
|
||||||
HttpSkipResponseCommand.cc HttpSkipResponseCommand.h \
|
HttpSkipResponseCommand.h InitiateConnectionCommand.cc \
|
||||||
InitiateConnectionCommand.cc InitiateConnectionCommand.h \
|
InitiateConnectionCommand.h FtpFinishDownloadCommand.cc \
|
||||||
FtpFinishDownloadCommand.cc FtpFinishDownloadCommand.h \
|
FtpFinishDownloadCommand.h A2STR.cc A2STR.h \
|
||||||
A2STR.cc A2STR.h RarestPieceSelector.cc RarestPieceSelector.h \
|
RarestPieceSelector.cc RarestPieceSelector.h Decoder.h \
|
||||||
Decoder.h ChunkedDecoder.cc ChunkedDecoder.h Signature.cc \
|
ChunkedDecoder.cc ChunkedDecoder.h Signature.cc Signature.h \
|
||||||
Signature.h ServerStat.cc ServerStat.h ServerStatMan.cc \
|
ServerStat.cc ServerStat.h ServerStatMan.cc ServerStatMan.h \
|
||||||
ServerStatMan.h URISelector.h AdaptiveURISelector.cc \
|
URISelector.h AdaptiveURISelector.cc AdaptiveURISelector.h \
|
||||||
AdaptiveURISelector.h InOrderURISelector.cc \
|
InOrderURISelector.cc InOrderURISelector.h \
|
||||||
InOrderURISelector.h FeedbackURISelector.cc \
|
FeedbackURISelector.cc FeedbackURISelector.h NsCookieParser.cc \
|
||||||
FeedbackURISelector.h NsCookieParser.cc NsCookieParser.h \
|
NsCookieParser.h CookieStorage.cc CookieStorage.h \
|
||||||
CookieStorage.cc CookieStorage.h SocketBuffer.cc \
|
SocketBuffer.cc SocketBuffer.h OptionHandlerException.cc \
|
||||||
SocketBuffer.h OptionHandlerException.cc \
|
|
||||||
OptionHandlerException.h URIResult.cc URIResult.h EventPoll.h \
|
OptionHandlerException.h URIResult.cc URIResult.h EventPoll.h \
|
||||||
SelectEventPoll.cc SelectEventPoll.h SequentialPicker.h \
|
SelectEventPoll.cc SelectEventPoll.h SequentialPicker.h \
|
||||||
SequentialDispatcherCommand.h PieceSelector.h \
|
SequentialDispatcherCommand.h PieceSelector.h \
|
||||||
|
@ -1527,7 +1525,6 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeedCheckCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeedCheckCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentMan.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentMan.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelectEventPoll.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelectEventPoll.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerHost.Po@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStat.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStat.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatMan.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerStatMan.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signature.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signature.Po@am__quote@
|
||||||
|
|
|
@ -217,6 +217,9 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
strconcat(option->get(PREF_DIR), "/", entry->file->getPath())));
|
strconcat(option->get(PREF_DIR), "/", entry->file->getPath())));
|
||||||
dctx->setDir(option->get(PREF_DIR));
|
dctx->setDir(option->get(PREF_DIR));
|
||||||
dctx->getFirstFileEntry()->setUris(uris);
|
dctx->getFirstFileEntry()->setUris(uris);
|
||||||
|
if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) {
|
||||||
|
dctx->getFirstFileEntry()->disableSingleHostMultiConnection();
|
||||||
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(entry->chunkChecksum.isNull()) {
|
if(entry->chunkChecksum.isNull()) {
|
||||||
if(!entry->checksum.isNull()) {
|
if(!entry->checksum.isNull()) {
|
||||||
|
@ -236,8 +239,6 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
option->getAsInt(PREF_METALINK_SERVERS) :
|
option->getAsInt(PREF_METALINK_SERVERS) :
|
||||||
std::min(option->getAsInt(PREF_METALINK_SERVERS),
|
std::min(option->getAsInt(PREF_METALINK_SERVERS),
|
||||||
static_cast<int32_t>(entry->maxConnections)));
|
static_cast<int32_t>(entry->maxConnections)));
|
||||||
// In metalink, multi connection to a single host is not allowed by default.
|
|
||||||
rg->setSingleHostMultiConnectionEnabled(!option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL));
|
|
||||||
// remove "metalink" from Accept Type list to avoid loop in tranparent
|
// remove "metalink" from Accept Type list to avoid loop in tranparent
|
||||||
// metalink
|
// metalink
|
||||||
rg->removeAcceptType(RequestGroup::ACCEPT_METALINK);
|
rg->removeAcceptType(RequestGroup::ACCEPT_METALINK);
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
#include "DownloadHandlerFactory.h"
|
#include "DownloadHandlerFactory.h"
|
||||||
#include "MemoryBufferPreDownloadHandler.h"
|
#include "MemoryBufferPreDownloadHandler.h"
|
||||||
#include "DownloadHandlerConstants.h"
|
#include "DownloadHandlerConstants.h"
|
||||||
#include "ServerHost.h"
|
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
|
@ -124,7 +123,6 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
||||||
_haltRequested(false),
|
_haltRequested(false),
|
||||||
_forceHaltRequested(false),
|
_forceHaltRequested(false),
|
||||||
_haltReason(RequestGroup::NONE),
|
_haltReason(RequestGroup::NONE),
|
||||||
_singleHostMultiConnectionEnabled(true),
|
|
||||||
_uriSelector(new InOrderURISelector()),
|
_uriSelector(new InOrderURISelector()),
|
||||||
_lastModifiedTime(Time::null()),
|
_lastModifiedTime(Time::null()),
|
||||||
_fileNotFoundCount(0),
|
_fileNotFoundCount(0),
|
||||||
|
@ -641,41 +639,7 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
|
||||||
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
|
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
|
||||||
_logger->debug("filePath=%s", _downloadContext->getFileEntries().front()->getPath().c_str());
|
_logger->debug("filePath=%s", _downloadContext->getFileEntries().front()->getPath().c_str());
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
|
|
||||||
// TODO1.5 ServerHost stuff should be moved into FileEntry or
|
|
||||||
// CreateRequestCommand
|
|
||||||
|
|
||||||
// std::string uri = _uriSelector->select(_uris);
|
|
||||||
// if(uri.empty())
|
|
||||||
// continue;
|
|
||||||
// RequestHandle req(new Request());
|
|
||||||
// if(req->setUrl(uri)) {
|
|
||||||
// ServerHostHandle sv;
|
|
||||||
// if(!_singleHostMultiConnectionEnabled){
|
|
||||||
// sv = searchServerHost(req->getHost());
|
|
||||||
// }
|
|
||||||
// if(sv.isNull()) {
|
|
||||||
// _spentUris.push_back(uri);
|
|
||||||
// req->setReferer(_option->get(PREF_REFERER));
|
|
||||||
// req->setMethod(method);
|
|
||||||
|
|
||||||
// Command* command =
|
|
||||||
// InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
|
||||||
// (e->newCUID(), req, this, e);
|
|
||||||
// ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
|
|
||||||
// registerServerHost(sv);
|
|
||||||
// // give a chance to be executed in the next loop in DownloadEngine
|
|
||||||
// command->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
|
||||||
// commands.push_back(command);
|
|
||||||
// } else {
|
|
||||||
// pendingURIs.push_back(uri);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// _logger->error(MSG_UNRECOGNIZED_URI, req->getUrl().c_str());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// _uris.insert(_uris.begin(), pendingURIs.begin(), pendingURIs.end());
|
|
||||||
if(!commands.empty()) {
|
if(!commands.empty()) {
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
@ -1005,64 +969,6 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
|
||||||
_downloadContext->calculateSessionTime(),
|
_downloadContext->calculateSessionTime(),
|
||||||
downloadResult()));
|
downloadResult()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestGroup::registerServerHost(const ServerHostHandle& serverHost)
|
|
||||||
{
|
|
||||||
_serverHosts.push_back(serverHost);
|
|
||||||
}
|
|
||||||
|
|
||||||
class FindServerHostByCUID
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int32_t _cuid;
|
|
||||||
public:
|
|
||||||
FindServerHostByCUID(int32_t cuid):_cuid(cuid) {}
|
|
||||||
|
|
||||||
bool operator()(const ServerHostHandle& sv) const
|
|
||||||
{
|
|
||||||
return sv->getCuid() == _cuid;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerHostHandle RequestGroup::searchServerHost(int32_t cuid) const
|
|
||||||
{
|
|
||||||
std::deque<SharedHandle<ServerHost> >::const_iterator itr =
|
|
||||||
std::find_if(_serverHosts.begin(), _serverHosts.end(), FindServerHostByCUID(cuid));
|
|
||||||
if(itr == _serverHosts.end()) {
|
|
||||||
return SharedHandle<ServerHost>();
|
|
||||||
} else {
|
|
||||||
return *itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FindServerHostByHostname
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string _hostname;
|
|
||||||
public:
|
|
||||||
FindServerHostByHostname(const std::string& hostname):_hostname(hostname) {}
|
|
||||||
|
|
||||||
bool operator()(const ServerHostHandle& sv) const
|
|
||||||
{
|
|
||||||
return sv->getHostname() == _hostname;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerHostHandle RequestGroup::searchServerHost(const std::string& hostname) const
|
|
||||||
{
|
|
||||||
std::deque<SharedHandle<ServerHost> >::const_iterator itr =
|
|
||||||
std::find_if(_serverHosts.begin(), _serverHosts.end(), FindServerHostByHostname(hostname));
|
|
||||||
if(itr == _serverHosts.end()) {
|
|
||||||
return SharedHandle<ServerHost>();
|
|
||||||
} else {
|
|
||||||
return *itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequestGroup::removeServerHost(int32_t cuid)
|
|
||||||
{
|
|
||||||
_serverHosts.erase(std::remove_if(_serverHosts.begin(), _serverHosts.end(), FindServerHostByCUID(cuid)), _serverHosts.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequestGroup::reportDownloadFinished()
|
void RequestGroup::reportDownloadFinished()
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,6 @@ class Logger;
|
||||||
class RequestGroup;
|
class RequestGroup;
|
||||||
class CheckIntegrityEntry;
|
class CheckIntegrityEntry;
|
||||||
class DownloadResult;
|
class DownloadResult;
|
||||||
class ServerHost;
|
|
||||||
class URISelector;
|
class URISelector;
|
||||||
class URIResult;
|
class URIResult;
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
@ -109,8 +108,6 @@ private:
|
||||||
|
|
||||||
SharedHandle<Dependency> _dependency;
|
SharedHandle<Dependency> _dependency;
|
||||||
|
|
||||||
std::deque<SharedHandle<ServerHost> > _serverHosts;
|
|
||||||
|
|
||||||
bool _fileAllocationEnabled;
|
bool _fileAllocationEnabled;
|
||||||
|
|
||||||
bool _preLocalFileCheckEnabled;
|
bool _preLocalFileCheckEnabled;
|
||||||
|
@ -121,8 +118,6 @@ private:
|
||||||
|
|
||||||
HaltReason _haltReason;
|
HaltReason _haltReason;
|
||||||
|
|
||||||
bool _singleHostMultiConnectionEnabled;
|
|
||||||
|
|
||||||
std::deque<SharedHandle<PreDownloadHandler> > _preDownloadHandlers;
|
std::deque<SharedHandle<PreDownloadHandler> > _preDownloadHandlers;
|
||||||
|
|
||||||
std::deque<SharedHandle<PostDownloadHandler> > _postDownloadHandlers;
|
std::deque<SharedHandle<PostDownloadHandler> > _postDownloadHandlers;
|
||||||
|
@ -377,31 +372,6 @@ public:
|
||||||
return _option;
|
return _option;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSingleHostMultiConnectionEnabled() const
|
|
||||||
{
|
|
||||||
return _singleHostMultiConnectionEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSingleHostMultiConnectionEnabled(bool f)
|
|
||||||
{
|
|
||||||
_singleHostMultiConnectionEnabled = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers given ServerHost.
|
|
||||||
*/
|
|
||||||
void registerServerHost(const SharedHandle<ServerHost>& serverHost);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns ServerHost whose cuid is given cuid. If it is not found, returns
|
|
||||||
* 0.
|
|
||||||
*/
|
|
||||||
SharedHandle<ServerHost> searchServerHost(int32_t cuid) const;
|
|
||||||
|
|
||||||
SharedHandle<ServerHost> searchServerHost(const std::string& hostname) const;
|
|
||||||
|
|
||||||
void removeServerHost(int32_t cuid);
|
|
||||||
|
|
||||||
void reportDownloadFinished();
|
void reportDownloadFinished();
|
||||||
|
|
||||||
const std::deque<std::string>& getAcceptTypes() const
|
const std::deque<std::string>& getAcceptTypes() const
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* <!-- copyright */
|
|
||||||
/*
|
|
||||||
* aria2 - The high speed download utility
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give
|
|
||||||
* permission to link the code of portions of this program with the
|
|
||||||
* OpenSSL library under certain conditions as described in each
|
|
||||||
* individual source file, and distribute linked combinations
|
|
||||||
* including the two.
|
|
||||||
* You must obey the GNU General Public License in all respects
|
|
||||||
* for all of the code used other than OpenSSL. If you modify
|
|
||||||
* file(s) with this exception, you may extend this exception to your
|
|
||||||
* version of the file(s), but you are not obligated to do so. If you
|
|
||||||
* do not wish to do so, delete this exception statement from your
|
|
||||||
* version. If you delete this exception statement from all source
|
|
||||||
* files in the program, then also delete it here.
|
|
||||||
*/
|
|
||||||
/* copyright --> */
|
|
||||||
#include "ServerHost.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
|
||||||
|
|
||||||
ServerHost::ServerHost(int32_t cuid, const std::string& hostname):
|
|
||||||
_cuid(cuid), _hostname(hostname) {}
|
|
||||||
|
|
||||||
ServerHost::~ServerHost() {}
|
|
||||||
|
|
||||||
} // namespace aria2
|
|
|
@ -1,75 +0,0 @@
|
||||||
/* <!-- copyright */
|
|
||||||
/*
|
|
||||||
* aria2 - The high speed download utility
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give
|
|
||||||
* permission to link the code of portions of this program with the
|
|
||||||
* OpenSSL library under certain conditions as described in each
|
|
||||||
* individual source file, and distribute linked combinations
|
|
||||||
* including the two.
|
|
||||||
* You must obey the GNU General Public License in all respects
|
|
||||||
* for all of the code used other than OpenSSL. If you modify
|
|
||||||
* file(s) with this exception, you may extend this exception to your
|
|
||||||
* version of the file(s), but you are not obligated to do so. If you
|
|
||||||
* do not wish to do so, delete this exception statement from your
|
|
||||||
* version. If you delete this exception statement from all source
|
|
||||||
* files in the program, then also delete it here.
|
|
||||||
*/
|
|
||||||
/* copyright --> */
|
|
||||||
#ifndef _D_SERVER_HOST_H_
|
|
||||||
#define _D_SERVER_HOST_H_
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "SharedHandle.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace aria2 {
|
|
||||||
|
|
||||||
class ServerHost {
|
|
||||||
private:
|
|
||||||
int32_t _cuid;
|
|
||||||
|
|
||||||
std::string _hostname;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ServerHost(int32_t cuid, const std::string& hostname);
|
|
||||||
|
|
||||||
~ServerHost();
|
|
||||||
|
|
||||||
int32_t getCuid() const
|
|
||||||
{
|
|
||||||
return _cuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& getHostname() const
|
|
||||||
{
|
|
||||||
return _hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const ServerHost& server) const
|
|
||||||
{
|
|
||||||
return this->_cuid < server._cuid;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SharedHandle<ServerHost> ServerHostHandle;
|
|
||||||
|
|
||||||
} // namespace aria2
|
|
||||||
|
|
||||||
#endif // _D_SERVER_HOST_H_
|
|
|
@ -31,6 +31,9 @@ class BtDependencyTest:public CppUnit::TestFixture {
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(0, 0, "/tmp/outfile.path"));
|
(new DownloadContext(0, 0, "/tmp/outfile.path"));
|
||||||
dctx->setDir("/tmp");
|
dctx->setDir("/tmp");
|
||||||
|
std::deque<std::string> uris;
|
||||||
|
uris.push_back("http://localhost/outfile.path");
|
||||||
|
dctx->getFirstFileEntry()->setUris(uris);
|
||||||
dependant->setDownloadContext(dctx);
|
dependant->setDownloadContext(dctx);
|
||||||
return dependant;
|
return dependant;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +86,11 @@ void BtDependencyTest::testResolve()
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(std::string("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"),
|
(std::string("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf"),
|
||||||
bittorrent::getInfoHashString(dependant->getDownloadContext()));
|
bittorrent::getInfoHashString(dependant->getDownloadContext()));
|
||||||
|
const SharedHandle<FileEntry>& firstFileEntry =
|
||||||
|
dependant->getDownloadContext()->getFirstFileEntry();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"),
|
||||||
dependant->getFirstFilePath());
|
firstFileEntry->getPath());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)1, firstFileEntry->getRemainingUris().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtDependencyTest::testResolve_loadError()
|
void BtDependencyTest::testResolve_loadError()
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
#include "InOrderURISelector.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class FileEntryTest : public CppUnit::TestFixture {
|
class FileEntryTest : public CppUnit::TestFixture {
|
||||||
|
@ -9,6 +12,8 @@ class FileEntryTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testSetupDir);
|
CPPUNIT_TEST(testSetupDir);
|
||||||
CPPUNIT_TEST(testRemoveURIWhoseHostnameIs);
|
CPPUNIT_TEST(testRemoveURIWhoseHostnameIs);
|
||||||
CPPUNIT_TEST(testExtractURIResult);
|
CPPUNIT_TEST(testExtractURIResult);
|
||||||
|
CPPUNIT_TEST(testGetRequest);
|
||||||
|
CPPUNIT_TEST(testGetRequest_disableSingleHostMultiConnection);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
public:
|
public:
|
||||||
void setUp() {}
|
void setUp() {}
|
||||||
|
@ -16,11 +21,23 @@ public:
|
||||||
void testSetupDir();
|
void testSetupDir();
|
||||||
void testRemoveURIWhoseHostnameIs();
|
void testRemoveURIWhoseHostnameIs();
|
||||||
void testExtractURIResult();
|
void testExtractURIResult();
|
||||||
|
void testGetRequest();
|
||||||
|
void testGetRequest_disableSingleHostMultiConnection();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest );
|
||||||
|
|
||||||
|
static SharedHandle<FileEntry> createFileEntry()
|
||||||
|
{
|
||||||
|
const char* uris[] = { "http://localhost/aria2.zip",
|
||||||
|
"ftp://localhost/aria2.zip",
|
||||||
|
"http://mirror/aria2.zip" };
|
||||||
|
SharedHandle<FileEntry> fileEntry(new FileEntry());
|
||||||
|
fileEntry->setUris(std::deque<std::string>(&uris[0], &uris[3]));
|
||||||
|
return fileEntry;
|
||||||
|
}
|
||||||
|
|
||||||
void FileEntryTest::testSetupDir()
|
void FileEntryTest::testSetupDir()
|
||||||
{
|
{
|
||||||
std::string dir = "/tmp/aria2-FileEntryTest-testSetupDir";
|
std::string dir = "/tmp/aria2-FileEntryTest-testSetupDir";
|
||||||
|
@ -40,15 +57,11 @@ void FileEntryTest::testSetupDir()
|
||||||
|
|
||||||
void FileEntryTest::testRemoveURIWhoseHostnameIs()
|
void FileEntryTest::testRemoveURIWhoseHostnameIs()
|
||||||
{
|
{
|
||||||
const char* uris[] = { "http://localhost/aria2.zip",
|
SharedHandle<FileEntry> fileEntry = createFileEntry();
|
||||||
"ftp://localhost/aria2.zip",
|
fileEntry->removeURIWhoseHostnameIs("localhost");
|
||||||
"http://mirror/aria2.zip" };
|
CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntry->getRemainingUris().size());
|
||||||
FileEntry fileEntry;
|
|
||||||
fileEntry.setUris(std::deque<std::string>(&uris[0], &uris[3]));
|
|
||||||
fileEntry.removeURIWhoseHostnameIs("localhost");
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntry.getRemainingUris().size());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/aria2.zip"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/aria2.zip"),
|
||||||
fileEntry.getRemainingUris()[0]);
|
fileEntry->getRemainingUris()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,4 +92,40 @@ void FileEntryTest::testExtractURIResult()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileEntryTest::testGetRequest()
|
||||||
|
{
|
||||||
|
SharedHandle<FileEntry> fileEntry = createFileEntry();
|
||||||
|
SharedHandle<InOrderURISelector> selector(new InOrderURISelector());
|
||||||
|
SharedHandle<Request> req = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req->getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req->getProtocol());
|
||||||
|
|
||||||
|
fileEntry->poolRequest(req);
|
||||||
|
|
||||||
|
SharedHandle<Request> req2nd = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req2nd->getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req2nd->getProtocol());
|
||||||
|
|
||||||
|
SharedHandle<Request> req3rd = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req3rd->getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("ftp"), req3rd->getProtocol());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTest::testGetRequest_disableSingleHostMultiConnection()
|
||||||
|
{
|
||||||
|
SharedHandle<FileEntry> fileEntry = createFileEntry();
|
||||||
|
fileEntry->disableSingleHostMultiConnection();
|
||||||
|
SharedHandle<InOrderURISelector> selector(new InOrderURISelector());
|
||||||
|
SharedHandle<Request> req = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), req->getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req->getProtocol());
|
||||||
|
|
||||||
|
SharedHandle<Request> req2nd = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("mirror"), req2nd->getHost());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req2nd->getProtocol());
|
||||||
|
|
||||||
|
SharedHandle<Request> req3rd = fileEntry->getRequest(selector);
|
||||||
|
CPPUNIT_ASSERT(req3rd.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
#include "ServerHost.h"
|
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
@ -14,7 +13,6 @@ namespace aria2 {
|
||||||
class RequestGroupTest : public CppUnit::TestFixture {
|
class RequestGroupTest : public CppUnit::TestFixture {
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(RequestGroupTest);
|
CPPUNIT_TEST_SUITE(RequestGroupTest);
|
||||||
CPPUNIT_TEST(testRegisterSearchRemove);
|
|
||||||
CPPUNIT_TEST(testGetFirstFilePath);
|
CPPUNIT_TEST(testGetFirstFilePath);
|
||||||
CPPUNIT_TEST(testCreateDownloadResult);
|
CPPUNIT_TEST(testCreateDownloadResult);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
@ -26,7 +24,6 @@ public:
|
||||||
_option.reset(new Option());
|
_option.reset(new Option());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testRegisterSearchRemove();
|
|
||||||
void testGetFirstFilePath();
|
void testGetFirstFilePath();
|
||||||
void testCreateDownloadResult();
|
void testCreateDownloadResult();
|
||||||
};
|
};
|
||||||
|
@ -34,38 +31,6 @@ public:
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupTest );
|
CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupTest );
|
||||||
|
|
||||||
void RequestGroupTest::testRegisterSearchRemove()
|
|
||||||
{
|
|
||||||
RequestGroup rg(_option);
|
|
||||||
SharedHandle<ServerHost> sv1(new ServerHost(1, "localhost1"));
|
|
||||||
SharedHandle<ServerHost> sv2(new ServerHost(2, "localhost2"));
|
|
||||||
SharedHandle<ServerHost> sv3(new ServerHost(3, "localhost3"));
|
|
||||||
|
|
||||||
rg.registerServerHost(sv3);
|
|
||||||
rg.registerServerHost(sv1);
|
|
||||||
rg.registerServerHost(sv2);
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT(rg.searchServerHost(0).isNull());
|
|
||||||
|
|
||||||
{
|
|
||||||
SharedHandle<ServerHost> sv = rg.searchServerHost(1);
|
|
||||||
CPPUNIT_ASSERT(!sv.isNull());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("localhost1"), sv->getHostname());
|
|
||||||
}
|
|
||||||
|
|
||||||
rg.removeServerHost(1);
|
|
||||||
|
|
||||||
{
|
|
||||||
SharedHandle<ServerHost> sv = rg.searchServerHost(1);
|
|
||||||
CPPUNIT_ASSERT(sv.isNull());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
SharedHandle<ServerHost> sv = rg.searchServerHost(2);
|
|
||||||
CPPUNIT_ASSERT(!sv.isNull());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("localhost2"), sv->getHostname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequestGroupTest::testGetFirstFilePath()
|
void RequestGroupTest::testGetFirstFilePath()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> ctx
|
SharedHandle<DownloadContext> ctx
|
||||||
|
|
Loading…
Reference in New Issue