diff options
author | alexmipt <alexmipt@yandex-team.com> | 2023-12-14 19:36:08 +0300 |
---|---|---|
committer | alexmipt <alexmipt@yandex-team.com> | 2023-12-14 20:14:23 +0300 |
commit | c68f7e8d18583fc189c8349895f3f3d8e84bd7bc (patch) | |
tree | ef2746db127f7874a2705cd4a50f88d328ddc2ca /yt | |
parent | 7af185ad218508a730b08251d4bdbdd4789cc779 (diff) | |
download | ydb-c68f7e8d18583fc189c8349895f3f3d8e84bd7bc.tar.gz |
YT-20123: make proto config && check it on const values Bundle Controller API
made proto, made c++ se-realisation for proto, made yson se-realisation for c++
for Bundle Controller API
Diffstat (limited to 'yt')
-rw-r--r-- | yt/yt/client/api/bundle_controller_client.cpp | 20 | ||||
-rw-r--r-- | yt/yt/client/api/bundle_controller_client.h | 22 | ||||
-rw-r--r-- | yt/yt/client/api/delegating_client.cpp | 2 | ||||
-rw-r--r-- | yt/yt/client/api/delegating_client.h | 2 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/client_impl.cpp | 2 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/client_impl.h | 2 | ||||
-rw-r--r-- | yt/yt/client/driver/bundle_controller_commands.cpp | 7 | ||||
-rw-r--r-- | yt/yt/client/federated/client.cpp | 2 | ||||
-rw-r--r-- | yt/yt/client/hedging/hedging.cpp | 2 | ||||
-rw-r--r-- | yt/yt/client/unittests/mock/client.h | 2 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/CMakeLists.darwin-arm64.txt | 13 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/CMakeLists.darwin-x86_64.txt | 13 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/CMakeLists.linux-aarch64.txt | 13 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/CMakeLists.linux-x86_64.txt | 13 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto | 52 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/ya.make | 2 |
16 files changed, 155 insertions, 14 deletions
diff --git a/yt/yt/client/api/bundle_controller_client.cpp b/yt/yt/client/api/bundle_controller_client.cpp index 454cbe5b4d..b22ff43d94 100644 --- a/yt/yt/client/api/bundle_controller_client.cpp +++ b/yt/yt/client/api/bundle_controller_client.cpp @@ -4,6 +4,26 @@ namespace NYT::NApi { //////////////////////////////////////////////////////////////////////////////// +void TBundleConfigDescriptor::Register(TRegistrar registrar) +{ + registrar.Parameter("bundle_name", &TThis::BundleName) + .Default(); + + registrar.Parameter("cpu_limits", &TThis::CpuLimits) + .DefaultNew(); + registrar.Parameter("memory_limits", &TThis::MemoryLimits) + .DefaultNew(); + + registrar.Parameter("rpc_proxy_count", &TThis::RpcProxyCount) + .Default(0); + registrar.Parameter("rpc_proxy_resource_guarantee", &TThis::RpcProxyResourceGuarantee) + .DefaultNew(); + registrar.Parameter("tablet_node_count", &TThis::TabletNodeCount) + .Default(0); + registrar.Parameter("tablet_node_resource_guarantee", &TThis::TabletNodeResourceGuarantee) + .DefaultNew(); +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NApi diff --git a/yt/yt/client/api/bundle_controller_client.h b/yt/yt/client/api/bundle_controller_client.h index 7d61f93562..5b7eaa582d 100644 --- a/yt/yt/client/api/bundle_controller_client.h +++ b/yt/yt/client/api/bundle_controller_client.h @@ -2,10 +2,16 @@ #include "client_common.h" +#include <yt/yt/ytlib/bundle_controller/bundle_controller_settings.h> + namespace NYT::NApi { //////////////////////////////////////////////////////////////////////////////// +DECLARE_REFCOUNTED_STRUCT(TBundleConfigDescriptor) + +//////////////////////////////////////////////////////////////////////////////// + struct TGetBundleConfigOptions : public TTimeoutOptions { }; @@ -13,19 +19,33 @@ struct TGetBundleConfigOptions //////////////////////////////////////////////////////////////////////////////// struct TBundleConfigDescriptor + : public NYTree::TYsonStruct { TString BundleName; + + NCellBalancer::TCpuLimitsPtr CpuLimits; + NCellBalancer::TMemoryLimitsPtr MemoryLimits; + int RpcProxyCount; + NCellBalancer::TInstanceResourcesPtr RpcProxyResourceGuarantee; + int TabletNodeCount; + NCellBalancer::TInstanceResourcesPtr TabletNodeResourceGuarantee; + + REGISTER_YSON_STRUCT(TBundleConfigDescriptor); + + static void Register(TRegistrar registrar); }; +DEFINE_REFCOUNTED_TYPE(TBundleConfigDescriptor) + //////////////////////////////////////////////////////////////////////////////// struct IBundleControllerClient { virtual ~IBundleControllerClient() = default; - virtual TFuture<TBundleConfigDescriptor> GetBundleConfig( + virtual TFuture<TBundleConfigDescriptorPtr> GetBundleConfig( const TString& bundleName, const TGetBundleConfigOptions& options = {}) = 0; }; diff --git a/yt/yt/client/api/delegating_client.cpp b/yt/yt/client/api/delegating_client.cpp index 75f4006502..c878d878ad 100644 --- a/yt/yt/client/api/delegating_client.cpp +++ b/yt/yt/client/api/delegating_client.cpp @@ -1004,7 +1004,7 @@ TFuture<void> TDelegatingClient::AlterQuery( return Underlying_->AlterQuery(queryId, options); } -TFuture<TBundleConfigDescriptor> TDelegatingClient::GetBundleConfig( +TFuture<TBundleConfigDescriptorPtr> TDelegatingClient::GetBundleConfig( const TString& bundleName, const TGetBundleConfigOptions& options) { diff --git a/yt/yt/client/api/delegating_client.h b/yt/yt/client/api/delegating_client.h index 07429b103f..15abcbedec 100644 --- a/yt/yt/client/api/delegating_client.h +++ b/yt/yt/client/api/delegating_client.h @@ -618,7 +618,7 @@ public: NQueryTrackerClient::TQueryId queryId, const TAlterQueryOptions& options) override; - virtual TFuture<TBundleConfigDescriptor> GetBundleConfig( + virtual TFuture<TBundleConfigDescriptorPtr> GetBundleConfig( const TString& bundleName, const TGetBundleConfigOptions& options = {}) override; diff --git a/yt/yt/client/api/rpc_proxy/client_impl.cpp b/yt/yt/client/api/rpc_proxy/client_impl.cpp index aa76339c5f..286b1785ef 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/client_impl.cpp @@ -2033,7 +2033,7 @@ TFuture<void> TClient::AlterQuery( ThrowUnimplemented("AlterQuery"); } -TFuture<TBundleConfigDescriptor> TClient::GetBundleConfig( +TFuture<TBundleConfigDescriptorPtr> TClient::GetBundleConfig( const TString& /*bundleName*/, const TGetBundleConfigOptions& /*options*/) { diff --git a/yt/yt/client/api/rpc_proxy/client_impl.h b/yt/yt/client/api/rpc_proxy/client_impl.h index e6ab691e43..77c1b429f8 100644 --- a/yt/yt/client/api/rpc_proxy/client_impl.h +++ b/yt/yt/client/api/rpc_proxy/client_impl.h @@ -482,7 +482,7 @@ public: const TString& passwordSha256, const TListUserTokensOptions& options) override; - TFuture<TBundleConfigDescriptor> GetBundleConfig( + TFuture<TBundleConfigDescriptorPtr> GetBundleConfig( const TString& bundleName, const TGetBundleConfigOptions& options = {}) override; diff --git a/yt/yt/client/driver/bundle_controller_commands.cpp b/yt/yt/client/driver/bundle_controller_commands.cpp index d7591c8635..b0f84ab542 100644 --- a/yt/yt/client/driver/bundle_controller_commands.cpp +++ b/yt/yt/client/driver/bundle_controller_commands.cpp @@ -22,12 +22,7 @@ void TGetBundleConfigCommand::DoExecute(ICommandContextPtr context) Options)) .ValueOrThrow(); - context->ProduceOutputValue(BuildYsonStringFluently() - .BeginMap() - .Item("bundle_name").Value(result.BundleName) - .Item("rpc_proxy_count").Value(result.RpcProxyCount) - .Item("tablet_node_count").Value(result.TabletNodeCount) - .EndMap()); + context->ProduceOutputValue(ConvertToYsonString(result)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/federated/client.cpp b/yt/yt/client/federated/client.cpp index 98efe5b9a7..f2606da4d6 100644 --- a/yt/yt/client/federated/client.cpp +++ b/yt/yt/client/federated/client.cpp @@ -407,7 +407,7 @@ public: UNIMPLEMENTED_METHOD(TFuture<TQuery>, GetQuery, (NQueryTrackerClient::TQueryId, const TGetQueryOptions&)); UNIMPLEMENTED_METHOD(TFuture<TListQueriesResult>, ListQueries, (const TListQueriesOptions&)); UNIMPLEMENTED_METHOD(TFuture<void>, AlterQuery, (NQueryTrackerClient::TQueryId, const TAlterQueryOptions&)); - UNIMPLEMENTED_METHOD(TFuture<TBundleConfigDescriptor>, GetBundleConfig, (const TString&, const TGetBundleConfigOptions&)); + UNIMPLEMENTED_METHOD(TFuture<TBundleConfigDescriptorPtr>, GetBundleConfig, (const TString&, const TGetBundleConfigOptions&)); UNIMPLEMENTED_METHOD(TFuture<ITableReaderPtr>, CreateTableReader, (const NYPath::TRichYPath&, const TTableReaderOptions&)); UNIMPLEMENTED_METHOD(TFuture<ITableWriterPtr>, CreateTableWriter, (const NYPath::TRichYPath&, const TTableWriterOptions&)); diff --git a/yt/yt/client/hedging/hedging.cpp b/yt/yt/client/hedging/hedging.cpp index f27c17cc78..b76b740345 100644 --- a/yt/yt/client/hedging/hedging.cpp +++ b/yt/yt/client/hedging/hedging.cpp @@ -210,7 +210,7 @@ public: UNSUPPORTED_METHOD(TFuture<TQuery>, GetQuery, (NQueryTrackerClient::TQueryId, const TGetQueryOptions&)); UNSUPPORTED_METHOD(TFuture<TListQueriesResult>, ListQueries, (const TListQueriesOptions&)); UNSUPPORTED_METHOD(TFuture<void>, AlterQuery, (NQueryTrackerClient::TQueryId, const TAlterQueryOptions&)); - UNSUPPORTED_METHOD(TFuture<TBundleConfigDescriptor>, GetBundleConfig, (const TString&, const TGetBundleConfigOptions&)); + UNSUPPORTED_METHOD(TFuture<TBundleConfigDescriptorPtr>, GetBundleConfig, (const TString&, const TGetBundleConfigOptions&)); private: THedgingExecutorPtr Executor_; diff --git a/yt/yt/client/unittests/mock/client.h b/yt/yt/client/unittests/mock/client.h index 49dbe4c741..49c221d8ad 100644 --- a/yt/yt/client/unittests/mock/client.h +++ b/yt/yt/client/unittests/mock/client.h @@ -620,7 +620,7 @@ public: MOCK_METHOD(TFuture<void>, AlterQuery, ( NQueryTrackerClient::TQueryId queryId, const TAlterQueryOptions& options), (override)); - MOCK_METHOD(TFuture<TBundleConfigDescriptor>, GetBundleConfig, ( + MOCK_METHOD(TFuture<TBundleConfigDescriptorPtr>, GetBundleConfig, ( const TString& bundleName, const TGetBundleConfigOptions& options), (override)); }; diff --git a/yt/yt_proto/yt/client/CMakeLists.darwin-arm64.txt b/yt/yt_proto/yt/client/CMakeLists.darwin-arm64.txt index bde6ffe9e0..6b09ba1a34 100644 --- a/yt/yt_proto/yt/client/CMakeLists.darwin-arm64.txt +++ b/yt/yt_proto/yt/client/CMakeLists.darwin-arm64.txt @@ -246,6 +246,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(yt_proto-yt-client) target_include_directories(yt_proto-yt-client PUBLIC @@ -260,6 +272,7 @@ target_link_libraries(yt_proto-yt-client PUBLIC target_proto_messages(yt_proto-yt-client PRIVATE ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/discovery_service.proto + ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/cell_master/proto/cell_directory.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chaos_client/proto/replication_card.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chunk_client/proto/data_statistics.proto diff --git a/yt/yt_proto/yt/client/CMakeLists.darwin-x86_64.txt b/yt/yt_proto/yt/client/CMakeLists.darwin-x86_64.txt index bde6ffe9e0..6b09ba1a34 100644 --- a/yt/yt_proto/yt/client/CMakeLists.darwin-x86_64.txt +++ b/yt/yt_proto/yt/client/CMakeLists.darwin-x86_64.txt @@ -246,6 +246,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(yt_proto-yt-client) target_include_directories(yt_proto-yt-client PUBLIC @@ -260,6 +272,7 @@ target_link_libraries(yt_proto-yt-client PUBLIC target_proto_messages(yt_proto-yt-client PRIVATE ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/discovery_service.proto + ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/cell_master/proto/cell_directory.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chaos_client/proto/replication_card.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chunk_client/proto/data_statistics.proto diff --git a/yt/yt_proto/yt/client/CMakeLists.linux-aarch64.txt b/yt/yt_proto/yt/client/CMakeLists.linux-aarch64.txt index b21f7290e7..9fa09c7646 100644 --- a/yt/yt_proto/yt/client/CMakeLists.linux-aarch64.txt +++ b/yt/yt_proto/yt/client/CMakeLists.linux-aarch64.txt @@ -246,6 +246,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(yt_proto-yt-client) target_include_directories(yt_proto-yt-client PUBLIC @@ -261,6 +273,7 @@ target_link_libraries(yt_proto-yt-client PUBLIC target_proto_messages(yt_proto-yt-client PRIVATE ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/discovery_service.proto + ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/cell_master/proto/cell_directory.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chaos_client/proto/replication_card.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chunk_client/proto/data_statistics.proto diff --git a/yt/yt_proto/yt/client/CMakeLists.linux-x86_64.txt b/yt/yt_proto/yt/client/CMakeLists.linux-x86_64.txt index b21f7290e7..9fa09c7646 100644 --- a/yt/yt_proto/yt/client/CMakeLists.linux-x86_64.txt +++ b/yt/yt_proto/yt/client/CMakeLists.linux-x86_64.txt @@ -246,6 +246,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(yt_proto-yt-client) target_include_directories(yt_proto-yt-client PUBLIC @@ -261,6 +273,7 @@ target_link_libraries(yt_proto-yt-client PUBLIC target_proto_messages(yt_proto-yt-client PRIVATE ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/api/rpc_proxy/proto/discovery_service.proto + ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/cell_master/proto/cell_directory.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chaos_client/proto/replication_card.proto ${CMAKE_SOURCE_DIR}/yt/yt_proto/yt/client/chunk_client/proto/data_statistics.proto diff --git a/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto b/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto new file mode 100644 index 0000000000..4629d1e559 --- /dev/null +++ b/yt/yt_proto/yt/client/bundle_controller/proto/bundle_controller_service.proto @@ -0,0 +1,52 @@ +package NYT.NBundleController.NProto; + +//////////////////////////////////////////////////////////////////////////////// + +message TCpuLimits +{ + optional int32 lookup_thread_pool_size = 1; + optional int32 query_thread_pool_size = 2; + optional int32 write_thread_pool_size = 3; +} + +message TMemoryLimits +{ + optional int64 compressed_block_cache = 1; + optional int64 key_filter_block_cache = 2; + optional int64 lookup_row_cache = 3; + + optional int64 tablet_dynamic = 4; + optional int64 tablet_static = 5; + + optional int64 uncompressed_block_cache = 6; + optional int64 versioned_chunk_meta = 7; +} + +message TInstanceResources +{ + optional int64 memory = 1; + optional int64 net = 2; + optional string type = 3; + optional int32 vcpu = 4; +} + +message TReqGetBundleConfig +{ + required string bundle_name = 1; +} + +message TRspGetBundleConfig +{ + optional string bundle_name = 1; + + optional TCpuLimits cpu_limits = 2; + optional TMemoryLimits memory_limits = 3; + + optional int32 rpc_proxy_count = 4; + optional TInstanceResources rpc_proxy_resource_guarantee = 5; + + optional int32 tablet_node_count = 6; + optional TInstanceResources tablet_node_resource_guarantee = 7; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt_proto/yt/client/ya.make b/yt/yt_proto/yt/client/ya.make index 0ac05be114..8c742acce8 100644 --- a/yt/yt_proto/yt/client/ya.make +++ b/yt/yt_proto/yt/client/ya.make @@ -14,6 +14,8 @@ SRCS( api/rpc_proxy/proto/api_service.proto api/rpc_proxy/proto/discovery_service.proto + bundle_controller/proto/bundle_controller_service.proto + cell_master/proto/cell_directory.proto chaos_client/proto/replication_card.proto |