-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathconfig.cpp
299 lines (258 loc) · 12.4 KB
/
config.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#include "config.h"
#include <cloud/storage/core/libs/common/proto_helpers.h>
#include <cloud/storage/core/protos/trace.pb.h>
#include <library/cpp/monlib/service/pages/templates.h>
#include <library/cpp/protobuf/util/pb_io.h>
namespace NCloud::NBlockStore {
namespace {
////////////////////////////////////////////////////////////////////////////////
#define BLOCKSTORE_DIAGNOSTICS_CONFIG(xxx) \
xxx(HostNameScheme, NProto::EHostNameScheme, NProto::EHostNameScheme::HOSTNAME_RAW )\
xxx(BastionNameSuffix, TString, "" )\
xxx(ViewerHostName, TString, "" )\
xxx(KikimrMonPort, ui32, 8765 )\
xxx(NbsMonPort, ui32, 8766 )\
\
xxx(SamplingRate, ui32, 0 )\
xxx(SlowRequestSamplingRate, ui32, 0 )\
xxx(TracesUnifiedAgentEndpoint, TString, "" )\
xxx(TracesSyslogIdentifier, TString, "" )\
\
xxx(ProfileLogTimeThreshold, TDuration, TDuration::Seconds(15) )\
xxx(UseAsyncLogger, bool, false )\
xxx(UnsafeLWTrace, bool, false )\
xxx(LWTraceDebugInitializationQuery, TString, "" )\
xxx(SsdPerfSettings, TVolumePerfSettings, {} )\
xxx(HddPerfSettings, TVolumePerfSettings, {} )\
xxx(NonreplPerfSettings, TVolumePerfSettings, {} )\
xxx(HddNonreplPerfSettings, TVolumePerfSettings, {} )\
xxx(Mirror2PerfSettings, TVolumePerfSettings, {} )\
xxx(Mirror3PerfSettings, TVolumePerfSettings, {} )\
xxx(LocalSSDPerfSettings, TVolumePerfSettings, {} )\
xxx(LocalHDDPerfSettings, TVolumePerfSettings, {} )\
xxx(ExpectedIoParallelism, ui32, 32 )\
xxx(CloudIdsWithStrictSLA, TVector<TString>, {} )\
xxx(LWTraceShuttleCount, ui32, 2000 )\
xxx(MonitoringUrlData, TMonitoringUrlData, {} )\
\
xxx(CpuWaitFilename, TString, "/sys/fs/cgroup/cpu/system.slice/nbs.service/cpuacct.wait" )\
\
xxx(PostponeTimePredictorInterval, TDuration, TDuration::Seconds(5) )\
xxx(PostponeTimePredictorMaxTime, TDuration, TDuration::Seconds(20) )\
xxx(PostponeTimePredictorPercentage, double, 0.5 )\
xxx(SSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(HDDDowntimeThreshold, TDuration, TDuration::Seconds(15) )\
xxx(NonreplicatedSSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(NonreplicatedHDDDowntimeThreshold, TDuration, TDuration::Seconds(15) )\
xxx(Mirror2SSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(Mirror3SSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(LocalSSDDowntimeThreshold, TDuration, TDuration::Seconds(5) )\
xxx(LocalHDDDowntimeThreshold, TDuration, TDuration::Seconds(15) )\
xxx(ReportHistogramAsMultipleCounters, bool, true )\
xxx(ReportHistogramAsSingleCounter, bool, false )\
xxx(StatsFetcherType, NCloud::NProto::EStatsFetcherType, NCloud::NProto::EStatsFetcherType::CGROUP )\
// BLOCKSTORE_DIAGNOSTICS_CONFIG
#define BLOCKSTORE_DIAGNOSTICS_DECLARE_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type Default##name = value; \
// BLOCKSTORE_DIAGOSTICS_DECLARE_CONFIG
BLOCKSTORE_DIAGNOSTICS_CONFIG(BLOCKSTORE_DIAGNOSTICS_DECLARE_CONFIG)
#undef BLOCKSTORE_DIAGNOSTICS_DECLARE_CONFIG
////////////////////////////////////////////////////////////////////////////////
template <typename TTarget, typename TSource>
TTarget ConvertValue(const TSource& value)
{
return static_cast<TTarget>(value);
}
template <>
TDuration ConvertValue<TDuration, ui32>(const ui32& value)
{
return TDuration::MilliSeconds(value);
}
template <>
TVolumePerfSettings
ConvertValue<TVolumePerfSettings, NProto::TVolumePerfSettings>(
const NProto::TVolumePerfSettings& value)
{
return TVolumePerfSettings(value);
}
template <>
TMonitoringUrlData
ConvertValue<TMonitoringUrlData, NProto::TMonitoringUrlData>(
const NProto::TMonitoringUrlData& value)
{
return TMonitoringUrlData(value);
}
template <>
TRequestThresholds
ConvertValue<TRequestThresholds, TProtoRequestThresholds>(
const TProtoRequestThresholds& value)
{
return ConvertRequestThresholds(value);
}
template <>
TVector<TString> ConvertValue(
const google::protobuf::RepeatedPtrField<TString>& value)
{
TVector<TString> v;
for (const auto& x : value) {
v.push_back(x);
}
return v;
}
template <typename T>
void DumpImpl(const T& t, IOutputStream& os)
{
os << t;
}
template <>
void DumpImpl(const TVector<TString>& value, IOutputStream& os)
{
for (size_t i = 0; i < value.size(); ++i) {
if (i) {
os << ",";
}
os << value[i];
}
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
TDiagnosticsConfig::TDiagnosticsConfig(NProto::TDiagnosticsConfig diagnosticsConfig)
: DiagnosticsConfig(std::move(diagnosticsConfig))
{}
#define BLOCKSTORE_CONFIG_GETTER(name, type, ...) \
type TDiagnosticsConfig::Get##name() const \
{ \
return NCloud::HasField(DiagnosticsConfig, #name) \
? ConvertValue<type>(DiagnosticsConfig.Get##name()) \
: Default##name; \
} \
// BLOCKSTORE_CONFIG_GETTER
BLOCKSTORE_DIAGNOSTICS_CONFIG(BLOCKSTORE_CONFIG_GETTER);
#undef BLOCKSTORE_CONFIG_GETTER
TRequestThresholds TDiagnosticsConfig::GetRequestThresholds() const
{
return ConvertValue<TRequestThresholds>(
DiagnosticsConfig.GetRequestThresholds());
}
EHistogramCounterOptions TDiagnosticsConfig::GetHistogramCounterOptions() const
{
EHistogramCounterOptions histogramCounterOptions;
if (GetReportHistogramAsMultipleCounters()) {
histogramCounterOptions |=
EHistogramCounterOption::ReportMultipleCounters;
}
if (GetReportHistogramAsSingleCounter()) {
histogramCounterOptions |= EHistogramCounterOption::ReportSingleCounter;
}
return histogramCounterOptions;
}
void TDiagnosticsConfig::Dump(IOutputStream& out) const
{
#define BLOCKSTORE_CONFIG_DUMP(name, ...) \
out << #name << ": "; \
DumpImpl(Get##name(), out); \
out << Endl; \
// BLOCKSTORE_CONFIG_DUMP
BLOCKSTORE_DIAGNOSTICS_CONFIG(BLOCKSTORE_CONFIG_DUMP);
#undef BLOCKSTORE_CONFIG_DUMP
}
void TDiagnosticsConfig::DumpHtml(IOutputStream& out) const
{
#define BLOCKSTORE_CONFIG_DUMP(name, ...) \
TABLER() { \
TABLED() { out << #name; } \
TABLED() { DumpImpl(Get##name(), out); } \
} \
// BLOCKSTORE_CONFIG_DUMP
HTML(out) {
TABLE_CLASS("table table-condensed") {
TABLEBODY() {
BLOCKSTORE_DIAGNOSTICS_CONFIG(BLOCKSTORE_CONFIG_DUMP);
}
}
}
#undef BLOCKSTORE_CONFIG_DUMP
}
TDuration GetDowntimeThreshold(
const TDiagnosticsConfig& config,
NCloud::NProto::EStorageMediaKind kind)
{
switch (kind) {
case NCloud::NProto::STORAGE_MEDIA_SSD: {
return config.GetSSDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_SSD_NONREPLICATED: {
return config.GetNonreplicatedSSDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_HDD_NONREPLICATED: {
return config.GetNonreplicatedHDDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_SSD_MIRROR3: {
return config.GetMirror3SSDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_SSD_MIRROR2: {
return config.GetMirror2SSDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_SSD_LOCAL: {
return config.GetLocalSSDDowntimeThreshold();
}
case NCloud::NProto::STORAGE_MEDIA_HDD_LOCAL: {
return config.GetLocalHDDDowntimeThreshold();
}
default: {
return config.GetHDDDowntimeThreshold();
}
}
}
} // namespace NCloud::NBlockStore
////////////////////////////////////////////////////////////////////////////////
template <>
void Out<NCloud::NBlockStore::NProto::EHostNameScheme>(
IOutputStream& out,
NCloud::NBlockStore::NProto::EHostNameScheme scheme)
{
out << NCloud::NBlockStore::NProto::EHostNameScheme_Name(scheme);
}
template <>
void Out<NCloud::NBlockStore::TVolumePerfSettings>(
IOutputStream& out,
const NCloud::NBlockStore::TVolumePerfSettings& value)
{
NCloud::NBlockStore::NProto::TVolumePerfSettings v;
v.MutableRead()->SetIops(value.ReadIops);
v.MutableRead()->SetBandwidth(value.ReadBandwidth);
v.MutableWrite()->SetIops(value.WriteIops);
v.MutableWrite()->SetBandwidth(value.WriteBandwidth);
v.SetCriticalFactor(value.CriticalFactor);
SerializeToTextFormat(v, out);
}
template <>
void Out<NCloud::NBlockStore::TMonitoringUrlData>(
IOutputStream& out,
const NCloud::NBlockStore::TMonitoringUrlData& value)
{
NCloud::NBlockStore::NProto::TMonitoringUrlData v;
v.SetMonitoringClusterName(value.MonitoringClusterName);
v.SetMonitoringUrl(value.MonitoringUrl);
v.SetMonitoringProject(value.MonitoringProject);
v.SetMonitoringVolumeDashboard(value.MonitoringVolumeDashboard);
v.SetMonitoringPartitionDashboard(value.MonitoringPartitionDashboard);
v.SetMonitoringNBSAlertsDashboard(value.MonitoringNBSAlertsDashboard);
v.SetMonitoringNBSTVDashboard(value.MonitoringNBSTVDashboard);
SerializeToTextFormat(v, out);
}
template <>
void Out<NCloud::TRequestThresholds>(
IOutputStream& out,
const NCloud::TRequestThresholds& value)
{
OutRequestThresholds(out, value);
}
template <>
void Out<NCloud::NProto::EStatsFetcherType>(
IOutputStream& out,
NCloud::NProto::EStatsFetcherType statsFetcherType)
{
out << NCloud::NProto::EStatsFetcherType_Name(
statsFetcherType);
}