Skip to content

Commit

Permalink
scope mapping has been supported for streaming (#11585)
Browse files Browse the repository at this point in the history
  • Loading branch information
dorooleg authored Nov 14, 2024
1 parent c6e9a17 commit d3eebb6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 11 additions & 1 deletion ydb/core/fq/libs/control_plane_config/control_plane_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ class TControlPlaneConfigActor : public NActors::TActorBootstrapped<TControlPlan
} else {
TenantInfo.reset(new TTenantInfo(ComputeConfig));
const auto& mapping = Config.GetMapping();
for (const auto& scopeToTenant : mapping.GetScopeToTenantName()) {
auto [_, isInserted] = TenantInfo->SubjectMapping[SUBJECT_TYPE_SCOPE].emplace(scopeToTenant.GetKey(), scopeToTenant.GetValue());
if (!isInserted) {
CPC_LOG_E("Invalid configuation, the scope with the name " << scopeToTenant.GetKey() << " already exists");
}
TenantInfo->TenantMapping.emplace(scopeToTenant.GetValue(), scopeToTenant.GetValue());
}
for (const auto& cloudToTenant : mapping.GetCloudIdToTenantName()) {
TenantInfo->SubjectMapping[SUBJECT_TYPE_CLOUD].emplace(cloudToTenant.GetKey(), cloudToTenant.GetValue());
auto [_, isInserted] = TenantInfo->SubjectMapping[SUBJECT_TYPE_CLOUD].emplace(cloudToTenant.GetKey(), cloudToTenant.GetValue());
if (!isInserted) {
CPC_LOG_E("Invalid configuation, the cloud with the name " << cloudToTenant.GetKey() << " already exists");
}
TenantInfo->TenantMapping.emplace(cloudToTenant.GetValue(), cloudToTenant.GetValue());
}
for (const auto& commonTenantName : mapping.GetCommonTenantName()) {
Expand Down
10 changes: 8 additions & 2 deletions ydb/core/fq/libs/control_plane_config/events/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ struct TTenantInfo {
return pinTenants[MultiHash(cloudId) % pinTenants.size()];
}

auto it = SubjectMapping.find(SUBJECT_TYPE_CLOUD);
auto vTenant = it == SubjectMapping.end() ? "" : it->second.Value(cloudId, "");
auto it = SubjectMapping.find(SUBJECT_TYPE_SCOPE);
auto vTenant = it == SubjectMapping.end() ? "" : it->second.Value(scope, "");

if (!vTenant) {
auto it = SubjectMapping.find(SUBJECT_TYPE_CLOUD);
vTenant = it == SubjectMapping.end() ? "" : it->second.Value(cloudId, "");
}

if (!vTenant && CommonVTenants.size()) {
vTenant = CommonVTenants[MultiHash(cloudId) % CommonVTenants.size()];
}
Expand Down
1 change: 1 addition & 0 deletions ydb/core/fq/libs/quota_manager/events/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace NFq {

constexpr auto SUBJECT_TYPE_CLOUD = "cloud";
constexpr auto SUBJECT_TYPE_SCOPE = "scope";

// Quota per cloud
constexpr auto QUOTA_ANALYTICS_COUNT_LIMIT = "yq.analyticsQuery.count";
Expand Down

0 comments on commit d3eebb6

Please sign in to comment.