@@ -1579,7 +1579,7 @@ class TStorageGroups : public TViewerPipeClient {
1579
1579
}
1580
1580
}
1581
1581
1582
- void RequestNodesList () {
1582
+ void RequestNodesListForStorageGroups () {
1583
1583
if (!NodesInfo.has_value ()) {
1584
1584
NodesInfo = MakeRequest<TEvInterconnect::TEvNodesInfo>(GetNameserviceActorId (), new TEvInterconnect::TEvListNodes ());
1585
1585
}
@@ -1628,34 +1628,30 @@ class TStorageGroups : public TViewerPipeClient {
1628
1628
}
1629
1629
1630
1630
void ProcessWhiteboardGroups () {
1631
- std::unordered_map<ui32, const NKikimrWhiteboard::TBSGroupStateInfo*> latestGroupInfo;
1632
- for (const auto & [nodeId, bsGroupStateResponse] : BSGroupStateResponse) {
1633
- if (bsGroupStateResponse.IsOk ()) {
1634
- for (const NKikimrWhiteboard::TBSGroupStateInfo& info : bsGroupStateResponse->Record .GetBSGroupStateInfo ()) {
1635
- TString storagePoolName = info.GetStoragePoolName ();
1636
- if (storagePoolName.empty ()) {
1637
- continue ;
1638
- }
1639
- if (info.VDiskNodeIdsSize () == 0 ) {
1640
- continue ;
1641
- }
1642
- auto itLatest = latestGroupInfo.find (info.GetGroupID ());
1643
- if (itLatest == latestGroupInfo.end ()) {
1644
- latestGroupInfo.emplace (info.GetGroupID (), &info);
1645
- } else {
1646
- if (info.GetGroupGeneration () > itLatest->second ->GetGroupGeneration ()) {
1647
- itLatest->second = &info;
1631
+ if (GroupData.empty ()) {
1632
+ std::unordered_map<ui32, const NKikimrWhiteboard::TBSGroupStateInfo*> latestGroupInfo;
1633
+ for (const auto & [nodeId, bsGroupStateResponse] : BSGroupStateResponse) {
1634
+ if (bsGroupStateResponse.IsOk ()) {
1635
+ for (const NKikimrWhiteboard::TBSGroupStateInfo& info : bsGroupStateResponse->Record .GetBSGroupStateInfo ()) {
1636
+ TString storagePoolName = info.GetStoragePoolName ();
1637
+ if (storagePoolName.empty ()) {
1638
+ continue ;
1639
+ }
1640
+ if (info.VDiskNodeIdsSize () == 0 ) {
1641
+ continue ;
1642
+ }
1643
+ auto itLatest = latestGroupInfo.find (info.GetGroupID ());
1644
+ if (itLatest == latestGroupInfo.end ()) {
1645
+ latestGroupInfo.emplace (info.GetGroupID (), &info);
1646
+ } else {
1647
+ if (info.GetGroupGeneration () > itLatest->second ->GetGroupGeneration ()) {
1648
+ itLatest->second = &info;
1649
+ }
1648
1650
}
1649
1651
}
1650
1652
}
1651
1653
}
1652
- }
1653
- GroupData.reserve (latestGroupInfo.size ()); // to keep cache stable after emplace
1654
- RebuildGroupsByGroupId ();
1655
- size_t capacity = GroupData.capacity ();
1656
- for (const auto & [groupId, info] : latestGroupInfo) {
1657
- auto itGroup = GroupsByGroupId.find (groupId);
1658
- if (itGroup == GroupsByGroupId.end ()) {
1654
+ for (const auto & [groupId, info] : latestGroupInfo) {
1659
1655
TGroup& group = GroupData.emplace_back ();
1660
1656
group.GroupId = groupId;
1661
1657
group.GroupGeneration = info->GetGroupGeneration ();
@@ -1670,26 +1666,15 @@ class TStorageGroups : public TViewerPipeClient {
1670
1666
TVDisk& vDisk = group.VDisks .emplace_back ();
1671
1667
vDisk.VDiskId = VDiskIDFromVDiskID (vDiskId);
1672
1668
}
1673
- if (capacity != GroupData.capacity ()) {
1674
- // we expect to never do this
1675
- RebuildGroupsByGroupId ();
1676
- capacity = GroupData.capacity ();
1677
- }
1678
- } else {
1679
- TGroup& group = *itGroup->second ;
1680
- if (group.VDiskNodeIds .empty ()) {
1681
- for (auto nodeId : info->GetVDiskNodeIds ()) {
1682
- group.VDiskNodeIds .push_back (nodeId);
1683
- }
1684
- }
1685
1669
}
1670
+ GroupView.clear ();
1671
+ for (TGroup& group : GroupData) {
1672
+ GroupView.emplace_back (&group);
1673
+ }
1674
+ FieldsAvailable |= FieldsWbGroups;
1675
+ FoundGroups = TotalGroups = GroupView.size ();
1676
+ ApplyEverything ();
1686
1677
}
1687
- for (TGroup& group : GroupData) {
1688
- GroupView.emplace_back (&group);
1689
- }
1690
- FieldsAvailable |= FieldsWbGroups;
1691
- FoundGroups = TotalGroups = GroupView.size ();
1692
- ApplyEverything ();
1693
1678
if (FieldsNeeded (FieldsWbDisks)) {
1694
1679
std::unordered_set<TNodeId> nodeIds;
1695
1680
for (const TGroup* group : GroupView) {
@@ -1907,7 +1892,7 @@ class TStorageGroups : public TViewerPipeClient {
1907
1892
1908
1893
void RequestWhiteboard () {
1909
1894
FallbackToWhiteboard = true ;
1910
- RequestNodesList ();
1895
+ RequestNodesListForStorageGroups ();
1911
1896
}
1912
1897
1913
1898
void OnBscError (const TString& error) {
0 commit comments