aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-10-04 22:05:19 +0200
committerHenning Baldersheim <balder@oath.com>2018-10-04 22:05:19 +0200
commit0bdd3c5fa4326ed4106b9aee0585d57c7193bd97 (patch)
tree2b519cf259eb30ab28d85fc560a589457f54ed17 /vespaclient
parent3f2b1a9230fbab12f2e8b5afcf1e0ad72f3d872a (diff)
Remove the costly and unnecessary setSlobrokId interface.
Diffstat (limited to 'vespaclient')
-rw-r--r--vespaclient/src/vespa/vespaclient/vesparoute/application.cpp28
-rw-r--r--vespaclient/src/vespa/vespaclient/vesparoute/params.cpp1
-rw-r--r--vespaclient/src/vespa/vespaclient/vesparoute/params.h4
3 files changed, 17 insertions, 16 deletions
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<const DocumentTypeRepo> repo(
- new DocumentTypeRepo(
- *ConfigGetter<DocumenttypesConfig>::getConfig(_params.getDocumentTypesConfigId())));
- _net.reset(new MyNetwork(_params.getRPCNetworkParams()));
- _mbus.reset(
- new mbus::MessageBus(
+ auto repo = std::make_shared<DocumentTypeRepo>(
+ *ConfigGetter<DocumenttypesConfig>::getConfig(_params.getDocumentTypesConfigId()));
+ _net = std::make_unique<MyNetwork>(mbus::RPCNetworkParams(_params.getSlobrokConfigId())
+ .setIdentity(_params.getRPCNetworkParams().getIdentity())
+ .setListenPort(_params.getRPCNetworkParams().getListenPort()));
+ _mbus = std::make_unique<mbus::MessageBus>(
*_net,
mbus::MessageBusParams()
.setRetryPolicy(mbus::IRetryPolicy::SP())
- .addProtocol(mbus::IProtocol::SP(
- new documentapi::DocumentProtocol(
- _loadTypes, repo)))));
+ .addProtocol(std::make_shared<documentapi::DocumentProtocol>(_loadTypes, repo)));
mbus::ConfigAgent cfg(*_mbus);
cfg.configure(ConfigGetter<MessagebusConfig>::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<std::string>::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<std::string> _hops;
@@ -99,6 +102,7 @@ private:
std::string _documentTypesConfigId;
std::string _routingConfigId;
std::string _protocol;
+ std::string _slobrokConfigId;
bool _lstHops;
bool _lstRoutes;
bool _lstServices;