diff options
author | babenko <babenko@yandex-team.com> | 2025-02-02 12:13:55 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2025-02-02 12:43:24 +0300 |
commit | c9f9f0a604f7c9472b05ee76b17ebf406a027c07 (patch) | |
tree | 0c1842805b342029a1e241a9e9d9853bed32d583 | |
parent | 804e760347a2165ab510d10b3979fe81363fd916 (diff) | |
download | ydb-c9f9f0a604f7c9472b05ee76b17ebf406a027c07.tar.gz |
Refactor local host name and YP cluster functions
commit_hash:a4ecfb1e06e82ba192646d3ab5417cb3f0c6991f
-rw-r--r-- | library/cpp/yt/system/exit.h | 1 | ||||
-rw-r--r-- | yt/yt/client/federated/client.cpp | 6 | ||||
-rw-r--r-- | yt/yt/client/federated/unittests/client_ut.cpp | 20 | ||||
-rw-r--r-- | yt/yt/client/federated/unittests/connection_ut.cpp | 8 | ||||
-rw-r--r-- | yt/yt/core/misc/error.cpp | 6 | ||||
-rw-r--r-- | yt/yt/core/misc/unittests/error_ut.cpp | 2 | ||||
-rw-r--r-- | yt/yt/core/net/address.cpp | 6 | ||||
-rw-r--r-- | yt/yt/core/net/address.h | 4 | ||||
-rw-r--r-- | yt/yt/core/net/local_address.cpp | 119 | ||||
-rw-r--r-- | yt/yt/core/net/local_address.h | 28 | ||||
-rw-r--r-- | yt/yt/core/net/unittests/local_address_ut.cpp | 8 | ||||
-rw-r--r-- | yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp | 24 |
12 files changed, 122 insertions, 110 deletions
diff --git a/library/cpp/yt/system/exit.h b/library/cpp/yt/system/exit.h index e06c0bd3ddd..15261d63342 100644 --- a/library/cpp/yt/system/exit.h +++ b/library/cpp/yt/system/exit.h @@ -13,6 +13,7 @@ DEFINE_ENUM(EProcessExitCode, ((ArgumentsError) (1)) ((GenericError) (2)) ((IOError) (3)) + ((InternalError) (4)) ((OutOfMemory) (9)) ); diff --git a/yt/yt/client/federated/client.cpp b/yt/yt/client/federated/client.cpp index c3efdb939ed..86ba307c1a9 100644 --- a/yt/yt/client/federated/client.cpp +++ b/yt/yt/client/federated/client.cpp @@ -42,7 +42,7 @@ DECLARE_REFCOUNTED_CLASS(TClient) //////////////////////////////////////////////////////////////////////////////// -TFuture<std::optional<TString>> GetDataCenterByClient(const IClientPtr& client) +TFuture<std::optional<std::string>> GetDataCenterByClient(const IClientPtr& client) { TListNodeOptions options; options.MaxSize = 1; @@ -51,10 +51,10 @@ TFuture<std::optional<TString>> GetDataCenterByClient(const IClientPtr& client) .Apply(BIND([] (const NYson::TYsonString& items) { auto itemsList = NYTree::ConvertTo<NYTree::IListNodePtr>(items); if (!itemsList->GetChildCount()) { - return std::optional<TString>(); + return std::optional<std::string>(); } auto host = itemsList->GetChildren()[0]; - return NNet::InferYPClusterFromHostName(host->GetValue<TString>()); + return NNet::InferYPClusterFromHostName(host->GetValue<std::string>()); })); } diff --git a/yt/yt/client/federated/unittests/client_ut.cpp b/yt/yt/client/federated/unittests/client_ut.cpp index daf7529e787..f57aeb670b8 100644 --- a/yt/yt/client/federated/unittests/client_ut.cpp +++ b/yt/yt/client/federated/unittests/client_ut.cpp @@ -108,9 +108,9 @@ TEST(TFederatedClientTest, Basic) .WillOnce(Return(MakeFuture(listResult2))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); EXPECT_CALL(*mockClientVla, CheckClusterLiveness(_)) .WillOnce(Return(VoidFuture)) @@ -187,9 +187,9 @@ TEST(TFederatedClientTest, CheckHealth) .WillOnce(Return(MakeFuture(listResult2))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); std::vector<IClientPtr> clients{mockClientSas, mockClientVla}; auto config = New<TFederationConfig>(); @@ -273,9 +273,9 @@ TEST(TFederatedClientTest, Transactions) .WillOnce(Return(MakeFuture(listResult2))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); EXPECT_CALL(*mockClientVla, CheckClusterLiveness(_)) .WillOnce(Return(VoidFuture)) @@ -364,9 +364,9 @@ TEST(TFederatedClientTest, RetryWithoutTransaction) .WillOnce(Return(MakeFuture(listResult2))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.vla.yp-c.yandex.net"); EXPECT_CALL(*mockClientVla, CheckClusterLiveness(_)) .WillOnce(Return(VoidFuture)) @@ -450,9 +450,9 @@ TEST(TFederatedClientTest, AttachTransaction) .WillOnce(Return(MakeFuture(listResult2))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("b-rpc-proxy.vla.yp-c.yandex.net"); + NNet::SetLocalHostName("b-rpc-proxy.vla.yp-c.yandex.net"); EXPECT_CALL(*mockClientVla, CheckClusterLiveness(_)) .WillRepeatedly(Return(MakeFuture(TError("Failure")))); diff --git a/yt/yt/client/federated/unittests/connection_ut.cpp b/yt/yt/client/federated/unittests/connection_ut.cpp index e512087a146..2034caa57f3 100644 --- a/yt/yt/client/federated/unittests/connection_ut.cpp +++ b/yt/yt/client/federated/unittests/connection_ut.cpp @@ -66,9 +66,9 @@ TEST(TFederatedConnectionTest, CreateClient) .WillOnce(ReturnRefOfCopy(TString("vla"))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.sas.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.sas.yp-c.yandex.net"); auto connection = CreateConnection({mockConnectionSas, mockConnectionVla}, config); EXPECT_THAT(connection->GetLoggingTag(), testing::HasSubstr("Clusters: (sas; vla)")); @@ -131,9 +131,9 @@ TEST(TFederatedConnectionTest, CreateClientWhenOneClusterUnavailable) .WillOnce(ReturnRefOfCopy(TString("vla"))); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("a-rpc-proxy.sas.yp-c.yandex.net"); + NNet::SetLocalHostName("a-rpc-proxy.sas.yp-c.yandex.net"); auto connection = CreateConnection({mockConnectionSas, mockConnectionVla}, config); EXPECT_THAT(connection->GetLoggingTag(), testing::HasSubstr("Clusters: (sas; vla)")); diff --git a/yt/yt/core/misc/error.cpp b/yt/yt/core/misc/error.cpp index d206029e19b..fb0b4d193f9 100644 --- a/yt/yt/core/misc/error.cpp +++ b/yt/yt/core/misc/error.cpp @@ -40,7 +40,7 @@ namespace { struct TExtensionData { NConcurrency::TFiberId Fid = NConcurrency::InvalidFiberId; - const char* HostName = nullptr; + TStringBuf HostName; TTraceId TraceId = InvalidTraceId; TSpanId SpanId = InvalidSpanId; }; @@ -141,9 +141,9 @@ TOriginAttributes::TErasedExtensionData GetExtensionDataOverride() { TExtensionData result; result.Fid = NConcurrency::GetCurrentFiberId(); - result.HostName = NNet::ReadLocalHostName(); + result.HostName = NNet::GetLocalHostNameRaw(); - if (auto* traceContext = NTracing::TryGetCurrentTraceContext()) { + if (const auto* traceContext = NTracing::TryGetCurrentTraceContext()) { result.TraceId = traceContext->GetTraceId(); result.SpanId = traceContext->GetSpanId(); } diff --git a/yt/yt/core/misc/unittests/error_ut.cpp b/yt/yt/core/misc/unittests/error_ut.cpp index de4e4fba123..0c6d32d08c5 100644 --- a/yt/yt/core/misc/unittests/error_ut.cpp +++ b/yt/yt/core/misc/unittests/error_ut.cpp @@ -206,7 +206,7 @@ TEST(TErrorTest, TraceContext) TEST(TErrorTest, NativeHostName) { auto hostName = "TestHost"; - NNet::WriteLocalHostName(hostName); + NNet::SetLocalHostName(hostName); auto error = TError("NativeHostTest"); diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp index 70a5d78bf5e..d09b5f846ce 100644 --- a/yt/yt/core/net/address.cpp +++ b/yt/yt/core/net/address.cpp @@ -1051,7 +1051,7 @@ public: TAsyncExpiringCache::Reconfigure(Config_); if (Config_->LocalHostNameOverride) { - WriteLocalHostName(*Config_->LocalHostNameOverride); + SetLocalHostName(*Config_->LocalHostNameOverride); YT_LOG_INFO("Localhost name configured via config override (LocalHostName: %v)", Config_->LocalHostNameOverride); } @@ -1281,7 +1281,7 @@ std::optional<TStringBuf> InferYPClusterFromHostNameRaw(TStringBuf hostName) return {cluster}; } -std::optional<TString> InferYPClusterFromHostName(TStringBuf hostName) +std::optional<std::string> InferYPClusterFromHostName(TStringBuf hostName) { if (auto rawResult = InferYPClusterFromHostNameRaw(hostName)) { return TString{*rawResult}; @@ -1303,7 +1303,7 @@ std::optional<TStringBuf> InferYTClusterFromClusterUrlRaw(TStringBuf clusterUrl) return clusterUrl; } -std::optional<TString> InferYTClusterFromClusterUrl(TStringBuf clusterUrl) +std::optional<std::string> InferYTClusterFromClusterUrl(TStringBuf clusterUrl) { if (auto rawResult = InferYTClusterFromClusterUrlRaw(clusterUrl)) { return TString{*rawResult}; diff --git a/yt/yt/core/net/address.h b/yt/yt/core/net/address.h index f770a4f8925..8fbfa20f101 100644 --- a/yt/yt/core/net/address.h +++ b/yt/yt/core/net/address.h @@ -266,12 +266,12 @@ private: // Expected format: sas1-5535-9d7.sas-test.yp.gencfg-c.yandex.net, or noqpmfiudzbb4hvs.man.yp-c.yandex.net. // YP pod id must not contain a '.' in its name. std::optional<TStringBuf> InferYPClusterFromHostNameRaw(TStringBuf hostName); -std::optional<TString> InferYPClusterFromHostName(TStringBuf hostName); +std::optional<std::string> InferYPClusterFromHostName(TStringBuf hostName); //////////////////////////////////////////////////////////////////////////////// std::optional<TStringBuf> InferYTClusterFromClusterUrlRaw(TStringBuf clusterUrl); -std::optional<TString> InferYTClusterFromClusterUrl(TStringBuf clusterUrl); +std::optional<std::string> InferYTClusterFromClusterUrl(TStringBuf clusterUrl); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/net/local_address.cpp b/yt/yt/core/net/local_address.cpp index 19d307faae6..86ebbda7869 100644 --- a/yt/yt/core/net/local_address.cpp +++ b/yt/yt/core/net/local_address.cpp @@ -8,6 +8,7 @@ #include <library/cpp/yt/threading/fork_aware_spin_lock.h> #include <library/cpp/yt/system/handle_eintr.h> +#include <library/cpp/yt/system/exit.h> #ifdef _unix_ #include <sys/types.h> @@ -28,96 +29,106 @@ namespace NYT::NNet { namespace { -constexpr size_t MaxLocalFieldLength = 256; -constexpr size_t MaxLocalFieldDataSize = 1024; +class TStaticName +{ +public: + TStringBuf Read() const noexcept + { + // Writer-side imposes AcqRel ordering, so all preceding writes must be visible. + char* ptr = Ptr_.load(std::memory_order::relaxed); + return ptr ? ptr : Buffer_; + } + + std::string Get() const + { + return std::string(Read()); + } + + void Write(TStringBuf value) noexcept + { + char* ptr = Ptr_.load(std::memory_order::relaxed); + ptr = ptr ? ptr : Buffer_; + + if (::strncmp(ptr, value.data(), value.length()) == 0) { + // No changes; just return. + return; + } + + ptr = ptr + strlen(ptr) + 1; + + if (ptr + value.length() + 1 >= Buffer_ + BufferSize) { + AbortProcessDramatically( + EProcessExitCode::InternalError, + "TStaticName is out of buffer space"); + } + + ::memcpy(ptr, value.data(), value.length()); + *(ptr + value.length()) = 0; -// All static variables below must be const-initialized. -// - char[] is a POD, so it must be const-initialized. -// - std::atomic has constexpr value constructors. -// However, there is no way to enforce in compile-time that these variables -// are really const-initialized, so please double-check it with `objdump -s`. -char LocalHostNameData[MaxLocalFieldDataSize] = "(unknown)"; -std::atomic<char*> LocalHostNamePtr; + Ptr_.store(ptr, std::memory_order::seq_cst); + } -char LocalYPClusterData[MaxLocalFieldDataSize] = "(unknown)"; -std::atomic<char*> LocalYPClusterPtr; +private: + static constexpr size_t BufferSize = 1024; + char Buffer_[BufferSize] = "(unknown)"; + std::atomic<char*> Ptr_; +}; -std::atomic<bool> IPv6Enabled_ = false; +// All static variables below must be constinit. +constinit TStaticName LocalHostName; +constinit TStaticName LocalYPCluster; +constinit std::atomic<bool> IPv6Enabled = false; } // namespace //////////////////////////////////////////////////////////////////////////////// -const char* ReadLocalHostName() noexcept +TStringBuf GetLocalHostNameRaw() noexcept { NYT::NDetail::EnableErrorOriginOverrides(); - // Writer-side imposes AcqRel ordering, so all preceding writes must be visible. - char* ptr = LocalHostNamePtr.load(std::memory_order::relaxed); - return ptr ? ptr : LocalHostNameData; + return LocalHostName.Read(); } -const char* ReadLocalYPCluster() noexcept +TStringBuf GetLocalYPClusterRaw() noexcept { // Writer-side imposes AcqRel ordering, so all preceding writes must be visible. - char* ptr = LocalYPClusterPtr.load(std::memory_order::relaxed); - return ptr ? ptr : LocalYPClusterData; -} - -void GuardedWriteString(std::atomic<char*>& storage, char* initial, TStringBuf string) -{ - char* ptr = storage.load(std::memory_order::relaxed); - ptr = ptr ? ptr : initial; - - if (::strncmp(ptr, string.data(), string.length()) == 0) { - return; // No changes; just return. - } - - ptr = ptr + strlen(ptr) + 1; - - if (ptr + string.length() + 1 >= initial + MaxLocalFieldDataSize) { - ::abort(); // Once we crash here, we can start reusing space. - } - - ::memcpy(ptr, string.data(), string.length()); - *(ptr + string.length()) = 0; - - storage.store(ptr, std::memory_order::seq_cst); + return LocalYPCluster.Read(); } -void WriteLocalHostName(TStringBuf hostName) noexcept +void SetLocalHostName(TStringBuf hostName) noexcept { NYT::NDetail::EnableErrorOriginOverrides(); static NThreading::TForkAwareSpinLock Lock; auto guard = Guard(Lock); - GuardedWriteString(LocalHostNamePtr, LocalHostNameData, hostName); + LocalHostName.Write(hostName); if (auto ypCluster = InferYPClusterFromHostNameRaw(hostName)) { - GuardedWriteString(LocalYPClusterPtr, LocalYPClusterData, *ypCluster); + LocalYPCluster.Write(*ypCluster); } } -TString GetLocalHostName() +std::string GetLocalHostName() { - return {ReadLocalHostName()}; + return LocalHostName.Get(); } -TString GetLocalYPCluster() +std::string GetLocalYPCluster() { - return {ReadLocalYPCluster()}; + return LocalYPCluster.Get(); } void UpdateLocalHostName(const TAddressResolverConfigPtr& config) { - std::array<char, MaxLocalFieldLength> hostName; - hostName.fill(0); + // See https://man7.org/linux/man-pages/man7/hostname.7.html + std::array<char, 256> hostName{}; auto onFail = [&] (const std::vector<TError>& errors) { THROW_ERROR_EXCEPTION("Failed to update localhost name") << errors; }; - auto runWithRetries = [&] (std::function<int()> func, std::function<TError(int /*result*/)> onError) { + auto runWithRetries = [&] (auto func, auto onError) { std::vector<TError> errors; for (int retryIndex = 0; retryIndex < config->Retries; ++retryIndex) { @@ -141,7 +152,7 @@ void UpdateLocalHostName(const TAddressResolverConfigPtr& config) [&] (int /*result*/) { return TError("gethostname failed: %v", strerror(errno)); }); if (!config->ResolveHostNameIntoFqdn) { - WriteLocalHostName(TStringBuf(hostName.data())); + SetLocalHostName(TStringBuf(hostName.data())); return; } @@ -164,7 +175,7 @@ void UpdateLocalHostName(const TAddressResolverConfigPtr& config) onFail({error}); } - WriteLocalHostName(TStringBuf(response->ai_canonname)); + SetLocalHostName(TStringBuf(response->ai_canonname)); } //////////////////////////////////////////////////////////////////////////////// @@ -173,12 +184,12 @@ const std::string& GetLoopbackAddress() { static const std::string ipv4result("[127.0.1.1]"); static const std::string ipv6result("[::1]"); - return IPv6Enabled_.load(std::memory_order::relaxed) ? ipv6result : ipv4result; + return IPv6Enabled.load(std::memory_order::relaxed) ? ipv6result : ipv4result; } void UpdateLoopbackAddress(const TAddressResolverConfigPtr& config) { - IPv6Enabled_ = config->EnableIPv6; + IPv6Enabled = config->EnableIPv6; } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/net/local_address.h b/yt/yt/core/net/local_address.h index 1c1c6bd2ff4..12beb3fd594 100644 --- a/yt/yt/core/net/local_address.h +++ b/yt/yt/core/net/local_address.h @@ -14,31 +14,31 @@ namespace NYT::NNet { */ /* - * Read* & Write* functions work with statically allocated buffer. + * Get*Raw & Set* functions work with statically allocated buffer. * These functions are carefully engineered to be as safe and as robust * as possible, because they may be called at any time (e. g. during * invocation of atexit() hooks; or during static initialization). * They must never throw / crash / corrupt program. * - * Read* returns a pointer to a null-terminated string. Pointer is always valid - * (because it is a static memory!), string content never changes. - * Read* may be called concurrently, it is a lock-free function. + * Get*Raw returns a string view pointing to a static buffer + * whose content never changes. Get*Raw may be called concurrently, + * it is a lock-free function. * - * Write* checks if the new value differs from the latest one, and saves - * new value to the static memory if so. New value becomes visible for future Read*s. + * Set* checks if the new value differs from the latest one, and saves + * new value to the static memory if so. New value becomes visible for future Get*s. * - * Write* may be called concurrently, but it blocks. + * Set* may be called concurrently, but it blocks. * It also updates the stored local YP cluster. */ -const char* ReadLocalHostName() noexcept; -void WriteLocalHostName(TStringBuf hostName) noexcept; +TStringBuf GetLocalHostNameRaw() noexcept; +TStringBuf GetLocalYPClusterRaw() noexcept; -const char* ReadLocalYPCluster() noexcept; +void SetLocalHostName(TStringBuf hostName) noexcept; -//! Get* & Set* wrap Read* & Write* for more convenient usage. -//! The price is a dynamically allocated string. -TString GetLocalHostName(); -TString GetLocalYPCluster(); +//! Get* wrap Get*Raw for more convenient usage. +//! The price is a (possibly) dynamically allocated string. +std::string GetLocalHostName(); +std::string GetLocalYPCluster(); // Returns the loopback address (either IPv4 or IPv6, depending on the configuration). const std::string& GetLoopbackAddress(); diff --git a/yt/yt/core/net/unittests/local_address_ut.cpp b/yt/yt/core/net/unittests/local_address_ut.cpp index d840b0d0249..8e5504ba940 100644 --- a/yt/yt/core/net/unittests/local_address_ut.cpp +++ b/yt/yt/core/net/unittests/local_address_ut.cpp @@ -12,13 +12,13 @@ TEST(TLocalYPClusterTest, Basic) TString ypHostNameMan = "noqpmfiudzbb4hvs.man.yp-c.yandex.net"; TString ypHostNameSas = "hellodarknessmyoldfriend.sas.yp-c.yandex.net"; - WriteLocalHostName(ypHostNameMan); - TStringBuf localYPCluster1{ReadLocalYPCluster()}; + SetLocalHostName(ypHostNameMan); + TStringBuf localYPCluster1{GetLocalYPClusterRaw()}; EXPECT_EQ(localYPCluster1, "man"); EXPECT_EQ(GetLocalYPCluster(), "man"); - WriteLocalHostName(ypHostNameSas); - TStringBuf localYPCluster2{ReadLocalYPCluster()}; + SetLocalHostName(ypHostNameSas); + TStringBuf localYPCluster2{GetLocalYPClusterRaw()}; EXPECT_EQ(localYPCluster1, "man"); EXPECT_EQ(localYPCluster2, "sas"); EXPECT_EQ(GetLocalYPCluster(), "sas"); diff --git a/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp b/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp index 9df0436e169..de4a3d99cf5 100644 --- a/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp +++ b/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp @@ -503,9 +503,9 @@ TEST(TPreferLocalViablePeerRegistryTest, Simple) auto viablePeerRegistry = CreateTestRegistry(EPeerPriorityStrategy::PreferLocal, channelFactory, 3); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("b.sas.yp-c.yandex.net")); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("c.sas.yp-c.yandex.net")); @@ -534,9 +534,9 @@ TEST(TPreferLocalViablePeerRegistryTest, MinPeerCountForPriorityAwareness) /*minPeerCountForPriorityAwareness*/ 2); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("local.man.yp-c.yandex.net")); @@ -563,9 +563,9 @@ TEST(TPreferLocalViablePeerRegistryTest, RegistrationEvictsLesserPeers) auto viablePeerRegistry = CreateTestRegistry(EPeerPriorityStrategy::PreferLocal, channelFactory, 3); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("b.sas.yp-c.yandex.net")); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("c.sas.yp-c.yandex.net")); @@ -591,9 +591,9 @@ TEST(TPreferLocalViablePeerRegistryTest, PeerRotationRespectsPriority) auto viablePeerRegistry = CreateTestRegistry(EPeerPriorityStrategy::PreferLocal, channelFactory, 3); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("b.sas.yp-c.yandex.net")); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("c.sas.yp-c.yandex.net")); @@ -615,9 +615,9 @@ TEST(TPreferLocalViablePeerRegistryTest, FillFromBacklogRespectsPriority) auto viablePeerRegistry = CreateTestRegistry(EPeerPriorityStrategy::PreferLocal, channelFactory, 3); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("b.sas.yp-c.yandex.net")); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("c.sas.yp-c.yandex.net")); @@ -650,9 +650,9 @@ TEST(TPreferLocalViablePeerRegistryTest, DoNotCrashIfNoLocalPeers) auto viablePeerRegistry = CreateTestRegistry(EPeerPriorityStrategy::PreferLocal, channelFactory, 3); auto finally = Finally([oldLocalHostName = NNet::GetLocalHostName()] { - NNet::WriteLocalHostName(oldLocalHostName); + NNet::SetLocalHostName(oldLocalHostName); }); - NNet::WriteLocalHostName("home.man.yp-c.yandex.net"); + NNet::SetLocalHostName("home.man.yp-c.yandex.net"); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("b.sas.yp-c.yandex.net")); EXPECT_TRUE(viablePeerRegistry->RegisterPeer("a.man.yp-c.yandex.net")); |