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 /searchlib/src/apps/docstore | |
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 'searchlib/src/apps/docstore')
-rw-r--r-- | searchlib/src/apps/docstore/benchmarkdatastore.cpp | 43 | ||||
-rw-r--r-- | searchlib/src/apps/docstore/create-idx-from-dat.cpp | 29 | ||||
-rw-r--r-- | searchlib/src/apps/docstore/documentstoreinspect.cpp | 41 | ||||
-rw-r--r-- | searchlib/src/apps/docstore/verifylogdatastore.cpp | 27 |
4 files changed, 80 insertions, 60 deletions
diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp index 4a0be335b11..9c2a40d6e98 100644 --- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp +++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp @@ -7,7 +7,7 @@ #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <unistd.h> #include <random> @@ -16,40 +16,41 @@ LOG_SETUP("documentstore.benchmark"); using namespace search; -class BenchmarkDataStoreApp : public FastOS_Application +class BenchmarkDataStoreApp { - void usage(); + void usage(const char *self); int benchmark(const vespalib::string & directory, size_t numReads, size_t numThreads, size_t perChunk, const vespalib::string & readType); - int Main() override; void read(size_t numReads, size_t perChunk, const IDataStore * dataStore); +public: + int main(int argc, char **argv); }; void -BenchmarkDataStoreApp::usage() +BenchmarkDataStoreApp::usage(const char *self) { - printf("Usage: %s <direcory> <numreads> <numthreads> <objects per read> <normal,directio,mmap>\n", _argv[0]); + printf("Usage: %s <direcory> <numreads> <numthreads> <objects per read> <normal,directio,mmap>\n", self); fflush(stdout); } int -BenchmarkDataStoreApp::Main() +BenchmarkDataStoreApp::main(int argc, char **argv) { - if (_argc >= 2) { + if (argc >= 2) { size_t numThreads(16); size_t numReads(1000000); size_t perChunk(1); vespalib::string readType("directio"); - vespalib::string directory(_argv[1]); - if (_argc >= 3) { - numReads = strtoul(_argv[2], NULL, 0); - if (_argc >= 4) { - numThreads = strtoul(_argv[3], NULL, 0); - if (_argc >= 5) { - perChunk = strtoul(_argv[4], NULL, 0); - if (_argc >= 5) { - readType = _argv[5]; + vespalib::string directory(argv[1]); + if (argc >= 3) { + numReads = strtoul(argv[2], NULL, 0); + if (argc >= 4) { + numThreads = strtoul(argv[3], NULL, 0); + if (argc >= 5) { + perChunk = strtoul(argv[4], NULL, 0); + if (argc >= 5) { + readType = argv[5]; } } } @@ -57,7 +58,7 @@ BenchmarkDataStoreApp::Main() return benchmark(directory, numReads, numThreads, perChunk, readType); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -111,4 +112,8 @@ BenchmarkDataStoreApp::benchmark(const vespalib::string & dir, size_t numReads, return retval; } -FASTOS_MAIN(BenchmarkDataStoreApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + BenchmarkDataStoreApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/create-idx-from-dat.cpp b/searchlib/src/apps/docstore/create-idx-from-dat.cpp index 30af02ddb92..7ac6b37473c 100644 --- a/searchlib/src/apps/docstore/create-idx-from-dat.cpp +++ b/searchlib/src/apps/docstore/create-idx-from-dat.cpp @@ -4,24 +4,25 @@ #include <vespa/searchlib/docstore/randreaders.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/vespalib/objects/nbostream.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/exception.h> #include <cinttypes> #include <cassert> using namespace search; -class CreateIdxFileFromDatApp : public FastOS_Application +class CreateIdxFileFromDatApp { - void usage(); + void usage(const char *self); int createIdxFile(const vespalib::string & datFileName, const vespalib::string & idxFileName); - int Main() override; +public: + int main(int argc, char **argv); }; void -CreateIdxFileFromDatApp::usage() +CreateIdxFileFromDatApp::usage(const char *self) { - printf("Usage: %s <datfile> <idxfile>\n", _argv[0]); + printf("Usage: %s <datfile> <idxfile>\n", self); fflush(stdout); } @@ -152,19 +153,23 @@ int CreateIdxFileFromDatApp::createIdxFile(const vespalib::string & datFileName, } int -CreateIdxFileFromDatApp::Main() +CreateIdxFileFromDatApp::main(int argc, char **argv) { vespalib::string cmd; - if (_argc == 3) { - vespalib::string datFile(_argv[1]); - vespalib::string idxfile(_argv[2]); + if (argc == 3) { + vespalib::string datFile(argv[1]); + vespalib::string idxfile(argv[2]); createIdxFile(datFile, idxfile); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; } -FASTOS_MAIN(CreateIdxFileFromDatApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + CreateIdxFileFromDatApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/documentstoreinspect.cpp b/searchlib/src/apps/docstore/documentstoreinspect.cpp index 0fc0c26f9c7..34afa0216ed 100644 --- a/searchlib/src/apps/docstore/documentstoreinspect.cpp +++ b/searchlib/src/apps/docstore/documentstoreinspect.cpp @@ -3,7 +3,7 @@ #include <vespa/searchlib/docstore/logdatastore.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> @@ -11,20 +11,21 @@ using namespace search; -class DocumentStoreInspectApp : public FastOS_Application +class DocumentStoreInspectApp { - void usage(); + void usage(const char *self); int verify(const vespalib::string & directory); int dumpIdxFile(const vespalib::string & file); - int Main() override; +public: + int main(int argc, char **argv); }; void -DocumentStoreInspectApp::usage() +DocumentStoreInspectApp::usage(const char *self) { - printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", _argv[0]); + printf("Usage: %s dumpidxfile [--idxfile idxFile]\n", self); fflush(stdout); } @@ -64,35 +65,35 @@ int DocumentStoreInspectApp::dumpIdxFile(const vespalib::string & file) } int -DocumentStoreInspectApp::Main() +DocumentStoreInspectApp::main(int argc, char **argv) { vespalib::string cmd; - if (_argc >= 2) { - cmd = _argv[1]; + if (argc >= 2) { + cmd = argv[1]; if (cmd == "dumpidxfile") { vespalib::string idxfile; - if (_argc >= 4) { - if (vespalib::string(_argv[2]) == vespalib::string("--idxfile")) { - idxfile = _argv[3]; + if (argc >= 4) { + if (vespalib::string(argv[2]) == vespalib::string("--idxfile")) { + idxfile = argv[3]; dumpIdxFile(idxfile); } else { - fprintf(stderr, "Unknown option '%s'.\n", _argv[2]); - usage(); + fprintf(stderr, "Unknown option '%s'.\n", argv[2]); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Unknown command '%s'.\n", cmd.c_str()); - usage(); + usage(argv[0]); return 1; } } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -116,4 +117,8 @@ DocumentStoreInspectApp::verify(const vespalib::string & dir) return retval; } -FASTOS_MAIN(DocumentStoreInspectApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + DocumentStoreInspectApp app; + return app.main(argc, argv); +} diff --git a/searchlib/src/apps/docstore/verifylogdatastore.cpp b/searchlib/src/apps/docstore/verifylogdatastore.cpp index c868707e545..3b673c172c9 100644 --- a/searchlib/src/apps/docstore/verifylogdatastore.cpp +++ b/searchlib/src/apps/docstore/verifylogdatastore.cpp @@ -4,38 +4,39 @@ #include <vespa/searchlib/docstore/logdatastore.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/exception.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> using namespace search; -class VerifyLogDataStoreApp : public FastOS_Application +class VerifyLogDataStoreApp { - void usage(); + void usage(const char *self); int verify(const vespalib::string & directory); - int Main() override; +public: + int main(int argc, char **argv); }; void -VerifyLogDataStoreApp::usage() +VerifyLogDataStoreApp::usage(const char *self) { - printf("Usage: %s <direcory>\n", _argv[0]); + printf("Usage: %s <direcory>\n", self); fflush(stdout); } int -VerifyLogDataStoreApp::Main() +VerifyLogDataStoreApp::main(int argc, char **argv) { - if (_argc >= 2) { - vespalib::string directory(_argv[1]); + if (argc >= 2) { + vespalib::string directory(argv[1]); return verify(directory); } else { fprintf(stderr, "Too few arguments\n"); - usage(); + usage(argv[0]); return 1; } return 0; @@ -65,4 +66,8 @@ VerifyLogDataStoreApp::verify(const vespalib::string & dir) return retval; } -FASTOS_MAIN(VerifyLogDataStoreApp); +int main(int argc, char **argv) { + vespalib::SignalHandler::PIPE.ignore(); + VerifyLogDataStoreApp app; + return app.main(argc, argv); +} |