forked from ydb-platform/nbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_service.h
230 lines (183 loc) · 5.81 KB
/
stats_service.h
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
#pragma once
#include "public.h"
#include <cloud/blockstore/libs/kikimr/components.h>
#include <cloud/blockstore/libs/kikimr/events.h>
#include <cloud/blockstore/libs/service/request.h>
#include <cloud/blockstore/libs/storage/core/disk_counters.h>
#include <cloud/blockstore/libs/storage/core/metrics.h>
#include <cloud/blockstore/libs/storage/protos/volume.pb.h>
#include <contrib/ydb/library/actors/core/actorid.h>
#include <util/generic/string.h>
namespace NCloud::NBlockStore::NStorage {
////////////////////////////////////////////////////////////////////////////////
#define BLOCKSTORE_STATS_SERVICE_REQUESTS(xxx, ...) \
xxx(GetVolumeStats, __VA_ARGS__) \
// BLOCKSTORE_SERVICE_REQUESTS
////////////////////////////////////////////////////////////////////////////////
struct TEvStatsService
{
//
// RegisterVolume notification
//
struct TRegisterVolume
{
const TString DiskId;
const ui64 TabletId;
const NProto::TVolume Config;
TRegisterVolume(
TString diskId,
ui64 tabletId,
NProto::TVolume config)
: DiskId(std::move(diskId))
, TabletId(tabletId)
, Config(std::move(config))
{}
};
//
// UnregisterVolume notification
//
struct TUnregisterVolume
{
const TString DiskId;
const NProto::TError Error;
TUnregisterVolume(TString DiskId, NProto::TError error = {})
: DiskId(std::move(DiskId))
, Error(std::move(error))
{}
};
//
// VolumeConfigUpdated notification
//
struct TVolumeConfigUpdated
{
const TString DiskId;
const NProto::TVolume Config;
TVolumeConfigUpdated(
TString diskId,
NProto::TVolume config)
: DiskId(std::move(diskId))
, Config(std::move(config))
{}
};
//
// VolumePartCounters notification
//
struct TVolumePartCounters
{
const TString DiskId;
TPartitionDiskCountersPtr DiskCounters;
ui64 VolumeSystemCpu;
ui64 VolumeUserCpu;
bool HasCheckpoint;
NBlobMetrics::TBlobLoadMetrics BlobLoadMetrics;
TVolumePartCounters(
TString diskId,
TPartitionDiskCountersPtr diskCounters,
ui64 volumeSystemCpu,
ui64 volumeUserCpu,
bool hasCheckpoint,
NBlobMetrics::TBlobLoadMetrics metrics)
: DiskId(std::move(diskId))
, DiskCounters(std::move(diskCounters))
, VolumeSystemCpu(volumeSystemCpu)
, VolumeUserCpu(volumeUserCpu)
, HasCheckpoint(hasCheckpoint)
, BlobLoadMetrics(std::move(metrics))
{}
};
//
// VolumeSelfCounters notification
//
struct TVolumeSelfCounters
{
const TString DiskId;
const bool HasClients;
const bool IsPreempted;
TVolumeSelfCountersPtr VolumeSelfCounters;
const ui32 FailedBoots;
TVolumeSelfCounters(
TString diskId,
bool hasClients,
bool isPreempted,
TVolumeSelfCountersPtr volumeCounters,
ui32 failedBoots)
: DiskId(std::move(diskId))
, HasClients(hasClients)
, IsPreempted(isPreempted)
, VolumeSelfCounters(std::move(volumeCounters))
, FailedBoots(failedBoots)
{}
TVolumeSelfCounters(
TString diskId,
bool hasClients,
bool isPreempted,
TVolumeSelfCountersPtr volumeCounters)
: TVolumeSelfCounters(
std::move(diskId),
hasClients,
isPreempted,
std::move(volumeCounters),
0)
{}
};
//
// GetVolumeStats
//
struct TGetVolumeStatsRequest
{
TVector<NProto::TVolumeBalancerDiskStats> VolumeStats;
TGetVolumeStatsRequest() = default;
TGetVolumeStatsRequest(TVector<NProto::TVolumeBalancerDiskStats> volumeStats)
: VolumeStats(std::move(volumeStats))
{}
};
struct TGetVolumeStatsResponse
{
TVector<NProto::TVolumeBalancerDiskStats> VolumeStats;
TGetVolumeStatsResponse() = default;
TGetVolumeStatsResponse(TVector<NProto::TVolumeBalancerDiskStats> volumeStats)
: VolumeStats(std::move(volumeStats))
{}
};
//
// Events declaration
//
enum EEvents
{
EvBegin = TBlockStoreEvents::STATS_SERVICE_START,
EvRegisterVolume,
EvUnregisterVolume,
EvVolumeConfigUpdated,
EvVolumePartCounters,
EvVolumeSelfCounters,
EvGetVolumeStatsRequest,
EvGetVolumeStatsResponse,
EvEnd
};
static_assert(EvEnd < (int)TBlockStoreEvents::STATS_SERVICE_END,
"EvEnd expected to be < TBlockStoreEvents::STATS_SERVICE_END");
BLOCKSTORE_STATS_SERVICE_REQUESTS(BLOCKSTORE_DECLARE_EVENTS)
using TEvRegisterVolume = TRequestEvent<
TRegisterVolume,
EvRegisterVolume
>;
using TEvUnregisterVolume = TRequestEvent<
TUnregisterVolume,
EvUnregisterVolume
>;
using TEvVolumeConfigUpdated = TRequestEvent<
TVolumeConfigUpdated,
EvVolumeConfigUpdated
>;
using TEvVolumePartCounters = TRequestEvent<
TVolumePartCounters,
EvVolumePartCounters
>;
using TEvVolumeSelfCounters = TRequestEvent<
TVolumeSelfCounters,
EvVolumeSelfCounters
>;
};
////////////////////////////////////////////////////////////////////////////////
NActors::TActorId MakeStorageStatsServiceId();
} // namespace NCloud::NBlockStore::NStorage