blob: c91c3acb3bdc424bb2d736aaba32fa8e7fc3d9e6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include <Disks/DiskFactory.h>
#include <Disks/IDisk.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <map>
namespace DB
{
class DiskSelector;
using DiskSelectorPtr = std::shared_ptr<const DiskSelector>;
/// Parse .xml configuration and store information about disks
/// Mostly used for introspection.
class DiskSelector
{
public:
static constexpr auto TMP_INTERNAL_DISK_PREFIX = "__tmp_internal_";
DiskSelector() = default;
DiskSelector(const DiskSelector & from) = default;
using DiskValidator = std::function<bool(const Poco::Util::AbstractConfiguration & config, const String & disk_config_prefix)>;
void initialize(const Poco::Util::AbstractConfiguration & config, const String & config_prefix, ContextPtr context, DiskValidator disk_validator = {});
DiskSelectorPtr updateFromConfig(
const Poco::Util::AbstractConfiguration & config,
const String & config_prefix,
ContextPtr context) const;
/// Get disk by name
DiskPtr get(const String & name) const;
DiskPtr tryGet(const String & name) const;
/// Get all disks with names
const DisksMap & getDisksMap() const;
void addToDiskMap(const String & name, DiskPtr disk);
void shutdown();
private:
DisksMap disks;
bool is_initialized = false;
void assertInitialized() const;
};
}
|