diff --git a/include/ydb-cpp-sdk/client/cms/cms.h b/include/ydb-cpp-sdk/client/cms/cms.h deleted file mode 100644 index 70091b005f..0000000000 --- a/include/ydb-cpp-sdk/client/cms/cms.h +++ /dev/null @@ -1,213 +0,0 @@ -#pragma once - -#include - -namespace Ydb::Cms { - class CreateDatabaseRequest; - class ListDatabasesResult; - class GetDatabaseStatusResult; - - class StorageUnits; - class ComputationalUnits; - class AllocatedComputationalUnit; - class ServerlessResources; - class Resources; - class SchemaOperationQuotas; - class SchemaOperationQuotas_LeakyBucket; - class DatabaseQuotas; - class DatabaseQuotas_StorageQuotas; - class ScaleRecommenderPolicies; - class ScaleRecommenderPolicies_ScaleRecommenderPolicy; - class ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy; -} // namespace Ydb::Cms - -namespace NYdb::inline V3::NCms { - -struct TListDatabasesSettings : public TOperationRequestSettings {}; - -class TListDatabasesResult : public TStatus { -public: - TListDatabasesResult(TStatus&& status, const Ydb::Cms::ListDatabasesResult& proto); - const std::vector& GetPaths() const; -private: - std::vector Paths_; -}; - -using TAsyncListDatabasesResult = NThreading::TFuture; - -struct TGetDatabaseStatusSettings : public TOperationRequestSettings {}; - -enum class EState { - StateUnspecified = 0, - Creating = 1, - Running = 2, - Removing = 3, - PendingResources = 4, - Configuring = 5, -}; - -struct TStorageUnits { - TStorageUnits() = default; - TStorageUnits(const Ydb::Cms::StorageUnits& proto); - - std::string UnitKind; - std::uint64_t Count; -}; - -struct TComputationalUnits { - TComputationalUnits() = default; - TComputationalUnits(const Ydb::Cms::ComputationalUnits& proto); - - std::string UnitKind; - std::string AvailabilityZone; - std::uint64_t Count; -}; - -struct TAllocatedComputationalUnit { - TAllocatedComputationalUnit() = default; - TAllocatedComputationalUnit(const Ydb::Cms::AllocatedComputationalUnit& proto); - - std::string Host; - std::uint32_t Port; - std::string UnitKind; -}; - -struct TResources { - TResources() = default; - TResources(const Ydb::Cms::Resources& proto); - - std::vector StorageUnits; - std::vector ComputationalUnits; -}; - -struct TSharedResources : public TResources { - using TResources::TResources; -}; - -struct TServerlessResources { - TServerlessResources() = default; - TServerlessResources(const Ydb::Cms::ServerlessResources& proto); - - std::string SharedDatabasePath; -}; - -struct TSchemaOperationQuotas { - struct TLeakyBucket { - TLeakyBucket() = default; - TLeakyBucket(const Ydb::Cms::SchemaOperationQuotas_LeakyBucket& proto); - - double BucketSize = 1; - std::uint64_t BucketSeconds = 2; - }; - - TSchemaOperationQuotas() = default; - TSchemaOperationQuotas(const Ydb::Cms::SchemaOperationQuotas& proto); - - std::vector LeakyBucketQuotas; -}; - -struct TDatabaseQuotas { - struct TStorageQuotas { - TStorageQuotas() = default; - TStorageQuotas(const Ydb::Cms::DatabaseQuotas_StorageQuotas& proto); - - std::string UnitKind; - std::uint64_t DataSizeHardQuota; - std::uint64_t DataSizeSoftQuota; - }; - - TDatabaseQuotas() = default; - TDatabaseQuotas(const Ydb::Cms::DatabaseQuotas& proto); - - std::uint64_t DataSizeHardQuota; - std::uint64_t DataSizeSoftQuota; - std::uint64_t DataStreamShardsQuota; - std::uint64_t DataStreamReservedStorageQuota; - std::uint32_t TtlMinRunInternalSeconds; - std::vector StorageQuotas; -}; - -struct TTargetTrackingPolicy { - using TAverageCpuUtilizationPercent = std::uint32_t; - - TTargetTrackingPolicy() = default; - TTargetTrackingPolicy(const Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy& proto); - - std::variant Target; -}; - -struct TScaleRecommenderPolicy { - TScaleRecommenderPolicy() = default; - TScaleRecommenderPolicy(const Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy& proto); - - std::variant Policy; -}; - -struct TScaleRecommenderPolicies { - TScaleRecommenderPolicies() = default; - TScaleRecommenderPolicies(const Ydb::Cms::ScaleRecommenderPolicies& proto); - - std::vector Policies; -}; - -using TResourcesKind = std::variant; - -class TGetDatabaseStatusResult : public TStatus { -public: - TGetDatabaseStatusResult(TStatus&& status, const Ydb::Cms::GetDatabaseStatusResult& proto); - - const std::string& GetPath() const; - EState GetState() const; - const TResourcesKind& GetResourcesKind() const; - const TResources& GetAllocatedResources() const; - const std::vector& GetRegisteredResources() const; - std::uint64_t GetGeneration() const; - const TSchemaOperationQuotas& GetSchemaOperationQuotas() const; - const TDatabaseQuotas& GetDatabaseQuotas() const; - const TScaleRecommenderPolicies& GetScaleRecommenderPolicies() const; - - // Fills CreateDatabaseRequest proto from this database status - void SerializeTo(Ydb::Cms::CreateDatabaseRequest& request) const; - -private: - std::string Path_; - EState State_; - TResourcesKind ResourcesKind_; - TResources AllocatedResources_; - std::vector RegisteredResources_; - std::uint64_t Generation_; - TSchemaOperationQuotas SchemaOperationQuotas_; - TDatabaseQuotas DatabaseQuotas_; - TScaleRecommenderPolicies ScaleRecommenderPolicies_; -}; - -using TAsyncGetDatabaseStatusResult = NThreading::TFuture; - -struct TCreateDatabaseSettings : public TOperationRequestSettings { - TCreateDatabaseSettings() = default; - explicit TCreateDatabaseSettings(const Ydb::Cms::CreateDatabaseRequest& request); - - // Fills CreateDatabaseRequest proto from this settings - void SerializeTo(Ydb::Cms::CreateDatabaseRequest& request) const; - - FLUENT_SETTING(TResourcesKind, ResourcesKind); - FLUENT_SETTING(TSchemaOperationQuotas, SchemaOperationQuotas); - FLUENT_SETTING(TDatabaseQuotas, DatabaseQuotas); - FLUENT_SETTING(TScaleRecommenderPolicies, ScaleRecommenderPolicies); -}; - -class TCmsClient { -public: - explicit TCmsClient(const TDriver& driver, const TCommonClientSettings& settings = TCommonClientSettings()); - - TAsyncListDatabasesResult ListDatabases(const TListDatabasesSettings& settings = TListDatabasesSettings()); - TAsyncGetDatabaseStatusResult GetDatabaseStatus(const std::string& path, - const TGetDatabaseStatusSettings& settings = TGetDatabaseStatusSettings()); - TAsyncStatus CreateDatabase(const std::string& path, - const TCreateDatabaseSettings& settings = TCreateDatabaseSettings()); -private: - class TImpl; - std::shared_ptr Impl_; -}; - -} // namespace NYdb::inline V3::NCms diff --git a/include/ydb-cpp-sdk/client/config/config.h b/include/ydb-cpp-sdk/client/config/config.h deleted file mode 100644 index 09dceae6fa..0000000000 --- a/include/ydb-cpp-sdk/client/config/config.h +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include - -namespace NYdb::inline V3::NConfig { - -struct TReplaceConfigSettings : public NYdb::TOperationRequestSettings { - FLUENT_SETTING_FLAG(DryRun); - FLUENT_SETTING_FLAG(AllowUnknownFields); - FLUENT_SETTING_FLAG(BypassChecks); -}; - -enum class EFetchAllConfigsTransform { - NONE, - DETACH_STORAGE_CONFIG_SECTION, - ATTACH_STORAGE_CONFIG_SECTION, -}; - -struct TFetchAllConfigsSettings : public NYdb::TOperationRequestSettings { - FLUENT_SETTING(EFetchAllConfigsTransform, Transform); -}; - -struct TBootstrapClusterSettings : public NYdb::TOperationRequestSettings {}; - -struct TMainConfigIdentity { - std::uint64_t Version; - std::string Cluster; -}; - -struct TStorageConfigIdentity { - std::uint64_t Version; - std::string Cluster; -}; - -struct TDatabaseConfigIdentity { - std::uint64_t Version; - std::string Cluster; - std::string Database; -}; - -using TIdentityTypes = std::variant< - std::monostate - , TMainConfigIdentity - , TStorageConfigIdentity - , TDatabaseConfigIdentity - >; - -struct TConfig { - TIdentityTypes Identity; - std::string Config; -}; - -struct TFetchConfigResult : public TStatus { - TFetchConfigResult( - TStatus&& status, - std::vector&& configs) - : TStatus(std::move(status)) - , Configs_(std::move(configs)) - {} - - const std::vector& GetConfigs() const { - return Configs_; - } - -private: - std::vector Configs_; -}; - -using TAsyncFetchConfigResult = NThreading::TFuture; - -class TConfigClient { -public: - explicit TConfigClient(const TDriver& driver, const TCommonClientSettings& settings = {}); - - ~TConfigClient(); - - // Replace config - TAsyncStatus ReplaceConfig( - const std::string& mainConfig, - const TReplaceConfigSettings& settings = {}); - - // Replace config - TAsyncStatus ReplaceConfig( - const std::string& mainConfig, - const std::string& storageConfig, - const TReplaceConfigSettings& settings = {}); - - // Replace config - TAsyncStatus ReplaceConfigDisableDedicatedStorageSection( - const std::string& mainConfig, - const TReplaceConfigSettings& settings = {}); - - // Replace config - TAsyncStatus ReplaceConfigEnableDedicatedStorageSection( - const std::string& mainConfig, - const std::string& storageConfig, - const TReplaceConfigSettings& settings = {}); - - // Fetch current cluster storage config - TAsyncFetchConfigResult FetchAllConfigs(const TFetchAllConfigsSettings& settings = {}); - - // Bootstrap cluster with automatic configuration - TAsyncStatus BootstrapCluster( - const std::string& selfAssemblyUUID, - const TBootstrapClusterSettings& settings = {}); - -private: - class TImpl; - - std::unique_ptr Impl_; -}; - -} diff --git a/include/ydb-cpp-sdk/client/debug/client.h b/include/ydb-cpp-sdk/client/debug/client.h deleted file mode 100644 index 56568743c5..0000000000 --- a/include/ydb-cpp-sdk/client/debug/client.h +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once - -#include - -namespace NYdb::inline V3::NDebug { - -//////////////////////////////////////////////////////////////////////////////// - -class TPlainGrpcPingResult: public TStatus { -public: - TPlainGrpcPingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -class TGrpcProxyPingResult: public TStatus { -public: - TGrpcProxyPingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -class TKqpProxyPingResult: public TStatus { -public: - TKqpProxyPingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -class TSchemeCachePingResult: public TStatus { -public: - TSchemeCachePingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -class TTxProxyPingResult: public TStatus { -public: - TTxProxyPingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -class TActorChainPingResult: public TStatus { -public: - TActorChainPingResult(TStatus&& status) - : TStatus(std::move(status)) - {} -}; - -//////////////////////////////////////////////////////////////////////////////// - -using TAsyncPlainGrpcPingResult = NThreading::TFuture; -using TAsyncGrpcProxyPingResult = NThreading::TFuture; -using TAsyncKqpProxyPingResult = NThreading::TFuture; -using TAsyncSchemeCachePingResult = NThreading::TFuture; -using TAsyncTxProxyPingResult = NThreading::TFuture; -using TAsyncActorChainPingResult = NThreading::TFuture; - -//////////////////////////////////////////////////////////////////////////////// - -struct TPlainGrpcPingSettings : public TSimpleRequestSettings {}; -struct TGrpcProxyPingSettings : public TSimpleRequestSettings {}; -struct TKqpProxyPingSettings : public TSimpleRequestSettings {}; -struct TSchemeCachePingSettings : public TSimpleRequestSettings {}; -struct TTxProxyPingSettings : public TSimpleRequestSettings {}; - -struct TActorChainPingSettings : public TSimpleRequestSettings { - FLUENT_SETTING_DEFAULT(size_t, ChainLength, 10); - FLUENT_SETTING_DEFAULT(size_t, WorkUsec, 5); - FLUENT_SETTING_DEFAULT(bool, NoTailChain, false); -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct TClientSettings : public TCommonClientSettingsBase { -}; - -class TDebugClient { -public: - using TAsyncPlainGrpcPingResult = TAsyncPlainGrpcPingResult; -public: - TDebugClient(const TDriver& driver, const TClientSettings& settings = TClientSettings()); - - TAsyncPlainGrpcPingResult PingPlainGrpc(const TPlainGrpcPingSettings& settings); - TAsyncGrpcProxyPingResult PingGrpcProxy(const TGrpcProxyPingSettings& settings); - TAsyncKqpProxyPingResult PingKqpProxy(const TKqpProxyPingSettings& settings); - - TAsyncSchemeCachePingResult PingSchemeCache(const TSchemeCachePingSettings& settings); - TAsyncTxProxyPingResult PingTxProxy(const TTxProxyPingSettings& settings); - - TAsyncActorChainPingResult PingActorChain(const TActorChainPingSettings& settings); - -private: - class TImpl; - std::shared_ptr Impl_; -}; - -} // namespace NYdb::V3::NDebug diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 2b83bfc61e..e6570ae0b9 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,9 +1,6 @@ -add_subdirectory(cms) add_subdirectory(common_client) -add_subdirectory(config) add_subdirectory(coordination) add_subdirectory(datastreams) -add_subdirectory(debug) add_subdirectory(discovery) add_subdirectory(draft) add_subdirectory(driver) diff --git a/src/client/cms/CMakeLists.txt b/src/client/cms/CMakeLists.txt deleted file mode 100644 index a330cf842f..0000000000 --- a/src/client/cms/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -_ydb_sdk_add_library(client-cms) - -target_link_libraries(client-cms - PUBLIC - client-ydb_driver - PRIVATE - api-grpc - api-protos - client-ydb_common_client-impl -) - -target_sources(client-cms - PRIVATE - cms.cpp -) - -_ydb_sdk_make_client_component(Cms client-cms) diff --git a/src/client/cms/cms.cpp b/src/client/cms/cms.cpp deleted file mode 100644 index 9d013fc24a..0000000000 --- a/src/client/cms/cms.cpp +++ /dev/null @@ -1,383 +0,0 @@ -#include - -#include -#include -#include - -#define INCLUDE_YDB_INTERNAL_H -#include -#undef INCLUDE_YDB_INTERNAL_H - -namespace NYdb::inline V3::NCms { - -namespace { - EState ConvertState(Ydb::Cms::GetDatabaseStatusResult_State protoState) { - switch (protoState) { - case Ydb::Cms::GetDatabaseStatusResult_State_STATE_UNSPECIFIED: - return EState::StateUnspecified; - case Ydb::Cms::GetDatabaseStatusResult_State_CREATING: - return EState::Creating; - case Ydb::Cms::GetDatabaseStatusResult_State_RUNNING: - return EState::Running; - case Ydb::Cms::GetDatabaseStatusResult_State_REMOVING: - return EState::Removing; - case Ydb::Cms::GetDatabaseStatusResult_State_PENDING_RESOURCES: - return EState::PendingResources; - case Ydb::Cms::GetDatabaseStatusResult_State_CONFIGURING: - return EState::Configuring; - default: - return EState::StateUnspecified; - } - } - - void SerializeToImpl( - const TResourcesKind& resourcesKind, - const TSchemaOperationQuotas& schemaQuotas, - const TDatabaseQuotas& dbQuotas, - const TScaleRecommenderPolicies& scaleRecommenderPolicies, - Ydb::Cms::CreateDatabaseRequest& out) - { - if (std::holds_alternative(resourcesKind)) { - const auto& resources = std::get(resourcesKind); - for (const auto& storageUnit : resources.StorageUnits) { - auto* protoUnit = out.mutable_resources()->add_storage_units(); - protoUnit->set_unit_kind(storageUnit.UnitKind); - protoUnit->set_count(storageUnit.Count); - } - for (const auto& computationalUnit : resources.ComputationalUnits) { - auto* protoUnit = out.mutable_resources()->add_computational_units(); - protoUnit->set_unit_kind(computationalUnit.UnitKind); - protoUnit->set_count(computationalUnit.Count); - protoUnit->set_availability_zone(computationalUnit.AvailabilityZone); - } - } else if (std::holds_alternative(resourcesKind)) { - const auto& resources = std::get(resourcesKind); - for (const auto& storageUnit : resources.StorageUnits) { - auto* protoUnit = out.mutable_shared_resources()->add_storage_units(); - protoUnit->set_unit_kind(storageUnit.UnitKind); - protoUnit->set_count(storageUnit.Count); - } - for (const auto& computationalUnit : resources.ComputationalUnits) { - auto* protoUnit = out.mutable_shared_resources()->add_computational_units(); - protoUnit->set_unit_kind(computationalUnit.UnitKind); - protoUnit->set_count(computationalUnit.Count); - protoUnit->set_availability_zone(computationalUnit.AvailabilityZone); - } - } else if (std::holds_alternative(resourcesKind)) { - const auto& resources = std::get(resourcesKind); - out.mutable_serverless_resources()->set_shared_database_path(resources.SharedDatabasePath); - } else if (std::holds_alternative(resourcesKind)) { - out.clear_resources_kind(); - } - - for (const auto& quota : schemaQuotas.LeakyBucketQuotas) { - auto protoQuota = out.mutable_schema_operation_quotas()->add_leaky_bucket_quotas(); - protoQuota->set_bucket_seconds(quota.BucketSeconds); - protoQuota->set_bucket_size(quota.BucketSize); - } - - out.mutable_database_quotas()->set_data_size_hard_quota(dbQuotas.DataSizeHardQuota); - out.mutable_database_quotas()->set_data_size_soft_quota(dbQuotas.DataSizeSoftQuota); - out.mutable_database_quotas()->set_data_stream_shards_quota(dbQuotas.DataStreamShardsQuota); - out.mutable_database_quotas()->set_data_stream_reserved_storage_quota(dbQuotas.DataStreamReservedStorageQuota); - out.mutable_database_quotas()->set_ttl_min_run_internal_seconds(dbQuotas.TtlMinRunInternalSeconds); - - for (const auto& quota : dbQuotas.StorageQuotas) { - auto protoQuota = out.mutable_database_quotas()->add_storage_quotas(); - protoQuota->set_unit_kind(quota.UnitKind); - protoQuota->set_data_size_hard_quota(quota.DataSizeHardQuota); - protoQuota->set_data_size_soft_quota(quota.DataSizeSoftQuota); - } - - for (const auto& policy : scaleRecommenderPolicies.Policies) { - auto* protoPolicy = out.mutable_scale_recommender_policies()->add_policies(); - if (std::holds_alternative(policy.Policy)) { - const auto& targetTracking = std::get(policy.Policy); - auto* protoTargetTracking = protoPolicy->mutable_target_tracking_policy(); - if (std::holds_alternative(targetTracking.Target)) { - const auto& target = std::get(targetTracking.Target); - protoTargetTracking->set_average_cpu_utilization_percent(target); - } else if (std::holds_alternative(targetTracking.Target)) { - protoTargetTracking->clear_target(); - } - } else if (std::holds_alternative(policy.Policy)) { - protoPolicy->clear_policy(); - } - } - } -} // anonymous namespace - -TListDatabasesResult::TListDatabasesResult(TStatus&& status, const Ydb::Cms::ListDatabasesResult& proto) - : TStatus(std::move(status)) - , Paths_(proto.paths().begin(), proto.paths().end()) -{} - -const std::vector& TListDatabasesResult::GetPaths() const { - return Paths_; -} - -TStorageUnits::TStorageUnits(const Ydb::Cms::StorageUnits& proto) - : UnitKind(proto.unit_kind()) - , Count(proto.count()) -{} - -TComputationalUnits::TComputationalUnits(const Ydb::Cms::ComputationalUnits& proto) - : UnitKind(proto.unit_kind()) - , AvailabilityZone(proto.availability_zone()) - , Count(proto.count()) -{} - -TAllocatedComputationalUnit::TAllocatedComputationalUnit(const Ydb::Cms::AllocatedComputationalUnit& proto) - : Host(proto.host()) - , Port(proto.port()) - , UnitKind(proto.unit_kind()) -{} - -TResources::TResources(const Ydb::Cms::Resources& proto) - : StorageUnits(proto.storage_units().begin(), proto.storage_units().end()) - , ComputationalUnits(proto.computational_units().begin(), proto.computational_units().end()) -{} - -TServerlessResources::TServerlessResources(const Ydb::Cms::ServerlessResources& proto) - : SharedDatabasePath(proto.shared_database_path()) -{} - -TSchemaOperationQuotas::TLeakyBucket::TLeakyBucket(const Ydb::Cms::SchemaOperationQuotas_LeakyBucket& proto) - : BucketSize(proto.bucket_size()) - , BucketSeconds(proto.bucket_seconds()) -{} - -TSchemaOperationQuotas::TSchemaOperationQuotas(const Ydb::Cms::SchemaOperationQuotas& proto) - : LeakyBucketQuotas(proto.leaky_bucket_quotas().begin(), proto.leaky_bucket_quotas().end()) -{} - -TDatabaseQuotas::TStorageQuotas::TStorageQuotas(const Ydb::Cms::DatabaseQuotas_StorageQuotas& proto) - : UnitKind(proto.unit_kind()) - , DataSizeHardQuota(proto.data_size_hard_quota()) - , DataSizeSoftQuota(proto.data_size_soft_quota()) -{} - -TDatabaseQuotas::TDatabaseQuotas(const Ydb::Cms::DatabaseQuotas& proto) - : DataSizeHardQuota(proto.data_size_hard_quota()) - , DataSizeSoftQuota(proto.data_size_soft_quota()) - , DataStreamShardsQuota(proto.data_stream_shards_quota()) - , DataStreamReservedStorageQuota(proto.data_stream_reserved_storage_quota()) - , TtlMinRunInternalSeconds(proto.ttl_min_run_internal_seconds()) - , StorageQuotas(proto.storage_quotas().begin(), proto.storage_quotas().end()) -{} - -TTargetTrackingPolicy::TTargetTrackingPolicy(const Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy& proto) -{ - switch (proto.target_case()) { - case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy::kAverageCpuUtilizationPercent: - Target = proto.average_cpu_utilization_percent(); - break; - case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy::TARGET_NOT_SET: - Target = std::monostate(); - break; - } -} - -TScaleRecommenderPolicy::TScaleRecommenderPolicy(const Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy& proto) -{ - switch (proto.policy_case()) { - case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy::kTargetTrackingPolicy: - Policy = proto.target_tracking_policy(); - break; - case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy::POLICY_NOT_SET: - Policy = std::monostate(); - break; - } -} - -TScaleRecommenderPolicies::TScaleRecommenderPolicies(const Ydb::Cms::ScaleRecommenderPolicies& proto) - : Policies(proto.policies().begin(), proto.policies().end()) -{} - -TGetDatabaseStatusResult::TGetDatabaseStatusResult(TStatus&& status, const Ydb::Cms::GetDatabaseStatusResult& proto) - : TStatus(std::move(status)) - , Path_(proto.path()) - , State_(ConvertState(proto.state())) - , AllocatedResources_(proto.allocated_resources()) - , RegisteredResources_(proto.registered_resources().begin(), proto.registered_resources().end()) - , Generation_(proto.generation()) - , SchemaOperationQuotas_(proto.schema_operation_quotas()) - , DatabaseQuotas_(proto.database_quotas()) - , ScaleRecommenderPolicies_(proto.scale_recommender_policies()) -{ - switch (proto.resources_kind_case()) { - case Ydb::Cms::GetDatabaseStatusResult::kRequiredResources: - ResourcesKind_ = TResources(proto.required_resources()); - break; - case Ydb::Cms::GetDatabaseStatusResult::kRequiredSharedResources: - ResourcesKind_ = TSharedResources(proto.required_shared_resources()); - break; - case Ydb::Cms::GetDatabaseStatusResult::kServerlessResources: - ResourcesKind_ = proto.serverless_resources(); - break; - case Ydb::Cms::GetDatabaseStatusResult::RESOURCES_KIND_NOT_SET: - ResourcesKind_ = std::monostate(); - break; - } -} - -const std::string& TGetDatabaseStatusResult::GetPath() const { - return Path_; -} - -EState TGetDatabaseStatusResult::GetState() const { - return State_; -} - -const TResourcesKind& TGetDatabaseStatusResult::GetResourcesKind() const { - return ResourcesKind_; -} - -const TResources& TGetDatabaseStatusResult::GetAllocatedResources() const { - return AllocatedResources_; -} - -const std::vector& TGetDatabaseStatusResult::GetRegisteredResources() const { - return RegisteredResources_; -} - -std::uint64_t TGetDatabaseStatusResult::GetGeneration() const { - return Generation_; -} - -const TSchemaOperationQuotas& TGetDatabaseStatusResult::GetSchemaOperationQuotas() const { - return SchemaOperationQuotas_; -} - -const TDatabaseQuotas& TGetDatabaseStatusResult::GetDatabaseQuotas() const { - return DatabaseQuotas_; -} - -const TScaleRecommenderPolicies& TGetDatabaseStatusResult::GetScaleRecommenderPolicies() const { - return ScaleRecommenderPolicies_; -} - -void TGetDatabaseStatusResult::SerializeTo(Ydb::Cms::CreateDatabaseRequest& request) const { - request.set_path(Path_); - SerializeToImpl(ResourcesKind_, SchemaOperationQuotas_, DatabaseQuotas_, ScaleRecommenderPolicies_, request); -} - -TCreateDatabaseSettings::TCreateDatabaseSettings(const Ydb::Cms::CreateDatabaseRequest& request) - : SchemaOperationQuotas_(request.schema_operation_quotas()) - , DatabaseQuotas_(request.database_quotas()) - , ScaleRecommenderPolicies_(request.scale_recommender_policies()) -{ - switch (request.resources_kind_case()) { - case Ydb::Cms::CreateDatabaseRequest::kResources: - ResourcesKind_ = TResources(request.resources()); - break; - case Ydb::Cms::CreateDatabaseRequest::kSharedResources: - ResourcesKind_ = TSharedResources(request.shared_resources()); - break; - case Ydb::Cms::CreateDatabaseRequest::kServerlessResources: - ResourcesKind_ = request.serverless_resources(); - break; - case Ydb::Cms::CreateDatabaseRequest::RESOURCES_KIND_NOT_SET: - ResourcesKind_ = std::monostate(); - break; - } -} - -void TCreateDatabaseSettings::SerializeTo(Ydb::Cms::CreateDatabaseRequest& request) const { - SerializeToImpl(ResourcesKind_, SchemaOperationQuotas_, DatabaseQuotas_, ScaleRecommenderPolicies_, request); -} - -class TCmsClient::TImpl : public TClientImplCommon { -public: - TImpl(std::shared_ptr&& connections, const TCommonClientSettings& settings) - : TClientImplCommon(std::move(connections), settings) - { } - - TAsyncListDatabasesResult ListDatabases(const TListDatabasesSettings& settings) { - auto request = MakeOperationRequest(settings); - - auto promise = NThreading::NewPromise(); - - auto extractor = [promise] - (google::protobuf::Any* any, TPlainStatus status) mutable { - Ydb::Cms::ListDatabasesResult result; - if (any) { - any->UnpackTo(&result); - } - TListDatabasesResult val{TStatus(std::move(status)), result}; - promise.SetValue(std::move(val)); - }; - - Connections_->RunDeferred( - std::move(request), - extractor, - &Ydb::Cms::V1::CmsService::Stub::AsyncListDatabases, - DbDriverState_, - INITIAL_DEFERRED_CALL_DELAY, - TRpcRequestSettings::Make(settings)); - - return promise.GetFuture(); - } - - TAsyncGetDatabaseStatusResult GetDatabaseStatus(const std::string& path, const TGetDatabaseStatusSettings& settings) { - auto request = MakeOperationRequest(settings); - request.set_path(path); - - auto promise = NThreading::NewPromise(); - - auto extractor = [promise] - (google::protobuf::Any* any, TPlainStatus status) mutable { - Ydb::Cms::GetDatabaseStatusResult result; - if (any) { - any->UnpackTo(&result); - } - TGetDatabaseStatusResult val{TStatus(std::move(status)), result}; - promise.SetValue(std::move(val)); - }; - - Connections_->RunDeferred( - std::move(request), - extractor, - &Ydb::Cms::V1::CmsService::Stub::AsyncGetDatabaseStatus, - DbDriverState_, - INITIAL_DEFERRED_CALL_DELAY, - TRpcRequestSettings::Make(settings)); - - return promise.GetFuture(); - } - - TAsyncStatus CreateDatabase(const std::string& path, const TCreateDatabaseSettings& settings) { - auto request = MakeOperationRequest(settings); - request.set_path(path); - settings.SerializeTo(request); - - return RunSimple( - std::move(request), - &Ydb::Cms::V1::CmsService::Stub::AsyncCreateDatabase, - TRpcRequestSettings::Make(settings)); - } -}; - -TCmsClient::TCmsClient(const TDriver& driver, const TCommonClientSettings& settings) - : Impl_(new TImpl(CreateInternalInterface(driver), settings)) -{} - -TAsyncListDatabasesResult TCmsClient::ListDatabases(const TListDatabasesSettings& settings) { - return Impl_->ListDatabases(settings); -} - -TAsyncGetDatabaseStatusResult TCmsClient::GetDatabaseStatus( - const std::string& path, - const TGetDatabaseStatusSettings& settings) -{ - return Impl_->GetDatabaseStatus(path, settings); -} - -TAsyncStatus TCmsClient::CreateDatabase( - const std::string& path, - const TCreateDatabaseSettings& settings) -{ - return Impl_->CreateDatabase(path, settings); -} - -} // namespace NYdb::NCms diff --git a/src/client/config/CMakeLists.txt b/src/client/config/CMakeLists.txt deleted file mode 100644 index 96fea5227b..0000000000 --- a/src/client/config/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -_ydb_sdk_add_library(client-config) - -target_link_libraries(client-config - PUBLIC - client-ydb_driver - client-ydb_common_client - client-ydb_types-status - client-ydb_types - PRIVATE - api-grpc - impl-ydb_internal-make_request - client-ydb_common_client-impl -) - -target_sources(client-config - PRIVATE - config.cpp -) - -_ydb_sdk_make_client_component(Config client-config) diff --git a/src/client/config/config.cpp b/src/client/config/config.cpp deleted file mode 100644 index 80a99b6001..0000000000 --- a/src/client/config/config.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include - -#include -#include - -#include - -namespace NYdb::inline V3::NConfig { - -class TConfigClient::TImpl : public TClientImplCommon { -public: - TImpl(std::shared_ptr connections, const TCommonClientSettings& settings) - : TClientImplCommon(std::move(connections), settings) - { - } - - TAsyncStatus ReplaceConfig(const std::string& mainConfig, const TReplaceConfigSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - request.set_replace(mainConfig); - - ApplyReplaceSettings(request, settings); - - return RunSimple( - std::move(request), - &Ydb::Config::V1::ConfigService::Stub::AsyncReplaceConfig, - TRpcRequestSettings::Make(settings)); - } - - TAsyncStatus ReplaceConfig(const std::string& mainConfig, const std::string& storageConfig, const TReplaceConfigSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - auto& replace = *request.mutable_replace_with_dedicated_storage_section(); - replace.set_main_config(mainConfig); - replace.set_storage_config(storageConfig); - - ApplyReplaceSettings(request, settings); - - return RunSimple( - std::move(request), - &Ydb::Config::V1::ConfigService::Stub::AsyncReplaceConfig, - TRpcRequestSettings::Make(settings)); - } - - TAsyncStatus ReplaceConfigDisableDedicatedStorageSection(const std::string& mainConfig, const TReplaceConfigSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - request.set_replace_disable_dedicated_storage_section(mainConfig); - - ApplyReplaceSettings(request, settings); - - return RunSimple( - std::move(request), - &Ydb::Config::V1::ConfigService::Stub::AsyncReplaceConfig, - TRpcRequestSettings::Make(settings)); - } - - TAsyncStatus ReplaceConfigEnableDedicatedStorageSection(const std::string& mainConfig, const std::string& storageConfig, const TReplaceConfigSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - auto& replace = *request.mutable_replace_enable_dedicated_storage_section(); - replace.set_main_config(mainConfig); - replace.set_storage_config(storageConfig); - - ApplyReplaceSettings(request, settings); - - return RunSimple( - std::move(request), - &Ydb::Config::V1::ConfigService::Stub::AsyncReplaceConfig, - TRpcRequestSettings::Make(settings)); - } - - TAsyncFetchConfigResult FetchAllConfigs(const TFetchAllConfigsSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - request.mutable_all(); - - auto promise = NThreading::NewPromise(); - - auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable { - std::vector configs; - if (Ydb::Config::FetchConfigResult result; any && any->UnpackTo(&result)) { - for (const auto& entry : result.config()) { - TIdentityTypes identity; - - switch (entry.identity().type_case()) { - case Ydb::Config::ConfigIdentity::TypeCase::kMain: - identity = TMainConfigIdentity { - .Version = entry.identity().version(), - .Cluster = entry.identity().cluster(), - }; - break; - case Ydb::Config::ConfigIdentity::TypeCase::kStorage: - identity = TStorageConfigIdentity { - .Version = entry.identity().version(), - .Cluster = entry.identity().cluster(), - }; - break; - case Ydb::Config::ConfigIdentity::TypeCase::kDatabase: - identity = TDatabaseConfigIdentity { - .Version = entry.identity().version(), - .Cluster = entry.identity().cluster(), - .Database = entry.identity().database().database(), - }; - break; - case Ydb::Config::ConfigIdentity::TypeCase::TYPE_NOT_SET: - break; // leave in monostate; uknown identity - } - - configs.push_back(TConfig{ - .Identity = identity, - .Config = entry.config(), - }); - } - } - - TFetchConfigResult val(TStatus(std::move(status)), std::move(configs)); - promise.SetValue(std::move(val)); - }; - - Connections_->RunDeferred( - std::move(request), - extractor, - &Ydb::Config::V1::ConfigService::Stub::AsyncFetchConfig, - DbDriverState_, - INITIAL_DEFERRED_CALL_DELAY, - TRpcRequestSettings::Make(settings)); - return promise.GetFuture(); - } - - TAsyncStatus BootstrapCluster(const std::string& selfAssemblyUUID, const TBootstrapClusterSettings& settings = {}) { - auto request = MakeOperationRequest(settings); - request.set_self_assembly_uuid(selfAssemblyUUID); - - return RunSimple(std::move(request), - &Ydb::Config::V1::ConfigService::Stub::AsyncBootstrapCluster); - } -private: - static void ApplyReplaceSettings(auto& request, const TReplaceConfigSettings& settings) { - request.set_dry_run(settings.DryRun_); - request.set_allow_unknown_fields(settings.AllowUnknownFields_); - request.set_bypass_checks(settings.BypassChecks_); - } -}; - -TConfigClient::TConfigClient(const TDriver& driver, const TCommonClientSettings& settings) - : Impl_(new TConfigClient::TImpl(CreateInternalInterface(driver), settings)) -{} - -TConfigClient::~TConfigClient() = default; - -TAsyncStatus TConfigClient::ReplaceConfig( - const std::string& mainConfig, - const TReplaceConfigSettings& settings) -{ - return Impl_->ReplaceConfig(mainConfig, settings); -} - -TAsyncStatus TConfigClient::ReplaceConfig( - const std::string& mainConfig, - const std::string& storageConfig, - const TReplaceConfigSettings& settings) -{ - return Impl_->ReplaceConfig(mainConfig, storageConfig, settings); -} - -TAsyncStatus TConfigClient::ReplaceConfigDisableDedicatedStorageSection( - const std::string& mainConfig, - const TReplaceConfigSettings& settings) -{ - return Impl_->ReplaceConfigDisableDedicatedStorageSection(mainConfig, settings); -} - -TAsyncStatus TConfigClient::ReplaceConfigEnableDedicatedStorageSection( - const std::string& mainConfig, - const std::string& storageConfig, - const TReplaceConfigSettings& settings) -{ - return Impl_->ReplaceConfigEnableDedicatedStorageSection(mainConfig, storageConfig, settings); -} - -TAsyncFetchConfigResult TConfigClient::FetchAllConfigs(const TFetchAllConfigsSettings& settings) { - return Impl_->FetchAllConfigs(settings); -} - -TAsyncStatus TConfigClient::BootstrapCluster( - const std::string& selfAssemblyUUID, - const TBootstrapClusterSettings& settings) -{ - return Impl_->BootstrapCluster(selfAssemblyUUID, settings); -} - -} diff --git a/src/client/debug/CMakeLists.txt b/src/client/debug/CMakeLists.txt deleted file mode 100644 index 3095290c04..0000000000 --- a/src/client/debug/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -_ydb_sdk_add_library(client-debug) - -target_link_libraries(client-debug - PUBLIC - client-ydb_driver - PRIVATE - api-grpc - api-protos - client-ydb_common_client-impl -) - -target_sources(client-debug - PRIVATE - client.cpp -) - -_ydb_sdk_make_client_component(Debug client-debug) diff --git a/src/client/debug/client.cpp b/src/client/debug/client.cpp deleted file mode 100644 index d00173b423..0000000000 --- a/src/client/debug/client.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include - -#include -#include -#include - -#define INCLUDE_YDB_INTERNAL_H -#include -#undef INCLUDE_YDB_INTERNAL_H - -#include - -namespace NYdb::inline V3::NDebug { - -using namespace Ydb; - -using namespace NThreading; - -class TDebugClient::TImpl: public TClientImplCommon { -public: - TImpl(std::shared_ptr&& connections, const TClientSettings& settings) - : TClientImplCommon(std::move(connections), settings) - {} - - template - auto Ping(const TSettings& settings, auto serviceMethod) { - auto pingPromise = NewPromise(); - auto responseCb = [pingPromise] (TResponse*, TPlainStatus status) mutable { - TResult val(TStatus(std::move(status))); - pingPromise.SetValue(std::move(val)); - }; - - Connections_->Run( - TRequest(), - responseCb, - serviceMethod, - DbDriverState_, - TRpcRequestSettings::Make(settings)); - - return pingPromise; - } - - auto PingActorChain(const TActorChainPingSettings& settings) { - auto pingPromise = NewPromise(); - auto responseCb = [pingPromise] (Debug::ActorChainResponse*, TPlainStatus status) mutable { - TActorChainPingResult val(TStatus(std::move(status))); - pingPromise.SetValue(std::move(val)); - }; - - Debug::ActorChainRequest request; - request.set_chainlength(settings.ChainLength_); - request.set_workusec(settings.WorkUsec_); - request.set_notailchain(settings.NoTailChain_); - - Connections_->Run( - std::move(request), - responseCb, - &Debug::V1::DebugService::Stub::AsyncPingActorChain, - DbDriverState_, - TRpcRequestSettings::Make(settings)); - - return pingPromise; - } - - ~TImpl() = default; -}; - -TDebugClient::TDebugClient(const TDriver& driver, const TClientSettings& settings) - : Impl_(new TImpl(CreateInternalInterface(driver), settings)) -{ -} - -TAsyncPlainGrpcPingResult TDebugClient::PingPlainGrpc(const TPlainGrpcPingSettings& settings) { - return Impl_->Ping( - settings, &Debug::V1::DebugService::Stub::AsyncPingPlainGrpc); -} - -TAsyncGrpcProxyPingResult TDebugClient::PingGrpcProxy(const TGrpcProxyPingSettings& settings) { - return Impl_->Ping( - settings, &Debug::V1::DebugService::Stub::AsyncPingGrpcProxy); -} - -TAsyncKqpProxyPingResult TDebugClient::PingKqpProxy(const TKqpProxyPingSettings& settings) { - return Impl_->Ping( - settings, &Debug::V1::DebugService::Stub::AsyncPingKqpProxy); -} - -TAsyncSchemeCachePingResult TDebugClient::PingSchemeCache(const TSchemeCachePingSettings& settings) { - return Impl_->Ping( - settings, &Debug::V1::DebugService::Stub::AsyncPingSchemeCache); -} - -TAsyncTxProxyPingResult TDebugClient::PingTxProxy(const TTxProxyPingSettings& settings) { - return Impl_->Ping( - settings, &Debug::V1::DebugService::Stub::AsyncPingTxProxy); -} - -TAsyncActorChainPingResult TDebugClient::PingActorChain(const TActorChainPingSettings& settings) { - return Impl_->PingActorChain(settings); -} - -} // namespace NYdb::V3::NDebug