diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-13 18:27:32 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-13 21:17:12 +0300 |
commit | 0a988ab570eb772cd7f95c49b811e9d2cda545f2 (patch) | |
tree | e897531d4ffe5b0c3de9986dd2c73d7a38487c18 | |
parent | 038b24cba61ab4049c204fec05146de9a77e80f8 (diff) | |
download | ydb-0a988ab570eb772cd7f95c49b811e9d2cda545f2.tar.gz |
Intermediate changes
-rw-r--r-- | yt/yt/client/cache/cache.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/yt/yt/client/cache/cache.cpp b/yt/yt/client/cache/cache.cpp index fe1430b60c..e863c107b8 100644 --- a/yt/yt/client/cache/cache.cpp +++ b/yt/yt/client/cache/cache.cpp @@ -2,20 +2,40 @@ #include "options.h" #include "rpc.h" +#include <yt/yt/core/net/address.h> + #include <yt/yt_proto/yt/client/cache/proto/config.pb.h> #include <util/stream/str.h> namespace NYT::NClient::NCache { +namespace { //////////////////////////////////////////////////////////////////////////////// +TStringBuf GetNormalClusterName(TStringBuf clusterName) +{ + return NNet::InferYTClusterFromClusterUrlRaw(clusterName).value_or(clusterName); +} + +TClustersConfig GetClustersConfigWithNormalClusterName(const TClustersConfig& config) +{ + TClustersConfig newConfig(config); + newConfig.ClearClusterConfigs(); + for (auto& [clusterName, clusterConfig] : config.GetClusterConfigs()) { + (*newConfig.MutableClusterConfigs())[ToString(GetNormalClusterName(clusterName))] = clusterConfig; + } + return newConfig; +} + +} // namespace + TConfig MakeClusterConfig( const TClustersConfig& clustersConfig, TStringBuf clusterUrl) { auto [cluster, proxyRole] = ExtractClusterAndProxyRole(clusterUrl); - auto it = clustersConfig.GetClusterConfigs().find(cluster); + auto it = clustersConfig.GetClusterConfigs().find(GetNormalClusterName(cluster)); auto config = (it != clustersConfig.GetClusterConfigs().end()) ? it->second : clustersConfig.GetDefaultConfig(); config.SetClusterName(ToString(cluster)); if (!proxyRole.empty()) { @@ -35,9 +55,9 @@ class TClientsCache { public: TClientsCache(const TClustersConfig& config, const NApi::TClientOptions& options) - : ClustersConfig_(config) + : ClustersConfig_(GetClustersConfigWithNormalClusterName(config)) , Options_(options) - {} + { } protected: NApi::IClientPtr CreateClient(TStringBuf clusterUrl) override |