@@ -72,21 +72,25 @@ namespace NKikimr::NBsController {
72
72
TEntityId RealmGroup;
73
73
TEntityId Realm;
74
74
TEntityId Domain;
75
+ TEntityId Device;
75
76
76
77
TPDiskLayoutPosition () = default ;
77
78
78
- TPDiskLayoutPosition (TEntityId realmGroup, TEntityId realm, TEntityId domain)
79
+ TPDiskLayoutPosition (TEntityId realmGroup, TEntityId realm, TEntityId domain, TEntityId device )
79
80
: RealmGroup(realmGroup)
80
81
, Realm(realm)
81
82
, Domain(domain)
83
+ , Device(device)
82
84
{}
83
85
84
86
TPDiskLayoutPosition (TDomainMapper& mapper, const TNodeLocation& location, TPDiskId pdiskId, const TGroupGeometryInfo& geom) {
85
- TStringStream realmGroup, realm, domain;
87
+ TStringStream realmGroup, realm, domain, device;
88
+ ui32 deviceLevelEnd = TNodeLocation::TKeys::E::Unit + 1 ;
86
89
const std::pair<int , TStringStream*> levels[] = {
87
90
{geom.GetRealmLevelBegin (), &realmGroup},
88
91
{Max (geom.GetRealmLevelEnd (), geom.GetDomainLevelBegin ()), &realm},
89
- {Max (geom.GetRealmLevelEnd (), geom.GetDomainLevelEnd ()), &domain}
92
+ {Max (geom.GetRealmLevelEnd (), geom.GetDomainLevelEnd ()), &domain},
93
+ {Max (geom.GetRealmLevelEnd (), geom.GetDomainLevelEnd (), deviceLevelEnd), &device}
90
94
};
91
95
auto addLevel = [&](int key, const TString& value) {
92
96
for (const auto & [reference, stream] : levels) {
@@ -102,14 +106,15 @@ namespace NKikimr::NBsController {
102
106
RealmGroup = mapper (realmGroup.Str ());
103
107
Realm = mapper (realm.Str ());
104
108
Domain = mapper (domain.Str ());
109
+ Device = mapper (device.Str ());
105
110
}
106
111
107
112
TString ToString () const {
108
- return TStringBuilder () << " {" << RealmGroup << " ." << Realm << " ." << Domain << " }" ;
113
+ return TStringBuilder () << " {" << RealmGroup << " ." << Realm << " ." << Domain << " . " << Device << " }" ;
109
114
}
110
115
111
116
auto AsTuple () const {
112
- return std::tie (RealmGroup, Realm, Domain);
117
+ return std::tie (RealmGroup, Realm, Domain, Device );
113
118
}
114
119
115
120
friend bool operator ==(const TPDiskLayoutPosition& x, const TPDiskLayoutPosition& y) {
@@ -124,12 +129,13 @@ namespace NKikimr::NBsController {
124
129
struct TScore {
125
130
ui32 RealmInterlace = 0 ;
126
131
ui32 DomainInterlace = 0 ;
132
+ ui32 DeviceInterlace = 0 ;
127
133
ui32 RealmGroupScatter = 0 ;
128
134
ui32 RealmScatter = 0 ;
129
135
ui32 DomainScatter = 0 ;
130
136
131
137
auto AsTuple () const {
132
- return std::make_tuple (RealmInterlace, DomainInterlace, RealmGroupScatter, RealmScatter, DomainScatter);
138
+ return std::make_tuple (RealmInterlace, DomainInterlace, DeviceInterlace, RealmGroupScatter, RealmScatter, DomainScatter);
133
139
}
134
140
135
141
bool BetterThan (const TScore& other) const {
@@ -141,12 +147,13 @@ namespace NKikimr::NBsController {
141
147
}
142
148
143
149
static TScore Max () {
144
- return {::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>()};
150
+ return {::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>() };
145
151
}
146
152
147
153
TString ToString () const {
148
154
return TStringBuilder () << " {RealmInterlace# " << RealmInterlace
149
155
<< " DomainInterlace# " << DomainInterlace
156
+ << " DeviceInterlace# " << DeviceInterlace
150
157
<< " RealmGroupScatter# " << RealmGroupScatter
151
158
<< " RealmScatter# " << RealmScatter
152
159
<< " DomainScatter# " << DomainScatter
@@ -168,6 +175,8 @@ namespace NKikimr::NBsController {
168
175
TStackVec<THashMap<TEntityId, ui32>, 32 > NumDisksPerDomain;
169
176
THashMap<TEntityId, ui32> NumDisksPerDomainTotal;
170
177
178
+ THashMap<TEntityId, ui32> NumDisksPerDevice;
179
+
171
180
TGroupLayout (const TBlobStorageGroupInfo::TTopology& topology)
172
181
: Topology(topology)
173
182
, NumDisksInRealm(Topology.GetTotalFailRealmsNum())
@@ -187,6 +196,8 @@ namespace NKikimr::NBsController {
187
196
NumDisksInDomain[domainIdx] += value;
188
197
NumDisksPerDomain[domainIdx][pos.Domain ] += value;
189
198
NumDisksPerDomainTotal[pos.Domain ] += value;
199
+
200
+ NumDisksPerDevice[pos.Device ] += value;
190
201
}
191
202
192
203
void AddDisk (const TPDiskLayoutPosition& pos, ui32 orderNumber) {
@@ -201,12 +212,18 @@ namespace NKikimr::NBsController {
201
212
const TVDiskIdShort vdisk = Topology.GetVDiskId (orderNumber);
202
213
const ui32 domainIdx = Topology.GetFailDomainOrderNumber (vdisk);
203
214
215
+ const auto & disksPerRealm = NumDisksPerRealm[vdisk.FailRealm ][pos.Realm ];
216
+ const auto & disksPerDomain = NumDisksPerDomain[domainIdx][pos.Domain ];
217
+
218
+ const ui32 disksOnDevice = NumDisksPerDevice[pos.Device ];
219
+
204
220
return {
205
- .RealmInterlace = NumDisksPerRealmTotal[pos.Realm ] - NumDisksPerRealm[vdisk.FailRealm ][pos.Realm ],
206
- .DomainInterlace = NumDisksPerDomainTotal[pos.Domain ] - NumDisksPerDomain[domainIdx][pos.Domain ],
221
+ .RealmInterlace = NumDisksPerRealmTotal[pos.Realm ] - disksPerRealm,
222
+ .DomainInterlace = NumDisksPerDomainTotal[pos.Domain ] - disksPerDomain,
223
+ .DeviceInterlace = disksOnDevice,
207
224
.RealmGroupScatter = NumDisks - NumDisksPerRealmGroup[pos.RealmGroup ],
208
- .RealmScatter = NumDisksInRealm[vdisk.FailRealm ] - NumDisksPerRealm[vdisk. FailRealm ][pos. Realm ] ,
209
- .DomainScatter = NumDisksInDomain[domainIdx] - NumDisksPerDomain[domainIdx][pos. Domain ] ,
225
+ .RealmScatter = NumDisksInRealm[vdisk.FailRealm ] - disksPerRealm ,
226
+ .DomainScatter = NumDisksInDomain[domainIdx] - disksPerDomain ,
210
227
};
211
228
}
212
229
0 commit comments