Skip to content

Commit 97eb510

Browse files
authored
scope mapping has been supported for streaming (ydb-platform#11585) (ydb-platform#11614)
1 parent d6c7e47 commit 97eb510

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

ydb/core/fq/libs/control_plane_config/control_plane_config.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,18 @@ class TControlPlaneConfigActor : public NActors::TActorBootstrapped<TControlPlan
6565
} else {
6666
TenantInfo.reset(new TTenantInfo(ComputeConfig));
6767
const auto& mapping = Config.GetMapping();
68+
for (const auto& scopeToTenant : mapping.GetScopeToTenantName()) {
69+
auto [_, isInserted] = TenantInfo->SubjectMapping[SUBJECT_TYPE_SCOPE].emplace(scopeToTenant.GetKey(), scopeToTenant.GetValue());
70+
if (!isInserted) {
71+
CPC_LOG_E("Invalid configuation, the scope with the name " << scopeToTenant.GetKey() << " already exists");
72+
}
73+
TenantInfo->TenantMapping.emplace(scopeToTenant.GetValue(), scopeToTenant.GetValue());
74+
}
6875
for (const auto& cloudToTenant : mapping.GetCloudIdToTenantName()) {
69-
TenantInfo->SubjectMapping[SUBJECT_TYPE_CLOUD].emplace(cloudToTenant.GetKey(), cloudToTenant.GetValue());
76+
auto [_, isInserted] = TenantInfo->SubjectMapping[SUBJECT_TYPE_CLOUD].emplace(cloudToTenant.GetKey(), cloudToTenant.GetValue());
77+
if (!isInserted) {
78+
CPC_LOG_E("Invalid configuation, the cloud with the name " << cloudToTenant.GetKey() << " already exists");
79+
}
7080
TenantInfo->TenantMapping.emplace(cloudToTenant.GetValue(), cloudToTenant.GetValue());
7181
}
7282
for (const auto& commonTenantName : mapping.GetCommonTenantName()) {

ydb/core/fq/libs/control_plane_config/events/events.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ struct TTenantInfo {
4646
return pinTenants[MultiHash(cloudId) % pinTenants.size()];
4747
}
4848

49-
auto it = SubjectMapping.find(SUBJECT_TYPE_CLOUD);
50-
auto vTenant = it == SubjectMapping.end() ? "" : it->second.Value(cloudId, "");
49+
auto it = SubjectMapping.find(SUBJECT_TYPE_SCOPE);
50+
auto vTenant = it == SubjectMapping.end() ? "" : it->second.Value(scope, "");
51+
52+
if (!vTenant) {
53+
auto it = SubjectMapping.find(SUBJECT_TYPE_CLOUD);
54+
vTenant = it == SubjectMapping.end() ? "" : it->second.Value(cloudId, "");
55+
}
56+
5157
if (!vTenant && CommonVTenants.size()) {
5258
vTenant = CommonVTenants[MultiHash(cloudId) % CommonVTenants.size()];
5359
}

ydb/core/fq/libs/quota_manager/events/events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace NFq {
1919

2020
constexpr auto SUBJECT_TYPE_CLOUD = "cloud";
21+
constexpr auto SUBJECT_TYPE_SCOPE = "scope";
2122

2223
// Quota per cloud
2324
constexpr auto QUOTA_ANALYTICS_COUNT_LIMIT = "yq.analyticsQuery.count";

0 commit comments

Comments
 (0)