diff options
author | Håvard Pettersen <havardpe@oath.com> | 2022-04-06 12:18:08 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2022-04-08 13:45:13 +0000 |
commit | 9fbcf76d088740aacf535e6482f86c833cfae871 (patch) | |
tree | c62dcd0f9cdcee9876b37c60f741958c14147f80 /vespaclient | |
parent | 69454cef2fe53694eb5541e5f622a4e973c081bf (diff) |
remove FastOS_Application
fixup (per application):
- maybe ignore SIGPIPE
- wire argc/argv
untangle Vespa Test Framework
strip down deprecated TestApp
Diffstat (limited to 'vespaclient')
4 files changed, 50 insertions, 55 deletions
diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index ad0a42e0c4e..017abfdf28c 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -13,7 +13,7 @@ #include <vespa/vespalib/text/lowercase.h> #include <vespa/config-stor-distribution.h> #include <vespa/config/helper/configgetter.hpp> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <sstream> #include <iostream> #include <thread> @@ -221,13 +221,13 @@ Options::Options(Mode mode) Options::~Options() {} -struct StateApp : public FastOS_Application { +struct StateApp { Options _options; StateApp(std::string calledAs) : _options(getMode(calledAs)) {} - int Main() override { - _options.setCommandLineArguments(_argc, _argv); + int main(int argc, char **argv) { + _options.setCommandLineArguments(argc, argv); try{ _options.parse(); } catch (vespalib::InvalidCommandLineArgumentsException& e) { @@ -455,11 +455,9 @@ struct StateApp : public FastOS_Application { } // storage -int -main(int argc, char **argv) -{ +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); assert(argc > 0); storage::StateApp client(argv[0]); - return client.Entry(argc, argv); + return client.main(argc, argv); } - diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp index 75d8f770c1a..b0c5545f3ac 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp @@ -33,14 +33,14 @@ Application::Application() : Application::~Application() = default; - int -Application::Main() +int +Application::main(int argc, char **argv) { try { - if (_argc == 1) { + if (argc == 1) { _params.setListRoutes(true); _params.setListHops(true); - } else if (!parseArgs()) { + } else if (!parseArgs(argc, argv)) { return EXIT_SUCCESS; } @@ -102,73 +102,73 @@ Application::Main() } bool -Application::parseArgs() +Application::parseArgs(int argc, char **argv) { - for (int arg = 1; arg < _argc; arg++) { - if (strcasecmp(_argv[arg], "--documenttypesconfigid") == 0) { - if (++arg < _argc) { - _params.setDocumentTypesConfigId(_argv[arg]); + for (int arg = 1; arg < argc; arg++) { + if (strcasecmp(argv[arg], "--documenttypesconfigid") == 0) { + if (++arg < argc) { + _params.setDocumentTypesConfigId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'documenttypesconfigid'."); } - } else if (strcasecmp(_argv[arg], "--dump") == 0) { + } else if (strcasecmp(argv[arg], "--dump") == 0) { _params.setDump(true); - } else if (strcasecmp(_argv[arg], "--help") == 0 || - strcasecmp(_argv[arg], "-h") == 0) { + } else if (strcasecmp(argv[arg], "--help") == 0 || + strcasecmp(argv[arg], "-h") == 0) { printHelp(); return false; - } else if (strcasecmp(_argv[arg], "--hop") == 0) { - if (++arg < _argc) { - _params.getHops().push_back(_argv[arg]); + } else if (strcasecmp(argv[arg], "--hop") == 0) { + if (++arg < argc) { + _params.getHops().push_back(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'hop'."); } - } else if (strcasecmp(_argv[arg], "--hops") == 0) { + } else if (strcasecmp(argv[arg], "--hops") == 0) { _params.setListHops(true); - } else if (strcasecmp(_argv[arg], "--identity") == 0) { - if (++arg < _argc) { - _params.getRPCNetworkParams().setIdentity(mbus::Identity(_argv[arg])); + } else if (strcasecmp(argv[arg], "--identity") == 0) { + if (++arg < argc) { + _params.getRPCNetworkParams().setIdentity(mbus::Identity(argv[arg])); } else { throw config::InvalidConfigException("Missing value for parameter 'identity'."); } - } else if (strcasecmp(_argv[arg], "--listenport") == 0) { - if (++arg < _argc) { - _params.getRPCNetworkParams().setListenPort(atoi(_argv[arg])); + } else if (strcasecmp(argv[arg], "--listenport") == 0) { + if (++arg < argc) { + _params.getRPCNetworkParams().setListenPort(atoi(argv[arg])); } else { throw config::InvalidConfigException("Missing value for parameter 'listenport'."); } - } else if (strcasecmp(_argv[arg], "--protocol") == 0) { - if (++arg < _argc) { - _params.setProtocol(_argv[arg]); + } else if (strcasecmp(argv[arg], "--protocol") == 0) { + if (++arg < argc) { + _params.setProtocol(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'protocol'."); } - } else if (strcasecmp(_argv[arg], "--route") == 0) { - if (++arg < _argc) { - _params.getRoutes().push_back(_argv[arg]); + } else if (strcasecmp(argv[arg], "--route") == 0) { + if (++arg < argc) { + _params.getRoutes().push_back(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'route'."); } - } else if (strcasecmp(_argv[arg], "--routes") == 0) { + } else if (strcasecmp(argv[arg], "--routes") == 0) { _params.setListRoutes(true); - } else if (strcasecmp(_argv[arg], "--routingconfigid") == 0) { - if (++arg < _argc) { - _params.setRoutingConfigId(_argv[arg]); + } else if (strcasecmp(argv[arg], "--routingconfigid") == 0) { + if (++arg < argc) { + _params.setRoutingConfigId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'routingconfigid'."); } - } else if (strcasecmp(_argv[arg], "--services") == 0) { + } else if (strcasecmp(argv[arg], "--services") == 0) { _params.setListServices(true); - } else if (strcasecmp(_argv[arg], "--slobrokconfigid") == 0) { - if (++arg < _argc) { - _params.setSlobrokId(_argv[arg]); + } else if (strcasecmp(argv[arg], "--slobrokconfigid") == 0) { + if (++arg < argc) { + _params.setSlobrokId(argv[arg]); } else { throw config::InvalidConfigException("Missing value for parameter 'slobrokconfigid'."); } - } else if (strcasecmp(_argv[arg], "--verify") == 0) { + } else if (strcasecmp(argv[arg], "--verify") == 0) { _params.setVerify(true); } else { - throw config::InvalidConfigException(vespalib::make_string("Unknown option '%s'.", _argv[arg])); + throw config::InvalidConfigException(vespalib::make_string("Unknown option '%s'.", argv[arg])); } } return true; diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h index b7a33134b0e..0e111a72359 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h @@ -5,21 +5,20 @@ #include "params.h" #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/routing/hopblueprint.h> -#include <vespa/fastos/app.h> #include <set> namespace vesparoute { /** * Command-line feeder running on document api. */ -class Application : public FastOS_Application { +class Application { private: std::unique_ptr<MyNetwork> _net; std::unique_ptr<mbus::MessageBus> _mbus; Params _params; /** Parses the arguments of this application into the given params object. */ - bool parseArgs(); + bool parseArgs(int argc, char **argv); /** Prints help for this application. */ void printHelp() const; @@ -63,7 +62,7 @@ private: public: Application(); ~Application(); - int Main() override; + int main(int argc, char **argv); }; } diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp index bc55cc18366..d34989b30ee 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/main.cpp @@ -3,12 +3,10 @@ #include "application.h" #include <vespa/vespalib/util/signalhandler.h> -int -main(int argc, char** argv) -{ +int main(int argc, char** argv) { vespalib::SignalHandler::PIPE.ignore(); vesparoute::Application app; - int ret = app.Entry(argc, argv); + int ret = app.main(argc, argv); if (ret) { printf("Non-zero exit status: %d\n", ret); } |