aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabcdef <akotov@ydb.tech>2023-06-28 16:27:33 +0300
committerabcdef <akotov@ydb.tech>2023-06-28 16:27:33 +0300
commitc41cbb372d40fdd4d243b98b76c86308cf8c8dfd (patch)
treede827d5459224cd5d0319de00e20a86d0ffbc28c
parente3141b4657c83fa042ee7bf85c5535b2bb250f6d (diff)
downloadydb-c41cbb372d40fdd4d243b98b76c86308cf8c8dfd.tar.gz
refactoring
рефакторинг
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.cpp4
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_reader.h4
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_full.cpp26
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_read.cpp2
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_write.cpp2
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.cpp2
-rw-r--r--ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.h4
7 files changed, 30 insertions, 14 deletions
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 c76717fc3f4..68b6729590a 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
@@ -7,7 +7,7 @@
using namespace NYdb::NConsoleClient;
-void TTopicWorkloadReader::ReaderLoop(TTopicWorkloadReaderParams&& params) {
+void TTopicWorkloadReader::ReaderLoop(TTopicWorkloadReaderParams& params) {
auto topicClient = std::make_unique<NYdb::NTopic::TTopicClient>(*params.Driver);
auto consumerName = TCommandWorkloadTopicDescribe::GenerateConsumerName(params.ConsumerIdx);
@@ -91,4 +91,4 @@ void TTopicWorkloadReader::ReaderLoop(TTopicWorkloadReaderParams&& params) {
}
}
}
-} \ No newline at end of file
+}
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 3fe3c39e077..1a3b43292dc 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
@@ -25,7 +25,7 @@ namespace NYdb {
class TTopicWorkloadReader {
public:
- static void ReaderLoop(TTopicWorkloadReaderParams&& params);
+ static void ReaderLoop(TTopicWorkloadReaderParams& params);
};
}
-} \ No newline at end of file
+}
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 54455ce26e3..2c9b2b83bf8 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
@@ -97,12 +97,28 @@ void TCommandWorkloadTopicRunFull::Parse(TConfig& config)
}
int TCommandWorkloadTopicRunFull::Run(TConfig& config) {
- Log = std::make_shared<TLog>(CreateLogBackend("cerr", TClientCommand::TConfig::VerbosityLevelToELogPriority(config.VerbosityLevel)));
+ auto makeLogBackend = [&config]() {
+ return CreateLogBackend("cerr",
+ TClientCommand::TConfig::VerbosityLevelToELogPriority(config.VerbosityLevel));
+ };
+
+ Log = std::make_shared<TLog>(makeLogBackend());
Log->SetFormatter(GetPrefixLogFormatter(""));
- Driver = std::make_unique<NYdb::TDriver>(CreateDriver(config, CreateLogBackend("cerr", TClientCommand::TConfig::VerbosityLevelToELogPriority(config.VerbosityLevel))));
- StatsCollector = std::make_shared<TTopicWorkloadStatsCollector>(ProducerThreadCount, ConsumerCount * ConsumerThreadCount, Quiet, PrintTimestamp, WindowSec, TotalSec, WarmupSec, Percentile, ErrorFlag);
+ Driver = std::make_unique<NYdb::TDriver>(CreateDriver(config, makeLogBackend()));
+
+ StatsCollector =
+ std::make_shared<TTopicWorkloadStatsCollector>(ProducerThreadCount,
+ ConsumerCount * ConsumerThreadCount,
+ Quiet,
+ PrintTimestamp,
+ WindowSec,
+ TotalSec,
+ WarmupSec,
+ Percentile,
+ ErrorFlag);
StatsCollector->PrintHeader();
+
std::vector<TString> generatedMessages = TTopicWorkloadWriterWorker::GenerateMessages(MessageSize);
auto describeTopicResult = TCommandWorkloadTopicDescribe::DescribeTopic(config.Database, TopicName, *Driver);
@@ -126,7 +142,7 @@ int TCommandWorkloadTopicRunFull::Run(TConfig& config) {
.ConsumerIdx = consumerIdx,
.ReaderIdx = consumerIdx * ConsumerCount + consumerThreadIdx};
- threads.push_back(std::async([readerParams = std::move(readerParams)]() mutable { TTopicWorkloadReader::ReaderLoop(std::move(readerParams)); }));
+ threads.push_back(std::async([readerParams = std::move(readerParams)]() mutable { TTopicWorkloadReader::ReaderLoop(readerParams); }));
}
}
while (*consumerStartedCount != ConsumerThreadCount * ConsumerCount)
@@ -152,7 +168,7 @@ int TCommandWorkloadTopicRunFull::Run(TConfig& config) {
.PartitionId = (partitionSeed + writerIdx) % partitionCount,
.Codec = Codec};
- threads.push_back(std::async([writerParams = std::move(writerParams)]() mutable { TTopicWorkloadWriterWorker::WriterLoop(std::move(writerParams)); }));
+ threads.push_back(std::async([writerParams = std::move(writerParams)]() mutable { TTopicWorkloadWriterWorker::WriterLoop(writerParams); }));
}
while (*producerStartedCount != ProducerThreadCount)
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 d6ea6a60393..d846332e323 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
@@ -100,7 +100,7 @@ int TCommandWorkloadTopicRunRead::Run(TConfig& config) {
.ConsumerIdx = consumerIdx,
.ReaderIdx = consumerIdx * ConsumerCount + consumerThreadIdx};
- threads.push_back(std::async([readerParams = std::move(readerParams)]() mutable { TTopicWorkloadReader::ReaderLoop(std::move(readerParams)); }));
+ threads.push_back(std::async([readerParams = std::move(readerParams)]() mutable { TTopicWorkloadReader::ReaderLoop(readerParams); }));
}
}
while (*consumerStartedCount != ConsumerThreadCount * ConsumerCount)
diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_write.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_write.cpp
index d1ec59f3db4..a25a9b01325 100644
--- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_write.cpp
+++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_run_write.cpp
@@ -124,7 +124,7 @@ int TCommandWorkloadTopicRunWrite::Run(TConfig& config) {
.PartitionId = (partitionSeed + writerIdx) % partitionCount,
.Codec = Codec};
- threads.push_back(std::async([writerParams = std::move(writerParams)]() mutable { TTopicWorkloadWriterWorker::WriterLoop(std::move(writerParams)); }));
+ threads.push_back(std::async([writerParams = std::move(writerParams)]() mutable { TTopicWorkloadWriterWorker::WriterLoop(writerParams); }));
}
while (*producerStartedCount != ProducerThreadCount)
diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.cpp
index d7960c4c6f4..5f9dccdb76e 100644
--- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.cpp
+++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.cpp
@@ -229,7 +229,7 @@ void TTopicWorkloadWriterWorker::CreateWorker() {
WriteSession = NYdb::NTopic::TTopicClient(*Params.Driver).CreateWriteSession(settings);
}
-void TTopicWorkloadWriterWorker::WriterLoop(TTopicWorkloadWriterParams&& params) {
+void TTopicWorkloadWriterWorker::WriterLoop(TTopicWorkloadWriterParams& params) {
TTopicWorkloadWriterWorker writer(std::move(params));
(*params.StartedCount)++;
diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.h b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.h
index 44c24b6be64..062f644f175 100644
--- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.h
+++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_writer.h
@@ -32,7 +32,7 @@ namespace NYdb {
class TTopicWorkloadWriterWorker {
public:
- static void WriterLoop(TTopicWorkloadWriterParams&& params);
+ static void WriterLoop(TTopicWorkloadWriterParams& params);
static std::vector<TString> GenerateMessages(size_t messageSize);
private:
TTopicWorkloadWriterWorker(TTopicWorkloadWriterParams&& params);
@@ -73,4 +73,4 @@ namespace NYdb {
THashMap<ui64, TInstant> InflightMessages;
};
}
-} \ No newline at end of file
+}