forked from ydb-platform/nbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart2_diagnostics.h
67 lines (51 loc) · 1.66 KB
/
part2_diagnostics.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
#pragma once
#include "public.h"
#include "part2_actor.h"
#include <cloud/blockstore/libs/diagnostics/profile_log.h>
#include <cloud/blockstore/libs/storage/partition2/model/block.h>
namespace NCloud::NBlockStore::NStorage::NPartition2 {
////////////////////////////////////////////////////////////////////////////////
class TDumpBlockCommitIds
{
private:
const TVector<TBlock>& Blocks;
TVector<IProfileLog::TBlockCommitId>& BlockCommitIds;
const bool Enabled;
public:
TDumpBlockCommitIds(
const TVector<TBlock>& blocks,
TVector<IProfileLog::TBlockCommitId>& blockCommitIds,
bool enabled)
: Blocks(blocks)
, BlockCommitIds(blockCommitIds)
, Enabled(enabled)
{
if (!Enabled) {
return;
}
BlockCommitIds.reserve(BlockCommitIds.size() + Blocks.size());
for (const auto& block: Blocks) {
BlockCommitIds.push_back({
block.BlockIndex,
block.MinCommitId,
block.MaxCommitId,
0, // minCommitIdNew (fill later)
0} // maxCommitIdNew (fill later)
);
}
}
~TDumpBlockCommitIds()
{
if (!Enabled) {
return;
}
auto it = BlockCommitIds.rbegin();
for (auto jt = Blocks.rbegin(); jt != Blocks.rend(); ++it, ++jt) {
Y_ABORT_UNLESS(it != BlockCommitIds.rend());
Y_ABORT_UNLESS(it->BlockIndex == jt->BlockIndex);
it->MinCommitIdNew = jt->MinCommitId;
it->MaxCommitIdNew = jt->MaxCommitId;
}
}
};
} // namespace NCloud::NBlockStore::NStorage::NPartition2