2022-09-27 13:26:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-27 18:47:22 +00:00
|
|
|
#include <IO/ResourceLink.h>
|
2022-09-27 13:26:41 +00:00
|
|
|
|
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
2023-09-03 21:48:33 +00:00
|
|
|
#include <functional>
|
2022-09-27 13:26:41 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Instance of derived class holds everything required for resource consumption,
|
|
|
|
* including resources currently registered at `SchedulerRoot`. This is required to avoid
|
|
|
|
* problems during configuration update. Do not hold instances longer than required.
|
|
|
|
* Should be created on query start and destructed when query is done.
|
|
|
|
*/
|
|
|
|
class IClassifier : private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IClassifier() {}
|
|
|
|
|
2023-02-28 13:17:31 +00:00
|
|
|
/// Returns ResourceLink that should be used to access resource.
|
2022-09-27 13:26:41 +00:00
|
|
|
/// Returned link is valid until classifier destruction.
|
|
|
|
virtual ResourceLink get(const String & resource_name) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ClassifierPtr = std::shared_ptr<IClassifier>;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Represents control plane of resource scheduling. Derived class is responsible for reading
|
|
|
|
* configuration, creating all required `ISchedulerNode` objects and
|
|
|
|
* managing their lifespan.
|
|
|
|
*/
|
|
|
|
class IResourceManager : private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IResourceManager() {}
|
|
|
|
|
|
|
|
/// Initialize or reconfigure manager.
|
|
|
|
virtual void updateConfiguration(const Poco::Util::AbstractConfiguration & config) = 0;
|
|
|
|
|
|
|
|
/// Obtain a classifier instance required to get access to resources.
|
|
|
|
/// Note that it holds resource configuration, so should be destructed when query is done.
|
|
|
|
virtual ClassifierPtr acquire(const String & classifier_name) = 0;
|
2023-09-03 21:48:33 +00:00
|
|
|
|
|
|
|
/// For introspection, see `system.scheduler` table
|
|
|
|
virtual void forEachNode(std::function<void(const String & resource, const String & path, const String & type, const SchedulerNodePtr & node)> visitor) = 0;
|
2022-09-27 13:26:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using ResourceManagerPtr = std::shared_ptr<IResourceManager>;
|
|
|
|
|
|
|
|
}
|