aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordon-dron <don-dron@yandex-team.com>2024-07-30 10:21:55 +0300
committerdon-dron <don-dron@yandex-team.com>2024-07-30 10:35:18 +0300
commitd7d99122c63ecaa60d07f3eea7589512ff729aec (patch)
treeb64cb789542600405af29e1351468b1cc074d46f
parent5b405616d0467647cb365e71237976a9f3810b42 (diff)
downloadydb-d7d99122c63ecaa60d07f3eea7589512ff729aec.tar.gz
YT-22317: Refactor after review
7cdfd2b230e7cc23a9e9d94f97981fcd5400903b
-rw-r--r--yt/yt/core/rpc/bus/channel.cpp2
-rw-r--r--yt/yt/core/rpc/channel.h2
-rw-r--r--yt/yt/core/rpc/channel_detail.cpp2
-rw-r--r--yt/yt/core/rpc/channel_detail.h2
-rw-r--r--yt/yt/core/rpc/grpc/channel.cpp5
-rw-r--r--yt/yt/core/rpc/hedging_channel.cpp2
-rw-r--r--yt/yt/core/rpc/http/channel.cpp6
-rw-r--r--yt/yt/core/rpc/local_channel.cpp5
-rw-r--r--yt/yt/core/rpc/null_channel.cpp5
-rw-r--r--yt/yt/core/rpc/roaming_channel.cpp5
-rw-r--r--yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp6
-rw-r--r--yt/yt/core/test_framework/test_proxy_service.cpp4
-rw-r--r--yt/yt/core/test_framework/test_proxy_service.h3
13 files changed, 29 insertions, 20 deletions
diff --git a/yt/yt/core/rpc/bus/channel.cpp b/yt/yt/core/rpc/bus/channel.cpp
index e62e8d3404..3d31d86de0 100644
--- a/yt/yt/core/rpc/bus/channel.cpp
+++ b/yt/yt/core/rpc/bus/channel.cpp
@@ -150,7 +150,7 @@ public:
return requestCount;
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
return MemoryUsageTracker_;
}
diff --git a/yt/yt/core/rpc/channel.h b/yt/yt/core/rpc/channel.h
index 8affb32b47..f3ebd37636 100644
--- a/yt/yt/core/rpc/channel.h
+++ b/yt/yt/core/rpc/channel.h
@@ -124,7 +124,7 @@ struct IChannel
virtual int GetInflightRequestCount() = 0;
- virtual IMemoryUsageTrackerPtr GetChannelMemoryTracker() = 0;
+ virtual const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() = 0;
};
DEFINE_REFCOUNTED_TYPE(IChannel)
diff --git a/yt/yt/core/rpc/channel_detail.cpp b/yt/yt/core/rpc/channel_detail.cpp
index fd4233826f..8b68f3d754 100644
--- a/yt/yt/core/rpc/channel_detail.cpp
+++ b/yt/yt/core/rpc/channel_detail.cpp
@@ -62,7 +62,7 @@ int TChannelWrapper::GetInflightRequestCount()
return UnderlyingChannel_->GetInflightRequestCount();
}
-IMemoryUsageTrackerPtr TChannelWrapper::GetChannelMemoryTracker()
+const IMemoryUsageTrackerPtr& TChannelWrapper::GetChannelMemoryTracker()
{
return UnderlyingChannel_->GetChannelMemoryTracker();
}
diff --git a/yt/yt/core/rpc/channel_detail.h b/yt/yt/core/rpc/channel_detail.h
index e01579f361..a601ab19c2 100644
--- a/yt/yt/core/rpc/channel_detail.h
+++ b/yt/yt/core/rpc/channel_detail.h
@@ -29,7 +29,7 @@ public:
int GetInflightRequestCount() override;
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override;
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override;
protected:
const IChannelPtr UnderlyingChannel_;
diff --git a/yt/yt/core/rpc/grpc/channel.cpp b/yt/yt/core/rpc/grpc/channel.cpp
index 0c0ed1fc88..48aeea0d8b 100644
--- a/yt/yt/core/rpc/grpc/channel.cpp
+++ b/yt/yt/core/rpc/grpc/channel.cpp
@@ -216,15 +216,16 @@ public:
YT_UNIMPLEMENTED();
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
private:
const TChannelConfigPtr Config_;
const TString EndpointAddress_;
const IAttributeDictionaryPtr EndpointAttributes_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
TSingleShotCallbackList<void(const TError&)> Terminated_;
diff --git a/yt/yt/core/rpc/hedging_channel.cpp b/yt/yt/core/rpc/hedging_channel.cpp
index b24e797b4e..85b095ee0e 100644
--- a/yt/yt/core/rpc/hedging_channel.cpp
+++ b/yt/yt/core/rpc/hedging_channel.cpp
@@ -392,7 +392,7 @@ public:
YT_UNIMPLEMENTED();
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
return PrimaryChannel_->GetChannelMemoryTracker();
}
diff --git a/yt/yt/core/rpc/http/channel.cpp b/yt/yt/core/rpc/http/channel.cpp
index fc58a04b76..4df4d37cb8 100644
--- a/yt/yt/core/rpc/http/channel.cpp
+++ b/yt/yt/core/rpc/http/channel.cpp
@@ -121,9 +121,9 @@ public:
YT_UNIMPLEMENTED();
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
private:
@@ -133,6 +133,8 @@ private:
const TString EndpointAddress_;
const IAttributeDictionaryPtr EndpointAttributes_;
const NConcurrency::IPollerPtr Poller_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
+
bool IsHttps_;
NHttps::TClientCredentialsConfigPtr Credentials_;
diff --git a/yt/yt/core/rpc/local_channel.cpp b/yt/yt/core/rpc/local_channel.cpp
index 6c83590794..11b7392836 100644
--- a/yt/yt/core/rpc/local_channel.cpp
+++ b/yt/yt/core/rpc/local_channel.cpp
@@ -133,9 +133,9 @@ public:
return 0;
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
private:
@@ -143,6 +143,7 @@ private:
using TSessionPtr = TIntrusivePtr<TSession>;
const IServerPtr Server_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
TSingleShotCallbackList<void(const TError&)> Terminated_;
diff --git a/yt/yt/core/rpc/null_channel.cpp b/yt/yt/core/rpc/null_channel.cpp
index a0b391dd74..41a1593d83 100644
--- a/yt/yt/core/rpc/null_channel.cpp
+++ b/yt/yt/core/rpc/null_channel.cpp
@@ -49,13 +49,14 @@ public:
return 0;
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
private:
const TString Address_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
};
IChannelPtr CreateNullChannel(TString address)
diff --git a/yt/yt/core/rpc/roaming_channel.cpp b/yt/yt/core/rpc/roaming_channel.cpp
index af4e689061..f0c011cc15 100644
--- a/yt/yt/core/rpc/roaming_channel.cpp
+++ b/yt/yt/core/rpc/roaming_channel.cpp
@@ -183,13 +183,14 @@ public:
return 0;
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
private:
const IRoamingChannelProviderPtr Provider_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
};
IChannelPtr CreateRoamingChannel(IRoamingChannelProviderPtr provider)
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 8096c20e08..382d8f142d 100644
--- a/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp
+++ b/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp
@@ -129,13 +129,15 @@ public:
return 0;
}
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
DEFINE_SIGNAL_OVERRIDE(void(const TError&), Terminated);
private:
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
+
TString Address_;
THashSet<TString>* ChannelRegistry_;
};
diff --git a/yt/yt/core/test_framework/test_proxy_service.cpp b/yt/yt/core/test_framework/test_proxy_service.cpp
index 8eb5b8da3d..692ebb65a8 100644
--- a/yt/yt/core/test_framework/test_proxy_service.cpp
+++ b/yt/yt/core/test_framework/test_proxy_service.cpp
@@ -167,9 +167,9 @@ int TTestChannel::GetInflightRequestCount()
return 0;
}
-IMemoryUsageTrackerPtr TTestChannel::GetChannelMemoryTracker()
+const IMemoryUsageTrackerPtr& TTestChannel::GetChannelMemoryTracker()
{
- return GetNullMemoryUsageTracker();
+ return MemoryUsageTracker_;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/test_framework/test_proxy_service.h b/yt/yt/core/test_framework/test_proxy_service.h
index 389d1eb344..c3dce7f78a 100644
--- a/yt/yt/core/test_framework/test_proxy_service.h
+++ b/yt/yt/core/test_framework/test_proxy_service.h
@@ -110,7 +110,7 @@ public:
int GetInflightRequestCount() override;
- IMemoryUsageTrackerPtr GetChannelMemoryTracker() override;
+ const IMemoryUsageTrackerPtr& GetChannelMemoryTracker() override;
void SubscribeTerminated(const TCallback<void(const TError&)>& callback) override;
@@ -121,6 +121,7 @@ private:
const TRealmIdServiceMap DefaultServices_;
const TString Address_;
const NYTree::IAttributeDictionaryPtr Attributes_;
+ const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker();
TSingleShotCallbackList<void(const TError&)> Terminated_;