blob: c843ee1156373549499831c2dc58bcd3a9e8eeaa (
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
54
55
56
57
58
59
60
61
62
63
|
#include <Disks/IStoragePolicy.h>
#include <Common/quoteString.h>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_VOLUME;
extern const int UNKNOWN_DISK;
}
DiskPtr IStoragePolicy::getDiskByName(const String & disk_name) const
{
auto disk = tryGetDiskByName(disk_name);
if (!disk)
throw Exception(ErrorCodes::UNKNOWN_DISK,
"No such disk {} in storage policy {}", backQuote(disk_name), backQuote(getName()));
return disk;
}
VolumePtr IStoragePolicy::getVolumeByName(const String & volume_name) const
{
auto volume = tryGetVolumeByName(volume_name);
if (!volume)
throw Exception(ErrorCodes::UNKNOWN_VOLUME,
"No such volume {} in storage policy {}", backQuote(volume_name), backQuote(getName()));
return volume;
}
size_t IStoragePolicy::getVolumeIndexByDiskName(const String & disk_name) const
{
auto index = tryGetVolumeIndexByDiskName(disk_name);
if (!index)
throw Exception(ErrorCodes::UNKNOWN_DISK,
"No disk {} in policy {}", backQuote(disk_name), backQuote(getName()));
return *index;
}
VolumePtr IStoragePolicy::tryGetVolumeByDiskName(const String & disk_name) const
{
auto index = tryGetVolumeIndexByDiskName(disk_name);
if (!index)
return nullptr;
return getVolume(*index);
}
VolumePtr IStoragePolicy::getVolumeByDiskName(const String & disk_name) const
{
auto volume = tryGetVolumeByDiskName(disk_name);
if (!volume)
throw Exception(ErrorCodes::UNKNOWN_DISK,
"No disk {} in policy {}", backQuote(disk_name), backQuote(getName()));
return volume;
}
}
|