From da668763a682e97b897f75af22b35e269f63261a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 19 Jul 2010 05:37:40 +0000 Subject: [PATCH] 2010-07-19 Tatsuhiro Tsujikawa Added hidden select-least-used-host option. * src/CreateRequestCommand.cc * src/OptionHandlerFactory.cc * src/TrackerWatcherCommand.cc * src/prefs.cc * src/prefs.h --- ChangeLog | 9 +++++++++ src/CreateRequestCommand.cc | 4 +++- src/OptionHandlerFactory.cc | 8 ++++++++ src/TrackerWatcherCommand.cc | 1 + src/prefs.cc | 2 ++ src/prefs.h | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 049ca50d..88577643 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-07-19 Tatsuhiro Tsujikawa + + Added hidden select-least-used-host option. + * src/CreateRequestCommand.cc + * src/OptionHandlerFactory.cc + * src/TrackerWatcherCommand.cc + * src/prefs.cc + * src/prefs.h + 2010-07-19 Tatsuhiro Tsujikawa Updated doc for --split option. diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index c7373fc7..2a8dfad0 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -72,7 +72,9 @@ bool CreateRequestCommand::executeInternal() (getSegments().front()->getPositionToWrite())); } std::vector > usedHosts; - getDownloadEngine()->getRequestGroupMan()->getUsedHosts(usedHosts); + if(getOption()->getAsBool(PREF_SELECT_LEAST_USED_HOST)) { + getDownloadEngine()->getRequestGroupMan()->getUsedHosts(usedHosts); + } setRequest (getFileEntry()->getRequest(getRequestGroup()->getURISelector(), getOption()->getAsBool(PREF_REUSE_URI), diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index d7c228d6..a1df7357 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -504,6 +504,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); handlers.push_back(op); } + { + SharedHandle op(new BooleanOptionHandler + (PREF_SELECT_LEAST_USED_HOST, + NO_DEFAULT_VALUE, + V_TRUE)); + op->hide(); + handlers.push_back(op); + } { SharedHandle op(new NumberOptionHandler (PREF_STOP, diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc index f2a1faaf..fe741501 100644 --- a/src/TrackerWatcherCommand.cc +++ b/src/TrackerWatcherCommand.cc @@ -242,6 +242,7 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri) rg->getOption()->put(PREF_CONNECT_TIMEOUT, rg->getOption()->get(PREF_BT_TRACKER_CONNECT_TIMEOUT)); rg->getOption()->put(PREF_REUSE_URI, V_FALSE); + rg->getOption()->put(PREF_SELECT_LEAST_USED_HOST, V_FALSE); static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]"); SharedHandle dctx (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE), diff --git a/src/prefs.cc b/src/prefs.cc index eee818e2..61bcc5cb 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -196,6 +196,8 @@ const std::string PREF_MAX_CONNECTION_PER_SERVER("max-connection-per-server"); const std::string PREF_MIN_SPLIT_SIZE("min-split-size"); // value: true | false const std::string PREF_CONDITIONAL_GET("conditional-get"); +// value: true | false +const std::string PREF_SELECT_LEAST_USED_HOST("select-least-used-host"); /** * FTP related preferences diff --git a/src/prefs.h b/src/prefs.h index 5beb93f7..7ba05f19 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -200,6 +200,8 @@ extern const std::string PREF_MAX_CONNECTION_PER_SERVER; extern const std::string PREF_MIN_SPLIT_SIZE; // value: true | false extern const std::string PREF_CONDITIONAL_GET; +// value: true | false +extern const std::string PREF_SELECT_LEAST_USED_HOST; /** * FTP related preferences