-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
552 additions
and
4 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
ydb/core/kqp/gateway/behaviour/resource_pool/behaviour.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "behaviour.h" | ||
#include "manager.h" | ||
|
||
#include <ydb/services/metadata/abstract/initialization.h> | ||
|
||
|
||
namespace NKikimr::NKqp { | ||
|
||
TResourcePoolBehaviour::TFactory::TRegistrator<TResourcePoolBehaviour> TResourcePoolBehaviour::Registrator(TResourcePoolConfig::GetTypeId()); | ||
|
||
NMetadata::NInitializer::IInitializationBehaviour::TPtr TResourcePoolBehaviour::ConstructInitializer() const { | ||
return nullptr; | ||
} | ||
|
||
NMetadata::NModifications::IOperationsManager::TPtr TResourcePoolBehaviour::ConstructOperationsManager() const { | ||
return std::make_shared<TResourcePoolManager>(); | ||
} | ||
|
||
TString TResourcePoolBehaviour::GetInternalStorageTablePath() const { | ||
return TResourcePoolConfig::GetTypeId(); | ||
} | ||
|
||
|
||
TString TResourcePoolBehaviour::GetTypeId() const { | ||
return TResourcePoolConfig::GetTypeId(); | ||
} | ||
|
||
} // namespace NKikimr::NKqp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include <ydb/services/metadata/abstract/kqp_common.h> | ||
|
||
|
||
namespace NKikimr::NKqp { | ||
|
||
class TResourcePoolConfig { | ||
public: | ||
static TString GetTypeId() { | ||
return "RESOURCE_POOL"; | ||
} | ||
}; | ||
|
||
class TResourcePoolBehaviour: public NMetadata::TClassBehaviour<TResourcePoolConfig> { | ||
static TFactory::TRegistrator<TResourcePoolBehaviour> Registrator; | ||
|
||
protected: | ||
virtual std::shared_ptr<NMetadata::NInitializer::IInitializationBehaviour> ConstructInitializer() const override; | ||
virtual std::shared_ptr<NMetadata::NModifications::IOperationsManager> ConstructOperationsManager() const override; | ||
virtual TString GetInternalStorageTablePath() const override; | ||
|
||
public: | ||
virtual TString GetTypeId() const override; | ||
}; | ||
|
||
} // namespace NKikimr::NKqp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "manager.h" | ||
|
||
#include <ydb/core/base/appdata_fwd.h> | ||
#include <ydb/core/base/feature_flags.h> | ||
|
||
|
||
namespace NKikimr::NKqp { | ||
|
||
namespace { | ||
|
||
void CheckFeatureFlag(TResourcePoolManager::TInternalModificationContext& context) { | ||
auto* actorSystem = context.GetExternalData().GetActorSystem(); | ||
if (!actorSystem) { | ||
ythrow yexception() << "This place needs an actor system. Please contact internal support"; | ||
} | ||
|
||
if (!AppData(actorSystem)->FeatureFlags.GetEnableResourcePools()) { | ||
throw std::runtime_error("Resource pools are disabled. Please contact your system administrator to enable it"); | ||
} | ||
} | ||
|
||
void ValidateObjectId(const TString& objectId) { | ||
if (objectId.find('/') != TString::npos) { | ||
throw std::runtime_error("Resource pool id should not contain '/' symbol"); | ||
} | ||
} | ||
|
||
TResourcePoolManager::TYqlConclusionStatus StatusFromActivityType(TResourcePoolManager::EActivityType activityType) { | ||
using TYqlConclusionStatus = TResourcePoolManager::TYqlConclusionStatus; | ||
using EActivityType = TResourcePoolManager::EActivityType; | ||
|
||
switch (activityType) { | ||
case EActivityType::Undefined: | ||
return TYqlConclusionStatus::Fail("Undefined operation for RESOURCE_POOL object"); | ||
case EActivityType::Upsert: | ||
return TYqlConclusionStatus::Fail("Upsert operation for RESOURCE_POOL objects is not implemented"); | ||
case EActivityType::Create: | ||
return TYqlConclusionStatus::Fail("Create operation for RESOURCE_POOL objects is not implemented"); | ||
case EActivityType::Alter: | ||
return TYqlConclusionStatus::Fail("Alter operation for RESOURCE_POOL objects is not implemented"); | ||
case EActivityType::Drop: | ||
return TYqlConclusionStatus::Fail("Drop operation for RESOURCE_POOL objects is not implemented"); | ||
} | ||
} | ||
|
||
} // anonymous namespace | ||
|
||
NThreading::TFuture<TResourcePoolManager::TYqlConclusionStatus> TResourcePoolManager::DoModify(const NYql::TObjectSettingsImpl& settings, ui32 nodeId, const NMetadata::IClassBehaviour::TPtr& manager, TInternalModificationContext& context) const { | ||
Y_UNUSED(settings, nodeId, manager); | ||
|
||
try { | ||
CheckFeatureFlag(context); | ||
ValidateObjectId(settings.GetObjectId()); | ||
|
||
return NThreading::MakeFuture<TYqlConclusionStatus>(StatusFromActivityType(context.GetActivityType())); | ||
} catch (...) { | ||
return NThreading::MakeFuture<TYqlConclusionStatus>(TYqlConclusionStatus::Fail(CurrentExceptionMessage())); | ||
} | ||
} | ||
|
||
TResourcePoolManager::TYqlConclusionStatus TResourcePoolManager::DoPrepare(NKqpProto::TKqpSchemeOperation& schemeOperation, const NYql::TObjectSettingsImpl& settings, const NMetadata::IClassBehaviour::TPtr& manager, TInternalModificationContext& context) const { | ||
Y_UNUSED(schemeOperation, settings, manager); | ||
|
||
try { | ||
CheckFeatureFlag(context); | ||
ValidateObjectId(settings.GetObjectId()); | ||
|
||
return StatusFromActivityType(context.GetActivityType()); | ||
} catch (...) { | ||
return TYqlConclusionStatus::Fail(CurrentExceptionMessage()); | ||
} | ||
} | ||
|
||
NThreading::TFuture<TResourcePoolManager::TYqlConclusionStatus> TResourcePoolManager::ExecutePrepared(const NKqpProto::TKqpSchemeOperation& schemeOperation, ui32 nodeId, const NMetadata::IClassBehaviour::TPtr& manager, const IOperationsManager::TExternalModificationContext& context) const { | ||
Y_UNUSED(schemeOperation, nodeId, manager, context); | ||
|
||
return NThreading::MakeFuture(TYqlConclusionStatus::Fail(TStringBuilder() << "Execution of prepare operation for RESOURCE_POOL object: unsupported operation: " << static_cast<i32>(schemeOperation.GetOperationCase()))); | ||
} | ||
|
||
} // namespace NKikimr::NKqp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <ydb/services/metadata/manager/abstract.h> | ||
|
||
|
||
namespace NKikimr::NKqp { | ||
|
||
class TResourcePoolManager : public NMetadata::NModifications::IOperationsManager { | ||
public: | ||
using NMetadata::NModifications::IOperationsManager::TYqlConclusionStatus; | ||
|
||
protected: | ||
NThreading::TFuture<TYqlConclusionStatus> DoModify(const NYql::TObjectSettingsImpl& settings, ui32 nodeId, | ||
const NMetadata::IClassBehaviour::TPtr& manager, TInternalModificationContext& context) const override; | ||
|
||
TYqlConclusionStatus DoPrepare(NKqpProto::TKqpSchemeOperation& schemeOperation, const NYql::TObjectSettingsImpl& settings, | ||
const NMetadata::IClassBehaviour::TPtr& manager, IOperationsManager::TInternalModificationContext& context) const override; | ||
|
||
public: | ||
|
||
NThreading::TFuture<TYqlConclusionStatus> ExecutePrepared(const NKqpProto::TKqpSchemeOperation& schemeOperation, | ||
const ui32 nodeId, const NMetadata::IClassBehaviour::TPtr& manager, const IOperationsManager::TExternalModificationContext& context) const override; | ||
}; | ||
|
||
} // namespace NKikimr::NKqp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
LIBRARY() | ||
|
||
SRCS( | ||
manager.cpp | ||
GLOBAL behaviour.cpp | ||
) | ||
|
||
PEERDIR( | ||
ydb/services/metadata/abstract | ||
ydb/services/metadata/manager | ||
) | ||
|
||
YQL_LAST_ABI_VERSION() | ||
|
||
END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
RECURSE( | ||
external_data_source | ||
resource_pool | ||
table | ||
tablestore | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.