aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgritukan <gritukan@yandex-team.com>2023-08-16 02:26:11 +0300
committergritukan <gritukan@yandex-team.com>2023-08-16 03:29:49 +0300
commitbeafb6ed034666d7979b71ec21bda9994ae224f1 (patch)
treec98c1df014fec315e8cb3033358fcf49914b1fbd
parentfebd7aad1485f0c7366b71363d3ec2f37281d5b1 (diff)
downloadydb-beafb6ed034666d7979b71ec21bda9994ae224f1.tar.gz
YT-19686: Make service and method names std::string
They are assumed to be short, so SSO should work
-rw-r--r--yt/yt/core/misc/protobuf_helpers-inl.h22
-rw-r--r--yt/yt/core/rpc/balancing_channel.cpp13
-rw-r--r--yt/yt/core/rpc/bus/channel.cpp50
-rw-r--r--yt/yt/core/rpc/channel_detail.cpp14
-rw-r--r--yt/yt/core/rpc/channel_detail.h4
-rw-r--r--yt/yt/core/rpc/client.cpp35
-rw-r--r--yt/yt/core/rpc/client.h27
-rw-r--r--yt/yt/core/rpc/dynamic_channel_pool.cpp6
-rw-r--r--yt/yt/core/rpc/dynamic_channel_pool.h2
-rw-r--r--yt/yt/core/rpc/helpers.cpp2
-rw-r--r--yt/yt/core/rpc/helpers.h4
-rw-r--r--yt/yt/core/rpc/roaming_channel.h2
-rw-r--r--yt/yt/core/rpc/server_detail.cpp12
-rw-r--r--yt/yt/core/rpc/server_detail.h8
-rw-r--r--yt/yt/core/rpc/service.cpp6
-rw-r--r--yt/yt/core/rpc/service.h10
-rw-r--r--yt/yt/core/rpc/service_detail.cpp8
-rw-r--r--yt/yt/core/rpc/unittests/mock/service.h4
-rw-r--r--yt/yt/core/rpc/unittests/roaming_channel_ut.cpp6
-rw-r--r--yt/yt/core/ytree/ypath_client.cpp16
-rw-r--r--yt/yt/core/ytree/ypath_client.h16
21 files changed, 136 insertions, 131 deletions
diff --git a/yt/yt/core/misc/protobuf_helpers-inl.h b/yt/yt/core/misc/protobuf_helpers-inl.h
index 93b4b362e7d..c292cd6dfc1 100644
--- a/yt/yt/core/misc/protobuf_helpers-inl.h
+++ b/yt/yt/core/misc/protobuf_helpers-inl.h
@@ -44,11 +44,23 @@ inline void ToProto(TString* serialized, TString original)
*serialized = std::move(original);
}
+inline void ToProto(TString* serialized, std::string original)
+{
+ *serialized = std::move(original);
+}
+
inline void FromProto(TString* original, TString serialized)
{
*original = std::move(serialized);
}
+// NB: ToProto works in O(1) time if TSTRING_IS_STD_STRING is used and
+// may work in O(n) time otherwise due to CoW.
+inline void FromProto(std::string* original, TString serialized)
+{
+ *original = std::move(serialized.MutRef());
+}
+
// These conversions work in case if the original protobuf that uses
// std::string is used.
// NB: ToProto works in O(1) time if TSTRING_IS_STD_STRING is used and
@@ -58,11 +70,21 @@ inline void ToProto(std::string* serialized, TString original)
*serialized = std::move(original.MutRef());
}
+inline void ToProto(std::string* serialized, std::string original)
+{
+ *serialized = std::move(original);
+}
+
inline void FromProto(TString* original, std::string serialized)
{
*original = std::move(serialized);
}
+inline void FromProto(std::string* original, std::string serialized)
+{
+ *original = std::move(serialized);
+}
+
////////////////////////////////////////////////////////////////////////////////
// These conversions work in case if the patched protobuf that uses
diff --git a/yt/yt/core/rpc/balancing_channel.cpp b/yt/yt/core/rpc/balancing_channel.cpp
index 82ee29216f1..fcc9911377f 100644
--- a/yt/yt/core/rpc/balancing_channel.cpp
+++ b/yt/yt/core/rpc/balancing_channel.cpp
@@ -44,7 +44,7 @@ public:
IChannelFactoryPtr channelFactory,
TString endpointDescription,
IAttributeDictionaryPtr endpointAttributes,
- TString serviceName,
+ std::string serviceName,
TDiscoverRequestHook discoverRequestHook)
: Config_(std::move(config))
, EndpointDescription_(endpointDescription)
@@ -216,9 +216,9 @@ public:
}
}
- TFuture<IChannelPtr> GetChannel(const TString& serviceName) override
+ TFuture<IChannelPtr> GetChannel(std::string serviceName) override
{
- return GetSubprovider(serviceName)->GetChannel();
+ return GetSubprovider(std::move(serviceName))->GetChannel();
}
TFuture<IChannelPtr> GetChannel() override
@@ -250,10 +250,10 @@ private:
const IAttributeDictionaryPtr EndpointAttributes_;
YT_DECLARE_SPIN_LOCK(NThreading::TReaderWriterSpinLock, SpinLock_);
- THashMap<TString, TBalancingChannelSubproviderPtr> SubproviderMap_;
+ THashMap<std::string, TBalancingChannelSubproviderPtr> SubproviderMap_;
- TBalancingChannelSubproviderPtr GetSubprovider(const TString& serviceName)
+ TBalancingChannelSubproviderPtr GetSubprovider(std::string serviceName)
{
{
auto guard = ReaderGuard(SpinLock_);
@@ -277,11 +277,10 @@ private:
EndpointAttributes_,
serviceName,
DiscoverRequestHook_);
- YT_VERIFY(SubproviderMap_.emplace(serviceName, subprovider).second);
+ EmplaceOrCrash(SubproviderMap_, serviceName, subprovider);
return subprovider;
}
}
-
};
DEFINE_REFCOUNTED_TYPE(TBalancingChannelProvider)
diff --git a/yt/yt/core/rpc/bus/channel.cpp b/yt/yt/core/rpc/bus/channel.cpp
index 57bb875a001..ae030b5615c 100644
--- a/yt/yt/core/rpc/bus/channel.cpp
+++ b/yt/yt/core/rpc/bus/channel.cpp
@@ -428,16 +428,12 @@ private:
return;
}
- const auto& realmId = requestControl->GetRealmId();
- const auto& service = requestControl->GetService();
- const auto& method = requestControl->GetMethod();
-
NProto::TRequestCancelationHeader header;
ToProto(header.mutable_request_id(), requestId);
- header.set_service(service);
- header.set_method(method);
- if (realmId) {
- ToProto(header.mutable_realm_id(), realmId);
+ ToProto(header.mutable_service(), requestControl->GetService());
+ ToProto(header.mutable_method(), requestControl->GetMethod());
+ if (auto realmId = requestControl->GetRealmId()) {
+ ToProto(header.mutable_realm_id(), requestControl->GetRealmId());
}
auto message = CreateRequestCancelationMessage(header);
@@ -454,17 +450,12 @@ private:
return MakeFuture(TError(NRpc::EErrorCode::TransportError, "Session is terminated"));
}
- auto requestId = requestControl->GetRequestId();
- const auto& realmId = requestControl->GetRealmId();
- const auto& service = requestControl->GetService();
- const auto& method = requestControl->GetMethod();
-
NProto::TStreamingPayloadHeader header;
- ToProto(header.mutable_request_id(), requestId);
- header.set_service(service);
- header.set_method(method);
- if (realmId) {
- ToProto(header.mutable_realm_id(), realmId);
+ ToProto(header.mutable_request_id(), requestControl->GetRequestId());
+ ToProto(header.mutable_service(), requestControl->GetService());
+ ToProto(header.mutable_method(), requestControl->GetMethod());
+ if (auto realmId = requestControl->GetRealmId()) {
+ ToProto(header.mutable_realm_id(), requestControl->GetRealmId());
}
header.set_sequence_number(payload.SequenceNumber);
header.set_codec(static_cast<int>(payload.Codec));
@@ -485,17 +476,12 @@ private:
return MakeFuture(TError(NRpc::EErrorCode::TransportError, "Session is terminated"));
}
- auto requestId = requestControl->GetRequestId();
- const auto& realmId = requestControl->GetRealmId();
- const auto& service = requestControl->GetService();
- const auto& method = requestControl->GetMethod();
-
NProto::TStreamingFeedbackHeader header;
- ToProto(header.mutable_request_id(), requestId);
- header.set_service(service);
- header.set_method(method);
- if (realmId) {
- ToProto(header.mutable_realm_id(), realmId);
+ ToProto(header.mutable_request_id(), requestControl->GetRequestId());
+ ToProto(header.mutable_service(), requestControl->GetService());
+ ToProto(header.mutable_method(), requestControl->GetMethod());
+ if (auto realmId = requestControl->GetRealmId()) {
+ ToProto(header.mutable_realm_id(), requestControl->GetRealmId());
}
header.set_read_position(feedback.ReadPosition);
@@ -1102,12 +1088,12 @@ private:
return RealmId_;
}
- const TString& GetService() const
+ std::string GetService() const
{
return Service_;
}
- const TString& GetMethod() const
+ std::string GetMethod() const
{
return Method_;
}
@@ -1186,8 +1172,8 @@ private:
private:
const TSessionPtr Session_;
const TRealmId RealmId_;
- const TString Service_;
- const TString Method_;
+ const std::string Service_;
+ const std::string Method_;
const TRequestId RequestId_;
const TSendOptions Options_;
diff --git a/yt/yt/core/rpc/channel_detail.cpp b/yt/yt/core/rpc/channel_detail.cpp
index 7a297f20c41..295457f947a 100644
--- a/yt/yt/core/rpc/channel_detail.cpp
+++ b/yt/yt/core/rpc/channel_detail.cpp
@@ -187,23 +187,23 @@ struct TClientRequestPerformanceProfiler::TPerformanceCounters
};
auto TClientRequestPerformanceProfiler::GetPerformanceCounters(
- const TString& service,
- const TString& method) -> const TPerformanceCounters*
+ std::string service,
+ std::string method) -> const TPerformanceCounters*
{
- using TCountersMap = NConcurrency::TSyncMap<std::pair<TString, TString>, TPerformanceCounters>;
+ using TCountersMap = NConcurrency::TSyncMap<std::pair<std::string, std::string>, TPerformanceCounters>;
auto [counter, _] = LeakySingleton<TCountersMap>()->FindOrInsert(std::pair(service, method), [&] {
auto profiler = RpcClientProfiler
.WithHot()
- .WithTag("yt_service", service)
- .WithTag("method", method, -1);
+ .WithTag("yt_service", TString(service))
+ .WithTag("method", TString(method), -1);
return TPerformanceCounters(profiler);
});
return counter;
}
-TClientRequestPerformanceProfiler::TClientRequestPerformanceProfiler(const TString& service, const TString& method)
- : MethodCounters_(GetPerformanceCounters(service, method))
+TClientRequestPerformanceProfiler::TClientRequestPerformanceProfiler(std::string service, std::string method)
+ : MethodCounters_(GetPerformanceCounters(std::move(service), std::move(method)))
{ }
void TClientRequestPerformanceProfiler::ProfileRequest(const TSharedRefArray& requestMessage)
diff --git a/yt/yt/core/rpc/channel_detail.h b/yt/yt/core/rpc/channel_detail.h
index a89568d100b..d23d2346b98 100644
--- a/yt/yt/core/rpc/channel_detail.h
+++ b/yt/yt/core/rpc/channel_detail.h
@@ -78,7 +78,7 @@ class TClientRequestPerformanceProfiler
: public IClientRequestControl
{
public:
- TClientRequestPerformanceProfiler(const TString& service, const TString& method);
+ TClientRequestPerformanceProfiler(std::string service, std::string method);
void ProfileRequest(const TSharedRefArray& requestMessage);
void ProfileAcknowledgement();
@@ -95,7 +95,7 @@ private:
const TPerformanceCounters* const MethodCounters_;
NProfiling::TWallTimer Timer_;
- static const TPerformanceCounters* GetPerformanceCounters(const TString& service, const TString& method);
+ static const TPerformanceCounters* GetPerformanceCounters(std::string service, std::string method);
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/rpc/client.cpp b/yt/yt/core/rpc/client.cpp
index 30758a48b29..a4c23c517a1 100644
--- a/yt/yt/core/rpc/client.cpp
+++ b/yt/yt/core/rpc/client.cpp
@@ -35,8 +35,8 @@ static const auto LightInvokerDurationWarningThreshold = TDuration::MilliSeconds
TClientContext::TClientContext(
TRequestId requestId,
NTracing::TTraceContextPtr traceContext,
- const TString& service,
- const TString& method,
+ std::string service,
+ std::string method,
TFeatureIdFormatter featureIdFormatter,
bool responseIsHeavy,
TAttachmentsOutputStreamPtr requestAttachmentsStream,
@@ -44,8 +44,8 @@ TClientContext::TClientContext(
TMemoryTag responseMemoryTag)
: RequestId_(requestId)
, TraceContext_(std::move(traceContext))
- , Service_(service)
- , Method_(method)
+ , Service_(std::move(service))
+ , Method_(std::move(method))
, FeatureIdFormatter_(featureIdFormatter)
, ResponseHeavy_(responseIsHeavy)
, RequestAttachmentsStream_(std::move(requestAttachmentsStream))
@@ -66,8 +66,8 @@ TClientRequest::TClientRequest(
{
YT_ASSERT(Channel_);
- Header_.set_service(serviceDescriptor.GetFullServiceName());
- Header_.set_method(methodDescriptor.MethodName);
+ ToProto(Header_.mutable_service(), serviceDescriptor.FullServiceName);
+ ToProto(Header_.mutable_method(), methodDescriptor.MethodName);
Header_.set_protocol_version_major(serviceDescriptor.ProtocolVersion.Major);
Header_.set_protocol_version_minor(serviceDescriptor.ProtocolVersion.Minor);
@@ -199,14 +199,14 @@ TRealmId TClientRequest::GetRealmId() const
return FromProto<TRealmId>(Header_.realm_id());
}
-const TString& TClientRequest::GetService() const
+std::string TClientRequest::GetService() const
{
- return Header_.service();
+ return FromProto<std::string>(Header_.service());
}
-const TString& TClientRequest::GetMethod() const
+std::string TClientRequest::GetMethod() const
{
- return Header_.method();
+ return FromProto<std::string>(Header_.method());
}
void TClientRequest::DeclareClientFeature(int featureId)
@@ -706,8 +706,9 @@ void TClientResponse::HandleStreamingFeedback(const TStreamingFeedback& feedback
////////////////////////////////////////////////////////////////////////////////
-TServiceDescriptor::TServiceDescriptor(const TString& serviceName)
- : ServiceName(serviceName)
+TServiceDescriptor::TServiceDescriptor(std::string serviceName)
+ : ServiceName(std::move(serviceName))
+ , FullServiceName(ServiceName)
{ }
TServiceDescriptor& TServiceDescriptor::SetProtocolVersion(int majorVersion)
@@ -724,9 +725,10 @@ TServiceDescriptor& TServiceDescriptor::SetProtocolVersion(TProtocolVersion vers
return *this;
}
-TServiceDescriptor& TServiceDescriptor::SetNamespace(const TString& value)
+TServiceDescriptor& TServiceDescriptor::SetNamespace(std::string value)
{
- Namespace = value;
+ Namespace = std::move(value);
+ FullServiceName = Namespace + "." + ServiceName;
return *this;
}
@@ -736,11 +738,6 @@ TServiceDescriptor& TServiceDescriptor::SetAcceptsBaggage(bool value)
return *this;
}
-TString TServiceDescriptor::GetFullServiceName() const
-{
- return Namespace ? Namespace + "." + ServiceName : ServiceName;
-}
-
////////////////////////////////////////////////////////////////////////////////
TMethodDescriptor::TMethodDescriptor(const TString& methodName)
diff --git a/yt/yt/core/rpc/client.h b/yt/yt/core/rpc/client.h
index 5b44257f6a5..dca8836b2bc 100644
--- a/yt/yt/core/rpc/client.h
+++ b/yt/yt/core/rpc/client.h
@@ -55,8 +55,8 @@ struct IClientRequest
virtual TRequestId GetRequestId() const = 0;
virtual TRealmId GetRealmId() const = 0;
- virtual const TString& GetService() const = 0;
- virtual const TString& GetMethod() const = 0;
+ virtual std::string GetService() const = 0;
+ virtual std::string GetMethod() const = 0;
virtual void DeclareClientFeature(int featureId) = 0;
virtual void RequireServerFeature(int featureId) = 0;
@@ -98,8 +98,8 @@ class TClientContext
public:
DEFINE_BYVAL_RO_PROPERTY(TRequestId, RequestId);
DEFINE_BYVAL_RO_PROPERTY(NTracing::TTraceContextPtr, TraceContext);
- DEFINE_BYVAL_RO_PROPERTY(TString, Service);
- DEFINE_BYVAL_RO_PROPERTY(TString, Method);
+ DEFINE_BYVAL_RO_PROPERTY(std::string, Service);
+ DEFINE_BYVAL_RO_PROPERTY(std::string, Method);
DEFINE_BYVAL_RO_PROPERTY(TFeatureIdFormatter, FeatureIdFormatter);
DEFINE_BYVAL_RO_PROPERTY(bool, ResponseHeavy);
DEFINE_BYVAL_RO_PROPERTY(TAttachmentsOutputStreamPtr, RequestAttachmentsStream);
@@ -110,8 +110,8 @@ public:
TClientContext(
TRequestId requestId,
NTracing::TTraceContextPtr traceContext,
- const TString& service,
- const TString& method,
+ std::string service,
+ std::string method,
TFeatureIdFormatter featureIdFormatter,
bool heavy,
TAttachmentsOutputStreamPtr requestAttachmentsStream,
@@ -163,8 +163,8 @@ public:
TRequestId GetRequestId() const override;
TRealmId GetRealmId() const override;
- const TString& GetService() const override;
- const TString& GetMethod() const override;
+ std::string GetService() const override;
+ std::string GetMethod() const override;
using NRpc::IClientRequest::DeclareClientFeature;
using NRpc::IClientRequest::RequireServerFeature;
@@ -402,22 +402,21 @@ private:
struct TServiceDescriptor
{
- TString ServiceName;
- TString Namespace;
+ std::string ServiceName;
+ std::string FullServiceName;
+ std::string Namespace;
TProtocolVersion ProtocolVersion = DefaultProtocolVersion;
TFeatureIdFormatter FeatureIdFormatter = nullptr;
bool AcceptsBaggage = true;
- explicit TServiceDescriptor(const TString& serviceName);
+ explicit TServiceDescriptor(std::string serviceName);
TServiceDescriptor& SetProtocolVersion(int majorVersion);
TServiceDescriptor& SetProtocolVersion(TProtocolVersion version);
- TServiceDescriptor& SetNamespace(const TString& value);
+ TServiceDescriptor& SetNamespace(std::string value);
TServiceDescriptor& SetAcceptsBaggage(bool value);
template <class E>
TServiceDescriptor& SetFeaturesType();
-
- TString GetFullServiceName() const;
};
#define DEFINE_RPC_PROXY(type, name, ...) \
diff --git a/yt/yt/core/rpc/dynamic_channel_pool.cpp b/yt/yt/core/rpc/dynamic_channel_pool.cpp
index a5fc8354720..f9c59d09676 100644
--- a/yt/yt/core/rpc/dynamic_channel_pool.cpp
+++ b/yt/yt/core/rpc/dynamic_channel_pool.cpp
@@ -45,7 +45,7 @@ public:
IChannelFactoryPtr channelFactory,
TString endpointDescription,
IAttributeDictionaryPtr endpointAttributes,
- TString serviceName,
+ std::string serviceName,
TDiscoverRequestHook discoverRequestHook)
: Config_(std::move(config))
, ChannelFactory_(std::move(channelFactory))
@@ -187,7 +187,7 @@ private:
const IChannelFactoryPtr ChannelFactory_;
const TString EndpointDescription_;
const IAttributeDictionaryPtr EndpointAttributes_;
- const TString ServiceName_;
+ const std::string ServiceName_;
const TDiscoverRequestHook DiscoverRequestHook_;
const NLogging::TLogger Logger;
@@ -868,7 +868,7 @@ TDynamicChannelPool::TDynamicChannelPool(
IChannelFactoryPtr channelFactory,
TString endpointDescription,
IAttributeDictionaryPtr endpointAttributes,
- TString serviceName,
+ std::string serviceName,
TDiscoverRequestHook discoverRequestHook)
: Impl_(New<TImpl>(
std::move(config),
diff --git a/yt/yt/core/rpc/dynamic_channel_pool.h b/yt/yt/core/rpc/dynamic_channel_pool.h
index 30483e339c4..94c67fa5d82 100644
--- a/yt/yt/core/rpc/dynamic_channel_pool.h
+++ b/yt/yt/core/rpc/dynamic_channel_pool.h
@@ -29,7 +29,7 @@ public:
IChannelFactoryPtr channelFactory,
TString endpointDescription,
NYTree::IAttributeDictionaryPtr endpointAttributes,
- TString serviceName,
+ std::string serviceName,
TDiscoverRequestHook discoverRequestHook = {});
~TDynamicChannelPool();
diff --git a/yt/yt/core/rpc/helpers.cpp b/yt/yt/core/rpc/helpers.cpp
index cce4c596768..86356f58439 100644
--- a/yt/yt/core/rpc/helpers.cpp
+++ b/yt/yt/core/rpc/helpers.cpp
@@ -413,7 +413,7 @@ TTraceContextPtr GetOrCreateHandlerTraceContext(
forceTracing);
}
-TTraceContextPtr CreateCallTraceContext(const TString& service, const TString& method)
+TTraceContextPtr CreateCallTraceContext(std::string service, std::string method)
{
auto context = TryGetCurrentTraceContext();
if (!context) {
diff --git a/yt/yt/core/rpc/helpers.h b/yt/yt/core/rpc/helpers.h
index 6a759d9bbe2..4973a1a9eac 100644
--- a/yt/yt/core/rpc/helpers.h
+++ b/yt/yt/core/rpc/helpers.h
@@ -65,8 +65,8 @@ NTracing::TTraceContextPtr GetOrCreateHandlerTraceContext(
const NProto::TRequestHeader& header,
bool forceTracing);
NTracing::TTraceContextPtr CreateCallTraceContext(
- const TString& service,
- const TString& method);
+ std::string service,
+ std::string method);
//! Generates a random mutation id.
TMutationId GenerateMutationId();
diff --git a/yt/yt/core/rpc/roaming_channel.h b/yt/yt/core/rpc/roaming_channel.h
index 6b12cd2a35c..b0e45249079 100644
--- a/yt/yt/core/rpc/roaming_channel.h
+++ b/yt/yt/core/rpc/roaming_channel.h
@@ -25,7 +25,7 @@ struct IRoamingChannelProvider
//! Returns the actual channel to use for sending to service with
//! a given #serviceName.
- virtual TFuture<IChannelPtr> GetChannel(const TString& serviceName) = 0;
+ virtual TFuture<IChannelPtr> GetChannel(std::string serviceName) = 0;
//! Returns a channel to use.
virtual TFuture<IChannelPtr> GetChannel() = 0;
diff --git a/yt/yt/core/rpc/server_detail.cpp b/yt/yt/core/rpc/server_detail.cpp
index e160257fdfa..fdf7c65e103 100644
--- a/yt/yt/core/rpc/server_detail.cpp
+++ b/yt/yt/core/rpc/server_detail.cpp
@@ -361,14 +361,14 @@ TMutationId TServiceContextBase::GetMutationId() const
return FromProto<TMutationId>(RequestHeader_->mutation_id());
}
-const TString& TServiceContextBase::GetService() const
+std::string TServiceContextBase::GetService() const
{
- return RequestHeader_->service();
+ return FromProto<std::string>(RequestHeader_->service());
}
-const TString& TServiceContextBase::GetMethod() const
+std::string TServiceContextBase::GetMethod() const
{
- return RequestHeader_->method();
+ return FromProto<std::string>(RequestHeader_->method());
}
TRealmId TServiceContextBase::GetRealmId() const
@@ -553,12 +553,12 @@ TMutationId TServiceContextWrapper::GetMutationId() const
return UnderlyingContext_->GetMutationId();
}
-const TString& TServiceContextWrapper::GetService() const
+std::string TServiceContextWrapper::GetService() const
{
return UnderlyingContext_->GetService();
}
-const TString& TServiceContextWrapper::GetMethod() const
+std::string TServiceContextWrapper::GetMethod() const
{
return UnderlyingContext_->GetMethod();
}
diff --git a/yt/yt/core/rpc/server_detail.h b/yt/yt/core/rpc/server_detail.h
index 652f359b9db..b746308d8bd 100644
--- a/yt/yt/core/rpc/server_detail.h
+++ b/yt/yt/core/rpc/server_detail.h
@@ -42,8 +42,8 @@ public:
bool IsRetry() const override;
TMutationId GetMutationId() const override;
- const TString& GetService() const override;
- const TString& GetMethod() const override;
+ std::string GetService() const override;
+ std::string GetMethod() const override;
TRealmId GetRealmId() const override;
const TAuthenticationIdentity& GetAuthenticationIdentity() const override;
@@ -186,8 +186,8 @@ public:
bool IsRetry() const override;
TMutationId GetMutationId() const override;
- const TString& GetService() const override;
- const TString& GetMethod() const override;
+ std::string GetService() const override;
+ std::string GetMethod() const override;
TRealmId GetRealmId() const override;
const TAuthenticationIdentity& GetAuthenticationIdentity() const override;
diff --git a/yt/yt/core/rpc/service.cpp b/yt/yt/core/rpc/service.cpp
index 441ab3e0b24..2ad79097764 100644
--- a/yt/yt/core/rpc/service.cpp
+++ b/yt/yt/core/rpc/service.cpp
@@ -83,8 +83,8 @@ void ThrowUnsupportedClientFeature(int featureId, TStringBuf featureName)
////////////////////////////////////////////////////////////////////////////////
-TServiceId::TServiceId(const TString& serviceName, TRealmId realmId)
- : ServiceName(serviceName)
+TServiceId::TServiceId(std::string serviceName, TRealmId realmId)
+ : ServiceName(std::move(serviceName))
, RealmId(realmId)
{ }
@@ -100,7 +100,7 @@ bool operator != (const TServiceId& lhs, const TServiceId& rhs)
TString ToString(const TServiceId& serviceId)
{
- auto result = serviceId.ServiceName;
+ auto result = TString(serviceId.ServiceName);
if (!serviceId.RealmId.IsEmpty()) {
result.append(':');
result.append(ToString(serviceId.RealmId));
diff --git a/yt/yt/core/rpc/service.h b/yt/yt/core/rpc/service.h
index 3b0869e4860..188e2f77aa6 100644
--- a/yt/yt/core/rpc/service.h
+++ b/yt/yt/core/rpc/service.h
@@ -94,10 +94,12 @@ struct IServiceContext
virtual TMutationId GetMutationId() const = 0;
//! Returns request service name.
- virtual const TString& GetService() const = 0;
+ // NB: Service name is supposed to be short, so SSO should work.
+ virtual std::string GetService() const = 0;
//! Returns request method name.
- virtual const TString& GetMethod() const = 0;
+ // NB: Method name is supposed to be short, so SSO should work.
+ virtual std::string GetMethod() const = 0;
//! Returns request realm id.
virtual TRealmId GetRealmId() const = 0;
@@ -268,9 +270,9 @@ DEFINE_REFCOUNTED_TYPE(IServiceContext)
struct TServiceId
{
TServiceId() = default;
- TServiceId(const TString& serviceName, TRealmId realmId = NullRealmId);
+ TServiceId(std::string serviceName, TRealmId realmId = NullRealmId);
- TString ServiceName;
+ std::string ServiceName;
TRealmId RealmId;
};
diff --git a/yt/yt/core/rpc/service_detail.cpp b/yt/yt/core/rpc/service_detail.cpp
index 3f862ca176a..54b62e43f91 100644
--- a/yt/yt/core/rpc/service_detail.cpp
+++ b/yt/yt/core/rpc/service_detail.cpp
@@ -1094,8 +1094,8 @@ private:
NProto::TStreamingPayloadHeader header;
ToProto(header.mutable_request_id(), RequestId_);
- header.set_service(GetService());
- header.set_method(GetMethod());
+ ToProto(header.mutable_service(), GetService());
+ ToProto(header.mutable_method(), GetMethod());
if (GetRealmId()) {
ToProto(header.mutable_realm_id(), GetRealmId());
}
@@ -1434,8 +1434,8 @@ TServiceBase::TServiceBase(
, DefaultInvoker_(std::move(defaultInvoker))
, Authenticator_(std::move(authenticator))
, ServiceDescriptor_(descriptor)
- , ServiceId_(descriptor.GetFullServiceName(), realmId)
- , Profiler_(RpcServerProfiler.WithHot().WithTag("yt_service", ServiceId_.ServiceName))
+ , ServiceId_(descriptor.FullServiceName, realmId)
+ , Profiler_(RpcServerProfiler.WithHot().WithTag("yt_service", TString(ServiceId_.ServiceName)))
, AuthenticationTimer_(Profiler_.Timer("/authentication_time"))
, ServiceLivenessChecker_(New<TPeriodicExecutor>(
TDispatcher::Get()->GetLightInvoker(),
diff --git a/yt/yt/core/rpc/unittests/mock/service.h b/yt/yt/core/rpc/unittests/mock/service.h
index 3367e6d390b..c78905c5b70 100644
--- a/yt/yt/core/rpc/unittests/mock/service.h
+++ b/yt/yt/core/rpc/unittests/mock/service.h
@@ -133,14 +133,14 @@ public:
);
MOCK_METHOD(
- const TString&,
+ std::string,
GetService,
(),
(const, override)
);
MOCK_METHOD(
- const TString&,
+ std::string,
GetMethod,
(),
(const, override)
diff --git a/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp b/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp
index 543bbfa291e..ffe6a075772 100644
--- a/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp
+++ b/yt/yt/core/rpc/unittests/roaming_channel_ut.cpp
@@ -38,7 +38,7 @@ public:
return GetChannel();
}
- TFuture<IChannelPtr> GetChannel(const TString& /*serviceName*/) override
+ TFuture<IChannelPtr> GetChannel(std::string /*serviceName*/) override
{
return GetChannel();
}
@@ -82,7 +82,7 @@ public:
return GetChannel();
}
- TFuture<IChannelPtr> GetChannel(const TString& /*serviceName*/) override
+ TFuture<IChannelPtr> GetChannel(std::string /*serviceName*/) override
{
return GetChannel();
}
@@ -120,7 +120,7 @@ public:
return GetChannel();
}
- TFuture<IChannelPtr> GetChannel(const TString& /*serviceName*/) override
+ TFuture<IChannelPtr> GetChannel(std::string /*serviceName*/) override
{
return GetChannel();
}
diff --git a/yt/yt/core/ytree/ypath_client.cpp b/yt/yt/core/ytree/ypath_client.cpp
index ceab65ab790..fc0671c399a 100644
--- a/yt/yt/core/ytree/ypath_client.cpp
+++ b/yt/yt/core/ytree/ypath_client.cpp
@@ -44,13 +44,13 @@ TYPathRequest::TYPathRequest(const TRequestHeader& header)
{ }
TYPathRequest::TYPathRequest(
- TString service,
- TString method,
+ std::string service,
+ std::string method,
TYPath path,
bool mutating)
{
- Header_.set_service(std::move(service));
- Header_.set_method(std::move(method));
+ ToProto(Header_.mutable_service(), std::move(service));
+ ToProto(Header_.mutable_method(), std::move(method));
auto* ypathExt = Header_.MutableExtension(NProto::TYPathHeaderExt::ypath_header_ext);
ypathExt->set_mutating(mutating);
@@ -67,14 +67,14 @@ TRealmId TYPathRequest::GetRealmId() const
return NullRealmId;
}
-const TString& TYPathRequest::GetMethod() const
+std::string TYPathRequest::GetMethod() const
{
- return Header_.method();
+ return FromProto<std::string>(Header_.method());
}
-const TString& TYPathRequest::GetService() const
+std::string TYPathRequest::GetService() const
{
- return Header_.service();
+ return FromProto<std::string>(Header_.service());
}
void TYPathRequest::DeclareClientFeature(int featureId)
diff --git a/yt/yt/core/ytree/ypath_client.h b/yt/yt/core/ytree/ypath_client.h
index a29633d67b3..187e6c2a73f 100644
--- a/yt/yt/core/ytree/ypath_client.h
+++ b/yt/yt/core/ytree/ypath_client.h
@@ -28,8 +28,8 @@ public:
public:
NRpc::TRequestId GetRequestId() const override;
NRpc::TRealmId GetRealmId() const override;
- const TString& GetMethod() const override;
- const TString& GetService() const override;
+ std::string GetMethod() const override;
+ std::string GetService() const override;
using NRpc::IClientRequest::DeclareClientFeature;
using NRpc::IClientRequest::RequireServerFeature;
@@ -75,8 +75,8 @@ protected:
explicit TYPathRequest(const NRpc::NProto::TRequestHeader& header);
TYPathRequest(
- TString service,
- TString method,
+ std::string service,
+ std::string method,
NYPath::TYPath path,
bool mutating);
@@ -103,13 +103,13 @@ public:
{ }
TTypedYPathRequest(
- const TString& service,
- const TString& method,
+ std::string service,
+ std::string method,
const NYPath::TYPath& path,
bool mutating)
: TYPathRequest(
- service,
- method,
+ std::move(service),
+ std::move(method),
path,
mutating)
{ }