Skip to content

Commit e539101

Browse files
authored
scheme connection has been supported (#8232)
1 parent 2a2768a commit e539101

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

ydb/core/fq/libs/compute/common/config.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ class TComputeConfig {
108108
}
109109
}
110110

111+
NFq::NConfig::TYdbStorageConfig GetSchemeConnection(const TString& scope) const {
112+
const auto& controlPlane = ComputeConfig.GetYdb().GetControlPlane();
113+
switch (controlPlane.type_case()) {
114+
case NConfig::TYdbComputeControlPlane::TYPE_NOT_SET:
115+
return {};
116+
case NConfig::TYdbComputeControlPlane::kSingle:
117+
return controlPlane.GetSingle().GetConnection();
118+
case NConfig::TYdbComputeControlPlane::kCms:
119+
return GetSchemeConnection(scope, controlPlane.GetCms().GetDatabaseMapping());
120+
case NConfig::TYdbComputeControlPlane::kYdbcp:
121+
return GetSchemeConnection(scope, controlPlane.GetYdbcp().GetDatabaseMapping());
122+
}
123+
}
124+
125+
NFq::NConfig::TYdbStorageConfig GetSchemeConnection(const TString& scope, const ::NFq::NConfig::TDatabaseMapping& databaseMapping) const {
126+
auto it = databaseMapping.GetScopeToComputeDatabase().find(scope);
127+
if (it != databaseMapping.GetScopeToComputeDatabase().end()) {
128+
return it->second.HasSchemeConnection() ? it->second.GetSchemeConnection() : it->second.GetExecutionConnection(); // TODO: for backward compatibility, cleanup it after migration
129+
}
130+
131+
if (databaseMapping.GetCommon().empty()) {
132+
return NFq::NConfig::TYdbStorageConfig{};
133+
}
134+
135+
auto config = databaseMapping.GetCommon(MultiHash(scope) % databaseMapping.GetCommon().size());
136+
return config.HasSchemeConnection() ? config.GetSchemeConnection() : config.GetExecutionConnection(); // TODO: for backward compatibility, cleanup it after migration
137+
}
138+
111139
NFq::NConfig::TYdbStorageConfig GetExecutionConnection(const TString& scope, const ::NFq::NConfig::TDatabaseMapping& databaseMapping) const {
112140
auto it = databaseMapping.GetScopeToComputeDatabase().find(scope);
113141
if (it != databaseMapping.GetScopeToComputeDatabase().end()) {

ydb/core/fq/libs/compute/common/utils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ inline std::shared_ptr<NYdb::NTable::TTableClient> CreateNewTableClient(const TS
1818
const ::NFq::NConfig::TYdbStorageConfig& connection,
1919
const TYqSharedResources::TPtr& yqSharedResources,
2020
const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) {
21-
22-
::NFq::NConfig::TYdbStorageConfig computeConnection = computeConfig.GetExecutionConnection(scope);
21+
::NFq::NConfig::TYdbStorageConfig computeConnection = computeConfig.GetSchemeConnection(scope);
2322
computeConnection.set_endpoint(connection.endpoint());
2423
computeConnection.set_database(connection.database());
2524
computeConnection.set_usessl(connection.usessl());

ydb/core/fq/libs/config/protos/compute.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ message TWorkloadManagerConfig {
4444

4545
message TComputeDatabaseConfig {
4646
TYdbStorageConfig ControlPlaneConnection = 1;
47+
TYdbStorageConfig SchemeConnection = 6;
4748
TYdbStorageConfig ExecutionConnection = 3;
4849
string Tenant = 2;
4950
TLoadControlConfig LoadControlConfig = 4;

0 commit comments

Comments
 (0)