diff options
author | osidorkin <osidorkin@yandex-team.com> | 2024-08-16 21:48:48 +0300 |
---|---|---|
committer | osidorkin <osidorkin@yandex-team.com> | 2024-08-16 22:00:57 +0300 |
commit | 0046422cdf7d52fdc7f8cacf92cb78744815b3af (patch) | |
tree | 0d88ae628a45e253b2259396ef1f754b6c52086f | |
parent | adab714a761bbbad2688678c439ca0b668176865 (diff) | |
download | ydb-0046422cdf7d52fdc7f8cacf92cb78744815b3af.tar.gz |
YT-21553: Add long-polling for replication cards cache
7129a02dcf5cb894b9786834aeb3a0737a53b392
-rw-r--r-- | yt/yt/client/chaos_client/config.cpp | 24 | ||||
-rw-r--r-- | yt/yt/client/chaos_client/config.h | 22 | ||||
-rw-r--r-- | yt/yt/client/chaos_client/public.h | 1 | ||||
-rw-r--r-- | yt/yt/client/chaos_client/replication_card_cache.h | 1 | ||||
-rw-r--r-- | yt/yt/client/ya.make | 1 | ||||
-rw-r--r-- | yt/yt/core/rpc/viable_peer_registry.cpp | 4 | ||||
-rw-r--r-- | yt/yt_proto/yt/core/rpc/proto/rpc.proto | 1 |
7 files changed, 51 insertions, 3 deletions
diff --git a/yt/yt/client/chaos_client/config.cpp b/yt/yt/client/chaos_client/config.cpp new file mode 100644 index 0000000000..2dce364270 --- /dev/null +++ b/yt/yt/client/chaos_client/config.cpp @@ -0,0 +1,24 @@ +#include "config.h" + +namespace NYT::NChaosClient { + +//////////////////////////////////////////////////////////////////////////////// + +void TReplicationCardCacheConfig::Register(TRegistrar registrar) +{ + registrar.Parameter("enable_watching", &TThis::EnableWatching) + .Default(false) + .DontSerializeDefault(); +} + +//////////////////////////////////////////////////////////////////////////////// + +void TReplicationCardCacheDynamicConfig::Register(TRegistrar registrar) +{ + registrar.Parameter("enable_watching", &TThis::EnableWatching) + .Optional(); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NChaosClient diff --git a/yt/yt/client/chaos_client/config.h b/yt/yt/client/chaos_client/config.h index bc284e856d..052e5d7d52 100644 --- a/yt/yt/client/chaos_client/config.h +++ b/yt/yt/client/chaos_client/config.h @@ -15,15 +15,33 @@ class TReplicationCardCacheConfig , public NRpc::TBalancingChannelConfig , public NRpc::TRetryingChannelConfig { +public: + bool EnableWatching; + REGISTER_YSON_STRUCT(TReplicationCardCacheConfig); - static void Register(TRegistrar) - { } + static void Register(TRegistrar registrar); }; DEFINE_REFCOUNTED_TYPE(TReplicationCardCacheConfig) //////////////////////////////////////////////////////////////////////////////// +class TReplicationCardCacheDynamicConfig + : public virtual NYTree::TYsonStruct +{ +public: + std::optional<bool> EnableWatching; + + REGISTER_YSON_STRUCT(TReplicationCardCacheDynamicConfig); + + static void Register(TRegistrar registrar); +}; + +DEFINE_REFCOUNTED_TYPE(TReplicationCardCacheDynamicConfig) + + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT::NChaosClient diff --git a/yt/yt/client/chaos_client/public.h b/yt/yt/client/chaos_client/public.h index 73baf9edd7..84964842d9 100644 --- a/yt/yt/client/chaos_client/public.h +++ b/yt/yt/client/chaos_client/public.h @@ -25,6 +25,7 @@ DECLARE_REFCOUNTED_STRUCT(TReplicationCard) DECLARE_REFCOUNTED_STRUCT(IReplicationCardCache) DECLARE_REFCOUNTED_CLASS(TReplicationCardCacheConfig) +DECLARE_REFCOUNTED_CLASS(TReplicationCardCacheDynamicConfig) struct TReplicationProgress; struct TReplicaHistoryItem; diff --git a/yt/yt/client/chaos_client/replication_card_cache.h b/yt/yt/client/chaos_client/replication_card_cache.h index ac75ab752d..259e38b776 100644 --- a/yt/yt/client/chaos_client/replication_card_cache.h +++ b/yt/yt/client/chaos_client/replication_card_cache.h @@ -27,6 +27,7 @@ struct IReplicationCardCache virtual TFuture<TReplicationCardPtr> GetReplicationCard(const TReplicationCardCacheKey& key) = 0; virtual void ForceRefresh(const TReplicationCardCacheKey& key, const TReplicationCardPtr& replicationCard) = 0; virtual void Clear() = 0; + virtual void Reconfigure(const TReplicationCardCacheDynamicConfigPtr& config) = 0; }; DEFINE_REFCOUNTED_TYPE(IReplicationCardCache) diff --git a/yt/yt/client/ya.make b/yt/yt/client/ya.make index 021717e062..60b7cdb362 100644 --- a/yt/yt/client/ya.make +++ b/yt/yt/client/ya.make @@ -61,6 +61,7 @@ SRCS( hydra/version.cpp + chaos_client/config.cpp chaos_client/helpers.cpp chaos_client/replication_card.cpp chaos_client/replication_card_cache.cpp diff --git a/yt/yt/core/rpc/viable_peer_registry.cpp b/yt/yt/core/rpc/viable_peer_registry.cpp index 77c840fb67..876a777b8e 100644 --- a/yt/yt/core/rpc/viable_peer_registry.cpp +++ b/yt/yt/core/rpc/viable_peer_registry.cpp @@ -166,7 +166,9 @@ public: } const auto& balancingExt = request->Header().GetExtension(NProto::TBalancingExt::balancing_ext); - auto hash = request->GetHash(); + auto hash = balancingExt.has_balancing_hint() + ? balancingExt.balancing_hint() + : request->GetHash(); auto randomNumber = balancingExt.enable_client_stickiness() ? ClientStickinessRandomNumber_ : RandomNumber<size_t>(); int stickyGroupSize = balancingExt.sticky_group_size(); auto randomIndex = randomNumber % stickyGroupSize; diff --git a/yt/yt_proto/yt/core/rpc/proto/rpc.proto b/yt/yt_proto/yt/core/rpc/proto/rpc.proto index c999caa4fc..6cd11f1d9e 100644 --- a/yt/yt_proto/yt/core/rpc/proto/rpc.proto +++ b/yt/yt_proto/yt/core/rpc/proto/rpc.proto @@ -106,6 +106,7 @@ message TBalancingExt optional bool enable_stickiness = 1; optional int32 sticky_group_size = 2 [default = 1]; optional bool enable_client_stickiness = 3; + optional uint64 balancing_hint = 4; } message TCredentialsExt |