aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrigminakov <grigminakov@yandex-team.com>2023-11-28 19:13:21 +0300
committergrigminakov <grigminakov@yandex-team.com>2023-11-28 20:08:12 +0300
commite79e79a7a59159e1994e51c878fed9324c44c974 (patch)
treea0c0e11c5085ca7b15dffbdfaab174ceb183f8da
parent80e1693e290dae63d499f3674e6b0c64d828a99b (diff)
downloadydb-e79e79a7a59159e1994e51c878fed9324c44c974.tar.gz
YT-20546: Bugfix and stylefixes in peer discovery
-rw-r--r--yt/yt/client/api/rpc_proxy/connection_impl.cpp2
-rw-r--r--yt/yt/core/rpc/balancing_channel.cpp2
-rw-r--r--yt/yt/core/rpc/balancing_channel.h4
-rw-r--r--yt/yt/core/rpc/dynamic_channel_pool.cpp3
-rw-r--r--yt/yt/core/rpc/peer_discovery.cpp14
-rw-r--r--yt/yt/core/rpc/peer_discovery.h2
6 files changed, 14 insertions, 13 deletions
diff --git a/yt/yt/client/api/rpc_proxy/connection_impl.cpp b/yt/yt/client/api/rpc_proxy/connection_impl.cpp
index 08e4f918c3..aa5d4e1080 100644
--- a/yt/yt/client/api/rpc_proxy/connection_impl.cpp
+++ b/yt/yt/client/api/rpc_proxy/connection_impl.cpp
@@ -244,7 +244,7 @@ TConnection::TConnection(TConnectionConfigPtr config, TConnectionOptions options
MakeEndpointDescription(Config_, ConnectionId_),
MakeEndpointAttributes(Config_, ConnectionId_),
TApiServiceProxy::GetDescriptor().ServiceName,
- CreateDefaultPeerDiscovery(TDiscoverRequestHook())))
+ CreateDefaultPeerDiscovery()))
{
if (options.ConnectionInvoker) {
ConnectionInvoker_ = options.ConnectionInvoker;
diff --git a/yt/yt/core/rpc/balancing_channel.cpp b/yt/yt/core/rpc/balancing_channel.cpp
index 2cc9595e89..f3e61afe78 100644
--- a/yt/yt/core/rpc/balancing_channel.cpp
+++ b/yt/yt/core/rpc/balancing_channel.cpp
@@ -189,7 +189,7 @@ public:
.Item("addresses").Value(Config_->Addresses)
.Items(*endpointAttributes)
.EndMap()))
- , PeerDiscovery_(peerDiscovery)
+ , PeerDiscovery_(std::move(peerDiscovery))
{ }
const TString& GetEndpointDescription() const override
diff --git a/yt/yt/core/rpc/balancing_channel.h b/yt/yt/core/rpc/balancing_channel.h
index d8d709abfd..2d448dd7cc 100644
--- a/yt/yt/core/rpc/balancing_channel.h
+++ b/yt/yt/core/rpc/balancing_channel.h
@@ -18,14 +18,14 @@ IChannelPtr CreateBalancingChannel(
IChannelFactoryPtr channelFactory,
TString endpointDescription,
NYTree::IAttributeDictionaryPtr endpointAttributes,
- IPeerDiscoveryPtr peerDiscovery = CreateDefaultPeerDiscovery(TDiscoverRequestHook{}));
+ IPeerDiscoveryPtr peerDiscovery = CreateDefaultPeerDiscovery());
IRoamingChannelProviderPtr CreateBalancingChannelProvider(
TBalancingChannelConfigPtr config,
IChannelFactoryPtr channelFactory,
TString endpointDescription,
NYTree::IAttributeDictionaryPtr endpointAttributes,
- IPeerDiscoveryPtr peerDiscovery = CreateDefaultPeerDiscovery(TDiscoverRequestHook{}));
+ IPeerDiscoveryPtr peerDiscovery = CreateDefaultPeerDiscovery());
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/rpc/dynamic_channel_pool.cpp b/yt/yt/core/rpc/dynamic_channel_pool.cpp
index ee69f72da0..3bb45c0548 100644
--- a/yt/yt/core/rpc/dynamic_channel_pool.cpp
+++ b/yt/yt/core/rpc/dynamic_channel_pool.cpp
@@ -335,8 +335,7 @@ private:
YT_LOG_DEBUG_IF(authError, "Peer has reported authentication error on discovery (Address: %v)",
address);
if (rspOrError.IsOK() || authError) {
- NProto::TRspDiscover resp;
- auto suggestedAddresses = FromProto<std::vector<TString>>(resp.suggested_addresses());
+ auto suggestedAddresses = authError ? std::vector<TString>() : rspOrError.Value().Addresses;
bool up = authError ? true : rspOrError.Value().IsUp;
if (!suggestedAddresses.empty()) {
diff --git a/yt/yt/core/rpc/peer_discovery.cpp b/yt/yt/core/rpc/peer_discovery.cpp
index fbc218e96d..5b3d031cff 100644
--- a/yt/yt/core/rpc/peer_discovery.cpp
+++ b/yt/yt/core/rpc/peer_discovery.cpp
@@ -6,13 +6,15 @@
namespace NYT::NRpc {
+using NYT::FromProto;
+
////////////////////////////////////////////////////////////////////////////////
class TDefaultPeerDiscovery
: public IPeerDiscovery
{
public:
- TDefaultPeerDiscovery(TDiscoverRequestHook hook)
+ explicit TDefaultPeerDiscovery(TDiscoverRequestHook hook)
: Hook_(std::move(hook))
{ }
@@ -35,14 +37,14 @@ public:
}
private:
- TDiscoverRequestHook Hook_;
+ const TDiscoverRequestHook Hook_;
static TPeerDiscoveryResponse ConvertResponse(const TIntrusivePtr<TTypedClientResponse<NProto::TRspDiscover>>& rsp)
{
- TPeerDiscoveryResponse response;
- response.Addresses = NYT::FromProto<std::vector<TString>>(rsp->suggested_addresses());
- response.IsUp = rsp->up();
- return response;
+ return TPeerDiscoveryResponse{
+ .IsUp = rsp->up(),
+ .Addresses = FromProto<std::vector<TString>>(rsp->suggested_addresses()),
+ };
}
};
diff --git a/yt/yt/core/rpc/peer_discovery.h b/yt/yt/core/rpc/peer_discovery.h
index e1b0f20101..a7120e2b33 100644
--- a/yt/yt/core/rpc/peer_discovery.h
+++ b/yt/yt/core/rpc/peer_discovery.h
@@ -26,7 +26,7 @@ DEFINE_REFCOUNTED_TYPE(IPeerDiscovery)
////////////////////////////////////////////////////////////////////////////////
-IPeerDiscoveryPtr CreateDefaultPeerDiscovery(TDiscoverRequestHook hook);
+IPeerDiscoveryPtr CreateDefaultPeerDiscovery(TDiscoverRequestHook hook = {});
////////////////////////////////////////////////////////////////////////////////