2020-05-04 20:15:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Disks/DiskFactory.h>
|
|
|
|
#include <Disks/IDisk.h>
|
|
|
|
|
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-05-22 10:33:57 +00:00
|
|
|
|
2020-05-04 20:15:38 +00:00
|
|
|
class DiskSelector;
|
|
|
|
using DiskSelectorPtr = std::shared_ptr<const DiskSelector>;
|
2020-05-22 10:33:57 +00:00
|
|
|
using DisksMap = std::map<String, DiskPtr>;
|
2020-05-04 20:15:38 +00:00
|
|
|
|
|
|
|
/// Parse .xml configuration and store information about disks
|
|
|
|
/// Mostly used for introspection.
|
|
|
|
class DiskSelector
|
|
|
|
{
|
|
|
|
public:
|
2021-04-10 23:33:54 +00:00
|
|
|
DiskSelector(const Poco::Util::AbstractConfiguration & config, const String & config_prefix, ContextConstPtr context);
|
2020-05-04 20:15:38 +00:00
|
|
|
DiskSelector(const DiskSelector & from) : disks(from.disks) { }
|
|
|
|
|
2020-10-20 15:10:24 +00:00
|
|
|
DiskSelectorPtr updateFromConfig(
|
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const String & config_prefix,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context
|
2020-10-20 15:10:24 +00:00
|
|
|
) const;
|
2020-05-04 20:15:38 +00:00
|
|
|
|
|
|
|
/// Get disk by name
|
|
|
|
DiskPtr get(const String & name) const;
|
|
|
|
|
|
|
|
/// Get all disks with names
|
2020-05-22 10:33:57 +00:00
|
|
|
const DisksMap & getDisksMap() const { return disks; }
|
2020-05-09 21:24:15 +00:00
|
|
|
void addToDiskMap(String name, DiskPtr disk)
|
|
|
|
{
|
|
|
|
disks.emplace(name, disk);
|
|
|
|
}
|
2020-05-04 20:15:38 +00:00
|
|
|
|
|
|
|
private:
|
2020-05-22 10:33:57 +00:00
|
|
|
DisksMap disks;
|
2020-05-04 20:15:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|