diff options
author | mokhotskii <mokhotskii@yandex-team.ru> | 2022-02-09 15:35:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 15:58:17 +0300 |
commit | 95f56ce40e2f7bb63cd38893fcc41b1692934640 (patch) | |
tree | 576fb8ac9e476c598ea6e581dcf3aa05940b7df9 | |
parent | 8f2bd4321c0db18b41461261f2f2ba3434e32e44 (diff) | |
download | ydb-95f56ce40e2f7bb63cd38893fcc41b1692934640.tar.gz |
LOGBROKER-7220 Move cloud_id, folder_id, db_id
Move cloud_id, folder_id, db_id
Move mentioned fields to schemeshard pq alter/create to make them
accessible in tablet.
ref:f77b4de51f0894a53ad11749add154d0ffbe577a
3 files changed, 38 insertions, 23 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp index c7480d3bee..f7a47459b9 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_pq.cpp @@ -75,6 +75,7 @@ public: } TPersQueueGroupInfo::TPtr ParseParams( + TOperationContext& context, NKikimrPQ::TPQTabletConfig* tabletConfig, const NKikimrSchemeOp::TPersQueueGroupDescription& alter, TString& errStr) @@ -138,6 +139,22 @@ public: return nullptr; } + const TPathElement::TPtr dbRootEl = context.SS->PathsById.at(context.SS->RootPathId()); + if (dbRootEl->UserAttrs->Attrs.contains("cloud_id")) { + auto cloudId = dbRootEl->UserAttrs->Attrs.at("cloud_id"); + tabletConfig->SetYcCloudId(cloudId); + } + if (dbRootEl->UserAttrs->Attrs.contains("folder_id")) { + auto folderId = dbRootEl->UserAttrs->Attrs.at("folder_id"); + tabletConfig->SetYcFolderId(folderId); + } + if (dbRootEl->UserAttrs->Attrs.contains("database_id")) { + auto databaseId = dbRootEl->UserAttrs->Attrs.at("database_id"); + tabletConfig->SetYdbDatabaseId(databaseId); + } + const TString databasePath = TPath::Init(context.SS->RootPathId(), context.SS).PathString(); + tabletConfig->SetYdbDatabasePath(databasePath); + alterConfig.MutablePartitionKeySchema()->Swap(tabletConfig->MutablePartitionKeySchema()); Y_PROTOBUF_SUPPRESS_NODISCARD alterConfig.SerializeToString(¶ms->TabletConfig); alterConfig.Swap(tabletConfig); @@ -436,7 +453,7 @@ public: newTabletConfig = tabletConfig; - TPersQueueGroupInfo::TPtr alterData = ParseParams(&newTabletConfig, alter, errStr); + TPersQueueGroupInfo::TPtr alterData = ParseParams(context, &newTabletConfig, alter, errStr); if (!alterData) { result->SetError(NKikimrScheme::StatusInvalidParameter, errStr); return result; diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_common.h b/ydb/core/tx/schemeshard/schemeshard__operation_common.h index ca21214993..5a3da32cad 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_common.h +++ b/ydb/core/tx/schemeshard/schemeshard__operation_common.h @@ -996,21 +996,6 @@ public: tabletConfig = &pqGroup->AlterData->TabletConfig; } - const TPathElement::TPtr dbRootEl = context.SS->PathsById.at(context.SS->RootPathId()); - TString cloudId; - if (dbRootEl->UserAttrs->Attrs.contains("cloud_id")) { - cloudId = dbRootEl->UserAttrs->Attrs.at("cloud_id"); - } - TString folderId; - if (dbRootEl->UserAttrs->Attrs.contains("folder_id")) { - folderId = dbRootEl->UserAttrs->Attrs.at("folder_id"); - } - TString databaseId; - if (dbRootEl->UserAttrs->Attrs.contains("database_id")) { - databaseId = dbRootEl->UserAttrs->Attrs.at("database_id"); - } - - TString databasePath = TPath::Init(context.SS->RootPathId(), context.SS).PathString(); for (auto shard : txState->Shards) { TShardIdx idx = shard.Idx; TTabletId tabletId = context.SS->ShardInfos.at(idx).TabletID; @@ -1036,11 +1021,6 @@ public: event->Record.MutableTabletConfig()->SetTopicPath(TPath::Init(txState->TargetPathId, context.SS).PathString()); event->Record.MutableTabletConfig()->MutablePartitionConfig()->SetTotalPartitions(pqGroup->AlterData ? pqGroup->AlterData->TotalGroupCount : pqGroup->TotalGroupCount); - event->Record.MutableTabletConfig()->SetYdbDatabaseId(databaseId); - event->Record.MutableTabletConfig()->SetYcCloudId(cloudId); - event->Record.MutableTabletConfig()->SetYcFolderId(folderId); - event->Record.MutableTabletConfig()->SetYdbDatabasePath(databasePath); - event->Record.MutableTabletConfig()->SetVersion(pqGroup->AlterVersion + 1); for (const auto& pq : pqShard->PQInfos) { diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp index 87c56a7466..992fd3175c 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_pq.cpp @@ -12,7 +12,8 @@ namespace { using namespace NKikimr; using namespace NSchemeShard; -TPersQueueGroupInfo::TPtr CreatePersQueueGroup(const NKikimrSchemeOp::TPersQueueGroupDescription& op, +TPersQueueGroupInfo::TPtr CreatePersQueueGroup(TOperationContext& context, + const NKikimrSchemeOp::TPersQueueGroupDescription& op, TEvSchemeShard::EStatus& status, TString& errStr) { TPersQueueGroupInfo::TPtr pqGroupInfo = new TPersQueueGroupInfo; @@ -146,6 +147,22 @@ TPersQueueGroupInfo::TPtr CreatePersQueueGroup(const NKikimrSchemeOp::TPersQueue return nullptr; } + const TPathElement::TPtr dbRootEl = context.SS->PathsById.at(context.SS->RootPathId()); + if (dbRootEl->UserAttrs->Attrs.contains("cloud_id")) { + auto cloudId = dbRootEl->UserAttrs->Attrs.at("cloud_id"); + tabletConfig.SetYcCloudId(cloudId); + } + if (dbRootEl->UserAttrs->Attrs.contains("folder_id")) { + auto folderId = dbRootEl->UserAttrs->Attrs.at("folder_id"); + tabletConfig.SetYcFolderId(folderId); + } + if (dbRootEl->UserAttrs->Attrs.contains("database_id")) { + auto databaseId = dbRootEl->UserAttrs->Attrs.at("database_id"); + tabletConfig.SetYdbDatabaseId(databaseId); + } + const TString databasePath = TPath::Init(context.SS->RootPathId(), context.SS).PathString(); + tabletConfig.SetYdbDatabasePath(databasePath); + Y_PROTOBUF_SUPPRESS_NODISCARD tabletConfig.SerializeToString(&pqGroupInfo->TabletConfig); if (op.HasBootstrapConfig()) { @@ -360,7 +377,7 @@ public: } TPersQueueGroupInfo::TPtr pqGroup = CreatePersQueueGroup( - createDEscription, status, errStr); + context, createDEscription, status, errStr); if (!pqGroup.Get()) { result->SetError(status, errStr); @@ -373,6 +390,7 @@ public: auto tabletConfig = pqGroup->TabletConfig; NKikimrPQ::TPQTabletConfig config; Y_VERIFY(!tabletConfig.empty()); + bool parseOk = ParseFromStringNoSizeLimit(config, tabletConfig); Y_VERIFY(parseOk); |