blob: 027fc5e64a8e7b003b4a4e6c8f6503ae1c621b7b (
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
|
#include "config.h"
#include <util/generic/hash_set.h>
#include <util/string/printf.h>
namespace NKikimr {
bool CheckPersQueueConfig(const NKikimrPQ::TPQTabletConfig& config, const bool shouldHavePartitionsList, TString *error) {
if (!config.HasPartitionConfig()) {
if (error)
*error = "no PartitionConfig";
return false;
}
const auto& partitionIds = config.GetPartitionIds();
const auto& partitions = config.GetPartitions();
if (shouldHavePartitionsList) {
if (partitionIds.empty() && partitions.empty()) {
if (error)
*error = "empty Partitions list";
return false;
}
THashSet<ui32> parts;
for (const auto partitionId : partitionIds) {
if (!parts.insert(partitionId).second) {
if (error)
*error = Sprintf("duplicate partitions with id %u", partitionId);
return false;
}
}
parts.clear();
for (const auto& partition : partitions) {
const auto partitionId = partition.GetPartitionId();
if (!parts.insert(partitionId).second) {
if (error)
*error = Sprintf("duplicate partitions with id %u", partitionId);
return false;
}
}
} else {
if (!partitionIds.empty() || !partitions.empty()) {
if (error)
*error = "Partitions list must be empty";
return false;
}
}
const auto& partCfg = config.GetPartitionConfig();
if (!partCfg.HasLifetimeSeconds()) {
if (error)
*error = "no lifetimeSeconds specified in TPartitionConfig";
return false;
}
return true;
}
} // NKikimr
|