diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-02-16 15:05:56 +0300 |
---|---|---|
committer | Innokentii Mokin <innokentii@ydb.tech> | 2024-02-16 18:35:26 +0000 |
commit | cd424968b328386acdfc8b7fb88b8ecebc2ad28c (patch) | |
tree | dc93ae51fa3baa49d1e3efa36398a9c273c7a885 | |
parent | 5b279da70a9df21add84ae8cbaf309e7bb67f4c8 (diff) | |
download | ydb-cd424968b328386acdfc8b7fb88b8ecebc2ad28c.tar.gz |
Intermediate changes
6 files changed, 67 insertions, 0 deletions
diff --git a/yt/yt/client/bundle_controller_client/bundle_controller_client.cpp b/yt/yt/client/bundle_controller_client/bundle_controller_client.cpp index b0eb346bf2..c7af8a0214 100644 --- a/yt/yt/client/bundle_controller_client/bundle_controller_client.cpp +++ b/yt/yt/client/bundle_controller_client/bundle_controller_client.cpp @@ -12,6 +12,8 @@ void TBundleConfigDescriptor::Register(TRegistrar registrar) .DefaultNew(); registrar.Parameter("bundle_constraints", &TThis::ConfigConstraints) .DefaultNew(); + registrar.Parameter("resource_quota", &TThis::ResourceQuota) + .DefaultNew(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/bundle_controller_client/bundle_controller_client.h b/yt/yt/client/bundle_controller_client/bundle_controller_client.h index 3c1ad6ffc2..35d43fd83a 100644 --- a/yt/yt/client/bundle_controller_client/bundle_controller_client.h +++ b/yt/yt/client/bundle_controller_client/bundle_controller_client.h @@ -26,6 +26,7 @@ struct TBundleConfigDescriptor TBundleTargetConfigPtr Config; TBundleConfigConstraintsPtr ConfigConstraints; + TResourceQuotaPtr ResourceQuota; REGISTER_YSON_STRUCT(TBundleConfigDescriptor); diff --git a/yt/yt/client/bundle_controller_client/bundle_controller_settings.cpp b/yt/yt/client/bundle_controller_client/bundle_controller_settings.cpp index 0c0c03329c..61982e36a5 100644 --- a/yt/yt/client/bundle_controller_client/bundle_controller_settings.cpp +++ b/yt/yt/client/bundle_controller_client/bundle_controller_settings.cpp @@ -98,6 +98,24 @@ void TBundleConfigConstraints::Register(TRegistrar registrar) registrar.Parameter("tablet_node_sizes", &TThis::TabletNodeSizes) .Default(); } + +void TResourceQuota::Register(TRegistrar registrar) +{ + registrar.Parameter("cpu", &TThis::Cpu) + .GreaterThanOrEqual(0) + .Default(0); + + registrar.Parameter("memory", &TThis::Memory) + .GreaterThanOrEqual(0) + .Default(0); +} + +int TResourceQuota::Vcpu() const +{ + const int VFactor = 1000; + return static_cast<int>(Cpu * VFactor); +} + //////////////////////////////////////////////////////////////////////////////// namespace NProto { @@ -267,6 +285,23 @@ void FromProto(TBundleConfigConstraintsPtr bundleConfigConstraints, const NBundl //////////////////////////////////////////////////////////////////////////////// +void ToProto(NBundleController::NProto::TResourceQuota* protoResourceQuota, const TResourceQuotaPtr resourceQuota) +{ + protoResourceQuota->set_vcpu(resourceQuota->Vcpu()); + protoResourceQuota->set_memory(resourceQuota->Memory); +} + +void FromProto(TResourceQuotaPtr resourceQuota, const NBundleController::NProto::TResourceQuota* protoResourceQuota) +{ + YT_FROMPROTO_OPTIONAL_PTR(protoResourceQuota, memory, resourceQuota, Memory); + if (protoResourceQuota->has_vcpu()) { + int VFactor = 1000; + resourceQuota->Cpu = static_cast<double>(protoResourceQuota->vcpu()) / VFactor; + } +} + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NProto } // namespace NYT::NBundleControllerClient diff --git a/yt/yt/client/bundle_controller_client/bundle_controller_settings.h b/yt/yt/client/bundle_controller_client/bundle_controller_settings.h index 952a2eb1ce..177d384782 100644 --- a/yt/yt/client/bundle_controller_client/bundle_controller_settings.h +++ b/yt/yt/client/bundle_controller_client/bundle_controller_settings.h @@ -137,6 +137,23 @@ DEFINE_REFCOUNTED_TYPE(TBundleConfigConstraints) //////////////////////////////////////////////////////////////////////////////// +struct TResourceQuota + : public NYTree::TYsonStruct +{ + double Cpu; + i64 Memory; + + int Vcpu() const; + + REGISTER_YSON_STRUCT(TResourceQuota); + + static void Register(TRegistrar registrar); +}; + +DEFINE_REFCOUNTED_TYPE(TResourceQuota) + +//////////////////////////////////////////////////////////////////////////////// + namespace NProto { //////////////////////////////////////////////////////////////////////////////// @@ -162,6 +179,9 @@ void FromProto(TBundleTargetConfigPtr bundleConfig, const NBundleController::NPr void ToProto(NBundleController::NProto::TBundleConfigConstraints* protoBundleConfigConstraints, const TBundleConfigConstraintsPtr bundleConfigConstraints); void FromProto(TBundleConfigConstraintsPtr bundleConfigConstraints, const NBundleController::NProto::TBundleConfigConstraints* protoBundleConfigConstraints); +void ToProto(NBundleController::NProto::TResourceQuota* protoResourceQuota, const TResourceQuotaPtr resourceQuota); +void FromProto(TResourceQuotaPtr resourceQuota, const NBundleController::NProto::TResourceQuota* protoResourceQuota); + //////////////////////////////////////////////////////////////////////////////// } // namespace NProto diff --git a/yt/yt/client/bundle_controller_client/public.h b/yt/yt/client/bundle_controller_client/public.h index aeeea9312d..c9672a78c8 100644 --- a/yt/yt/client/bundle_controller_client/public.h +++ b/yt/yt/client/bundle_controller_client/public.h @@ -18,6 +18,7 @@ DECLARE_REFCOUNTED_STRUCT(TInstanceSize) DECLARE_REFCOUNTED_STRUCT(TBundleTargetConfig) DECLARE_REFCOUNTED_STRUCT(TBundleConfigDescriptor) DECLARE_REFCOUNTED_STRUCT(TBundleConfigConstraints) +DECLARE_REFCOUNTED_STRUCT(TResourceQuota) struct TBundleConfigDescriptor; @@ -28,6 +29,7 @@ struct TDefaultInstanceConfig; struct TInstanceSize; struct TBundleTargetConfig; struct TBundleConfigConstraints; +struct TResourceQuota; //////////////////////////////////////////////////////////////////////////////// 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 index a88e8fd2ba..e650d899d0 100644 --- 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 @@ -61,6 +61,12 @@ message TBundleConfig optional TInstanceResources tablet_node_resource_guarantee = 6; } +message TResourceQuota +{ + optional int32 vcpu = 1; + optional int64 memory = 2; +} + message TReqGetBundleConfig { required string bundle_name = 1; @@ -71,6 +77,7 @@ message TRspGetBundleConfig optional string bundle_name = 1; optional TBundleConfig bundle_config = 2; optional TBundleConfigConstraints bundle_constraints = 3; + optional TResourceQuota resource_quota = 4; } message TReqSetBundleConfig |