diff options
author | artem-trof <artem-trof@yandex-team.com> | 2023-07-25 20:27:04 +0300 |
---|---|---|
committer | root <root@qavm-2ed34686.qemu> | 2023-07-25 20:27:04 +0300 |
commit | 54799eaba9e7338773883367169f28cd1e9b7799 (patch) | |
tree | 06d6d8f33b51427f8130a6d33368f2f085f25a41 | |
parent | d49935cc4b833d7adefe349d251a8705fbc8e6fe (diff) | |
download | ydb-54799eaba9e7338773883367169f28cd1e9b7799.tar.gz |
add consumer prefix for workload topic commands
9 files changed, 20 insertions, 8 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.cpp b/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.cpp index fde85a89ff..9a9e170937 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.cpp @@ -144,7 +144,7 @@ void TTopicOperationsScenario::CreateTopic(const TString& topic, for (unsigned consumerIdx = 0; consumerIdx < consumerCount; ++consumerIdx) { settings - .BeginAddConsumer(TCommandWorkloadTopicDescribe::GenerateConsumerName(consumerIdx)) + .BeginAddConsumer(TCommandWorkloadTopicDescribe::GenerateConsumerName(ConsumerPrefix, consumerIdx)) .EndAddConsumer(); } @@ -176,6 +176,7 @@ void TTopicOperationsScenario::StartConsumerThreads(std::vector<std::future<void .Database = database, .TopicName = TopicName, .ConsumerIdx = consumerIdx, + .ConsumerPrefix = ConsumerPrefix, .ReaderIdx = readerIdx }; diff --git a/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.h b/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.h index 8db8551787..fbdcd65035 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.h +++ b/ydb/public/lib/ydb_cli/commands/topic_operations_scenario.h @@ -52,6 +52,7 @@ public: ui32 ProducerThreadCount; ui32 ConsumerThreadCount; ui32 ConsumerCount; + TString ConsumerPrefix; size_t MessageSize; size_t MessageRate; size_t ByteRate; diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.cpp index 63005fb04a..1635b9e376 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.cpp @@ -5,9 +5,9 @@ using namespace NYdb::NConsoleClient; -TString TCommandWorkloadTopicDescribe::GenerateConsumerName(ui32 consumerIdx) +TString TCommandWorkloadTopicDescribe::GenerateConsumerName(const TString& consumerPrefix, ui32 consumerIdx) { - TString consumerName = TStringBuilder() << CONSUMER_PREFIX << '-' << consumerIdx; + TString consumerName = TStringBuilder() << consumerPrefix << '-' << consumerIdx; return consumerName; } diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.h b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.h index fb19fd4a94..e7eb0c1d45 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.h +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_describe.h @@ -9,7 +9,7 @@ namespace NYdb { namespace NConsoleClient { class TCommandWorkloadTopicDescribe { public: - static TString GenerateConsumerName(ui32 consumerIdx); + static TString GenerateConsumerName(const TString& consumerPrefix, ui32 consumerIdx); static TString GenerateFullTopicName(const TString& database, const TString& topicName); static NTopic::TTopicDescription DescribeTopic(const TString& database, const TString& topicName, const NYdb::TDriver& driver); }; diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_init.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_init.cpp index 0183654ba4..5d140b8a3a 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_init.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_init.cpp @@ -29,6 +29,9 @@ void TCommandWorkloadTopicInit::Config(TConfig& config) config.Opts->AddLongOption("topic", "Topic name.") .DefaultValue(TOPIC) .StoreResult(&Scenario.TopicName); + config.Opts->AddLongOption("consumer-prefix", "Use consumers with names '<consumer-prefix>-0' ... '<consumer-prefix>-<n-1>' where n is set in the '--consumers' option.") + .DefaultValue(CONSUMER_PREFIX) + .StoreResult(&Scenario.ConsumerPrefix); config.Opts->AddLongOption('p', "partitions", "Number of partitions in the topic.") .DefaultValue(128) diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.cpp index e4f3a9a768..e6dae133cc 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.cpp @@ -10,7 +10,7 @@ using namespace NYdb::NConsoleClient; void TTopicWorkloadReader::ReaderLoop(TTopicWorkloadReaderParams& params) { auto topicClient = std::make_unique<NYdb::NTopic::TTopicClient>(params.Driver); - auto consumerName = TCommandWorkloadTopicDescribe::GenerateConsumerName(params.ConsumerIdx); + auto consumerName = TCommandWorkloadTopicDescribe::GenerateConsumerName(params.ConsumerPrefix, params.ConsumerIdx); auto describeTopicResult = TCommandWorkloadTopicDescribe::DescribeTopic(params.Database, params.TopicName, params.Driver); auto consumers = describeTopicResult.GetConsumers(); if (!std::any_of(consumers.begin(), consumers.end(), [consumerName](const auto& consumer) { return consumer.GetConsumerName() == consumerName; })) @@ -59,7 +59,7 @@ void TTopicWorkloadReader::ReaderLoop(TTopicWorkloadReaderParams& params) { ui64 fullTime = (now - message.GetCreateTime()).MilliSeconds(); params.StatsCollector->AddReaderEvent(params.ReaderIdx, {message.GetData().Size(), fullTime}); - WRITE_LOG(params.Log, ELogPriority::TLOG_DEBUG, TStringBuilder() << "Got message: " << message.GetMessageGroupId() + WRITE_LOG(params.Log, ELogPriority::TLOG_DEBUG, TStringBuilder() << "Got message: " << message.GetMessageGroupId() << " topic " << message.GetPartitionSession()->GetTopicPath() << " partition " << message.GetPartitionSession()->GetPartitionId() << " offset " << message.GetOffset() << " seqNo " << message.GetSeqNo() << " createTime " << message.GetCreateTime() << " fullTimeMs " << fullTime); diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.h b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.h index 0ee310d080..0d3406312b 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.h +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.h @@ -20,6 +20,7 @@ namespace NYdb { TString Database; TString TopicName; ui32 ConsumerIdx; + TString ConsumerPrefix; ui64 ReaderIdx; }; diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_full.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_full.cpp index 18467c5d14..c137b3e8a5 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_full.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_full.cpp @@ -45,6 +45,9 @@ void TCommandWorkloadTopicRunFull::Config(TConfig& config) config.Opts->AddLongOption('t', "consumer-threads", "Number of consumer threads.") .DefaultValue(1) .StoreResult(&Scenario.ConsumerThreadCount); + config.Opts->AddLongOption("consumer-prefix", "Use consumers with names '<consumer-prefix>-0' ... '<consumer-prefix>-<n-1>' where n is set in the '--consumers' option.") + .DefaultValue(CONSUMER_PREFIX) + .StoreResult(&Scenario.ConsumerPrefix); config.Opts->AddLongOption('c', "consumers", "Number of consumers in a topic.") .DefaultValue(1) .StoreResult(&Scenario.ConsumerCount); @@ -67,7 +70,7 @@ void TCommandWorkloadTopicRunFull::Config(TConfig& config) config.IsNetworkIntensive = true; } -void TCommandWorkloadTopicRunFull::Parse(TConfig& config) +void TCommandWorkloadTopicRunFull::Parse(TConfig& config) { TClientCommand::Parse(config); diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_read.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_read.cpp index fc8fb17629..555ca5eb48 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_read.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_read.cpp @@ -36,6 +36,9 @@ void TCommandWorkloadTopicRunRead::Config(TConfig& config) .StoreResult(&Scenario.TopicName); // Specific params + config.Opts->AddLongOption("consumer-prefix", "Use consumers with names '<consumer-prefix>-0' ... '<consumer-prefix>-<n-1>' where n is set in the '--consumers' option.") + .DefaultValue(CONSUMER_PREFIX) + .StoreResult(&Scenario.ConsumerPrefix); config.Opts->AddLongOption('c', "consumers", "Number of consumers in a topic.") .DefaultValue(1) .StoreResult(&Scenario.ConsumerCount); @@ -46,7 +49,7 @@ void TCommandWorkloadTopicRunRead::Config(TConfig& config) config.IsNetworkIntensive = true; } -void TCommandWorkloadTopicRunRead::Parse(TConfig& config) +void TCommandWorkloadTopicRunRead::Parse(TConfig& config) { TClientCommand::Parse(config); |