From 0bdd3c5fa4326ed4106b9aee0585d57c7193bd97 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 4 Oct 2018 22:05:19 +0200 Subject: Remove the costly and unnecessary setSlobrokId interface. --- .../vespa/vespaclient/vesparoute/application.cpp | 28 ++++++++++------------ .../src/vespa/vespaclient/vesparoute/params.cpp | 1 + .../src/vespa/vespaclient/vesparoute/params.h | 4 ++++ 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'vespaclient') diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp index 1f35d348e28..5f2bbe8e11a 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp @@ -45,33 +45,29 @@ Application::Main() return EXIT_SUCCESS; } - std::shared_ptr repo( - new DocumentTypeRepo( - *ConfigGetter::getConfig(_params.getDocumentTypesConfigId()))); - _net.reset(new MyNetwork(_params.getRPCNetworkParams())); - _mbus.reset( - new mbus::MessageBus( + auto repo = std::make_shared( + *ConfigGetter::getConfig(_params.getDocumentTypesConfigId())); + _net = std::make_unique(mbus::RPCNetworkParams(_params.getSlobrokConfigId()) + .setIdentity(_params.getRPCNetworkParams().getIdentity()) + .setListenPort(_params.getRPCNetworkParams().getListenPort())); + _mbus = std::make_unique( *_net, mbus::MessageBusParams() .setRetryPolicy(mbus::IRetryPolicy::SP()) - .addProtocol(mbus::IProtocol::SP( - new documentapi::DocumentProtocol( - _loadTypes, repo))))); + .addProtocol(std::make_shared(_loadTypes, repo))); mbus::ConfigAgent cfg(*_mbus); cfg.configure(ConfigGetter::getConfig(_params.getRoutingConfigId())); // _P_A_R_A_N_O_I_A_ mbus::RoutingTable::SP table = _mbus->getRoutingTable(_params.getProtocol()); - if (table.get() == NULL) { + if ( ! table) { throw config::InvalidConfigException(vespalib::make_string("There is no routing table for protocol '%s'.", _params.getProtocol().c_str())); } - for (std::vector::iterator it = _params.getHops().begin(); - it != _params.getHops().end(); ++it) - { - if (table->getHop(*it) == NULL) { + for (const std::string & hop : _params.getHops()) { + if (table->getHop(hop) == NULL) { throw config::InvalidConfigException(vespalib::make_string("There is no hop named '%s' for protocol '%s'.", - it->c_str(), _params.getProtocol().c_str())); + hop.c_str(), _params.getProtocol().c_str())); } } @@ -166,7 +162,7 @@ Application::parseArgs() _params.setListServices(true); } else if (strcasecmp(_argv[arg], "--slobrokconfigid") == 0) { if (++arg < _argc) { - _params.getRPCNetworkParams().setSlobrokConfig(_argv[arg]); + _params.setSlobrokId(_argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'slobrokconfigid'."); } diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/params.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/params.cpp index 45a14691648..ded7013ccc9 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/params.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/params.cpp @@ -11,6 +11,7 @@ Params::Params() : _documentTypesConfigId("client"), _routingConfigId("client"), _protocol("document"), + _slobrokConfigId(""), _lstHops(false), _lstRoutes(false), _lstServices(false), diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/params.h b/vespaclient/src/vespa/vespaclient/vesparoute/params.h index a4b09e66a61..b16ac40212b 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/params.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/params.h @@ -92,6 +92,9 @@ public: /** Returns wether or not to verify service names. */ bool getVerify() const { return _verify; } + const std::string & getSlobrokConfigId() const { return _slobrokConfigId; } + void setSlobrokId(const std::string & id) { _slobrokConfigId = id; } + private: mbus::RPCNetworkParams _rpcParams; std::vector _hops; @@ -99,6 +102,7 @@ private: std::string _documentTypesConfigId; std::string _routingConfigId; std::string _protocol; + std::string _slobrokConfigId; bool _lstHops; bool _lstRoutes; bool _lstServices; -- cgit v1.2.3