diff options
author | babenko <babenko@yandex-team.com> | 2024-08-23 07:32:27 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-08-23 07:43:37 +0300 |
commit | 6bc0348d6bbac57fc9d1a9ab8d811ed632d217fe (patch) | |
tree | adace577b3a9550d4861a98317ae4a37b3d9c7ab | |
parent | 8e9d4416205322c34eba63df877991ac43e5a612 (diff) | |
download | ydb-6bc0348d6bbac57fc9d1a9ab8d811ed632d217fe.tar.gz |
YT-25593: Replace TString with std::string for addresses, hostnames etc
e10316e900a0dd13e98e68dacd3338f5d277c8a2
99 files changed, 487 insertions, 484 deletions
diff --git a/yt/yt/client/api/admin_client.h b/yt/yt/client/api/admin_client.h index b81b7a0f9b..1ebd2cf060 100644 --- a/yt/yt/client/api/admin_client.h +++ b/yt/yt/client/api/admin_client.h @@ -227,7 +227,7 @@ struct IAdminClient virtual TFuture<void> SwitchLeader( NHydra::TCellId cellId, - const TString& newLeaderAddress, + const std::string& newLeaderAddress, const TSwitchLeaderOptions& options = {}) = 0; virtual TFuture<void> ResetStateHash( @@ -238,15 +238,15 @@ struct IAdminClient const TGCCollectOptions& options = {}) = 0; virtual TFuture<void> KillProcess( - const TString& address, + const std::string& address, const TKillProcessOptions& options = {}) = 0; virtual TFuture<TString> WriteCoreDump( - const TString& address, + const std::string& address, const TWriteCoreDumpOptions& options = {}) = 0; virtual TFuture<TGuid> WriteLogBarrier( - const TString& address, + const std::string& address, const TWriteLogBarrierOptions& options) = 0; virtual TFuture<TString> WriteOperationControllerCoreDump( @@ -254,7 +254,7 @@ struct IAdminClient const TWriteOperationControllerCoreDumpOptions& options = {}) = 0; virtual TFuture<void> HealExecNode( - const TString& address, + const std::string& address, const THealExecNodeOptions& options = {}) = 0; virtual TFuture<void> SuspendCoordinator( @@ -287,35 +287,35 @@ struct IAdminClient virtual TFuture<TMaintenanceIdPerTarget> AddMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, EMaintenanceType type, const TString& comment, const TAddMaintenanceOptions& options = {}) = 0; virtual TFuture<TMaintenanceCountsPerTarget> RemoveMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, const TMaintenanceFilter& filter, const TRemoveMaintenanceOptions& options = {}) = 0; virtual TFuture<TDisableChunkLocationsResult> DisableChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TDisableChunkLocationsOptions& options = {}) = 0; virtual TFuture<TDestroyChunkLocationsResult> DestroyChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, bool recoverUnlinkedDisks, const std::vector<TGuid>& locationUuids, const TDestroyChunkLocationsOptions& options = {}) = 0; virtual TFuture<TResurrectChunkLocationsResult> ResurrectChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TResurrectChunkLocationsOptions& options = {}) = 0; virtual TFuture<TRequestRestartResult> RequestRestart( - const TString& nodeAddress, + const std::string& nodeAddress, const TRequestRestartOptions& options = {}) = 0; }; diff --git a/yt/yt/client/api/config.h b/yt/yt/client/api/config.h index ed646f2f52..1ef1d79e0f 100644 --- a/yt/yt/client/api/config.h +++ b/yt/yt/client/api/config.h @@ -50,7 +50,7 @@ class TConnectionConfig { public: EConnectionType ConnectionType; - std::optional<TString> ClusterName; + std::optional<std::string> ClusterName; TTableMountCacheConfigPtr TableMountCache; NChaosClient::TReplicationCardCacheConfigPtr ReplicationCardCache; diff --git a/yt/yt/client/api/connection.h b/yt/yt/client/api/connection.h index 795cb55a59..76d61db5d7 100644 --- a/yt/yt/client/api/connection.h +++ b/yt/yt/client/api/connection.h @@ -48,7 +48,7 @@ struct IConnection virtual TClusterTag GetClusterTag() const = 0; virtual const TString& GetLoggingTag() const = 0; virtual const TString& GetClusterId() const = 0; - virtual const std::optional<TString>& GetClusterName() const = 0; + virtual const std::optional<std::string>& GetClusterName() const = 0; virtual IInvokerPtr GetInvoker() = 0; // TODO(gritukan): Fix alien transaction creation for RPC proxy connection diff --git a/yt/yt/client/api/delegating_client.h b/yt/yt/client/api/delegating_client.h index 4976888d0a..a7982186ac 100644 --- a/yt/yt/client/api/delegating_client.h +++ b/yt/yt/client/api/delegating_client.h @@ -599,7 +599,7 @@ public: DELEGATE_METHOD(TFuture<void>, SwitchLeader, ( NHydra::TCellId cellId, - const TString& newLeaderAddress, + const std::string& newLeaderAddress, const TSwitchLeaderOptions& options), (cellId, newLeaderAddress, options)) @@ -613,17 +613,17 @@ public: (options)) DELEGATE_METHOD(TFuture<void>, KillProcess, ( - const TString& address, + const std::string& address, const TKillProcessOptions& options), (address, options)) DELEGATE_METHOD(TFuture<TString>, WriteCoreDump, ( - const TString& address, + const std::string& address, const TWriteCoreDumpOptions& options), (address, options)) DELEGATE_METHOD(TFuture<TGuid>, WriteLogBarrier, ( - const TString& address, + const std::string& address, const TWriteLogBarrierOptions& options), (address, options)) @@ -633,7 +633,7 @@ public: (operationId, options)) DELEGATE_METHOD(TFuture<void>, HealExecNode, ( - const TString& address, + const std::string& address, const THealExecNodeOptions& options), (address, options)) @@ -674,7 +674,7 @@ public: DELEGATE_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, ( EMaintenanceComponent component, - const TString& address, + const std::string& address, EMaintenanceType type, const TString& comment, const TAddMaintenanceOptions& options), @@ -682,32 +682,32 @@ public: DELEGATE_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, ( EMaintenanceComponent component, - const TString& address, + const std::string& address, const TMaintenanceFilter& filter, const TRemoveMaintenanceOptions& options), (component, address, filter, options)) DELEGATE_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TDisableChunkLocationsOptions& options), (nodeAddress, locationUuids, options)) DELEGATE_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, bool recoverUnlinkedDisks, const std::vector<TGuid>& locationUuids, const TDestroyChunkLocationsOptions& options), (nodeAddress, recoverUnlinkedDisks, locationUuids, options)) DELEGATE_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TResurrectChunkLocationsOptions& options), (nodeAddress, locationUuids, options)) DELEGATE_METHOD(TFuture<TRequestRestartResult>, RequestRestart, ( - const TString& nodeAddress, + const std::string& nodeAddress, const TRequestRestartOptions& options), (nodeAddress, options)) diff --git a/yt/yt/client/api/etc_client.h b/yt/yt/client/api/etc_client.h index 90e08fd8b2..0d0150c761 100644 --- a/yt/yt/client/api/etc_client.h +++ b/yt/yt/client/api/etc_client.h @@ -32,8 +32,8 @@ struct TClusterMeta std::shared_ptr<NHiveClient::NProto::TClusterDirectory> ClusterDirectory; std::shared_ptr<NChunkClient::NProto::TMediumDirectory> MediumDirectory; std::shared_ptr<NObjectClient::NProto::TUserDirectory> UserDirectory; - std::vector<TString> MasterCacheNodeAddresses; - std::vector<TString> TimestampProviderAddresses; + std::vector<std::string> MasterCacheNodeAddresses; + std::vector<std::string> TimestampProviderAddresses; NYTree::IMapNodePtr Features; }; diff --git a/yt/yt/client/api/public.h b/yt/yt/client/api/public.h index d715976292..fe0a173f31 100644 --- a/yt/yt/client/api/public.h +++ b/yt/yt/client/api/public.h @@ -226,8 +226,8 @@ using TMaintenanceCounts = TEnumIndexedArray<EMaintenanceType, int>; // "host" target which represents all nodes on a given host. constexpr int TypicalMaintenanceTargetCount = 1; -using TMaintenanceIdPerTarget = TCompactFlatMap<TString, TMaintenanceId, TypicalMaintenanceTargetCount>; -using TMaintenanceCountsPerTarget = TCompactFlatMap<TString, TMaintenanceCounts, TypicalMaintenanceTargetCount>; +using TMaintenanceIdPerTarget = TCompactFlatMap<std::string, TMaintenanceId, TypicalMaintenanceTargetCount>; +using TMaintenanceCountsPerTarget = TCompactFlatMap<std::string, TMaintenanceCounts, TypicalMaintenanceTargetCount>; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/api/rpc_proxy/address_helpers.cpp b/yt/yt/client/api/rpc_proxy/address_helpers.cpp index 753e95d8a5..3af925ca3c 100644 --- a/yt/yt/client/api/rpc_proxy/address_helpers.cpp +++ b/yt/yt/client/api/rpc_proxy/address_helpers.cpp @@ -10,7 +10,7 @@ using namespace NNet; //////////////////////////////////////////////////////////////////////////////// const EAddressType DefaultAddressType(EAddressType::InternalRpc); -const TString DefaultNetworkName("default"); +const std::string DefaultNetworkName("default"); //////////////////////////////////////////////////////////////////////////////// @@ -31,10 +31,10 @@ TAddressMap GetLocalAddresses(const NNodeTrackerClient::TNetworkAddressList& add //////////////////////////////////////////////////////////////////////////////// -std::optional<TString> GetAddressOrNull( +std::optional<std::string> GetAddressOrNull( const TProxyAddressMap& addresses, EAddressType type, - const TString& network) + const std::string& network) { auto typeAddressesIt = addresses.find(type); if (typeAddressesIt != addresses.end()) { @@ -48,11 +48,11 @@ std::optional<TString> GetAddressOrNull( //////////////////////////////////////////////////////////////////////////////// -std::optional<std::vector<TString>> GetBalancersOrNull( +std::optional<std::vector<std::string>> GetBalancersOrNull( const TBalancersMap& balancers, - const TString& role, + const std::string& role, EAddressType addressType, - const TString& network) + const std::string& network) { auto roleBalancersIt = balancers.find(role); if (roleBalancersIt != balancers.end()) { diff --git a/yt/yt/client/api/rpc_proxy/address_helpers.h b/yt/yt/client/api/rpc_proxy/address_helpers.h index c4ce50b5ad..a81b636e3a 100644 --- a/yt/yt/client/api/rpc_proxy/address_helpers.h +++ b/yt/yt/client/api/rpc_proxy/address_helpers.h @@ -9,22 +9,22 @@ namespace NYT::NApi::NRpcProxy { //////////////////////////////////////////////////////////////////////////////// // Network -> host:port. -using TAddressMap = THashMap<TString, TString>; +using TAddressMap = THashMap<std::string, std::string>; // Address type (e.g. RPC, HTTP) -> network -> host:port. using TProxyAddressMap = THashMap<EAddressType, TAddressMap>; extern const EAddressType DefaultAddressType; -extern const TString DefaultNetworkName; +extern const std::string DefaultNetworkName; // Network -> [host:port]. -using TNetworkAddressesMap = THashMap<TString, std::vector<TString>>; +using TNetworkAddressesMap = THashMap<std::string, std::vector<std::string>>; // Address type (e.g. RPC, HTTP) -> network -> [host:port]. using TAddressTypeAddressesMap = THashMap<EAddressType, TNetworkAddressesMap>; // Role -> address type -> network -> host:port. -using TBalancersMap = THashMap<TString, TAddressTypeAddressesMap>; +using TBalancersMap = THashMap<std::string, TAddressTypeAddressesMap>; //////////////////////////////////////////////////////////////////////////////// @@ -34,18 +34,18 @@ TAddressMap GetLocalAddresses( //////////////////////////////////////////////////////////////////////////////// -std::optional<TString> GetAddressOrNull( +std::optional<std::string> GetAddressOrNull( const TProxyAddressMap& addresses, EAddressType addressType, - const TString& network); + const std::string& network); //////////////////////////////////////////////////////////////////////////////// -std::optional<std::vector<TString>> GetBalancersOrNull( +std::optional<std::vector<std::string>> GetBalancersOrNull( const TBalancersMap& balancers, - const TString& role, + const std::string& role, EAddressType addressType, - const TString& network); + const std::string& network); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/api/rpc_proxy/client_impl.cpp b/yt/yt/client/api/rpc_proxy/client_impl.cpp index a854a959fc..beb3b391ec 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/client_impl.cpp @@ -117,7 +117,7 @@ IChannelPtr TClient::CreateSequoiaAwareRetryingChannel(NRpc::IChannelPtr channel })); } -IChannelPtr TClient::CreateNonRetryingChannelByAddress(const TString& address) const +IChannelPtr TClient::CreateNonRetryingChannelByAddress(const std::string& address) const { return CreateCredentialsInjectingChannel( Connection_->CreateChannelByAddress(address), @@ -1757,7 +1757,7 @@ TFuture<void> TClient::DiscombobulateNonvotingPeers( TFuture<void> TClient::SwitchLeader( NHydra::TCellId /*cellId*/, - const TString& /*newLeaderAddress*/, + const std::string& /*newLeaderAddress*/, const TSwitchLeaderOptions& /*options*/) { ThrowUnimplemented("SwitchLeader"); @@ -1783,21 +1783,21 @@ TFuture<void> TClient::GCCollect(const TGCCollectOptions& options) } TFuture<void> TClient::KillProcess( - const TString& /*address*/, + const std::string& /*address*/, const TKillProcessOptions& /*options*/) { ThrowUnimplemented("KillProcess"); } TFuture<TString> TClient::WriteCoreDump( - const TString& /*address*/, + const std::string& /*address*/, const TWriteCoreDumpOptions& /*options*/) { ThrowUnimplemented("WriteCoreDump"); } TFuture<TGuid> TClient::WriteLogBarrier( - const TString& /*address*/, + const std::string& /*address*/, const TWriteLogBarrierOptions& /*options*/) { ThrowUnimplemented("WriteLogBarrier"); @@ -1811,7 +1811,7 @@ TFuture<TString> TClient::WriteOperationControllerCoreDump( } TFuture<void> TClient::HealExecNode( - const TString& /*address*/, + const std::string& /*address*/, const THealExecNodeOptions& /*options*/) { ThrowUnimplemented("HealExecNode"); @@ -1905,7 +1905,7 @@ NProto::EMaintenanceType ConvertMaintenanceTypeToProto(EMaintenanceType type) TFuture<TMaintenanceIdPerTarget> TClient::AddMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, EMaintenanceType type, const TString& comment, const TAddMaintenanceOptions& options) @@ -1918,7 +1918,7 @@ TFuture<TMaintenanceIdPerTarget> TClient::AddMaintenance( SetTimeoutOptions(*req, options); req->set_component(ConvertMaintenanceComponentToProto(component)); - req->set_address(address); + req->set_address(ToProto<TProtobufString>(address)); req->set_type(ConvertMaintenanceTypeToProto(type)); req->set_comment(comment); req->set_supports_per_target_response(true); @@ -1944,7 +1944,7 @@ TFuture<TMaintenanceIdPerTarget> TClient::AddMaintenance( TFuture<TMaintenanceCountsPerTarget> TClient::RemoveMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, const TMaintenanceFilter& filter, const TRemoveMaintenanceOptions& options) { @@ -1954,7 +1954,7 @@ TFuture<TMaintenanceCountsPerTarget> TClient::RemoveMaintenance( SetTimeoutOptions(*req, options); req->set_component(ConvertMaintenanceComponentToProto(component)); - req->set_address(address); + req->set_address(ToProto<TProtobufString>(address)); ToProto(req->mutable_ids(), filter.Ids); @@ -2057,7 +2057,7 @@ TFuture<void> TClient::ResumeTabletCells( } TFuture<TDisableChunkLocationsResult> TClient::DisableChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TDisableChunkLocationsOptions& /*options*/) { @@ -2076,7 +2076,7 @@ TFuture<TDisableChunkLocationsResult> TClient::DisableChunkLocations( } TFuture<TDestroyChunkLocationsResult> TClient::DestroyChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, bool recoverUnlinkedDisks, const std::vector<TGuid>& locationUuids, const TDestroyChunkLocationsOptions& /*options*/) @@ -2097,7 +2097,7 @@ TFuture<TDestroyChunkLocationsResult> TClient::DestroyChunkLocations( } TFuture<TResurrectChunkLocationsResult> TClient::ResurrectChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TResurrectChunkLocationsOptions& /*options*/) { @@ -2116,7 +2116,7 @@ TFuture<TResurrectChunkLocationsResult> TClient::ResurrectChunkLocations( } TFuture<TRequestRestartResult> TClient::RequestRestart( - const TString& nodeAddress, + const std::string& nodeAddress, const TRequestRestartOptions& /*options*/) { auto proxy = CreateApiServiceProxy(); diff --git a/yt/yt/client/api/rpc_proxy/client_impl.h b/yt/yt/client/api/rpc_proxy/client_impl.h index 7f1e145d10..f6020cd0af 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.h +++ b/yt/yt/client/api/rpc_proxy/client_impl.h @@ -357,7 +357,7 @@ public: TFuture<void> SwitchLeader( NHydra::TCellId cellId, - const TString& newLeaderAddress, + const std::string& newLeaderAddress, const TSwitchLeaderOptions& options) override; TFuture<void> ResetStateHash( @@ -368,15 +368,15 @@ public: const NApi::TGCCollectOptions& options) override; TFuture<void> KillProcess( - const TString& address, + const std::string& address, const NApi::TKillProcessOptions& options) override; TFuture<TString> WriteCoreDump( - const TString& address, + const std::string& address, const NApi::TWriteCoreDumpOptions& options) override; TFuture<TGuid> WriteLogBarrier( - const TString& address, + const std::string& address, const TWriteLogBarrierOptions& options) override; TFuture<TString> WriteOperationControllerCoreDump( @@ -384,7 +384,7 @@ public: const NApi::TWriteOperationControllerCoreDumpOptions& options) override; TFuture<void> HealExecNode( - const TString& address, + const std::string& address, const THealExecNodeOptions& options) override; TFuture<void> SuspendCoordinator( @@ -417,35 +417,35 @@ public: TFuture<TMaintenanceIdPerTarget> AddMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, EMaintenanceType type, const TString& comment, const TAddMaintenanceOptions& options) override; TFuture<TMaintenanceCountsPerTarget> RemoveMaintenance( EMaintenanceComponent component, - const TString& address, + const std::string& address, const TMaintenanceFilter& filter, const TRemoveMaintenanceOptions& options) override; TFuture<TDisableChunkLocationsResult> DisableChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TDisableChunkLocationsOptions& options) override; TFuture<TDestroyChunkLocationsResult> DestroyChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, bool recoverUnlinkedDisks, const std::vector<TGuid>& locationUuids, const TDestroyChunkLocationsOptions& options) override; TFuture<TResurrectChunkLocationsResult> ResurrectChunkLocations( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TResurrectChunkLocationsOptions& options) override; TFuture<TRequestRestartResult> RequestRestart( - const TString& nodeAddress, + const std::string& nodeAddress, const TRequestRestartOptions& options) override; // Query tracker @@ -574,7 +574,7 @@ private: NRpc::IChannelPtr CreateSequoiaAwareRetryingChannel(NRpc::IChannelPtr channel, bool retryProxyBanned) const; // Returns an RPC channel to use for API calls to the particular address (e.g.: AttachTransaction). // The channel is non-retrying, so should be wrapped into retrying channel on demand. - NRpc::IChannelPtr CreateNonRetryingChannelByAddress(const TString& address) const; + NRpc::IChannelPtr CreateNonRetryingChannelByAddress(const std::string& address) const; TConnectionPtr GetRpcProxyConnection() override; TClientPtr GetRpcProxyClient() override; diff --git a/yt/yt/client/api/rpc_proxy/config.cpp b/yt/yt/client/api/rpc_proxy/config.cpp index c4e3cddf4c..e3ed474ab6 100644 --- a/yt/yt/client/api/rpc_proxy/config.cpp +++ b/yt/yt/client/api/rpc_proxy/config.cpp @@ -19,8 +19,8 @@ using namespace NNet; //////////////////////////////////////////////////////////////////////////////// TConnectionConfigPtr TConnectionConfig::CreateFromClusterUrl( - TString clusterUrl, - std::optional<TString> proxyRole) + const std::string& clusterUrl, + const std::optional<std::string>& proxyRole) { auto config = New<TConnectionConfig>(); config->ClusterUrl = std::move(clusterUrl); diff --git a/yt/yt/client/api/rpc_proxy/config.h b/yt/yt/client/api/rpc_proxy/config.h index 4e6a49be06..b31fdaa2c8 100644 --- a/yt/yt/client/api/rpc_proxy/config.h +++ b/yt/yt/client/api/rpc_proxy/config.h @@ -24,17 +24,17 @@ class TConnectionConfig { public: static TConnectionConfigPtr CreateFromClusterUrl( - TString clusterUrl, - std::optional<TString> proxyRole = {}); + const std::string& clusterUrl, + const std::optional<std::string>& proxyRole = {}); - std::optional<TString> ClusterUrl; + std::optional<std::string> ClusterUrl; std::optional<TClusterTag> ClusterTag; - std::optional<TString> ProxyRole; + std::optional<std::string> ProxyRole; std::optional<EAddressType> ProxyAddressType; - std::optional<TString> ProxyNetworkName; - std::optional<std::vector<TString>> ProxyAddresses; + std::optional<std::string> ProxyNetworkName; + std::optional<std::vector<std::string>> ProxyAddresses; NRpc::TServiceDiscoveryEndpointsConfigPtr ProxyEndpoints; - std::optional<TString> ProxyUnixDomainSocket; + std::optional<std::string> ProxyUnixDomainSocket; bool EnableProxyDiscovery; NRpc::TDynamicChannelPoolConfigPtr DynamicChannelPool; diff --git a/yt/yt/client/api/rpc_proxy/connection_impl.cpp b/yt/yt/client/api/rpc_proxy/connection_impl.cpp index 9e87f1ccae..3e84e0ef5d 100644 --- a/yt/yt/client/api/rpc_proxy/connection_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/connection_impl.cpp @@ -52,21 +52,21 @@ using namespace NServiceDiscovery; //////////////////////////////////////////////////////////////////////////////// -static const TStringBuf ProxyUrlCanonicalHttpPrefix = "http://"; -static const TStringBuf ProxyUrlCanonicalHttpsPrefix = "https://"; -static const TStringBuf ProxyUrlCanonicalSuffix = ".yt.yandex.net"; +static const std::string ProxyUrlCanonicalHttpPrefix = "http://"; +static const std::string ProxyUrlCanonicalHttpsPrefix = "https://"; +static const std::string ProxyUrlCanonicalSuffix = ".yt.yandex.net"; //////////////////////////////////////////////////////////////////////////////// -THashMap<TString, TString> ParseProxyUrlAliasingRules(TString envConfig) +THashMap<std::string, std::string> ParseProxyUrlAliasingRules(const TString& envConfig) { if (envConfig.empty()) { return {}; } - return ConvertTo<THashMap<TString, TString>>(TYsonString(envConfig)); + return ConvertTo<THashMap<std::string, std::string>>(TYsonString(envConfig)); } -void ApplyProxyUrlAliasingRules(TString& url, const std::optional<THashMap<TString, TString>>& proxyUrlAliasingRules) +void ApplyProxyUrlAliasingRules(std::string& url, const std::optional<THashMap<std::string, std::string>>& proxyUrlAliasingRules) { static const auto rulesFromEnv = ParseProxyUrlAliasingRules(GetEnv("YT_PROXY_URL_ALIASING_CONFIG")); @@ -77,7 +77,7 @@ void ApplyProxyUrlAliasingRules(TString& url, const std::optional<THashMap<TStri } } -TString NormalizeHttpProxyUrl(TString url, const std::optional<THashMap<TString, TString>>& proxyUrlAliasingRules) +std::string NormalizeHttpProxyUrl(std::string url, const std::optional<THashMap<std::string, std::string>>& proxyUrlAliasingRules) { ApplyProxyUrlAliasingRules(url, proxyUrlAliasingRules); @@ -88,8 +88,8 @@ TString NormalizeHttpProxyUrl(TString url, const std::optional<THashMap<TString, url.append(ProxyUrlCanonicalSuffix); } - if (!url.StartsWith(ProxyUrlCanonicalHttpPrefix) && !url.StartsWith(ProxyUrlCanonicalHttpsPrefix)) { - url.prepend(ProxyUrlCanonicalHttpPrefix); + if (!url.starts_with(ProxyUrlCanonicalHttpPrefix) && !url.starts_with(ProxyUrlCanonicalHttpsPrefix)) { + url = ProxyUrlCanonicalHttpPrefix + url; } return url; @@ -97,9 +97,9 @@ TString NormalizeHttpProxyUrl(TString url, const std::optional<THashMap<TString, namespace { -bool IsProxyUrlSecure(const TString& url) +bool IsProxyUrlSecure(const std::string& url) { - return url.StartsWith(ProxyUrlCanonicalHttpsPrefix); + return url.starts_with(ProxyUrlCanonicalHttpsPrefix); } TString MakeConnectionLoggingTag(const TConnectionConfigPtr& config, TGuid connectionId) @@ -290,7 +290,7 @@ IChannelPtr TConnection::CreateChannel(bool sticky) return CreateRoamingChannel(std::move(provider)); } -IChannelPtr TConnection::CreateChannelByAddress(const TString& address) +IChannelPtr TConnection::CreateChannelByAddress(const std::string& address) { return CachingChannelFactory_->CreateChannel(address); } @@ -312,7 +312,7 @@ const TString& TConnection::GetClusterId() const return ClusterId_; } -const std::optional<TString>& TConnection::GetClusterName() const +const std::optional<std::string>& TConnection::GetClusterName() const { return Config_->ClusterName; } @@ -366,7 +366,7 @@ const TConnectionConfigPtr& TConnection::GetConfig() return Config_; } -std::vector<TString> TConnection::DiscoverProxiesViaHttp() +std::vector<std::string> TConnection::DiscoverProxiesViaHttp() { auto correlationId = TGuid::Create(); @@ -399,7 +399,8 @@ std::vector<TString> TConnection::DiscoverProxiesViaHttp() auto client = IsProxyUrlSecure(*Config_->ClusterUrl) ? NHttps::CreateClient(Config_->HttpsClient, std::move(poller)) : NHttp::CreateClient(Config_->HttpClient, std::move(poller)); - auto rsp = WaitFor(client->Get(url, headers)) + // TODO(babenko): switch to std::string + auto rsp = WaitFor(client->Get(TString(url), headers)) .ValueOrThrow(); if (rsp->GetStatusCode() != EStatusCode::OK) { @@ -414,7 +415,7 @@ std::vector<TString> TConnection::DiscoverProxiesViaHttp() auto node = ConvertTo<INodePtr>(TYsonString(ToString(body))); node = node->AsMap()->FindChild("proxies"); - return ConvertTo<std::vector<TString>>(node); + return ConvertTo<std::vector<std::string>>(node); } catch (const std::exception& ex) { THROW_ERROR_EXCEPTION("Error discovering RPC proxies via HTTP") << TErrorAttribute("correlation_id", correlationId) @@ -422,7 +423,7 @@ std::vector<TString> TConnection::DiscoverProxiesViaHttp() } } -std::vector<TString> TConnection::DiscoverProxiesViaServiceDiscovery() +std::vector<std::string> TConnection::DiscoverProxiesViaServiceDiscovery() { YT_LOG_DEBUG("Updating proxy list via Service Discovery"); @@ -442,7 +443,7 @@ std::vector<TString> TConnection::DiscoverProxiesViaServiceDiscovery() auto endpointSets = WaitFor(AllSet(asyncEndpointSets)) .ValueOrThrow(); - std::vector<TString> allAddresses; + std::vector<std::string> allAddresses; std::vector<TError> errors; for (int i = 0; i < std::ssize(endpointSets); ++i) { if (!endpointSets[i].IsOK()) { @@ -482,7 +483,7 @@ void TConnection::OnProxyListUpdate() auto backoff = Config_->ProxyListRetryPeriod; for (int attempt = 0;; ++attempt) { try { - std::vector<TString> proxies; + std::vector<std::string> proxies; if (Config_->ProxyEndpoints) { proxies = DiscoverProxiesViaServiceDiscovery(); } else if (Config_->ClusterUrl) { diff --git a/yt/yt/client/api/rpc_proxy/connection_impl.h b/yt/yt/client/api/rpc_proxy/connection_impl.h index 5f2c618cfe..576b655870 100644 --- a/yt/yt/client/api/rpc_proxy/connection_impl.h +++ b/yt/yt/client/api/rpc_proxy/connection_impl.h @@ -27,7 +27,7 @@ public: ~TConnection(); NRpc::IChannelPtr CreateChannel(bool sticky); - NRpc::IChannelPtr CreateChannelByAddress(const TString& address); + NRpc::IChannelPtr CreateChannelByAddress(const std::string& address); const TConnectionConfigPtr& GetConfig(); @@ -35,7 +35,7 @@ public: TClusterTag GetClusterTag() const override; const TString& GetLoggingTag() const override; const TString& GetClusterId() const override; - const std::optional<TString>& GetClusterName() const override; + const std::optional<std::string>& GetClusterName() const override; bool IsSameCluster(const IConnectionPtr& other) const override; @@ -77,8 +77,8 @@ private: NServiceDiscovery::IServiceDiscoveryPtr ServiceDiscovery_; - std::vector<TString> DiscoverProxiesViaHttp(); - std::vector<TString> DiscoverProxiesViaServiceDiscovery(); + std::vector<std::string> DiscoverProxiesViaHttp(); + std::vector<std::string> DiscoverProxiesViaServiceDiscovery(); void OnProxyListUpdate(); }; diff --git a/yt/yt/client/api/rpc_proxy/private.h b/yt/yt/client/api/rpc_proxy/private.h index 4c2eae9aa5..3b1eba9665 100644 --- a/yt/yt/client/api/rpc_proxy/private.h +++ b/yt/yt/client/api/rpc_proxy/private.h @@ -26,13 +26,13 @@ YT_DEFINE_GLOBAL(const NLogging::TLogger, RpcProxyClientLogger, "RpcProxyClient" //////////////////////////////////////////////////////////////////////////////// -THashMap<TString, TString> ParseProxyUrlAliasingRules(TString envConfig); +THashMap<std::string, std::string> ParseProxyUrlAliasingRules(const TString& envConfig); void ApplyProxyUrlAliasingRules( - TString& url, - const std::optional<THashMap<TString, TString>>& proxyUrlAliasingRules = std::nullopt); -TString NormalizeHttpProxyUrl( - TString url, - const std::optional<THashMap<TString, TString>>& proxyUrlAliasingRules = std::nullopt); + std::string& url, + const std::optional<THashMap<std::string, std::string>>& proxyUrlAliasingRules = {}); +std::string NormalizeHttpProxyUrl( + std::string url, + const std::optional<THashMap<std::string, std::string>>& proxyUrlAliasingRules = {}); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/cache/rpc.cpp b/yt/yt/client/cache/rpc.cpp index a75ab1a0a4..e1b71c27f2 100644 --- a/yt/yt/client/cache/rpc.cpp +++ b/yt/yt/client/cache/rpc.cpp @@ -53,7 +53,7 @@ NApi::NRpcProxy::TConnectionConfigPtr GetConnectionConfig(const TConfig& config) connectionConfig->EnableProxyDiscovery = config.GetEnableProxyDiscovery(); } if (!config.GetProxyAddresses().empty()) { - connectionConfig->ProxyAddresses = std::vector<TString>(config.GetProxyAddresses().begin(), config.GetProxyAddresses().end()); + connectionConfig->ProxyAddresses = FromProto<std::vector<std::string>>(config.GetProxyAddresses()); } #define SET_TIMEOUT_OPTION(name) \ diff --git a/yt/yt/client/chaos_client/replication_card.cpp b/yt/yt/client/chaos_client/replication_card.cpp index 7a36a4e95c..cc789139a9 100644 --- a/yt/yt/client/chaos_client/replication_card.cpp +++ b/yt/yt/client/chaos_client/replication_card.cpp @@ -17,6 +17,8 @@ using namespace NTableClient; using namespace NTabletClient; using namespace NTransactionClient; +//////////////////////////////////////////////////////////////////////////////// + namespace NDetail { void FormatProgressWithProjection( @@ -702,7 +704,7 @@ std::vector<TReplicationProgress> ScatterReplicationProgress( bool IsReplicaLocationValid( const TReplicaInfo* replica, const NYPath::TYPath& tablePath, - const TString& clusterName) + const std::string& clusterName) { return replica->ReplicaPath == tablePath && replica->ClusterName == clusterName; } diff --git a/yt/yt/client/chaos_client/replication_card.h b/yt/yt/client/chaos_client/replication_card.h index 764c035c1e..5d16e8ac4f 100644 --- a/yt/yt/client/chaos_client/replication_card.h +++ b/yt/yt/client/chaos_client/replication_card.h @@ -41,7 +41,7 @@ struct TReplicaHistoryItem struct TReplicaInfo { - TString ClusterName; + std::string ClusterName; NYPath::TYPath ReplicaPath; NTabletClient::ETableReplicaContentType ContentType; NTabletClient::ETableReplicaMode Mode; @@ -68,7 +68,7 @@ struct TReplicationCard TReplicationEra Era = InvalidReplicationEra; NTableClient::TTableId TableId; NYPath::TYPath TablePath; - TString TableClusterName; + std::string TableClusterName; NTransactionClient::TTimestamp CurrentTimestamp = NTransactionClient::NullTimestamp; NTabletClient::TReplicatedTableOptionsPtr ReplicatedTableOptions; TReplicationCardCollocationId ReplicationCardCollocationId; @@ -180,7 +180,7 @@ std::vector<TReplicationProgress> ScatterReplicationProgress( bool IsReplicaLocationValid( const TReplicaInfo* replica, const NYPath::TYPath& tablePath, - const TString& clusterName); + const std::string& clusterName); TReplicationProgress BuildMaxProgress(const TReplicationProgress& progress1, const TReplicationProgress& progress2); diff --git a/yt/yt/client/chaos_client/replication_card_serialization.cpp b/yt/yt/client/chaos_client/replication_card_serialization.cpp index 159aa547d3..85d4785871 100644 --- a/yt/yt/client/chaos_client/replication_card_serialization.cpp +++ b/yt/yt/client/chaos_client/replication_card_serialization.cpp @@ -348,8 +348,8 @@ void ToProto(NChaosClient::NProto::TReplicaHistoryItem* protoHistoryItem, const { protoHistoryItem->set_era(historyItem.Era); protoHistoryItem->set_timestamp(ToProto<ui64>(historyItem.Timestamp)); - protoHistoryItem->set_mode(ToProto<i32>(historyItem.Mode)); - protoHistoryItem->set_state(ToProto<i32>(historyItem.State)); + protoHistoryItem->set_mode(ToProto<int>(historyItem.Mode)); + protoHistoryItem->set_state(ToProto<int>(historyItem.State)); } void FromProto(TReplicaHistoryItem* historyItem, const NChaosClient::NProto::TReplicaHistoryItem& protoHistoryItem) @@ -365,11 +365,11 @@ void ToProto( const TReplicaInfo& replicaInfo, const TReplicationCardFetchOptions& options) { - protoReplicaInfo->set_cluster_name(replicaInfo.ClusterName); + protoReplicaInfo->set_cluster_name(ToProto<TProtobufString>(replicaInfo.ClusterName)); protoReplicaInfo->set_replica_path(replicaInfo.ReplicaPath); - protoReplicaInfo->set_content_type(ToProto<i32>(replicaInfo.ContentType)); - protoReplicaInfo->set_mode(ToProto<i32>(replicaInfo.Mode)); - protoReplicaInfo->set_state(ToProto<i32>(replicaInfo.State)); + protoReplicaInfo->set_content_type(ToProto<int>(replicaInfo.ContentType)); + protoReplicaInfo->set_mode(ToProto<int>(replicaInfo.Mode)); + protoReplicaInfo->set_state(ToProto<int>(replicaInfo.State)); protoReplicaInfo->set_enable_replicated_table_tracker(replicaInfo.EnableReplicatedTableTracker); if (options.IncludeProgress) { ToProto(protoReplicaInfo->mutable_progress(), replicaInfo.ReplicationProgress); @@ -414,7 +414,7 @@ void ToProto( protoReplicationCard->set_era(replicationCard.Era); ToProto(protoReplicationCard->mutable_table_id(), replicationCard.TableId); protoReplicationCard->set_table_path(replicationCard.TablePath); - protoReplicationCard->set_table_cluster_name(replicationCard.TableClusterName); + protoReplicationCard->set_table_cluster_name(ToProto<TProtobufString>(replicationCard.TableClusterName)); protoReplicationCard->set_current_timestamp(replicationCard.CurrentTimestamp); ToProto(protoReplicationCard->mutable_replication_card_collocation_id(), replicationCard.ReplicationCardCollocationId); } diff --git a/yt/yt/client/driver/admin_commands.cpp b/yt/yt/client/driver/admin_commands.cpp index bee91a2b66..eb019c050e 100644 --- a/yt/yt/client/driver/admin_commands.cpp +++ b/yt/yt/client/driver/admin_commands.cpp @@ -397,7 +397,7 @@ void TAddMaintenanceCommand::DoExecute(ICommandContextPtr context) ProduceOutput(context, [&] (NYson::IYsonConsumer* consumer) { BuildYsonFluently(consumer) .BeginMap() - .DoFor(response, [] (auto fluent, const std::pair<TString, TMaintenanceId>& targetAndId) { + .DoFor(response, [] (auto fluent, const std::pair<std::string, TMaintenanceId>& targetAndId) { fluent.Item(targetAndId.first).Value(targetAndId.second); }) .EndMap(); @@ -510,7 +510,7 @@ void TRemoveMaintenanceCommand::DoExecute(ICommandContextPtr context) .BeginMap() .DoFor( response, - [&] (auto fluent, const std::pair<TString, TMaintenanceCounts>& targetWithCounts) { + [&] (auto fluent, const std::pair<std::string, TMaintenanceCounts>& targetWithCounts) { produceCounts(fluent.Item(targetWithCounts.first), targetWithCounts.second); }) .EndMap(); diff --git a/yt/yt/client/driver/etc_commands.h b/yt/yt/client/driver/etc_commands.h index 2135cef597..7135ddc555 100644 --- a/yt/yt/client/driver/etc_commands.h +++ b/yt/yt/client/driver/etc_commands.h @@ -231,9 +231,9 @@ public: private: NApi::EProxyType Type; - TString Role; + std::string Role; NApi::NRpcProxy::EAddressType AddressType; - TString NetworkName; + std::string NetworkName; bool IgnoreBalancers; void DoExecute(ICommandContextPtr context) override; diff --git a/yt/yt/client/driver/proxy_discovery_cache.h b/yt/yt/client/driver/proxy_discovery_cache.h index 7b5871d1d4..9564dbdf67 100644 --- a/yt/yt/client/driver/proxy_discovery_cache.h +++ b/yt/yt/client/driver/proxy_discovery_cache.h @@ -15,9 +15,9 @@ namespace NYT::NDriver { struct TProxyDiscoveryRequest { NApi::EProxyType Type; - TString Role = NApi::DefaultRpcProxyRole; + std::string Role = NApi::DefaultRpcProxyRole; NApi::NRpcProxy::EAddressType AddressType = NApi::NRpcProxy::DefaultAddressType; - TString NetworkName = NApi::NRpcProxy::DefaultNetworkName; + std::string NetworkName = NApi::NRpcProxy::DefaultNetworkName; bool IgnoreBalancers = false; bool operator==(const TProxyDiscoveryRequest& other) const = default; @@ -31,7 +31,7 @@ void FormatValue(TStringBuilderBase* builder, const TProxyDiscoveryRequest& requ struct TProxyDiscoveryResponse { - std::vector<TString> Addresses; + std::vector<std::string> Addresses; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/federated/cache.cpp b/yt/yt/client/federated/cache.cpp index a3462977fb..d686f01767 100644 --- a/yt/yt/client/federated/cache.cpp +++ b/yt/yt/client/federated/cache.cpp @@ -1,5 +1,4 @@ #include "cache.h" -#include "client.h" #include "connection.h" #include <yt/yt/client/api/options.h> @@ -32,7 +31,7 @@ public: protected: NApi::IClientPtr CreateClient(TStringBuf clusterUrl) override { - std::vector<TString> clusters; + std::vector<std::string> clusters; NYT::NApi::IClientPtr client; StringSplitter(clusterUrl).SplitByString(ClusterSeparator_).SkipEmpty().Collect(&clusters); switch (clusters.size()) { @@ -46,9 +45,9 @@ protected: } private: - NApi::IClientPtr CreateFederatedClient(const std::vector<TString>& clusters) + NApi::IClientPtr CreateFederatedClient(const std::vector<std::string>& clusters) { - THashSet<TString> seenClusters; + THashSet<std::string> seenClusters; for (const auto& connectionConfig : FederationConfig_->RpcProxyConnections) { THROW_ERROR_EXCEPTION_UNLESS( connectionConfig->ClusterUrl, diff --git a/yt/yt/client/federated/client.cpp b/yt/yt/client/federated/client.cpp index 3302fcd923..771ca3e3ac 100644 --- a/yt/yt/client/federated/client.cpp +++ b/yt/yt/client/federated/client.cpp @@ -421,14 +421,14 @@ public: UNIMPLEMENTED_METHOD(TFuture<void>, ExitReadOnly, (NObjectClient::TCellId, const TExitReadOnlyOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, MasterExitReadOnly, (const TMasterExitReadOnlyOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, DiscombobulateNonvotingPeers, (NObjectClient::TCellId, const TDiscombobulateNonvotingPeersOptions&)); - UNIMPLEMENTED_METHOD(TFuture<void>, SwitchLeader, (NObjectClient::TCellId, const TString&, const TSwitchLeaderOptions&)); + UNIMPLEMENTED_METHOD(TFuture<void>, SwitchLeader, (NObjectClient::TCellId, const std::string&, const TSwitchLeaderOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, ResetStateHash, (NObjectClient::TCellId, const TResetStateHashOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, GCCollect, (const TGCCollectOptions&)); - UNIMPLEMENTED_METHOD(TFuture<void>, KillProcess, (const TString&, const TKillProcessOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TString>, WriteCoreDump, (const TString&, const TWriteCoreDumpOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TGuid>, WriteLogBarrier, (const TString&, const TWriteLogBarrierOptions&)); + UNIMPLEMENTED_METHOD(TFuture<void>, KillProcess, (const std::string&, const TKillProcessOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TString>, WriteCoreDump, (const std::string&, const TWriteCoreDumpOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TGuid>, WriteLogBarrier, (const std::string&, const TWriteLogBarrierOptions&)); UNIMPLEMENTED_METHOD(TFuture<TString>, WriteOperationControllerCoreDump, (NJobTrackerClient::TOperationId, const TWriteOperationControllerCoreDumpOptions&)); - UNIMPLEMENTED_METHOD(TFuture<void>, HealExecNode, (const TString&, const THealExecNodeOptions&)); + UNIMPLEMENTED_METHOD(TFuture<void>, HealExecNode, (const std::string&, const THealExecNodeOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, SuspendCoordinator, (NObjectClient::TCellId, const TSuspendCoordinatorOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, ResumeCoordinator, (NObjectClient::TCellId, const TResumeCoordinatorOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, MigrateReplicationCards, (NObjectClient::TCellId, const TMigrateReplicationCardsOptions&)); @@ -437,12 +437,12 @@ public: UNIMPLEMENTED_METHOD(TFuture<void>, SuspendTabletCells, (const std::vector<NObjectClient::TCellId>&, const TSuspendTabletCellsOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, ResumeTabletCells, (const std::vector<NObjectClient::TCellId>&, const TResumeTabletCellsOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, UpdateChaosTableReplicaProgress, (NChaosClient::TReplicaId, const TUpdateChaosTableReplicaProgressOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, (EMaintenanceComponent, const TString&, EMaintenanceType, const TString&, const TAddMaintenanceOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, (EMaintenanceComponent, const TString&, const TMaintenanceFilter&, const TRemoveMaintenanceOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, (const TString&, const std::vector<TGuid>&, const TDisableChunkLocationsOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, (const TString&, bool, const std::vector<TGuid>&, const TDestroyChunkLocationsOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, (const TString&, const std::vector<TGuid>&, const TResurrectChunkLocationsOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TRequestRestartResult>, RequestRestart, (const TString&, const TRequestRestartOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, (EMaintenanceComponent, const std::string&, EMaintenanceType, const TString&, const TAddMaintenanceOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, (EMaintenanceComponent, const std::string&, const TMaintenanceFilter&, const TRemoveMaintenanceOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, (const std::string&, const std::vector<TGuid>&, const TDisableChunkLocationsOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, (const std::string&, bool, const std::vector<TGuid>&, const TDestroyChunkLocationsOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, (const std::string&, const std::vector<TGuid>&, const TResurrectChunkLocationsOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TRequestRestartResult>, RequestRestart, (const std::string&, const TRequestRestartOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, SetUserPassword, (const TString&, const TString&, const TString&, const TSetUserPasswordOptions&)); UNIMPLEMENTED_METHOD(TFuture<TIssueTokenResult>, IssueToken, (const TString&, const TString&, const TIssueTokenOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, RevokeToken, (const TString&, const TString&, const TString&, const TRevokeTokenOptions&)); diff --git a/yt/yt/client/federated/connection.cpp b/yt/yt/client/federated/connection.cpp index ec0d6bfdfd..b50e202bc0 100644 --- a/yt/yt/client/federated/connection.cpp +++ b/yt/yt/client/federated/connection.cpp @@ -94,7 +94,7 @@ public: UNIMPLEMENTED_CONST_METHOD(NApi::TClusterTag, GetClusterTag, ()); UNIMPLEMENTED_CONST_METHOD(const TString&, GetClusterId, ()); - UNIMPLEMENTED_CONST_METHOD(const std::optional<TString>&, GetClusterName, ()); + UNIMPLEMENTED_CONST_METHOD(const std::optional<std::string>&, GetClusterName, ()); UNIMPLEMENTED_CONST_METHOD(bool, IsSameCluster, (const NApi::IConnectionPtr&)); UNIMPLEMENTED_METHOD( NHiveClient::ITransactionParticipantPtr, diff --git a/yt/yt/client/hedging/config.cpp b/yt/yt/client/hedging/config.cpp index a0b009f1b3..9c25a6e13f 100644 --- a/yt/yt/client/hedging/config.cpp +++ b/yt/yt/client/hedging/config.cpp @@ -15,11 +15,11 @@ void TClientConfig::Register(TRegistrar registrar) THedgingClientOptions::TClientOptions::TClientOptions( NApi::IClientPtr client, - TString clusterName, + const std::string& clusterName, TDuration initialPenalty, TCounterPtr counter) : Client(std::move(client)) - , ClusterName(std::move(clusterName)) + , ClusterName(clusterName) , InitialPenalty(initialPenalty) , Counter(std::move(counter)) { } diff --git a/yt/yt/client/hedging/config.h b/yt/yt/client/hedging/config.h index bd21956f69..6e6cc41697 100644 --- a/yt/yt/client/hedging/config.h +++ b/yt/yt/client/hedging/config.h @@ -37,7 +37,7 @@ struct THedgingClientOptions { TClientOptions( NApi::IClientPtr client, - TString clusterName, + const std::string& clusterName, TDuration initialPenalty, TCounterPtr counter = {}); @@ -47,7 +47,7 @@ struct THedgingClientOptions TCounterPtr counter = {}); NApi::IClientPtr Client; - TString ClusterName; + std::string ClusterName; TDuration InitialPenalty; TCounterPtr Counter; }; diff --git a/yt/yt/client/hedging/hedging.cpp b/yt/yt/client/hedging/hedging.cpp index 4bc18bebd0..ab41ce4c2f 100644 --- a/yt/yt/client/hedging/hedging.cpp +++ b/yt/yt/client/hedging/hedging.cpp @@ -181,14 +181,14 @@ public: UNSUPPORTED_METHOD(TFuture<void>, ExitReadOnly, (NObjectClient::TCellId, const TExitReadOnlyOptions&)); UNSUPPORTED_METHOD(TFuture<void>, MasterExitReadOnly, (const TMasterExitReadOnlyOptions&)); UNSUPPORTED_METHOD(TFuture<void>, DiscombobulateNonvotingPeers, (NObjectClient::TCellId, const TDiscombobulateNonvotingPeersOptions&)); - UNSUPPORTED_METHOD(TFuture<void>, SwitchLeader, (NObjectClient::TCellId, const TString&, const TSwitchLeaderOptions&)); + UNSUPPORTED_METHOD(TFuture<void>, SwitchLeader, (NObjectClient::TCellId, const std::string&, const TSwitchLeaderOptions&)); UNSUPPORTED_METHOD(TFuture<void>, ResetStateHash, (NObjectClient::TCellId, const TResetStateHashOptions&)); UNSUPPORTED_METHOD(TFuture<void>, GCCollect, (const TGCCollectOptions&)); - UNSUPPORTED_METHOD(TFuture<void>, KillProcess, (const TString&, const TKillProcessOptions&)); - UNSUPPORTED_METHOD(TFuture<TString>, WriteCoreDump, (const TString&, const TWriteCoreDumpOptions&)); - UNSUPPORTED_METHOD(TFuture<TGuid>, WriteLogBarrier, (const TString&, const TWriteLogBarrierOptions&)); + UNSUPPORTED_METHOD(TFuture<void>, KillProcess, (const std::string&, const TKillProcessOptions&)); + UNSUPPORTED_METHOD(TFuture<TString>, WriteCoreDump, (const std::string&, const TWriteCoreDumpOptions&)); + UNSUPPORTED_METHOD(TFuture<TGuid>, WriteLogBarrier, (const std::string&, const TWriteLogBarrierOptions&)); UNSUPPORTED_METHOD(TFuture<TString>, WriteOperationControllerCoreDump, (NJobTrackerClient::TOperationId, const TWriteOperationControllerCoreDumpOptions&)); - UNSUPPORTED_METHOD(TFuture<void>, HealExecNode, (const TString&, const THealExecNodeOptions&)); + UNSUPPORTED_METHOD(TFuture<void>, HealExecNode, (const std::string&, const THealExecNodeOptions&)); UNSUPPORTED_METHOD(TFuture<void>, SuspendCoordinator, (NObjectClient::TCellId, const TSuspendCoordinatorOptions&)); UNSUPPORTED_METHOD(TFuture<void>, ResumeCoordinator, (NObjectClient::TCellId, const TResumeCoordinatorOptions&)); UNSUPPORTED_METHOD(TFuture<void>, MigrateReplicationCards, (NObjectClient::TCellId, const TMigrateReplicationCardsOptions&)); @@ -198,12 +198,12 @@ public: UNSUPPORTED_METHOD(TFuture<void>, ResumeTabletCells, (const std::vector<NObjectClient::TCellId>&, const TResumeTabletCellsOptions&)); UNSUPPORTED_METHOD(TFuture<NChaosClient::TReplicationCardPtr>, GetReplicationCard, (NChaosClient::TReplicationCardId, const TGetReplicationCardOptions&)); UNSUPPORTED_METHOD(TFuture<void>, UpdateChaosTableReplicaProgress, (NChaosClient::TReplicaId, const TUpdateChaosTableReplicaProgressOptions&)); - UNSUPPORTED_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, (EMaintenanceComponent, const TString&, EMaintenanceType, const TString&, const TAddMaintenanceOptions&)); - UNSUPPORTED_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, (EMaintenanceComponent, const TString&, const TMaintenanceFilter&, const TRemoveMaintenanceOptions&)); - UNSUPPORTED_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, (const TString&, const std::vector<TGuid>&, const TDisableChunkLocationsOptions&)); - UNSUPPORTED_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, (const TString&, bool, const std::vector<TGuid>&, const TDestroyChunkLocationsOptions&)); - UNSUPPORTED_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, (const TString&, const std::vector<TGuid>&, const TResurrectChunkLocationsOptions&)); - UNSUPPORTED_METHOD(TFuture<TRequestRestartResult>, RequestRestart, (const TString&, const TRequestRestartOptions&)); + UNSUPPORTED_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, (EMaintenanceComponent, const std::string&, EMaintenanceType, const TString&, const TAddMaintenanceOptions&)); + UNSUPPORTED_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, (EMaintenanceComponent, const std::string&, const TMaintenanceFilter&, const TRemoveMaintenanceOptions&)); + UNSUPPORTED_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, (const std::string&, const std::vector<TGuid>&, const TDisableChunkLocationsOptions&)); + UNSUPPORTED_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, (const std::string&, bool, const std::vector<TGuid>&, const TDestroyChunkLocationsOptions&)); + UNSUPPORTED_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, (const std::string&, const std::vector<TGuid>&, const TResurrectChunkLocationsOptions&)); + UNSUPPORTED_METHOD(TFuture<TRequestRestartResult>, RequestRestart, (const std::string&, const TRequestRestartOptions&)); UNSUPPORTED_METHOD(TFuture<TPullRowsResult>, PullRows, (const TYPath&, const TPullRowsOptions&)); UNSUPPORTED_METHOD(TFuture<void>, SetUserPassword, (const TString&, const TString&, const TString&, const TSetUserPasswordOptions&)); UNSUPPORTED_METHOD(TFuture<TIssueTokenResult>, IssueToken, (const TString&, const TString&, const TIssueTokenOptions&)); diff --git a/yt/yt/client/hedging/hedging_executor.cpp b/yt/yt/client/hedging/hedging_executor.cpp index 2eef4faa40..3459dfa19e 100644 --- a/yt/yt/client/hedging/hedging_executor.cpp +++ b/yt/yt/client/hedging/hedging_executor.cpp @@ -65,9 +65,9 @@ THedgingExecutor::TEntry::TEntry( NApi::IClientPtr client, NProfiling::TCpuDuration initialPenalty, TCounterPtr counter, - TString clusterName) + const std::string& clusterName) : Client(std::move(client)) - , ClusterName(std::move(clusterName)) + , ClusterName(clusterName) , AdaptivePenalty(0) , InitialPenalty(initialPenalty) , ExternalPenalty(0) diff --git a/yt/yt/client/hedging/hedging_executor.h b/yt/yt/client/hedging/hedging_executor.h index b9e4380f9b..cd07651e6f 100644 --- a/yt/yt/client/hedging/hedging_executor.h +++ b/yt/yt/client/hedging/hedging_executor.h @@ -86,10 +86,10 @@ private: NApi::IClientPtr client, NProfiling::TCpuDuration initialPenalty, TCounterPtr counter, - TString clusterName); + const std::string& clusterName); NApi::IClientPtr Client; - TString ClusterName; + std::string ClusterName; NProfiling::TCpuDuration AdaptivePenalty; NProfiling::TCpuDuration InitialPenalty; NProfiling::TCpuDuration ExternalPenalty; diff --git a/yt/yt/client/hedging/penalty_provider.cpp b/yt/yt/client/hedging/penalty_provider.cpp index 8fc5368c5e..8021ee0f2d 100644 --- a/yt/yt/client/hedging/penalty_provider.cpp +++ b/yt/yt/client/hedging/penalty_provider.cpp @@ -29,9 +29,12 @@ namespace { //////////////////////////////////////////////////////////////////////////////// -class TDummyLagProvider: public IPenaltyProvider { +class TDummyLagProvider + : public IPenaltyProvider +{ public: - NProfiling::TCpuDuration Get(const TString&) override { + NProfiling::TCpuDuration Get(const std::string& /*cluster*/) override + { return 0; } }; @@ -87,7 +90,7 @@ public: auto replicasNode = NYTree::ConvertToNode(NConcurrency::WaitFor(Client_->GetNode(TablePath_ + "/@replicas", GetNodeOptions_)).ValueOrThrow())->AsMap(); for (const auto& row : replicasNode->GetChildren()) { - TString cluster = row.second->AsMap()->GetChildOrThrow("cluster_name")->AsString()->GetValue(); + auto cluster = row.second->AsMap()->GetChildOrThrow("cluster_name")->AsString()->GetValue(); if (auto* info = ReplicaClusters_.FindPtr(cluster)) { info->ReplicaId = NTabletClient::TTableReplicaId::FromString(row.first); YT_LOG_INFO("Found ReplicaId %v for table %v in cluster %v", info->ReplicaId, TablePath_, cluster); @@ -174,9 +177,9 @@ public: } } - NProfiling::TCpuDuration Get(const TString& cluster) override + NProfiling::TCpuDuration Get(const std::string& cluster) override { - if (const TReplicaInfo* info = ReplicaClusters_.FindPtr(cluster)) { + if (const auto* info = ReplicaClusters_.FindPtr(cluster)) { return info->CurrentLagPenalty.load(std::memory_order::relaxed); } return 0; @@ -190,12 +193,13 @@ public: private: struct TReplicaInfo { - NTabletClient::TTableReplicaId ReplicaId = {}; + NTabletClient::TTableReplicaId ReplicaId; std::atomic<NProfiling::TCpuDuration> CurrentLagPenalty = 0; }; const TString TablePath_; - THashMap<TString, TReplicaInfo> ReplicaClusters_; + + THashMap<std::string, TReplicaInfo> ReplicaClusters_; const TDuration MaxTabletLag_; const NProfiling::TCpuDuration LagPenalty_; const float MaxTabletsWithLagFraction_; @@ -218,10 +222,10 @@ IPenaltyProviderPtr CreateDummyPenaltyProvider() } IPenaltyProviderPtr CreateReplicationLagPenaltyProvider( - const TReplicationLagPenaltyProviderConfig& config, - NApi::IClientPtr client) + TReplicationLagPenaltyProviderConfig config, + NApi::IClientPtr client) { - return New<TLagPenaltyProvider>(config, client); + return New<TLagPenaltyProvider>(std::move(config), std::move(client)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/hedging/penalty_provider.h b/yt/yt/client/hedging/penalty_provider.h index b7cf72aee2..4c4d04e975 100644 --- a/yt/yt/client/hedging/penalty_provider.h +++ b/yt/yt/client/hedging/penalty_provider.h @@ -15,7 +15,7 @@ namespace NYT::NClient::NHedging::NRpc { struct IPenaltyProvider : public TRefCounted { - virtual NProfiling::TCpuDuration Get(const TString& cluster) = 0; + virtual NProfiling::TCpuDuration Get(const std::string& cluster) = 0; }; DEFINE_REFCOUNTED_TYPE(IPenaltyProvider) @@ -32,7 +32,8 @@ class TReplicationLagPenaltyProviderConfig; // Based on values from TReplicationLagPenaltyProviderConfig add current number of tablets with lag, it either returns 0 or LagPenalty value. // Master client - main cluster with replicated table. ReplicaCluster + TablePath specifies concrete replica for table from main cluster. IPenaltyProviderPtr CreateReplicationLagPenaltyProvider( - const TReplicationLagPenaltyProviderConfig& config, NApi::IClientPtr client); + TReplicationLagPenaltyProviderConfig config, + NApi::IClientPtr client); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/hedging/unittests/hedging_ut.cpp b/yt/yt/client/hedging/unittests/hedging_ut.cpp index 43ce0d0cb6..3d3d28cda7 100644 --- a/yt/yt/client/hedging/unittests/hedging_ut.cpp +++ b/yt/yt/client/hedging/unittests/hedging_ut.cpp @@ -58,7 +58,7 @@ NApi::IClientPtr CreateTestHedgingClient( IPenaltyProviderPtr CreateReplicationLagPenaltyProvider( const NYPath::TYPath& path, - const TString& cluster, + const std::string& cluster, TDuration maxTabletLag, TDuration lagPenalty, NApi::IClientPtr client, @@ -68,7 +68,7 @@ IPenaltyProviderPtr CreateReplicationLagPenaltyProvider( TReplicationLagPenaltyProviderConfig config; config.SetTablePath(path); - config.AddReplicaClusters(cluster); + config.AddReplicaClusters(TProtobufString(cluster)); config.SetMaxTabletsWithLagFraction(0.5); config.SetMaxTabletLag(maxTabletLag.Seconds()); config.SetCheckPeriod(checkPeriod.Seconds()); diff --git a/yt/yt/client/hedging/unittests/penalty_provider_ut.cpp b/yt/yt/client/hedging/unittests/penalty_provider_ut.cpp index 914c0d6ce7..db1b90a01b 100644 --- a/yt/yt/client/hedging/unittests/penalty_provider_ut.cpp +++ b/yt/yt/client/hedging/unittests/penalty_provider_ut.cpp @@ -24,7 +24,7 @@ namespace { TReplicationLagPenaltyProviderConfig GenerateReplicationLagPenaltyProviderConfig( const NYPath::TYPath& path, - const TString& cluster, + const std::string& cluster, const ui32 maxLagInSeconds = 10, const bool clearPenaltiesOnErrors = false, const TDuration checkPeriod = CheckPeriod) @@ -32,7 +32,7 @@ namespace { TReplicationLagPenaltyProviderConfig config; config.SetTablePath(path); - config.AddReplicaClusters(cluster); + config.AddReplicaClusters(TProtobufString(cluster)); config.SetMaxTabletsWithLagFraction(0.5); config.SetMaxTabletLag(maxLagInSeconds); config.SetCheckPeriod(checkPeriod.Seconds()); diff --git a/yt/yt/client/node_tracker_client/node_directory.cpp b/yt/yt/client/node_tracker_client/node_directory.cpp index 7c76e66fd6..0ef4ee4561 100644 --- a/yt/yt/client/node_tracker_client/node_directory.cpp +++ b/yt/yt/client/node_tracker_client/node_directory.cpp @@ -39,7 +39,7 @@ static constexpr auto& Logger = NodeTrackerClientLogger; //////////////////////////////////////////////////////////////////////////////// -const TString& NullNodeAddress() +const std::string& NullNodeAddress() { static const TString Result("<null>"); return Result; @@ -77,12 +77,12 @@ TNodeDescriptor::TNodeDescriptor() : DefaultAddress_(NullNodeAddress()) { } -TNodeDescriptor::TNodeDescriptor(const TString& defaultAddress) +TNodeDescriptor::TNodeDescriptor(const std::string& defaultAddress) : Addresses_{std::pair(DefaultNetworkName, defaultAddress)} , DefaultAddress_(defaultAddress) { } -TNodeDescriptor::TNodeDescriptor(const std::optional<TString>& defaultAddress) +TNodeDescriptor::TNodeDescriptor(const std::optional<std::string>& defaultAddress) { if (defaultAddress) { *this = TNodeDescriptor(*defaultAddress); @@ -91,9 +91,9 @@ TNodeDescriptor::TNodeDescriptor(const std::optional<TString>& defaultAddress) TNodeDescriptor::TNodeDescriptor( TAddressMap addresses, - std::optional<TString> host, - std::optional<TString> rack, - std::optional<TString> dc, + const std::optional<std::string>& host, + const std::optional<std::string>& rack, + const std::optional<std::string>& dc, const std::vector<TString>& tags, std::optional<TInstant> lastSeenTime) : Addresses_(std::move(addresses)) @@ -115,32 +115,32 @@ const TAddressMap& TNodeDescriptor::Addresses() const return Addresses_; } -const TString& TNodeDescriptor::GetDefaultAddress() const +const std::string& TNodeDescriptor::GetDefaultAddress() const { return DefaultAddress_; } -const TString& TNodeDescriptor::GetAddressOrThrow(const TNetworkPreferenceList& networks) const +const std::string& TNodeDescriptor::GetAddressOrThrow(const TNetworkPreferenceList& networks) const { return NNodeTrackerClient::GetAddressOrThrow(Addresses(), networks); } -std::optional<TString> TNodeDescriptor::FindAddress(const TNetworkPreferenceList& networks) const +std::optional<std::string> TNodeDescriptor::FindAddress(const TNetworkPreferenceList& networks) const { return NNodeTrackerClient::FindAddress(Addresses(), networks); } -const std::optional<TString>& TNodeDescriptor::GetHost() const +const std::optional<std::string>& TNodeDescriptor::GetHost() const { return Host_; } -const std::optional<TString>& TNodeDescriptor::GetRack() const +const std::optional<std::string>& TNodeDescriptor::GetRack() const { return Rack_; } -const std::optional<TString>& TNodeDescriptor::GetDataCenter() const +const std::optional<std::string>& TNodeDescriptor::GetDataCenter() const { return DataCenter_; } @@ -234,7 +234,7 @@ void FormatValue(TStringBuilderBase* builder, const TNodeDescriptor& descriptor, } } -std::optional<TString> FindDefaultAddress(const TAddressMap& addresses) +std::optional<std::string> FindDefaultAddress(const TAddressMap& addresses) { if (addresses.empty()) { return NullNodeAddress(); @@ -246,7 +246,7 @@ std::optional<TString> FindDefaultAddress(const TAddressMap& addresses) return std::nullopt; } -const TString& GetDefaultAddress(const TAddressMap& addresses) +const std::string& GetDefaultAddress(const TAddressMap& addresses) { if (addresses.empty()) { return NullNodeAddress(); @@ -254,7 +254,7 @@ const TString& GetDefaultAddress(const TAddressMap& addresses) return GetOrCrash(addresses, DefaultNetworkName); } -const TString& GetDefaultAddress(const NProto::TAddressMap& addresses) +const std::string& GetDefaultAddress(const NProto::TAddressMap& addresses) { if (addresses.entries_size() == 0) { return NullNodeAddress(); @@ -303,8 +303,8 @@ void ToProto(NNodeTrackerClient::NProto::TAddressMap* protoAddresses, const NNod { for (const auto& [networkName, networkAddress] : addresses) { auto* entry = protoAddresses->add_entries(); - entry->set_network(networkName); - entry->set_address(networkAddress); + entry->set_network(NYT::ToProto<TProtobufString>(networkName)); + entry->set_address(NYT::ToProto<TProtobufString>(networkAddress)); } } @@ -345,19 +345,19 @@ void ToProto(NNodeTrackerClient::NProto::TNodeDescriptor* protoDescriptor, const ToProto(protoDescriptor->mutable_addresses(), descriptor.Addresses()); if (auto host = descriptor.GetHost()) { - protoDescriptor->set_host(*host); + protoDescriptor->set_host(ToProto<TProtobufString>(*host)); } else { protoDescriptor->clear_host(); } if (auto rack = descriptor.GetRack()) { - protoDescriptor->set_rack(*rack); + protoDescriptor->set_rack(ToProto<TProtobufString>(*rack)); } else { protoDescriptor->clear_rack(); } if (auto dataCenter = descriptor.GetDataCenter()) { - protoDescriptor->set_data_center(*dataCenter); + protoDescriptor->set_data_center(ToProto<TProtobufString>(*dataCenter)); } else { protoDescriptor->clear_data_center(); } @@ -656,14 +656,14 @@ std::vector<std::pair<TNodeId, TNodeDescriptor>> TNodeDirectory::GetAllDescripto return result; } -const TNodeDescriptor* TNodeDirectory::FindDescriptor(const TString& address) +const TNodeDescriptor* TNodeDirectory::FindDescriptor(const std::string& address) { auto guard = ReaderGuard(SpinLock_); auto it = AddressToDescriptor_.find(address); return it == AddressToDescriptor_.end() ? nullptr : it->second; } -const TNodeDescriptor& TNodeDirectory::GetDescriptor(const TString& address) +const TNodeDescriptor& TNodeDirectory::GetDescriptor(const std::string& address) { const auto* result = FindDescriptor(address); YT_VERIFY(result); @@ -711,13 +711,13 @@ TAddressMap::const_iterator SelectAddress(const TAddressMap& addresses, const TN } // namespace -std::optional<TString> FindAddress(const TAddressMap& addresses, const TNetworkPreferenceList& networks) +std::optional<std::string> FindAddress(const TAddressMap& addresses, const TNetworkPreferenceList& networks) { const auto it = SelectAddress(addresses, networks); return it == addresses.cend() ? std::nullopt : std::make_optional(it->second); } -const TString& GetAddressOrThrow(const TAddressMap& addresses, const TNetworkPreferenceList& networks) +const std::string& GetAddressOrThrow(const TAddressMap& addresses, const TNetworkPreferenceList& networks) { const auto it = SelectAddress(addresses, networks); if (it != addresses.cend()) { diff --git a/yt/yt/client/node_tracker_client/node_directory.h b/yt/yt/client/node_tracker_client/node_directory.h index b26593a8e5..f8ebc1ba0c 100644 --- a/yt/yt/client/node_tracker_client/node_directory.h +++ b/yt/yt/client/node_tracker_client/node_directory.h @@ -28,13 +28,13 @@ public: TNodeDescriptor(); TNodeDescriptor(const TNodeDescriptor& other) = default; TNodeDescriptor(TNodeDescriptor&& other) = default; - explicit TNodeDescriptor(const TString& defaultAddress); - explicit TNodeDescriptor(const std::optional<TString>& defaultAddress); + explicit TNodeDescriptor(const std::string& defaultAddress); + explicit TNodeDescriptor(const std::optional<std::string>& defaultAddress); explicit TNodeDescriptor( TAddressMap addresses, - std::optional<TString> host = std::nullopt, - std::optional<TString> rack = std::nullopt, - std::optional<TString> dc = std::nullopt, + const std::optional<std::string>& host = {}, + const std::optional<std::string>& rack = {}, + const std::optional<std::string>& dc = {}, const std::vector<TString>& tags = {}, std::optional<TInstant> lastSeenTime = {}); @@ -45,15 +45,15 @@ public: const TAddressMap& Addresses() const; - const TString& GetDefaultAddress() const; + const std::string& GetDefaultAddress() const; - const TString& GetAddressOrThrow(const TNetworkPreferenceList& networks) const; + const std::string& GetAddressOrThrow(const TNetworkPreferenceList& networks) const; - std::optional<TString> FindAddress(const TNetworkPreferenceList& networks) const; + std::optional<std::string> FindAddress(const TNetworkPreferenceList& networks) const; - const std::optional<TString>& GetHost() const; - const std::optional<TString>& GetRack() const; - const std::optional<TString>& GetDataCenter() const; + const std::optional<std::string>& GetHost() const; + const std::optional<std::string>& GetRack() const; + const std::optional<std::string>& GetDataCenter() const; const std::vector<TString>& GetTags() const; @@ -72,17 +72,17 @@ public: private: TAddressMap Addresses_; - TString DefaultAddress_; - std::optional<TString> Host_; - std::optional<TString> Rack_; - std::optional<TString> DataCenter_; + std::string DefaultAddress_; + std::optional<std::string> Host_; + std::optional<std::string> Rack_; + std::optional<std::string> DataCenter_; std::vector<TString> Tags_; // Not persisted. mutable TCopyableAtomic<TCpuInstant> LastSeenTime_; }; -const TString& NullNodeAddress(); +const std::string& NullNodeAddress(); const TNodeDescriptor& NullNodeDescriptor(); //////////////////////////////////////////////////////////////////////////////// @@ -93,12 +93,12 @@ bool operator == (const TNodeDescriptor& lhs, const NProto::TNodeDescriptor& rhs void FormatValue(TStringBuilderBase* builder, const TNodeDescriptor& descriptor, TStringBuf spec); // Accessors for some well-known addresses. -std::optional<TString> FindDefaultAddress(const TAddressMap& addresses); -const TString& GetDefaultAddress(const TAddressMap& addresses); -const TString& GetDefaultAddress(const NProto::TAddressMap& addresses); +std::optional<std::string> FindDefaultAddress(const TAddressMap& addresses); +const std::string& GetDefaultAddress(const TAddressMap& addresses); +const std::string& GetDefaultAddress(const NProto::TAddressMap& addresses); -const TString& GetAddressOrThrow(const TAddressMap& addresses, const TNetworkPreferenceList& networks); -std::optional<TString> FindAddress(const TAddressMap& addresses, const TNetworkPreferenceList& networks); +const std::string& GetAddressOrThrow(const TAddressMap& addresses, const TNetworkPreferenceList& networks); +std::optional<std::string> FindAddress(const TAddressMap& addresses, const TNetworkPreferenceList& networks); const TAddressMap& GetAddressesOrThrow(const TNodeAddressMap& nodeAddresses, EAddressType type); @@ -162,8 +162,8 @@ public: std::vector<TNodeDescriptor> GetDescriptors(const NChunkClient::TChunkReplicaList& replicas) const; std::vector<std::pair<NNodeTrackerClient::TNodeId, TNodeDescriptor>> GetAllDescriptors() const; - const TNodeDescriptor* FindDescriptor(const TString& address); - const TNodeDescriptor& GetDescriptor(const TString& address); + const TNodeDescriptor* FindDescriptor(const std::string& address); + const TNodeDescriptor& GetDescriptor(const std::string& address); void Save(TStreamSaveContext& context) const; void Load(TStreamLoadContext& context); diff --git a/yt/yt/client/node_tracker_client/public.cpp b/yt/yt/client/node_tracker_client/public.cpp index 0ffc8e4ee8..3f50ece7ff 100644 --- a/yt/yt/client/node_tracker_client/public.cpp +++ b/yt/yt/client/node_tracker_client/public.cpp @@ -4,7 +4,7 @@ namespace NYT::NNodeTrackerClient { //////////////////////////////////////////////////////////////////////////////// -const TString DefaultNetworkName("default"); +const std::string DefaultNetworkName("default"); const TNetworkPreferenceList DefaultNetworkPreferences{DefaultNetworkName}; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/node_tracker_client/public.h b/yt/yt/client/node_tracker_client/public.h index f0d44bbf8d..bbba404eed 100644 --- a/yt/yt/client/node_tracker_client/public.h +++ b/yt/yt/client/node_tracker_client/public.h @@ -50,11 +50,11 @@ using TRackId = NObjectClient::TObjectId; using TDataCenterId = NObjectClient::TObjectId; // Only domain names, without port number. -using TNetworkAddressList = std::vector<std::pair<TString, TString>>; -using TNetworkPreferenceList = std::vector<TString>; +using TNetworkAddressList = std::vector<std::pair<std::string, std::string>>; +using TNetworkPreferenceList = std::vector<std::string>; // Network -> host:port. -using TAddressMap = THashMap<TString, TString>; +using TAddressMap = THashMap<std::string, std::string>; // Address type (e.g. RPC, HTTP) -> network -> host:port. using TNodeAddressMap = THashMap<EAddressType, TAddressMap>; @@ -62,7 +62,7 @@ using TNodeAddressMap = THashMap<EAddressType, TAddressMap>; DECLARE_REFCOUNTED_CLASS(TNodeDirectory) class TNodeDescriptor; -extern const TString DefaultNetworkName; +extern const std::string DefaultNetworkName; extern const TNetworkPreferenceList DefaultNetworkPreferences; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/queue_client/common.h b/yt/yt/client/queue_client/common.h index 9403017410..2089c9d205 100644 --- a/yt/yt/client/queue_client/common.h +++ b/yt/yt/client/queue_client/common.h @@ -13,7 +13,7 @@ namespace NYT::NQueueClient { // TODO(achulkov2): Replace this with TRichYPath in YT-18038. struct TCrossClusterReference { - TString Cluster; + std::string Cluster; NYPath::TYPath Path; bool operator==(const TCrossClusterReference& other) const; @@ -33,7 +33,7 @@ void Serialize(const TCrossClusterReference& queueRef, NYson::IYsonConsumer* con struct TProfilingTags { - TString Cluster; + std::string Cluster; TString LeadingStatus; TString QueueAgentStage; TString ObjectType; diff --git a/yt/yt/client/table_client/wire_protocol.cpp b/yt/yt/client/table_client/wire_protocol.cpp index 7ca676dd02..c4b11c926b 100644 --- a/yt/yt/client/table_client/wire_protocol.cpp +++ b/yt/yt/client/table_client/wire_protocol.cpp @@ -1196,7 +1196,7 @@ class TWireProtocolRowsetWriter public: TWireProtocolRowsetWriter( NCompression::ECodec codecId, - size_t desiredUncompressedBlockSize, + i64 desiredUncompressedBlockSize, TTableSchemaPtr schema, bool schemaful, const NLogging::TLogger& logger) @@ -1296,7 +1296,7 @@ private: IWireProtocolRowsetWriterPtr CreateWireProtocolRowsetWriter( NCompression::ECodec codecId, - size_t desiredUncompressedBlockSize, + i64 desiredUncompressedBlockSize, TTableSchemaPtr schema, bool schemaful, const NLogging::TLogger& logger) diff --git a/yt/yt/client/table_client/wire_protocol.h b/yt/yt/client/table_client/wire_protocol.h index b83888b1ab..e8a496280e 100644 --- a/yt/yt/client/table_client/wire_protocol.h +++ b/yt/yt/client/table_client/wire_protocol.h @@ -316,7 +316,7 @@ DEFINE_REFCOUNTED_TYPE(IWireProtocolRowsetWriter) IWireProtocolRowsetWriterPtr CreateWireProtocolRowsetWriter( NCompression::ECodec codecId, - size_t desiredUncompressedBlockSize, + i64 desiredUncompressedBlockSize, NTableClient::TTableSchemaPtr schema, bool isSchemaful, const NLogging::TLogger& logger); diff --git a/yt/yt/client/transaction_client/remote_timestamp_provider.cpp b/yt/yt/client/transaction_client/remote_timestamp_provider.cpp index a29cea5ece..d523aaf188 100644 --- a/yt/yt/client/transaction_client/remote_timestamp_provider.cpp +++ b/yt/yt/client/transaction_client/remote_timestamp_provider.cpp @@ -49,7 +49,7 @@ IChannelPtr CreateTimestampProviderChannel( IChannelPtr CreateTimestampProviderChannelFromAddresses( TRemoteTimestampProviderConfigPtr config, IChannelFactoryPtr channelFactory, - const std::vector<TString>& discoveredAddresses) + const std::vector<std::string>& discoveredAddresses) { auto channelConfig = CloneYsonStruct(config); if (!discoveredAddresses.empty()) { diff --git a/yt/yt/client/transaction_client/remote_timestamp_provider.h b/yt/yt/client/transaction_client/remote_timestamp_provider.h index 806f47a5b3..cf45e1fca9 100644 --- a/yt/yt/client/transaction_client/remote_timestamp_provider.h +++ b/yt/yt/client/transaction_client/remote_timestamp_provider.h @@ -19,7 +19,7 @@ NRpc::IChannelPtr CreateTimestampProviderChannel( NRpc::IChannelPtr CreateTimestampProviderChannelFromAddresses( TRemoteTimestampProviderConfigPtr config, NRpc::IChannelFactoryPtr channelFactory, - const std::vector<TString>& addresses); + const std::vector<std::string>& addresses); ITimestampProviderPtr CreateBatchingTimestampProvider( ITimestampProviderPtr underlying, diff --git a/yt/yt/client/unittests/connection_ut.cpp b/yt/yt/client/unittests/connection_ut.cpp index c9baba4468..336d1a5b6d 100644 --- a/yt/yt/client/unittests/connection_ut.cpp +++ b/yt/yt/client/unittests/connection_ut.cpp @@ -24,13 +24,13 @@ TEST_F(TProxyUrlTest, ApplyProxyUrlAliasingRules) { { TString url = "markov"; - ApplyProxyUrlAliasingRules(url, THashMap<TString, TString>({{"primary", "localhost:12345"}})); + ApplyProxyUrlAliasingRules(url, THashMap<std::string, std::string>({{"primary", "localhost:12345"}})); ASSERT_EQ(url, "markov"); } // See ENV in ya.make { TString url = "primary"; - ApplyProxyUrlAliasingRules(url, THashMap<TString, TString>({{"primary", "localhost:12345"}})); + ApplyProxyUrlAliasingRules(url, THashMap<std::string, std::string>({{"primary", "localhost:12345"}})); ASSERT_EQ(url, "localhost:12345"); } } @@ -40,7 +40,7 @@ TEST_F(TProxyUrlTest, NormalizeHttpProxyUrl) ASSERT_EQ(NormalizeHttpProxyUrl("markov"), "http://markov.yt.yandex.net"); // See ENV in ya.make ASSERT_EQ( - NormalizeHttpProxyUrl("primary", THashMap<TString, TString>({{"primary", "localhost:12345"}})), + NormalizeHttpProxyUrl("primary", THashMap<std::string, std::string>({{"primary", "localhost:12345"}})), "http://localhost:12345"); } diff --git a/yt/yt/client/unittests/mock/client.h b/yt/yt/client/unittests/mock/client.h index 234a1c3131..39d7aa777b 100644 --- a/yt/yt/client/unittests/mock/client.h +++ b/yt/yt/client/unittests/mock/client.h @@ -272,7 +272,7 @@ public: MOCK_METHOD(TFuture<void>, SwitchLeader, ( NHydra::TCellId cellId, - const TString& newLeaderAddress, + const std::string& newLeaderAddress, const TSwitchLeaderOptions& options), (override)); @@ -286,17 +286,17 @@ public: (override)); MOCK_METHOD(TFuture<void>, KillProcess, ( - const TString& address, + const std::string& address, const TKillProcessOptions& options), (override)); MOCK_METHOD(TFuture<TString>, WriteCoreDump, ( - const TString& address, + const std::string& address, const TWriteCoreDumpOptions& options), (override)); MOCK_METHOD(TFuture<TGuid>, WriteLogBarrier, ( - const TString& address, + const std::string& address, const TWriteLogBarrierOptions& options), (override)); @@ -306,7 +306,7 @@ public: (override)); MOCK_METHOD(TFuture<void>, HealExecNode, ( - const TString& address, + const std::string& address, const THealExecNodeOptions& options), (override)); @@ -347,7 +347,7 @@ public: MOCK_METHOD(TFuture<TMaintenanceIdPerTarget>, AddMaintenance, ( EMaintenanceComponent component, - const TString& address, + const std::string& address, EMaintenanceType type, const TString& comment, const TAddMaintenanceOptions& options), @@ -355,7 +355,7 @@ public: MOCK_METHOD(TFuture<TMaintenanceCountsPerTarget>, RemoveMaintenance, ( EMaintenanceComponent component, - const TString& address, + const std::string& address, const TMaintenanceFilter& filter, const TRemoveMaintenanceOptions& options), (override)); @@ -679,26 +679,26 @@ public: (override)); MOCK_METHOD(TFuture<TDisableChunkLocationsResult>, DisableChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TDisableChunkLocationsOptions& options), (override)); MOCK_METHOD(TFuture<TDestroyChunkLocationsResult>, DestroyChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, bool recoverUnlinkedDisks, const std::vector<TGuid>& locationUuids, const TDestroyChunkLocationsOptions& options), (override)); MOCK_METHOD(TFuture<TResurrectChunkLocationsResult>, ResurrectChunkLocations, ( - const TString& nodeAddress, + const std::string& nodeAddress, const std::vector<TGuid>& locationUuids, const TResurrectChunkLocationsOptions& options), (override)); MOCK_METHOD(TFuture<TRequestRestartResult>, RequestRestart, ( - const TString& nodeAddress, + const std::string& nodeAddress, const TRequestRestartOptions& options), (override)); diff --git a/yt/yt/client/unittests/mock/connection.h b/yt/yt/client/unittests/mock/connection.h index bcbfdf1faf..3c30558003 100644 --- a/yt/yt/client/unittests/mock/connection.h +++ b/yt/yt/client/unittests/mock/connection.h @@ -19,7 +19,7 @@ public: MOCK_METHOD(TClusterTag, GetClusterTag, (), (const, override)); MOCK_METHOD(const TString&, GetLoggingTag, (), (const, override)); MOCK_METHOD(const TString&, GetClusterId, (), (const, override)); - MOCK_METHOD(const std::optional<TString>&, GetClusterName, (), (const, override)); + MOCK_METHOD(const std::optional<std::string>&, GetClusterName, (), (const, override)); MOCK_METHOD(IInvokerPtr, GetInvoker, (), (override)); diff --git a/yt/yt/client/ypath/rich.cpp b/yt/yt/client/ypath/rich.cpp index 138d41d5d9..b275c2ea04 100644 --- a/yt/yt/client/ypath/rich.cpp +++ b/yt/yt/client/ypath/rich.cpp @@ -655,14 +655,15 @@ std::optional<TSortColumns> TRichYPath::GetChunkSortColumns() const return FindAttribute<TSortColumns>(*this, "chunk_sort_columns"); } -std::optional<TString> TRichYPath::GetCluster() const +std::optional<std::string> TRichYPath::GetCluster() const { - return FindAttribute<TString>(*this, "cluster"); + return FindAttribute<std::string>(*this, "cluster"); } -void TRichYPath::SetCluster(const TString& value) +void TRichYPath::SetCluster(const std::string& value) { - Attributes().Set("cluster", value); + // TODO(babenko): switch to std::string + Attributes().Set("cluster", TString(value)); } std::optional<std::vector<TString>> TRichYPath::GetClusters() const diff --git a/yt/yt/client/ypath/rich.h b/yt/yt/client/ypath/rich.h index ad84c12848..0e483b4838 100644 --- a/yt/yt/client/ypath/rich.h +++ b/yt/yt/client/ypath/rich.h @@ -157,8 +157,8 @@ public: std::optional<NTableClient::TSortColumns> GetChunkSortColumns() const; // "cluster" - std::optional<TString> GetCluster() const; - void SetCluster(const TString& value); + std::optional<std::string> GetCluster() const; + void SetCluster(const std::string& value); // "clusters" std::optional<std::vector<TString>> GetClusters() const; diff --git a/yt/yt/core/bus/bus.h b/yt/yt/core/bus/bus.h index bf8fc62101..5140baf33f 100644 --- a/yt/yt/core/bus/bus.h +++ b/yt/yt/core/bus/bus.h @@ -78,7 +78,7 @@ struct IBus //! Returns the bus' endpoint address as it was provided by the configuration (e.g.: non-resolved FQDN). //! Empty if it is not supported by the implementation (e.g.: Unix sockets). - virtual const TString& GetEndpointAddress() const = 0; + virtual const std::string& GetEndpointAddress() const = 0; //! Returns the bus' endpoint network address (e.g. a resolved IP address). //! Null if it is not supported by the implementation (e.g. for a client-side bus). diff --git a/yt/yt/core/bus/tcp/client.cpp b/yt/yt/core/bus/tcp/client.cpp index efcd140620..3fc419d7d9 100644 --- a/yt/yt/core/bus/tcp/client.cpp +++ b/yt/yt/core/bus/tcp/client.cpp @@ -63,7 +63,7 @@ public: return Connection_->GetEndpointAttributes(); } - const TString& GetEndpointAddress() const override + const std::string& GetEndpointAddress() const override { VERIFY_THREAD_AFFINITY_ANY(); return Connection_->GetEndpointAddress(); diff --git a/yt/yt/core/bus/tcp/config.cpp b/yt/yt/core/bus/tcp/config.cpp index 198d25ff83..6c158bd378 100644 --- a/yt/yt/core/bus/tcp/config.cpp +++ b/yt/yt/core/bus/tcp/config.cpp @@ -98,7 +98,7 @@ TBusServerConfigPtr TBusServerConfig::CreateTcp(int port) return config; } -TBusServerConfigPtr TBusServerConfig::CreateUds(const TString& socketPath) +TBusServerConfigPtr TBusServerConfig::CreateUds(const std::string& socketPath) { auto config = New<TBusServerConfig>(); config->UnixDomainSocketPath = socketPath; @@ -161,14 +161,14 @@ void TBusClientConfig::Register(TRegistrar registrar) }); } -TBusClientConfigPtr TBusClientConfig::CreateTcp(const TString& address) +TBusClientConfigPtr TBusClientConfig::CreateTcp(const std::string& address) { auto config = New<TBusClientConfig>(); config->Address = address; return config; } -TBusClientConfigPtr TBusClientConfig::CreateUds(const TString& socketPath) +TBusClientConfigPtr TBusClientConfig::CreateUds(const std::string& socketPath) { auto config = New<TBusClientConfig>(); config->UnixDomainSocketPath = socketPath; diff --git a/yt/yt/core/bus/tcp/config.h b/yt/yt/core/bus/tcp/config.h index 8baedade8f..bdda59c5da 100644 --- a/yt/yt/core/bus/tcp/config.h +++ b/yt/yt/core/bus/tcp/config.h @@ -18,7 +18,7 @@ class TMultiplexingBandConfig { public: int TosLevel; - THashMap<TString, int> NetworkToTosLevel; + THashMap<std::string, int> NetworkToTosLevel; REGISTER_YSON_STRUCT(TMultiplexingBandConfig); @@ -40,7 +40,7 @@ public: //! Used for profiling export and alerts. std::optional<i64> NetworkBandwidth; - THashMap<TString, std::vector<NNet::TIP6Network>> Networks; + THashMap<std::string, std::vector<NNet::TIP6Network>> Networks; TEnumIndexedArray<EMultiplexingBand, TMultiplexingBandConfigPtr> MultiplexingBands; @@ -68,7 +68,7 @@ public: std::optional<i64> NetworkBandwidth; - std::optional<THashMap<TString, std::vector<NNet::TIP6Network>>> Networks; + std::optional<THashMap<std::string, std::vector<NNet::TIP6Network>>> Networks; std::optional<TEnumIndexedArray<EMultiplexingBand, TMultiplexingBandConfigPtr>> MultiplexingBands; @@ -126,12 +126,12 @@ class TBusServerConfig { public: std::optional<int> Port; - std::optional<TString> UnixDomainSocketPath; + std::optional<std::string> UnixDomainSocketPath; int MaxBacklogSize; int MaxSimultaneousConnections; static TBusServerConfigPtr CreateTcp(int port); - static TBusServerConfigPtr CreateUds(const TString& socketPath); + static TBusServerConfigPtr CreateUds(const std::string& socketPath); REGISTER_YSON_STRUCT(TBusServerConfig); @@ -146,11 +146,11 @@ class TBusClientConfig : public TBusConfig { public: - std::optional<TString> Address; - std::optional<TString> UnixDomainSocketPath; + std::optional<std::string> Address; + std::optional<std::string> UnixDomainSocketPath; - static TBusClientConfigPtr CreateTcp(const TString& address); - static TBusClientConfigPtr CreateUds(const TString& socketPath); + static TBusClientConfigPtr CreateTcp(const std::string& address); + static TBusClientConfigPtr CreateUds(const std::string& socketPath); REGISTER_YSON_STRUCT(TBusClientConfig); diff --git a/yt/yt/core/bus/tcp/connection.cpp b/yt/yt/core/bus/tcp/connection.cpp index e084539c97..871d039ae9 100644 --- a/yt/yt/core/bus/tcp/connection.cpp +++ b/yt/yt/core/bus/tcp/connection.cpp @@ -109,8 +109,8 @@ TTcpConnection::TTcpConnection( const TString& endpointDescription, const IAttributeDictionary& endpointAttributes, const TNetworkAddress& endpointNetworkAddress, - const std::optional<TString>& endpointAddress, - const std::optional<TString>& unixDomainSocketPath, + const std::optional<std::string>& endpointAddress, + const std::optional<std::string>& unixDomainSocketPath, IMessageHandlerPtr handler, IPollerPtr poller, IPacketTranscoderFactory* packetTranscoderFactory, @@ -664,12 +664,12 @@ const IAttributeDictionary& TTcpConnection::GetEndpointAttributes() const return *EndpointAttributes_; } -const TString& TTcpConnection::GetEndpointAddress() const +const std::string& TTcpConnection::GetEndpointAddress() const { if (EndpointAddress_) { return *EndpointAddress_; } else { - static const TString EmptyAddress; + static const std::string EmptyAddress; return EmptyAddress; } } diff --git a/yt/yt/core/bus/tcp/connection.h b/yt/yt/core/bus/tcp/connection.h index 05a5bdc62f..0559282f6c 100644 --- a/yt/yt/core/bus/tcp/connection.h +++ b/yt/yt/core/bus/tcp/connection.h @@ -83,8 +83,8 @@ public: const TString& endpointDescription, const NYTree::IAttributeDictionary& endpointAttributes, const NNet::TNetworkAddress& endpointNetworkAddress, - const std::optional<TString>& endpointAddress, - const std::optional<TString>& unixDomainSocketPath, + const std::optional<std::string>& endpointAddress, + const std::optional<std::string>& unixDomainSocketPath, IMessageHandlerPtr handler, NConcurrency::IPollerPtr poller, IPacketTranscoderFactory* packetTranscoderFactory, @@ -106,7 +106,7 @@ public: // IBus implementation. const TString& GetEndpointDescription() const override; const NYTree::IAttributeDictionary& GetEndpointAttributes() const override; - const TString& GetEndpointAddress() const override; + const std::string& GetEndpointAddress() const override; const NNet::TNetworkAddress& GetEndpointNetworkAddress() const override; bool IsEndpointLocal() const override; bool IsEncrypted() const override; diff --git a/yt/yt/core/bus/tcp/server.cpp b/yt/yt/core/bus/tcp/server.cpp index 527c0e18c1..98903ce583 100644 --- a/yt/yt/core/bus/tcp/server.cpp +++ b/yt/yt/core/bus/tcp/server.cpp @@ -372,7 +372,8 @@ private: TNetworkAddress netAddress; if (Config_->UnixDomainSocketPath) { // NB(gritukan): Unix domain socket path cannot be longer than 108 symbols, so let's try to shorten it. - netAddress = TNetworkAddress::CreateUnixDomainSocketAddress(NFS::GetShortestPath(*Config_->UnixDomainSocketPath)); + // TODO(babenko): switch to std::string + netAddress = TNetworkAddress::CreateUnixDomainSocketAddress(NFS::GetShortestPath(TString(*Config_->UnixDomainSocketPath))); } else { netAddress = GetLocalBusAddress(*Config_->Port); } diff --git a/yt/yt/core/dns/ares_dns_resolver.cpp b/yt/yt/core/dns/ares_dns_resolver.cpp index b627cda872..fc415dc246 100644 --- a/yt/yt/core/dns/ares_dns_resolver.cpp +++ b/yt/yt/core/dns/ares_dns_resolver.cpp @@ -164,7 +164,7 @@ public: } TFuture<TNetworkAddress> Resolve( - const TString& hostName, + const std::string& hostName, const TDnsResolveOptions& options) override { EnsureRunning(); @@ -191,7 +191,7 @@ private: TAresDnsResolver* Owner; TGuid RequestId; TPromise<TNetworkAddress> Promise; - TString HostName; + std::string HostName; TDnsResolveOptions Options; NProfiling::TWallTimer Timer; TDelayedExecutorCookie TimeoutCookie; @@ -594,7 +594,7 @@ private: } std::unique_ptr<TResolveRequest> PrepareRequest( - const TString& hostName, + const std::string& hostName, const TDnsResolveOptions& options) { auto requestId = TGuid::Create(); diff --git a/yt/yt/core/dns/dns_resolver.h b/yt/yt/core/dns/dns_resolver.h index c19ab9e66d..ee7b5d4fd9 100644 --- a/yt/yt/core/dns/dns_resolver.h +++ b/yt/yt/core/dns/dns_resolver.h @@ -24,7 +24,7 @@ struct IDnsResolver : public TRefCounted { virtual TFuture<NNet::TNetworkAddress> Resolve( - const TString& hostName, + const std::string& hostName, const TDnsResolveOptions& options) = 0; }; diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp index 4801474056..40107c3278 100644 --- a/yt/yt/core/net/address.cpp +++ b/yt/yt/core/net/address.cpp @@ -966,7 +966,7 @@ void Serialize(const TIP6Network& value, IYsonConsumer* consumer) //! Performs asynchronous host name resolution. class TAddressResolver::TImpl : public virtual TRefCounted - , private TAsyncExpiringCache<TString, TNetworkAddress> + , private TAsyncExpiringCache<std::string, TNetworkAddress> { public: explicit TImpl(TAddressResolverConfigPtr config) @@ -978,7 +978,7 @@ public: Configure(std::move(config)); } - TFuture<TNetworkAddress> Resolve(const TString& hostName) + TFuture<TNetworkAddress> Resolve(const std::string& hostName) { // Check if |address| parses into a valid IPv4 or IPv6 address. if (auto result = TNetworkAddress::TryParse(hostName); result.IsOK()) { @@ -1053,7 +1053,7 @@ private: TAtomicIntrusivePtr<IDnsResolver> DnsResolver_; - TFuture<TNetworkAddress> DoGet(const TString& hostName, bool /*isPeriodicUpdate*/) noexcept override + TFuture<TNetworkAddress> DoGet(const std::string& hostName, bool /*isPeriodicUpdate*/) noexcept override { TDnsResolveOptions options{ .EnableIPv4 = Config_->EnableIPv4, @@ -1102,7 +1102,7 @@ TAddressResolver* TAddressResolver::Get() return LeakySingleton<TAddressResolver>(); } -TFuture<TNetworkAddress> TAddressResolver::Resolve(const TString& address) +TFuture<TNetworkAddress> TAddressResolver::Resolve(const std::string& address) { return Impl_->Resolve(address); } diff --git a/yt/yt/core/net/address.h b/yt/yt/core/net/address.h index 8bca3e4add..6f77b1b65f 100644 --- a/yt/yt/core/net/address.h +++ b/yt/yt/core/net/address.h @@ -186,7 +186,7 @@ public: * Calls |getaddrinfo| and returns the first entry belonging to |AF_INET| or |AF_INET6| family. * Caches successful resolutions. */ - TFuture<TNetworkAddress> Resolve(const TString& address); + TFuture<TNetworkAddress> Resolve(const std::string& address); //! Returns the currently installed global DNS resolver. NDns::IDnsResolverPtr GetDnsResolver(); diff --git a/yt/yt/core/rpc/balancing_channel.cpp b/yt/yt/core/rpc/balancing_channel.cpp index 5231086218..f5dbc43ec3 100644 --- a/yt/yt/core/rpc/balancing_channel.cpp +++ b/yt/yt/core/rpc/balancing_channel.cpp @@ -142,7 +142,7 @@ private: { const auto& endpointSets = endpointSetsOrError.ValueOrThrow(); - std::vector<TString> allAddresses; + std::vector<std::string> allAddresses; std::vector<TError> errors; for (const auto& endpointSetOrError : endpointSets) { if (!endpointSetOrError.IsOK()) { diff --git a/yt/yt/core/rpc/bus/channel.cpp b/yt/yt/core/rpc/bus/channel.cpp index 29746cda72..c10204f12d 100644 --- a/yt/yt/core/rpc/bus/channel.cpp +++ b/yt/yt/core/rpc/bus/channel.cpp @@ -1308,7 +1308,7 @@ public: YT_VERIFY(MemoryUsageTracker_); } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto config = TBusClientConfig::CreateTcp(address); config->Load(Config_, /*postprocess*/ true, /*setDefaults*/ false); @@ -1350,7 +1350,7 @@ public: YT_VERIFY(MemoryUsageTracker_); } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto config = TBusClientConfig::CreateUds(address); config->Load(Config_, /*postprocess*/ true, /*setDefaults*/ false); diff --git a/yt/yt/core/rpc/caching_channel_factory.cpp b/yt/yt/core/rpc/caching_channel_factory.cpp index 8f8c8c784a..df436d877f 100644 --- a/yt/yt/core/rpc/caching_channel_factory.cpp +++ b/yt/yt/core/rpc/caching_channel_factory.cpp @@ -31,7 +31,7 @@ public: TCachedChannel( TCachingChannelFactory* factory, IChannelPtr underlyingChannel, - const TString& address) + const std::string& address) : TChannelWrapper(std::move(underlyingChannel)) , Factory_(factory) , Address_(address) @@ -96,14 +96,14 @@ public: ExpirationExecutor_->Start(); } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { return DoCreateChannel( address, [&] { return UnderlyingFactory_->CreateChannel(address); }); } - void EvictChannel(const TString& address, IChannel* evictableChannel) + void EvictChannel(const std::string& address, IChannel* evictableChannel) { auto guard = WriterGuard(SpinLock_); @@ -130,15 +130,15 @@ private: TPeriodicExecutorPtr ExpirationExecutor_; YT_DECLARE_SPIN_LOCK(NThreading::TReaderWriterSpinLock, SpinLock_); - THashMap<TString, TCachedChannelPtr> StrongChannelMap_; - THashMap<TString, TWeakPtr<TCachedChannel>> WeakChannelMap_; + THashMap<std::string, TCachedChannelPtr> StrongChannelMap_; + THashMap<std::string, TWeakPtr<TCachedChannel>> WeakChannelMap_; - using TTtlItem = std::pair<TString, TWeakPtr<TCachedChannel>>; + using TTtlItem = std::pair<std::string, TWeakPtr<TCachedChannel>>; TMpscStack<TTtlItem> TtlRegisterQueue_; std::vector<TTtlItem> TtlCheckQueue_; template <class TFactory> - IChannelPtr DoCreateChannel(const TString& address, const TFactory& factory) + IChannelPtr DoCreateChannel(const std::string& address, const TFactory& factory) { { auto readerGuard = ReaderGuard(SpinLock_); @@ -195,7 +195,7 @@ private: } } - void RegisterChannelForTtlChecks(const TString& address, const TCachedChannelPtr& channel) + void RegisterChannelForTtlChecks(const std::string& address, const TCachedChannelPtr& channel) { TtlRegisterQueue_.Enqueue({address, channel}); } diff --git a/yt/yt/core/rpc/channel.h b/yt/yt/core/rpc/channel.h index f3ebd37636..1a815d8878 100644 --- a/yt/yt/core/rpc/channel.h +++ b/yt/yt/core/rpc/channel.h @@ -135,7 +135,7 @@ DEFINE_REFCOUNTED_TYPE(IChannel) struct IChannelFactory : public virtual TRefCounted { - virtual IChannelPtr CreateChannel(const TString& address) = 0; + virtual IChannelPtr CreateChannel(const std::string& address) = 0; }; DEFINE_REFCOUNTED_TYPE(IChannelFactory) diff --git a/yt/yt/core/rpc/client.cpp b/yt/yt/core/rpc/client.cpp index 2dbc67f888..9beb0c3bf6 100644 --- a/yt/yt/core/rpc/client.cpp +++ b/yt/yt/core/rpc/client.cpp @@ -640,7 +640,7 @@ void TClientResponse::HandleAcknowledgement() State_.compare_exchange_strong(expected, EState::Ack); } -void TClientResponse::HandleResponse(TSharedRefArray message, TString address) +void TClientResponse::HandleResponse(TSharedRefArray message, const std::string& address) { auto prevState = State_.exchange(EState::Done); YT_ASSERT(prevState == EState::Sent || prevState == EState::Ack); @@ -648,14 +648,14 @@ void TClientResponse::HandleResponse(TSharedRefArray message, TString address) GetInvoker()->Invoke(BIND(&TClientResponse::DoHandleResponse, MakeStrong(this), Passed(std::move(message)), - Passed(std::move(address)))); + address)); } -void TClientResponse::DoHandleResponse(TSharedRefArray message, TString address) +void TClientResponse::DoHandleResponse(TSharedRefArray message, const std::string& address) { NProfiling::TWallTimer timer; - Address_ = std::move(address); + Address_ = address; try { Deserialize(std::move(message)); diff --git a/yt/yt/core/rpc/client.h b/yt/yt/core/rpc/client.h index c67980d0d5..97a01be51e 100644 --- a/yt/yt/core/rpc/client.h +++ b/yt/yt/core/rpc/client.h @@ -294,7 +294,7 @@ struct IClientResponseHandler * \param message A message containing the response. * \param address Address of the response sender. Empty if it is not supported by the underlying RPC stack. */ - virtual void HandleResponse(TSharedRefArray message, TString address) = 0; + virtual void HandleResponse(TSharedRefArray message, const std::string& address) = 0; //! Called if the request fails. /*! @@ -353,7 +353,7 @@ protected: // IClientResponseHandler implementation. void HandleError(TError error) override; void HandleAcknowledgement() override; - void HandleResponse(TSharedRefArray message, TString address) override; + void HandleResponse(TSharedRefArray message, const std::string& address) override; void HandleStreamingPayload(const TStreamingPayload& payload) override; void HandleStreamingFeedback(const TStreamingFeedback& feedback) override; @@ -371,7 +371,7 @@ private: void TraceResponse(); void DoHandleError(TError error); - void DoHandleResponse(TSharedRefArray message, TString address); + void DoHandleResponse(TSharedRefArray message, const std::string& address); void Deserialize(TSharedRefArray responseMessage); }; diff --git a/yt/yt/core/rpc/config.h b/yt/yt/core/rpc/config.h index 00235cda77..f77fb077d2 100644 --- a/yt/yt/core/rpc/config.h +++ b/yt/yt/core/rpc/config.h @@ -327,7 +327,7 @@ class TBalancingChannelConfig { public: //! First option: static list of addresses. - std::optional<std::vector<TString>> Addresses; + std::optional<std::vector<std::string>> Addresses; //! Disables discovery and balancing when just one address is given. //! This is vital for jobs since node's redirector is incapable of handling diff --git a/yt/yt/core/rpc/dynamic_channel_pool.cpp b/yt/yt/core/rpc/dynamic_channel_pool.cpp index 6581b3080f..a469175212 100644 --- a/yt/yt/core/rpc/dynamic_channel_pool.cpp +++ b/yt/yt/core/rpc/dynamic_channel_pool.cpp @@ -115,16 +115,16 @@ public: })); } - void SetPeers(std::vector<TString> addresses) + void SetPeers(std::vector<std::string> addresses) { SortUnique(addresses); Shuffle(addresses.begin(), addresses.end()); - THashSet<TString> addressSet(addresses.begin(), addresses.end()); + THashSet<std::string> addressSet(addresses.begin(), addresses.end()); { auto guard = WriterGuard(SpinLock_); - std::vector<TString> addressesToRemove; + std::vector<std::string> addressesToRemove; for (const auto& address : ActiveAddresses_) { if (!addressSet.contains(address)) { @@ -205,10 +205,10 @@ private: TError PeerDiscoveryError_; TError LastGlobalDiscoveryError_; - THashSet<TString> ActiveAddresses_; - THashSet<TString> BannedAddresses_; + THashSet<std::string> ActiveAddresses_; + THashSet<std::string> BannedAddresses_; - THashMap<TString, TPeerPollerPtr> AddressToPoller_; + THashMap<std::string, TPeerPollerPtr> AddressToPoller_; IViablePeerRegistryPtr ViablePeerRegistry_; @@ -218,9 +218,10 @@ private: struct TNoMorePeers { }; using TPickPeerResult = std::variant< - TString, + std::string, TTooManyConcurrentRequests, - TNoMorePeers>; + TNoMorePeers + >; class TDiscoverySession : public TRefCounted @@ -243,7 +244,7 @@ private: TDispatcher::Get()->GetLightInvoker()->Invoke(BIND_NO_PROPAGATE(&TDiscoverySession::DoRun, MakeStrong(this))); } - void OnPeerDiscovered(const TString& address) + void OnPeerDiscovered(const std::string& address) { AddViablePeer(address); Success_.store(true); @@ -259,8 +260,8 @@ private: std::atomic<bool> Success_ = false; YT_DECLARE_SPIN_LOCK(NThreading::TSpinLock, SpinLock_); - THashSet<TString> RequestedAddresses_; - THashSet<TString> RequestingAddresses_; + THashSet<std::string> RequestedAddresses_; + THashSet<std::string> RequestingAddresses_; static constexpr int MaxDiscoveryErrorsToKeep = 100; std::deque<TError> PeerDiscoveryErrors_; @@ -287,7 +288,7 @@ private: } mustBreak = true; }, - [&] (const TString& address) { + [&] (const std::string& address) { QueryPeer(address); }); @@ -297,7 +298,7 @@ private: } } - void QueryPeer(const TString& address) + void QueryPeer(const std::string& address) { auto owner = Owner_.Lock(); if (!owner) { @@ -324,7 +325,7 @@ private: } void OnResponse( - const TString& address, + const std::string& address, const TErrorOr<TPeerDiscoveryResponse> rspOrError) { auto owner = Owner_.Lock(); @@ -337,7 +338,7 @@ private: YT_LOG_DEBUG_IF(authError, "Peer has reported authentication error on discovery (Address: %v)", address); if (rspOrError.IsOK() || authError) { - auto suggestedAddresses = authError ? std::vector<TString>() : rspOrError.Value().Addresses; + auto suggestedAddresses = authError ? std::vector<std::string>() : rspOrError.Value().Addresses; bool up = authError ? true : rspOrError.Value().IsUp; if (!suggestedAddresses.empty()) { @@ -385,7 +386,7 @@ private: return owner->PickPeer(&RequestingAddresses_, &RequestedAddresses_); } - void OnPeerQueried(const TString& address) + void OnPeerQueried(const std::string& address) { auto guard = Guard(SpinLock_); YT_VERIFY(RequestingAddresses_.erase(address) == 1); @@ -397,7 +398,7 @@ private: return !RequestingAddresses_.empty(); } - void BanPeer(const TString& address, const TError& error, TDuration backoffTime) + void BanPeer(const std::string& address, const TError& error, TDuration backoffTime) { auto owner = Owner_.Lock(); if (!owner) { @@ -423,7 +424,7 @@ private: return {PeerDiscoveryErrors_.begin(), PeerDiscoveryErrors_.end()}; } - void AddViablePeer(const TString& address) + void AddViablePeer(const std::string& address) { auto owner = Owner_.Lock(); if (!owner) { @@ -433,7 +434,7 @@ private: owner->AddViablePeer(address); } - void InvalidatePeer(const TString& address) + void InvalidatePeer(const std::string& address) { auto owner = Owner_.Lock(); if (!owner) { @@ -473,10 +474,10 @@ private: : public TRefCounted { public: - TPeerPoller(TImpl* owner, TString peerAddress) + TPeerPoller(TImpl* owner, const std::string& peerAddress) : Owner_(owner) , Logger(owner->Logger().WithTag("Address: %v", peerAddress)) - , PeerAddress_(std::move(peerAddress)) + , PeerAddress_(peerAddress) { } void Run() @@ -495,7 +496,7 @@ private: const TWeakPtr<TImpl> Owner_; const NLogging::TLogger Logger; - const TString PeerAddress_; + const std::string PeerAddress_; std::atomic<bool> Stopped_ = false; @@ -646,13 +647,13 @@ private: } } - TError MakePeerDownError(const TString& address) + TError MakePeerDownError(const std::string& address) { return TError("Peer %v is down", address) << *EndpointAttributes_; } - TError MakePeerDiscoveryFailedError(const TString& address, const TError& error) + TError MakePeerDiscoveryFailedError(const std::string& address, const TError& error) { return TError("Discovery request failed for peer %v", address) << *EndpointAttributes_ @@ -697,19 +698,19 @@ private: Y_UNUSED(RunDiscoverySession()); } - void AddPeers(const std::vector<TString>& addresses) + void AddPeers(const std::vector<std::string>& addresses) { auto guard = WriterGuard(SpinLock_); DoAddPeers(addresses); } - void DoAddPeers(const std::vector<TString>& addresses) + void DoAddPeers(const std::vector<std::string>& addresses) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); PeerDiscoveryError_ = {}; - std::vector<TString> newAddresses; + std::vector<std::string> newAddresses; for (const auto& address : addresses) { if (!BannedAddresses_.contains(address) && !ActiveAddresses_.contains(address)) { newAddresses.push_back(address); @@ -726,7 +727,7 @@ private: ViablePeerRegistry_->MaybeRotateRandomPeer(); } - void AddPeer(const TString& address) + void AddPeer(const std::string& address) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -741,7 +742,7 @@ private: YT_LOG_DEBUG("Peer added (Address: %v)", address); } - void RemovePeer(const TString& address) + void RemovePeer(const std::string& address) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -762,8 +763,8 @@ private: } TPickPeerResult PickPeer( - THashSet<TString>* requestingAddresses, - THashSet<TString>* requestedAddresses) + THashSet<std::string>* requestingAddresses, + THashSet<std::string>* requestedAddresses) { auto guard = ReaderGuard(SpinLock_); @@ -771,7 +772,7 @@ private: return TTooManyConcurrentRequests(); } - std::vector<TString> candidates; + std::vector<std::string> candidates; candidates.reserve(ActiveAddresses_.size()); for (const auto& address : ActiveAddresses_) { @@ -792,7 +793,7 @@ private: return result; } - void BanPeer(const TString& address, TDuration backoffTime) + void BanPeer(const std::string& address, TDuration backoffTime) { { auto guard = WriterGuard(SpinLock_); @@ -811,7 +812,7 @@ private: backoffTime); } - void UnbanPeer(const TString& address) + void UnbanPeer(const std::string& address) { auto guard = WriterGuard(SpinLock_); if (BannedAddresses_.erase(address) != 1) { @@ -822,7 +823,7 @@ private: YT_LOG_DEBUG("Peer unbanned (Address: %v)", address); } - void OnPeerBanTimeout(const TString& address, bool aborted) + void OnPeerBanTimeout(const std::string& address, bool aborted) { if (aborted) { // If we are terminating -- do not unban anyone to prevent infinite retries. @@ -832,7 +833,7 @@ private: UnbanPeer(address); } - void AddViablePeer(const TString& address) + void AddViablePeer(const std::string& address) { bool added = ViablePeerRegistry_->RegisterPeer(address); @@ -841,7 +842,7 @@ private: added); } - void InvalidatePeer(const TString& address) + void InvalidatePeer(const std::string& address) { ViablePeerRegistry_->UnregisterPeer(address); } @@ -858,7 +859,7 @@ private: } void OnChannelFailed( - const TString& address, + const std::string& address, const IChannelPtr& channel, const TError& error) { @@ -877,7 +878,7 @@ private: evicted); } - IChannelPtr CreateChannel(const TString& address) + IChannelPtr CreateChannel(const std::string& address) { return CreateFailureDetectingChannel( ChannelFactory_->CreateChannel(address), @@ -926,7 +927,7 @@ TFuture<IChannelPtr> TDynamicChannelPool::GetChannel( return Impl_->GetChannel(request, hedgingOptions); } -void TDynamicChannelPool::SetPeers(const std::vector<TString>& addresses) +void TDynamicChannelPool::SetPeers(const std::vector<std::string>& addresses) { Impl_->SetPeers(addresses); } diff --git a/yt/yt/core/rpc/dynamic_channel_pool.h b/yt/yt/core/rpc/dynamic_channel_pool.h index 76013e753a..7ac5f2c233 100644 --- a/yt/yt/core/rpc/dynamic_channel_pool.h +++ b/yt/yt/core/rpc/dynamic_channel_pool.h @@ -39,7 +39,7 @@ public: const IClientRequestPtr& request, const std::optional<THedgingChannelOptions>& hedgingOptions = std::nullopt); - void SetPeers(const std::vector<TString>& addresses); + void SetPeers(const std::vector<std::string>& addresses); void SetPeerDiscoveryError(const TError& error); void Terminate(const TError& error); diff --git a/yt/yt/core/rpc/grpc/channel.cpp b/yt/yt/core/rpc/grpc/channel.cpp index 5072245a29..dbdd5bfb07 100644 --- a/yt/yt/core/rpc/grpc/channel.cpp +++ b/yt/yt/core/rpc/grpc/channel.cpp @@ -206,7 +206,7 @@ public: } // Custom methods. - const TString& GetEndpointAddress() const + const std::string& GetEndpointAddress() const { return EndpointAddress_; } @@ -722,7 +722,7 @@ class TChannelFactory : public IChannelFactory { public: - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto config = New<TChannelConfig>(); config->Address = address; diff --git a/yt/yt/core/rpc/grpc/server.cpp b/yt/yt/core/rpc/grpc/server.cpp index c005265d9b..e19bc7a47d 100644 --- a/yt/yt/core/rpc/grpc/server.cpp +++ b/yt/yt/core/rpc/grpc/server.cpp @@ -253,7 +253,7 @@ private: return {}; } - const TString& GetEndpointAddress() const override + const std::string& GetEndpointAddress() const override { return PeerAddressString_; } diff --git a/yt/yt/core/rpc/hedging_channel.cpp b/yt/yt/core/rpc/hedging_channel.cpp index 85b095ee0e..0b9fbd3c6f 100644 --- a/yt/yt/core/rpc/hedging_channel.cpp +++ b/yt/yt/core/rpc/hedging_channel.cpp @@ -44,7 +44,7 @@ public: // IClientResponseHandler implementation. void HandleAcknowledgement() override; - void HandleResponse(TSharedRefArray message, TString address) override; + void HandleResponse(TSharedRefArray message, const std::string& address) override; void HandleError(TError error) override; void HandleStreamingPayload(const TStreamingPayload& /*payload*/) override; void HandleStreamingFeedback(const TStreamingFeedback& /*feedback*/) override; @@ -114,7 +114,7 @@ public: responseHandler->HandleAcknowledgement(); } - void HandleResponse(TSharedRefArray message, TString address, bool backup) + void HandleResponse(TSharedRefArray message, const std::string& address, bool backup) { IClientResponseHandlerPtr responseHandler; { @@ -146,7 +146,7 @@ public: message = SetResponseHeader(std::move(message), header); } - responseHandler->HandleResponse(std::move(message), std::move(address)); + responseHandler->HandleResponse(std::move(message), address); } void HandleError(TError error, bool backup) @@ -307,9 +307,9 @@ void THedgingResponseHandler::HandleError(TError error) Session_->HandleError(std::move(error), Backup_); } -void THedgingResponseHandler::HandleResponse(TSharedRefArray message, TString address) +void THedgingResponseHandler::HandleResponse(TSharedRefArray message, const std::string& address) { - Session_->HandleResponse(std::move(message), std::move(address), Backup_); + Session_->HandleResponse(std::move(message), address, Backup_); } void THedgingResponseHandler::HandleStreamingPayload(const TStreamingPayload& /*payload*/) diff --git a/yt/yt/core/rpc/helpers.cpp b/yt/yt/core/rpc/helpers.cpp index 49d61147e6..c6fbdaa099 100644 --- a/yt/yt/core/rpc/helpers.cpp +++ b/yt/yt/core/rpc/helpers.cpp @@ -128,7 +128,7 @@ public: , Timeout_(timeout) { } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto underlyingChannel = UnderlyingFactory_->CreateChannel(address); return CreateDefaultTimeoutChannel(underlyingChannel, Timeout_); @@ -201,7 +201,7 @@ public: , AuthenticationIdentity_(identity) { } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto underlyingChannel = UnderlyingFactory_->CreateChannel(address); return CreateAuthenticatedChannel(underlyingChannel, AuthenticationIdentity_); @@ -272,7 +272,7 @@ public: , RealmId_(realmId) { } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto underlyingChannel = UnderlyingFactory_->CreateChannel(address); return CreateRealmChannel(underlyingChannel, RealmId_); @@ -369,9 +369,9 @@ private: UnderlyingHandler_->HandleAcknowledgement(); } - void HandleResponse(TSharedRefArray message, TString address) override + void HandleResponse(TSharedRefArray message, const std::string& address) override { - UnderlyingHandler_->HandleResponse(std::move(message), std::move(address)); + UnderlyingHandler_->HandleResponse(std::move(message), address); } void HandleError(TError error) override @@ -517,9 +517,9 @@ void SetCurrentAuthenticationIdentity(const IClientRequestPtr& request) SetAuthenticationIdentity(request, GetCurrentAuthenticationIdentity()); } -std::vector<TString> AddressesFromEndpointSet(const NServiceDiscovery::TEndpointSet& endpointSet) +std::vector<std::string> AddressesFromEndpointSet(const NServiceDiscovery::TEndpointSet& endpointSet) { - std::vector<TString> addresses; + std::vector<std::string> addresses; addresses.reserve(endpointSet.Endpoints.size()); for (const auto& endpoint : endpointSet.Endpoints) { addresses.push_back(NNet::BuildServiceAddress(endpoint.Fqdn, endpoint.Port)); diff --git a/yt/yt/core/rpc/helpers.h b/yt/yt/core/rpc/helpers.h index 792c43a0ea..c631684555 100644 --- a/yt/yt/core/rpc/helpers.h +++ b/yt/yt/core/rpc/helpers.h @@ -93,7 +93,7 @@ void WriteAuthenticationIdentityToProto(T* proto, const TAuthenticationIdentity& template <class T> TAuthenticationIdentity ParseAuthenticationIdentityFromProto(const T& proto); -std::vector<TString> AddressesFromEndpointSet(const NServiceDiscovery::TEndpointSet& endpointSet); +std::vector<std::string> AddressesFromEndpointSet(const NServiceDiscovery::TEndpointSet& endpointSet); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/http/channel.cpp b/yt/yt/core/rpc/http/channel.cpp index 4df4d37cb8..dfcf8b1e73 100644 --- a/yt/yt/core/rpc/http/channel.cpp +++ b/yt/yt/core/rpc/http/channel.cpp @@ -27,8 +27,8 @@ class THttpChannel : public IChannel { public: - explicit THttpChannel( - const TString& address, + THttpChannel( + const std::string& address, const NConcurrency::IPollerPtr& poller, bool isHttps, NHttps::TClientCredentialsConfigPtr credentials) @@ -111,7 +111,7 @@ public: } // Custom methods. - const TString& GetEndpointAddress() const + const std::string& GetEndpointAddress() const { return EndpointAddress_; } @@ -344,7 +344,7 @@ DEFINE_REFCOUNTED_TYPE(THttpChannel) } // namespace IChannelPtr CreateHttpChannel( - const TString& address, + const std::string& address, const NConcurrency::IPollerPtr& poller, bool isHttps, NHttps::TClientCredentialsConfigPtr credentials) diff --git a/yt/yt/core/rpc/http/channel.h b/yt/yt/core/rpc/http/channel.h index ad4bd2a0c4..c5a9d7de8c 100644 --- a/yt/yt/core/rpc/http/channel.h +++ b/yt/yt/core/rpc/http/channel.h @@ -12,7 +12,7 @@ namespace NYT::NRpc::NHttp { //! Creates a channel implemented via HTTP/HTTPs. NRpc::IChannelPtr CreateHttpChannel( - const TString& address, + const std::string& address, const NConcurrency::IPollerPtr& poller, bool isHttps = true, NHttps::TClientCredentialsConfigPtr credentials = nullptr diff --git a/yt/yt/core/rpc/http/server.cpp b/yt/yt/core/rpc/http/server.cpp index 73b32cf679..eb6545015f 100644 --- a/yt/yt/core/rpc/http/server.cpp +++ b/yt/yt/core/rpc/http/server.cpp @@ -64,7 +64,7 @@ public: return *EndpointAttributes_; } - const TString& GetEndpointAddress() const override + const std::string& GetEndpointAddress() const override { return EndpointAddress_; } diff --git a/yt/yt/core/rpc/local_channel.cpp b/yt/yt/core/rpc/local_channel.cpp index 11b7392836..cbe73574cc 100644 --- a/yt/yt/core/rpc/local_channel.cpp +++ b/yt/yt/core/rpc/local_channel.cpp @@ -180,7 +180,7 @@ private: return {}; } - const TString& GetEndpointAddress() const override + const std::string& GetEndpointAddress() const override { static const TString EmptyAddress; return EmptyAddress; diff --git a/yt/yt/core/rpc/null_channel.cpp b/yt/yt/core/rpc/null_channel.cpp index 41a1593d83..9e7b831925 100644 --- a/yt/yt/core/rpc/null_channel.cpp +++ b/yt/yt/core/rpc/null_channel.cpp @@ -17,8 +17,8 @@ class TNullChannel : public NRpc::IChannel { public: - explicit TNullChannel(TString address) - : Address_(std::move(address)) + explicit TNullChannel(const std::string& address) + : Address_(address) { } const TString& GetEndpointDescription() const override @@ -59,9 +59,9 @@ private: const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker(); }; -IChannelPtr CreateNullChannel(TString address) +IChannelPtr CreateNullChannel(const std::string& address) { - return New<TNullChannel>(std::move(address)); + return New<TNullChannel>(address); } //////////////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ class TNullChannelFactory : public IChannelFactory { public: - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { return CreateNullChannel(address); } diff --git a/yt/yt/core/rpc/null_channel.h b/yt/yt/core/rpc/null_channel.h index c3db18830c..a3a21f99af 100644 --- a/yt/yt/core/rpc/null_channel.h +++ b/yt/yt/core/rpc/null_channel.h @@ -6,7 +6,7 @@ namespace NYT::NRpc { //////////////////////////////////////////////////////////////////////////////// -IChannelPtr CreateNullChannel(TString address); +IChannelPtr CreateNullChannel(const std::string& address); IChannelFactoryPtr GetNullChannelFactory(); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/peer_discovery.cpp b/yt/yt/core/rpc/peer_discovery.cpp index 3b4ab1549d..d73f3d43ac 100644 --- a/yt/yt/core/rpc/peer_discovery.cpp +++ b/yt/yt/core/rpc/peer_discovery.cpp @@ -20,7 +20,7 @@ public: TFuture<TPeerDiscoveryResponse> Discover( IChannelPtr channel, - const TString& /*address*/, + const std::string& /*address*/, TDuration timeout, TDuration replyDelay, const std::string& serviceName) override @@ -48,7 +48,7 @@ private: return TPeerDiscoveryResponse{ .IsUp = rsp->up(), - .Addresses = FromProto<std::vector<TString>>(rsp->suggested_addresses()), + .Addresses = FromProto<std::vector<std::string>>(rsp->suggested_addresses()), }; } }; diff --git a/yt/yt/core/rpc/peer_discovery.h b/yt/yt/core/rpc/peer_discovery.h index 09a4149dc9..322dc99146 100644 --- a/yt/yt/core/rpc/peer_discovery.h +++ b/yt/yt/core/rpc/peer_discovery.h @@ -20,7 +20,7 @@ DEFINE_REFCOUNTED_TYPE(IDiscoverRequestHook); struct TPeerDiscoveryResponse { bool IsUp; - std::vector<TString> Addresses; + std::vector<std::string> Addresses; }; struct IPeerDiscovery @@ -28,7 +28,7 @@ struct IPeerDiscovery { virtual TFuture<TPeerDiscoveryResponse> Discover( IChannelPtr channel, - const TString& address, + const std::string& address, TDuration timeout, TDuration replyDelay, const std::string& serviceName) = 0; diff --git a/yt/yt/core/rpc/retrying_channel.cpp b/yt/yt/core/rpc/retrying_channel.cpp index 5e50f4e5bd..196cb9c3ee 100644 --- a/yt/yt/core/rpc/retrying_channel.cpp +++ b/yt/yt/core/rpc/retrying_channel.cpp @@ -232,12 +232,12 @@ private: Retry(); } - void HandleResponse(TSharedRefArray message, TString address) override + void HandleResponse(TSharedRefArray message, const std::string& address) override { YT_LOG_DEBUG("Request attempt succeeded (RequestId: %v)", Request_->GetRequestId()); - ResponseHandler_->HandleResponse(std::move(message), std::move(address)); + ResponseHandler_->HandleResponse(std::move(message), address); } void HandleStreamingPayload(const TStreamingPayload& /*payload*/) override diff --git a/yt/yt/core/rpc/serialized_channel.cpp b/yt/yt/core/rpc/serialized_channel.cpp index 12c76ad100..5e927673c3 100644 --- a/yt/yt/core/rpc/serialized_channel.cpp +++ b/yt/yt/core/rpc/serialized_channel.cpp @@ -72,9 +72,9 @@ private: UnderlyingHandler_->HandleAcknowledgement(); } - void HandleResponse(TSharedRefArray message, TString address) override + void HandleResponse(TSharedRefArray message, const std::string& address) override { - UnderlyingHandler_->HandleResponse(std::move(message), std::move(address)); + UnderlyingHandler_->HandleResponse(std::move(message), address); Owner_->OnRequestCompleted(); } diff --git a/yt/yt/core/rpc/static_channel_factory.cpp b/yt/yt/core/rpc/static_channel_factory.cpp index a4be915ae7..2f57915a71 100644 --- a/yt/yt/core/rpc/static_channel_factory.cpp +++ b/yt/yt/core/rpc/static_channel_factory.cpp @@ -6,13 +6,13 @@ using namespace NYT::NBus; //////////////////////////////////////////////////////////////////////////////// -TStaticChannelFactoryPtr TStaticChannelFactory::Add(const TString& address, IChannelPtr channel) +TStaticChannelFactoryPtr TStaticChannelFactory::Add(const std::string& address, IChannelPtr channel) { YT_VERIFY(ChannelMap.emplace(address, channel).second); return this; } -IChannelPtr TStaticChannelFactory::CreateChannel(const TString& address) +IChannelPtr TStaticChannelFactory::CreateChannel(const std::string& address) { auto it = ChannelMap.find(address); if (it == ChannelMap.end()) { diff --git a/yt/yt/core/rpc/static_channel_factory.h b/yt/yt/core/rpc/static_channel_factory.h index 43cc06c148..29a4fb83cb 100644 --- a/yt/yt/core/rpc/static_channel_factory.h +++ b/yt/yt/core/rpc/static_channel_factory.h @@ -12,8 +12,8 @@ class TStaticChannelFactory : public IChannelFactory { public: - TStaticChannelFactoryPtr Add(const TString& address, IChannelPtr channel); - IChannelPtr CreateChannel(const TString& address) override; + TStaticChannelFactoryPtr Add(const std::string& address, IChannelPtr channel); + IChannelPtr CreateChannel(const std::string& address) override; private: THashMap<TString, IChannelPtr> ChannelMap; diff --git a/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp b/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp index f927969c24..ef7592dcf2 100644 --- a/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp +++ b/yt/yt/core/rpc/unittests/handle_channel_failure_ut.cpp @@ -23,7 +23,7 @@ public: std::move(memoryUsageTracker)); } - IChannelPtr CreateChannel(const TString& address) + IChannelPtr CreateChannel(const std::string& address) { return TImpl::CreateChannel(address, address, {}); } @@ -47,7 +47,7 @@ TYPED_TEST(THandleChannelFailureTest, HandleChannelFailureTest) CreateTestService( workerPool->GetInvoker(), false, - BIND([&] (const TString& address) { + BIND([&] (const std::string& address) { return this->CreateChannel(address); }), outerMemoryUsageTracker), @@ -58,7 +58,7 @@ TYPED_TEST(THandleChannelFailureTest, HandleChannelFailureTest) CreateTestService( workerPool->GetInvoker(), false, - BIND([&] (const TString& address) { + BIND([&] (const std::string& address) { return this->CreateChannel(address); }), innerMemoryUsageTracker), diff --git a/yt/yt/core/rpc/unittests/lib/common.cpp b/yt/yt/core/rpc/unittests/lib/common.cpp deleted file mode 100644 index d906d82fd4..0000000000 --- a/yt/yt/core/rpc/unittests/lib/common.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "common.h" - -namespace NYT::NRpc { - -//////////////////////////////////////////////////////////////////////////////// - -TString TRpcOverUdsImpl::SocketPath_ = ""; - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NRpc diff --git a/yt/yt/core/rpc/unittests/lib/common.h b/yt/yt/core/rpc/unittests/lib/common.h index 25999404f6..4f24a3b964 100644 --- a/yt/yt/core/rpc/unittests/lib/common.h +++ b/yt/yt/core/rpc/unittests/lib/common.h @@ -175,8 +175,8 @@ public: } static IChannelPtr CreateChannel( - const TString& address, - const TString& serverAddress, + const std::string& address, + const std::string& serverAddress, THashMap<TString, NYTree::INodePtr> grpcArguments) { return TImpl::CreateChannel(address, serverAddress, std::move(grpcArguments)); @@ -195,8 +195,8 @@ class TRpcOverBusImpl { public: static IChannelPtr CreateChannel( - const TString& address, - const TString& /*serverAddress*/, + const std::string& address, + const std::string& /*serverAddress*/, THashMap<TString, NYTree::INodePtr> /*grpcArguments*/) { auto client = CreateBusClient(NYT::NBus::TBusClientConfig::CreateTcp(address)); @@ -363,8 +363,8 @@ public: static constexpr bool Secure = EnableSsl; static IChannelPtr CreateChannel( - const TString& address, - const TString& /*serverAddress*/, + const std::string& address, + const std::string& /*serverAddress*/, THashMap<TString, NYTree::INodePtr> grpcArguments) { auto channelConfig = New<NGrpc::TChannelConfig>(); @@ -441,8 +441,8 @@ public: } static IChannelPtr CreateChannel( - const TString& address, - const TString& serverAddress, + const std::string& address, + const std::string& serverAddress, THashMap<TString, NYTree::INodePtr> /*grpcArguments*/) { auto clientConfig = NYT::NBus::TBusClientConfig::CreateUds( @@ -452,7 +452,7 @@ public: } private: - static TString SocketPath_; + static inline std::string SocketPath_; }; //////////////////////////////////////////////////////////////////////////////// @@ -468,8 +468,8 @@ public: static constexpr bool Secure = false; static IChannelPtr CreateChannel( - const TString& address, - const TString& /*serverAddress*/, + const std::string& address, + const std::string& /*serverAddress*/, THashMap<TString, NYTree::INodePtr> /*grpcArguments*/) { static auto poller = NConcurrency::CreateThreadPoolPoller(4, "HttpChannelTest"); diff --git a/yt/yt/core/rpc/unittests/lib/test_service.h b/yt/yt/core/rpc/unittests/lib/test_service.h index 45d261f002..3bc224eee8 100644 --- a/yt/yt/core/rpc/unittests/lib/test_service.h +++ b/yt/yt/core/rpc/unittests/lib/test_service.h @@ -65,7 +65,7 @@ DEFINE_REFCOUNTED_TYPE(ITestService) //////////////////////////////////////////////////////////////////////////////// -using TTestCreateChannelCallback = TCallback<IChannelPtr(const TString& address)>; +using TTestCreateChannelCallback = TCallback<IChannelPtr(const std::string& address)>; ITestServicePtr CreateTestService( IInvokerPtr invoker, diff --git a/yt/yt/core/rpc/unittests/lib/ya.make b/yt/yt/core/rpc/unittests/lib/ya.make index 33588b10e8..772e9a6731 100644 --- a/yt/yt/core/rpc/unittests/lib/ya.make +++ b/yt/yt/core/rpc/unittests/lib/ya.make @@ -3,7 +3,6 @@ LIBRARY() INCLUDE(${ARCADIA_ROOT}/yt/ya_cpp.make.inc) SRCS( - common.cpp test_service.cpp test_service.proto no_baggage_service.cpp diff --git a/yt/yt/core/rpc/unittests/rpc_ut.cpp b/yt/yt/core/rpc/unittests/rpc_ut.cpp index 310cb73f67..be2a78de9a 100644 --- a/yt/yt/core/rpc/unittests/rpc_ut.cpp +++ b/yt/yt/core/rpc/unittests/rpc_ut.cpp @@ -1553,7 +1553,7 @@ TEST(TCachingChannelFactoryTest, IdleChannels) : public IChannelFactory { public: - IChannelPtr CreateChannel(const TString& /*address*/) override + IChannelPtr CreateChannel(const std::string& /*address*/) override { return CreateLocalChannel(Server_); } 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 382d8f142d..563ff3c3cf 100644 --- a/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp +++ b/yt/yt/core/rpc/unittests/viable_peer_registry_ut.cpp @@ -85,8 +85,9 @@ class TFakeChannel : public IChannel { public: - TFakeChannel(TString address, THashSet<TString>* channelRegistry) - : Address_(std::move(address)) + TFakeChannel(const std::string& address, THashSet<std::string>* channelRegistry) + : Address_(address) + , EndpointDescription_(address) , ChannelRegistry_(channelRegistry) { if (ChannelRegistry_) { @@ -96,7 +97,7 @@ public: const TString& GetEndpointDescription() const override { - return Address_; + return EndpointDescription_; } const NYTree::IAttributeDictionary& GetEndpointAttributes() const override @@ -135,29 +136,31 @@ public: } DEFINE_SIGNAL_OVERRIDE(void(const TError&), Terminated); + private: + const std::string Address_; + const TString EndpointDescription_; const IMemoryUsageTrackerPtr MemoryUsageTracker_ = GetNullMemoryUsageTracker(); - TString Address_; - THashSet<TString>* ChannelRegistry_; + THashSet<std::string>* ChannelRegistry_; }; class TFakeChannelFactory : public IChannelFactory { public: - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { return New<TFakeChannel>(address, &ChannelRegistry_); } - const THashSet<TString>& GetChannelRegistry() const + const THashSet<std::string>& GetChannelRegistry() const { return ChannelRegistry_; } private: - THashSet<TString> ChannelRegistry_; + THashSet<std::string> ChannelRegistry_; }; IViablePeerRegistryPtr CreateTestRegistry( @@ -180,13 +183,13 @@ IViablePeerRegistryPtr CreateTestRegistry( return CreateViablePeerRegistry( config, - BIND([=] (const TString& address) { return channelFactory->CreateChannel(address); }), + BIND([=] (const std::string& address) { return channelFactory->CreateChannel(address); }), Logger); } -std::vector<TString> AddressesFromChannels(const std::vector<IChannelPtr>& channels) +std::vector<std::string> AddressesFromChannels(const std::vector<IChannelPtr>& channels) { - std::vector<TString> result; + std::vector<std::string> result; for (const auto& channel: channels) { result.push_back(channel->GetEndpointDescription()); } diff --git a/yt/yt/core/rpc/viable_peer_registry.cpp b/yt/yt/core/rpc/viable_peer_registry.cpp index 876a777b8e..5fbcc4f93e 100644 --- a/yt/yt/core/rpc/viable_peer_registry.cpp +++ b/yt/yt/core/rpc/viable_peer_registry.cpp @@ -38,7 +38,7 @@ public: } } - bool RegisterPeer(const TString& address) override + bool RegisterPeer(const std::string& address) override { int priority = 0; if (Config_->PeerPriorityStrategy == EPeerPriorityStrategy::PreferLocal) { @@ -60,7 +60,7 @@ public: return peerAdded; } - bool UnregisterPeer(const TString& address) override + bool UnregisterPeer(const std::string& address) override { auto guard = WriterGuard(SpinLock_); bool peerUnregistered = GuardedUnregisterPeer(address); @@ -72,7 +72,7 @@ public: return peerUnregistered; } - bool UnregisterChannel(const TString& address, const IChannelPtr& channel) override + bool UnregisterChannel(const std::string& address, const IChannelPtr& channel) override { auto guard = WriterGuard(SpinLock_); @@ -119,7 +119,7 @@ public: InitPeersAvailablePromise(); } - std::optional<TString> MaybeRotateRandomPeer() override + std::optional<std::string> MaybeRotateRandomPeer() override { auto guard = WriterGuard(SpinLock_); @@ -177,14 +177,14 @@ public: return nullptr; } - auto it = HashToActiveChannel_.lower_bound(std::pair(hash, TString())); + auto it = HashToActiveChannel_.lower_bound(std::pair(hash, std::string())); auto rebaseIt = [&] { if (it == HashToActiveChannel_.end()) { it = HashToActiveChannel_.begin(); } }; - TCompactSet<TStringBuf, 16> seenAddresses; + TCompactSet<std::string, 16> seenAddresses; auto currentRandomIndex = randomIndex % ActivePeerToPriority_.Size(); while (true) { rebaseIt(); @@ -224,7 +224,7 @@ public: return result; } - std::vector<std::pair<TString, IChannelPtr>> PickRandomPeers(int peerCount = 1) const + std::vector<std::pair<std::string, IChannelPtr>> PickRandomPeers(int peerCount = 1) const { VERIFY_READER_SPINLOCK_AFFINITY(SpinLock_); @@ -232,7 +232,7 @@ public: int minPeersToPickFrom = std::max(Config_->MinPeerCountForPriorityAwareness, peerCount); - std::vector<std::pair<TString, IChannelPtr>> peers; + std::vector<std::pair<std::string, IChannelPtr>> peers; const auto& smallestPriorityPool = PriorityToActivePeers_.begin()->second; @@ -314,7 +314,7 @@ public: return channel; } - IChannelPtr GetChannel(const TString& address) const override + IChannelPtr GetChannel(const std::string& address) const override { auto guard = ReaderGuard(SpinLock_); @@ -338,7 +338,7 @@ public: private: const TViablePeerRegistryConfigPtr Config_; - const TCallback<IChannelPtr(TString address)> CreateChannel_; + const TCallback<IChannelPtr(const std::string& address)> CreateChannel_; const NLogging::TLogger Logger; const size_t ClientStickinessRandomNumber_ = RandomNumber<size_t>(); @@ -347,16 +347,16 @@ private: YT_DECLARE_SPIN_LOCK(NThreading::TReaderWriterSpinLock, SpinLock_); // Information for active peers with created channels. - std::map<int, TIndexedHashMap<TString, IChannelPtr>> PriorityToActivePeers_; - TIndexedHashMap<TString, int> ActivePeerToPriority_; + std::map<int, TIndexedHashMap<std::string, IChannelPtr>> PriorityToActivePeers_; + TIndexedHashMap<std::string, int> ActivePeerToPriority_; // A consistent-hashing storage for serving sticky requests. - std::map<std::pair<size_t, TString>, IChannelPtr> HashToActiveChannel_; + std::map<std::pair<size_t, std::string>, IChannelPtr> HashToActiveChannel_; // Information for non-active peers which go over the max peer count limit. - TIndexedHashMap<TString, int> BacklogPeers_; + TIndexedHashMap<std::string, int> BacklogPeers_; - THashMap<TString, int> BacklogPeerToPriority_; - std::map<int, TIndexedHashMap<TString, std::monostate>> PriorityToBacklogPeers_; + THashMap<std::string, int> BacklogPeerToPriority_; + std::map<int, TIndexedHashMap<std::string, std::monostate>> PriorityToBacklogPeers_; TPromise<void> PeersAvailablePromise_; @@ -398,7 +398,7 @@ private: //! Returns true if a new peer was successfully registered and false if it already existed. //! Trying to call this method for a currently viable address with a different priority than stored leads to failure. - bool RegisterPeerWithPriority(const TString& address, int priority) + bool RegisterPeerWithPriority(const std::string& address, int priority) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -463,7 +463,7 @@ private: } template <class F> - void GeneratePeerHashes(const TString& address, F f) + void GeneratePeerHashes(const std::string& address, F f) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -473,7 +473,7 @@ private: } } - bool GuardedUnregisterPeer(const TString& address) + bool GuardedUnregisterPeer(const std::string& address) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -520,7 +520,7 @@ private: } } - void AddActivePeer(const TString& address, int priority) + void AddActivePeer(const std::string& address, int priority) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -537,7 +537,7 @@ private: PriorityToActivePeers_[priority].Set(address, channel); } - void AddBacklogPeer(const TString& address, int priority) + void AddBacklogPeer(const std::string& address, int priority) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -545,7 +545,7 @@ private: PriorityToBacklogPeers_[priority].Set(address, {}); } - bool EraseActivePeer(const TString& address) + bool EraseActivePeer(const std::string& address) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); @@ -571,7 +571,7 @@ private: return true; } - bool EraseBacklogPeer(const TString& address) + bool EraseBacklogPeer(const std::string& address) { VERIFY_WRITER_SPINLOCK_AFFINITY(SpinLock_); diff --git a/yt/yt/core/rpc/viable_peer_registry.h b/yt/yt/core/rpc/viable_peer_registry.h index d0d1486875..f2e0b5eb16 100644 --- a/yt/yt/core/rpc/viable_peer_registry.h +++ b/yt/yt/core/rpc/viable_peer_registry.h @@ -27,20 +27,20 @@ struct IViablePeerRegistry //! Returns nullptr if the registry is empty. virtual IChannelPtr PickStickyChannel(const IClientRequestPtr& request) const = 0; //! Returns nullptr if this address is not an active peer. - virtual IChannelPtr GetChannel(const TString& address) const = 0; + virtual IChannelPtr GetChannel(const std::string& address) const = 0; //! Returns true if a new peer was actually registered and false if it already existed. - virtual bool RegisterPeer(const TString& address) = 0; + virtual bool RegisterPeer(const std::string& address) = 0; //! Returns true if this peer was actually unregistered. - virtual bool UnregisterPeer(const TString& address) = 0; + virtual bool UnregisterPeer(const std::string& address) = 0; //! Unregisters stored active peer with the given channel. //! Does nothing and returns false if the peer is no longer active //! or if the currently stored channel differs from the one given. - virtual bool UnregisterChannel(const TString& address, const IChannelPtr& channel) = 0; + virtual bool UnregisterChannel(const std::string& address, const IChannelPtr& channel) = 0; //! Tries to evict a random active peer and replace it with a peer from the backlog. //! The evicted peer is stored in the backlog instead. //! Returns the address of the rotated peer. - virtual std::optional<TString> MaybeRotateRandomPeer() = 0; + virtual std::optional<std::string> MaybeRotateRandomPeer() = 0; virtual std::vector<IChannelPtr> GetActiveChannels() const = 0; virtual void Clear() = 0; @@ -58,7 +58,7 @@ struct IViablePeerRegistry DEFINE_REFCOUNTED_TYPE(IViablePeerRegistry) -using TCreateChannelCallback = TCallback<IChannelPtr(const TString& address)>; +using TCreateChannelCallback = TCallback<IChannelPtr(const std::string& address)>; IViablePeerRegistryPtr CreateViablePeerRegistry( TViablePeerRegistryConfigPtr config, diff --git a/yt/yt/core/test_framework/public.h b/yt/yt/core/test_framework/public.h index 8850e5cdbc..9d4b8d7d69 100644 --- a/yt/yt/core/test_framework/public.h +++ b/yt/yt/core/test_framework/public.h @@ -8,8 +8,8 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// -using TServiceMap = THashMap<TString, NRpc::IServicePtr>; -using TRealmIdServiceMap = THashMap<TGuid, TServiceMap>; +using TServiceMap = THashMap<std::string, NRpc::IServicePtr>; +using TRealmIdServiceMap = THashMap<NRpc::TRealmId, TServiceMap>; DECLARE_REFCOUNTED_CLASS(TTestService); DECLARE_REFCOUNTED_CLASS(TTestChannelFactory); @@ -24,7 +24,7 @@ DECLARE_REFCOUNTED_CLASS(TTestBus); //////////////////////////////////////////////////////////////////////////////// -} // namespace NYT::NRpc +} // namespace NRpc //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/test_framework/test_proxy_service-inl.h b/yt/yt/core/test_framework/test_proxy_service-inl.h index 3a6556e2b5..0d74eb7e32 100644 --- a/yt/yt/core/test_framework/test_proxy_service-inl.h +++ b/yt/yt/core/test_framework/test_proxy_service-inl.h @@ -52,9 +52,9 @@ TRealmIdServiceMap ConvertToRealmIdMap(const TContainer& services) } template <class TContainer> -THashMap<TString, TRealmIdServiceMap> ConvertToAddressMap(const THashMap<TString, TContainer>& addressToServices) +THashMap<std::string, TRealmIdServiceMap> ConvertToAddressMap(const THashMap<std::string, TContainer>& addressToServices) { - THashMap<TString, TRealmIdServiceMap> result; + THashMap<std::string, TRealmIdServiceMap> result; for (const auto& [address, map] : addressToServices) { result[address] = ConvertToRealmIdMap(map); @@ -65,7 +65,7 @@ THashMap<TString, TRealmIdServiceMap> ConvertToAddressMap(const THashMap<TString template <class TAddressContainer, class TDefaultContainer> IChannelFactoryPtr CreateTestChannelFactory( - const THashMap<TString, TAddressContainer>& addressToServices, + const THashMap<std::string, TAddressContainer>& addressToServices, const TDefaultContainer& defaultServices) { return New<TTestChannelFactory>(ConvertToAddressMap(addressToServices), ConvertToRealmIdMap(defaultServices)); @@ -74,7 +74,7 @@ IChannelFactoryPtr CreateTestChannelFactory( template <class TDefaultContainer> IChannelFactoryPtr CreateTestChannelFactoryWithDefaultServices(const TDefaultContainer& defaultServices) { - return CreateTestChannelFactory(THashMap<TString, TDefaultContainer>{}, defaultServices); + return CreateTestChannelFactory(THashMap<std::string, TDefaultContainer>{}, defaultServices); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/test_framework/test_proxy_service.cpp b/yt/yt/core/test_framework/test_proxy_service.cpp index 692ebb65a8..56c6df767b 100644 --- a/yt/yt/core/test_framework/test_proxy_service.cpp +++ b/yt/yt/core/test_framework/test_proxy_service.cpp @@ -11,13 +11,13 @@ using NYT::FromProto; //////////////////////////////////////////////////////////////////////////////// TTestChannelFactory::TTestChannelFactory( - THashMap<TString, TRealmIdServiceMap> addressToServices, + THashMap<std::string, TRealmIdServiceMap> addressToServices, TRealmIdServiceMap defaultServices) : AddressToServices_(std::move(addressToServices)) , DefaultServices_(std::move(defaultServices)) { } -IChannelPtr TTestChannelFactory::CreateChannel(const TString& address) +IChannelPtr TTestChannelFactory::CreateChannel(const std::string& address) { return New<TTestChannel>(GetOrDefault(AddressToServices_, address, {}), DefaultServices_, address); } @@ -27,10 +27,10 @@ IChannelPtr TTestChannelFactory::CreateChannel(const TString& address) TTestChannel::TTestChannel( TRealmIdServiceMap services, TRealmIdServiceMap defaultServices, - TString address) + const std::string& address) : Services_(std::move(services)) , DefaultServices_(std::move(defaultServices)) - , Address_(std::move(address)) + , Address_(address) , Attributes_(ConvertToAttributes(BuildYsonStringFluently() .BeginMap() .Item("address").Value(Address_) @@ -85,7 +85,7 @@ const IServicePtr& TTestChannel::GetServiceOrThrow(const TServiceId& serviceId) } void TTestChannel::HandleRequestResult( - TString address, + const std::string& address, TGuid requestId, IClientResponseHandlerPtr response, const TError& error) @@ -174,8 +174,9 @@ const IMemoryUsageTrackerPtr& TTestChannel::GetChannelMemoryTracker() //////////////////////////////////////////////////////////////////////////////// -TTestBus::TTestBus(TString address) - : Address_(std::move(address)) +TTestBus::TTestBus(const std::string& address) + : Address_(address) + , EndpointDescription_(address) , Attributes_(ConvertToAttributes(BuildYsonStringFluently() .BeginMap() .Item("address").Value(Address_) @@ -185,7 +186,7 @@ TTestBus::TTestBus(TString address) const TString& TTestBus::GetEndpointDescription() const { - return Address_; + return EndpointDescription_; } const NYTree::IAttributeDictionary& TTestBus::GetEndpointAttributes() const @@ -193,7 +194,7 @@ const NYTree::IAttributeDictionary& TTestBus::GetEndpointAttributes() const return *Attributes_; } -const TString& TTestBus::GetEndpointAddress() const +const std::string& TTestBus::GetEndpointAddress() const { return Address_; } diff --git a/yt/yt/core/test_framework/test_proxy_service.h b/yt/yt/core/test_framework/test_proxy_service.h index c3dce7f78a..e92739e33f 100644 --- a/yt/yt/core/test_framework/test_proxy_service.h +++ b/yt/yt/core/test_framework/test_proxy_service.h @@ -25,13 +25,13 @@ class TTestChannelFactory { public: TTestChannelFactory( - THashMap<TString, TRealmIdServiceMap> addressToServices, + THashMap<std::string, TRealmIdServiceMap> addressToServices, TRealmIdServiceMap defaultServices); - IChannelPtr CreateChannel(const TString& address) override; + IChannelPtr CreateChannel(const std::string& address) override; private: - const THashMap<TString, TRealmIdServiceMap> AddressToServices_; + const THashMap<std::string, TRealmIdServiceMap> AddressToServices_; const TRealmIdServiceMap DefaultServices_; }; @@ -43,13 +43,13 @@ class TTestBus : public ::NYT::NBus::IBus { public: - explicit TTestBus(TString address); + explicit TTestBus(const std::string& address); const TString& GetEndpointDescription() const override; const NYTree::IAttributeDictionary& GetEndpointAttributes() const override; - const TString& GetEndpointAddress() const override; + const std::string& GetEndpointAddress() const override; const NNet::TNetworkAddress& GetEndpointNetworkAddress() const override; @@ -74,7 +74,8 @@ public: DECLARE_SIGNAL_OVERRIDE(void(const TError&), Terminated); private: - const TString Address_; + const std::string Address_; + const TString EndpointDescription_; const NYTree::IAttributeDictionaryPtr Attributes_; const NNet::TNetworkAddress NetworkAddress_; @@ -95,7 +96,7 @@ public: TTestChannel( TRealmIdServiceMap services, TRealmIdServiceMap defaultServices, - TString address); + const std::string& address); const TString& GetEndpointDescription() const override; @@ -131,7 +132,7 @@ private: THashMap<std::pair<TString, TGuid>, TTestBusPtr> RequestToBus_; void HandleRequestResult( - TString address, + const std::string& address, TGuid requestId, IClientResponseHandlerPtr responseHandler, const TError& error); @@ -166,7 +167,7 @@ DEFINE_REFCOUNTED_TYPE(TTestClientRequestControl); template <class TAddressContainer, class TDefaultContainer> IChannelFactoryPtr CreateTestChannelFactory( - const THashMap<TString, TAddressContainer>& addressToServices, + const THashMap<std::string, TAddressContainer>& addressToServices, const TDefaultContainer& defaultServices = {}); template <class TDefaultContainer> diff --git a/yt/yt/library/auth/credentials_injecting_channel.cpp b/yt/yt/library/auth/credentials_injecting_channel.cpp index 2ddd4c7898..7744a019fb 100644 --- a/yt/yt/library/auth/credentials_injecting_channel.cpp +++ b/yt/yt/library/auth/credentials_injecting_channel.cpp @@ -259,7 +259,7 @@ public: , ServiceTicketAuth_(std::move(serviceTicketAuth)) { } - IChannelPtr CreateChannel(const TString& address) override + IChannelPtr CreateChannel(const std::string& address) override { auto channel = UnderlyingFactory_->CreateChannel(address); if (!ServiceTicketAuth_) { |