aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/client/client.cpp
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-02-27 16:27:23 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-02-27 17:00:48 +0300
commit6c35e9daf4dc86464e1a262236b8d3593e690ee5 (patch)
tree2727d5da08d12182c1a705ec7213a6b97f5da521 /yt/cpp/mapreduce/client/client.cpp
parent6fa64684d15341dd701bf1498ecafdd764d5f097 (diff)
downloadydb-6c35e9daf4dc86464e1a262236b8d3593e690ee5.tar.gz
Intermediate changes
Diffstat (limited to 'yt/cpp/mapreduce/client/client.cpp')
-rw-r--r--yt/cpp/mapreduce/client/client.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/yt/cpp/mapreduce/client/client.cpp b/yt/cpp/mapreduce/client/client.cpp
index 22f1253e2e..4548577834 100644
--- a/yt/cpp/mapreduce/client/client.cpp
+++ b/yt/cpp/mapreduce/client/client.cpp
@@ -44,6 +44,8 @@
#include <yt/cpp/mapreduce/raw_client/raw_requests.h>
#include <yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.h>
+#include <yt/yt/core/ytree/fluent.h>
+
#include <library/cpp/json/json_reader.h>
#include <util/generic/algorithm.h>
@@ -62,6 +64,32 @@ namespace NDetail {
////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+
+THashMap<TString, TString> ParseProxyUrlAliasingRules(TString envConfig)
+{
+ if (envConfig.empty()) {
+ return {};
+ }
+ return NYTree::ConvertTo<THashMap<TString, TString>>(NYson::TYsonString(envConfig));
+}
+
+void ApplyProxyUrlAliasingRules(TString& url)
+{
+ static auto rules = ParseProxyUrlAliasingRules(GetEnv("YT_PROXY_URL_ALIASING_CONFIG"));
+ if (auto ruleIt = rules.find(url); ruleIt != rules.end()) {
+ url = ruleIt->second;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+
TClientBase::TClientBase(
const TClientContext& context,
const TTransactionId& transactionId,
@@ -1333,8 +1361,10 @@ TClientPtr CreateClientImpl(
context.ProxyAddress = options.ProxyAddress_;
context.ServerName = serverName;
+
if (context.ServerName.find('.') == TString::npos &&
- context.ServerName.find(':') == TString::npos)
+ context.ServerName.find(':') == TString::npos &&
+ context.ServerName.find("localhost") == TString::npos)
{
context.ServerName += ".yt.yandex.net";
}
@@ -1419,6 +1449,8 @@ IClientPtr CreateClientFromEnv(const TCreateClientOptions& options)
ythrow yexception() << "YT_PROXY is not set";
}
+ NDetail::ApplyProxyUrlAliasingRules(serverName);
+
return NDetail::CreateClientImpl(serverName, options);
}