/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
cloud/blockstore/tools/testing/rdma-test/options.cpp
215 строк
6 KB
Daniil Komarevtsev
Add various parameters to the RDMA configs (#5911)
15 май 2026, 11:16
Не верифицирован
15 май 2026, 11:16
d157982
Код
Авторство
О чём код?
#include "options.h" #include <library/cpp/getopt/small/last_getopt.h> #include <util/generic/serialized_enum.h> namespace NCloud::NBlockStore { using namespace NLastGetopt; //////////////////////////////////////////////////////////////////////////////// void TOptions::Parse(int argc, char** argv) { TOpts opts; opts.AddHelpOption(); opts.AddLongOption("test") .RequiredArgument("{" + GetEnumAllNames<ETestMode>() + "}") .DefaultValue(ToString(TestMode)) .Handler1T<TString>([this] (const auto& s) { TestMode = FromString<ETestMode>(s); }); const auto& verbose = opts.AddLongOption("verbose") .OptionalArgument("STR") .StoreResult(&VerboseLevel); // connection options opts.AddLongOption("host") .RequiredArgument() .DefaultValue(Host) .StoreResult(&Host); opts.AddLongOption("port") .RequiredArgument("NUM") .DefaultValue(ToString(Port)) .StoreResult(&Port); opts.AddLongOption("backlog") .RequiredArgument("NUM") .DefaultValue(ToString(Backlog)) .StoreResult(&Backlog); opts.AddLongOption("queue-size") .RequiredArgument("NUM") .DefaultValue(ToString(QueueSize)) .StoreResult(&QueueSize); opts.AddLongOption("send-queue-size") .RequiredArgument("NUM") .DefaultValue(SendQueueSize) .StoreResult(&SendQueueSize); opts.AddLongOption("recv-queue-size") .RequiredArgument("NUM") .DefaultValue(RecvQueueSize) .StoreResult(&RecvQueueSize); opts.AddLongOption("poller-threads") .RequiredArgument("NUM") .DefaultValue(ToString(PollerThreads)) .StoreResult(&PollerThreads); opts.AddLongOption("wait") .RequiredArgument("{" + GetEnumAllNames<EWaitMode>() + "}") .DefaultValue(ToString(WaitMode)) .Handler1T<TString>([this] (const auto& s) { WaitMode = FromString<EWaitMode>(s); }); opts.AddLongOption("connect-timeout") .RequiredArgument("SEC") .DefaultValue(ToString(ConnectTimeout)) .StoreResult(&ConnectTimeout); opts.AddLongOption("tos") .RequiredArgument("NUM") .StoreResult(&Tos); opts.AddLongOption("source-interface") .RequiredArgument() .StoreResult(&SourceInterface); opts.AddLongOption("verbs-qp") .StoreTrue(&VerbsQP); opts.AddLongOption("resolve-timeout") .RequiredArgument("MSEC") .DefaultValue(ResolveTimeout) .StoreResult(&ResolveTimeout); opts.AddLongOption("flush-timeout") .RequiredArgument("MSEC") .DefaultValue(FlushTimeout) .StoreResult(&FlushTimeout); opts.AddLongOption("qp-retry-count") .RequiredArgument("NUM") .DefaultValue(QpRetryCount) .StoreResult(&QpRetryCount); opts.AddLongOption("qp-rnr-retry-count") .RequiredArgument("NUM") .DefaultValue(QpRnrRetryCount) .StoreResult(&QpRnrRetryCount); opts.AddLongOption("qp-timeout") .RequiredArgument("NUM") .DefaultValue(QpTimeout) .StoreResult(&QpTimeout); opts.AddLongOption("qp-min-rnr-timer") .RequiredArgument("NUM") .DefaultValue(QpMinRnrTimer) .StoreResult(&QpMinRnrTimer); // device geometry opts.AddLongOption("storage") .RequiredArgument("{" + GetEnumAllNames<EStorageKind>() + "}") .DefaultValue(ToString(StorageKind)) .Handler1T<TString>([this] (const auto& s) { StorageKind = FromString<EStorageKind>(s); }); opts.AddLongOption("storage-path") .RequiredArgument("PATH") .StoreResult(&StoragePath); opts.AddLongOption("block-size") .RequiredArgument("NUM") .DefaultValue(ToString(BlockSize)) .StoreResult(&BlockSize); opts.AddLongOption("blocks-count") .RequiredArgument("NUM") .DefaultValue(ToString(BlocksCount)) .StoreResult(&BlocksCount); // test options opts.AddLongOption("iodepth") .RequiredArgument("NUM") .DefaultValue(ToString(MaxIoDepth)) .StoreResult(&MaxIoDepth); opts.AddLongOption("min-blocks-count") .RequiredArgument("NUM") .DefaultValue(ToString(MinBlocksCount)) .StoreResult(&MinBlocksCount); opts.AddLongOption("max-blocks-count") .RequiredArgument("NUM") .DefaultValue(ToString(MaxBlocksCount)) .StoreResult(&MaxBlocksCount); opts.AddLongOption("write-rate") .RequiredArgument("NUM") .DefaultValue(ToString(WriteRate)) .StoreResult(&WriteRate); ui32 seconds = 0; opts.AddLongOption("test-duration") .RequiredArgument("NUM") .StoreResult(&seconds); opts.AddLongOption("threadpool") .RequiredArgument("NUM") .DefaultValue(ToString(ThreadPool)) .StoreResult(&ThreadPool); // request tracing opts.AddLongOption("trace-path") .RequiredArgument("PATH") .StoreResult(&TracePath); opts.AddLongOption("trace-rate") .RequiredArgument("NUM") .DefaultValue(ToString(TraceRate)) .StoreResult(&TraceRate); opts.AddLongOption("chunk-size") .RequiredArgument("NUM") .DefaultValue(ToString(BufferPool.ChunkSize)) .StoreResult(&BufferPool.ChunkSize); opts.AddLongOption("max-chunk-alloc") .RequiredArgument("NUM") .DefaultValue(ToString(BufferPool.MaxChunkAlloc)) .StoreResult(&BufferPool.MaxChunkAlloc); opts.AddLongOption("max-free-chunks") .RequiredArgument("NUM") .DefaultValue(ToString(BufferPool.MaxFreeChunks)) .StoreResult(&BufferPool.MaxFreeChunks); TOptsParseResultException res(&opts, argc, argv); if (res.Has(&verbose) && !VerboseLevel) { VerboseLevel = "debug"; } TestDuration = TDuration::Seconds(seconds); if (!MaxBlocksCount) { MaxBlocksCount = MinBlocksCount; } Y_ENSURE(BufferPool.ChunkSize >= BufferPool.MaxChunkAlloc); Y_ENSURE(BlockSize && (BlockSize & (BlockSize - 1)) == 0); Y_ENSURE(BlocksCount && BlocksCount > MaxBlocksCount); Y_ENSURE(MinBlocksCount && MinBlocksCount <= MaxBlocksCount); Y_ENSURE(WriteRate <= 100); } } // namespace NCloud::NBlockStore