aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshmel1k <shmel1k@ydb.tech>2022-09-09 12:55:16 +0300
committershmel1k <shmel1k@ydb.tech>2022-09-09 12:55:16 +0300
commit75a5e826e2f818015c40fc7d76f3cdb4d5116151 (patch)
tree2557001662dce9a7c61064f16322338ae3cb51d4
parent9a5ad888338657a4461fb8401e0f3f58b89ac299 (diff)
downloadydb-75a5e826e2f818015c40fc7d76f3cdb4d5116151.tar.gz
[] add retention-storage-mb option
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp2
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp18
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_service_topic.h2
3 files changed, 16 insertions, 6 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp
index 2294be5944f..d1eaf8e49af 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp
@@ -206,7 +206,7 @@ namespace {
int TCommandDescribe::PrintTopicResponsePretty(const NYdb::NTopic::TTopicDescription& description) {
Cout << Endl << "RetentionPeriod: " << description.GetRetentionPeriod().Hours() << " hours";
if (description.GetRetentionStorageMb().Defined()) {
- Cout << Endl << "StorageRetention: " << *description.GetRetentionStorageMb() / 1_MB << " MB";
+ Cout << Endl << "StorageRetention: " << *description.GetRetentionStorageMb() << " MB";
}
Cout << Endl << "PartitionsCount: " << description.GetTotalPartitionsCount();
Cout << Endl << "PartitionWriteSpeed: " << description.GetPartitionWriteSpeedBytesPerSecond() / 1_KB << " KB";
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp
index 0ff3db06e75..7585a101331 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp
@@ -184,6 +184,10 @@ namespace NYdb::NConsoleClient {
.DefaultValue(1024)
.Optional()
.StoreResult(&PartitionWriteSpeedKbps_);
+ config.Opts->AddLongOption("retention-storage-mb", "Storage retention in megabytes")
+ .DefaultValue(0)
+ .Optional()
+ .StoreResult(&RetentionStorageMb_);
config.Opts->SetFreeArgsNum(1);
SetFreeArgTitle(0, "<topic-path>", "New topic path");
AddAllowedCodecs(config, AllowedCodecs);
@@ -217,6 +221,7 @@ namespace NYdb::NConsoleClient {
}
settings.RetentionPeriod(TDuration::Hours(RetentionPeriodHours_));
+ settings.RetentionStorageMb(RetentionStorageMb_ / 1_MB);
auto status = persQueueClient.CreateTopic(TopicName, settings).GetValueSync();
ThrowOnError(status);
@@ -237,6 +242,10 @@ namespace NYdb::NConsoleClient {
config.Opts->AddLongOption("partition-write-speed-kbps", "Partition write speed in kilobytes per second")
.Optional()
.StoreResult(&PartitionWriteSpeedKbps_);
+ config.Opts->AddLongOption("retention-storage-mb", "Storage retention in megabytes")
+ .DefaultValue(1024)
+ .Optional()
+ .StoreResult(&RetentionStorageMb_);
config.Opts->SetFreeArgsNum(1);
SetFreeArgTitle(0, "<topic-path>", "Topic to alter");
AddAllowedCodecs(config, AllowedCodecs);
@@ -276,15 +285,14 @@ namespace NYdb::NConsoleClient {
settings.SetMeteringMode(GetMeteringMode());
}
+ if (RetentionStorageMb_.Defined() && describeResult.GetTopicDescription().GetRetentionStorageMb() != *RetentionStorageMb_) {
+ settings.SetRetentionStorageMb(*RetentionStorageMb_);
+ }
+
return settings;
}
int TCommandTopicAlter::Run(TConfig& config) {
- if (!PartitionsCount_.Defined() && GetCodecs().empty() && !RetentionPeriodHours_.Defined() && !PartitionWriteSpeedKbps_.Defined() &&
- GetMeteringMode() == NTopic::EMeteringMode::Unspecified) {
- return EXIT_SUCCESS;
- }
-
TDriver driver = CreateDriver(config);
NYdb::NTopic::TTopicClient topicClient(driver);
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_topic.h b/ydb/public/lib/ydb_cli/commands/ydb_service_topic.h
index baea8b9dd1d..3cfde53b576 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_service_topic.h
+++ b/ydb/public/lib/ydb_cli/commands/ydb_service_topic.h
@@ -50,6 +50,7 @@ namespace NYdb::NConsoleClient {
private:
ui64 RetentionPeriodHours_;
+ ui64 RetentionStorageMb_;
ui32 PartitionsCount_;
ui32 PartitionWriteSpeedKbps_;
};
@@ -63,6 +64,7 @@ namespace NYdb::NConsoleClient {
private:
TMaybe<ui64> RetentionPeriodHours_;
+ TMaybe<ui64> RetentionStorageMb_;
TMaybe<ui32> PartitionsCount_;
TMaybe<ui32> PartitionWriteSpeedKbps_;