Skip to content

Commit 9a77c62

Browse files
committed
Move stats to TDomainInfo KIKIMR-19289
1 parent 1d77d19 commit 9a77c62

File tree

7 files changed

+29
-30
lines changed

7 files changed

+29
-30
lines changed

ydb/core/mind/hive/domain_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ struct TDomainInfo {
1515
TTabletId HiveId = 0;
1616
TMaybeServerlessComputeResourcesMode ServerlessComputeResourcesMode;
1717

18+
ui64 TabletsTotal = 0;
19+
ui64 TabletsAlive = 0;
20+
ui64 TabletsAliveInObjectDomain = 0;
21+
1822
ENodeSelectionPolicy GetNodeSelectionPolicy() const;
1923
};
2024

ydb/core/mind/hive/hive_impl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ void THive::DeleteTablet(TTabletId tabletId) {
15521552
}
15531553
const i64 tabletsTotalDiff = -1 - (tablet.Followers.size());
15541554
UpdateCounterTabletsTotal(tabletsTotalDiff);
1555-
UpdateTabletsTotalByDomain(tabletsTotalDiff, tablet.ObjectDomain);
1555+
UpdateDomainTabletsTotal(tablet.ObjectDomain, tabletsTotalDiff);
15561556
Tablets.erase(it);
15571557
}
15581558
}
@@ -1585,17 +1585,17 @@ void THive::KillNode(TNodeId nodeId, const TActorId& local) {
15851585
Execute(CreateKillNode(nodeId, local));
15861586
}
15871587

1588-
void THive::UpdateTabletsTotalByDomain(i64 tabletsTotalDiff, const TSubDomainKey& objectDomain) {
1588+
void THive::UpdateDomainTabletsTotal(const TSubDomainKey& objectDomain, i64 tabletsTotalDiff) {
15891589
if (objectDomain) {
1590-
TabletsTotalByDomain[objectDomain] += tabletsTotalDiff;
1590+
Domains[objectDomain].TabletsTotal += tabletsTotalDiff;
15911591
}
15921592
}
15931593

1594-
void THive::UpdateTabletsAliveByDomain(i64 tabletsAliveDiff, const TSubDomainKey& objectDomain, const TSubDomainKey& tabletNodeDomain) {
1594+
void THive::UpdateDomainTabletsAlive(const TSubDomainKey& objectDomain, i64 tabletsAliveDiff, const TSubDomainKey& tabletNodeDomain) {
15951595
if (objectDomain) {
1596-
TabletsAliveByDomain[objectDomain] += tabletsAliveDiff;
1597-
if (objectDomain == tabletNodeDomain) {
1598-
TabletsAliveInObjectDomainByDomain[objectDomain] += tabletsAliveDiff;
1596+
Domains[objectDomain].TabletsAlive += tabletsAliveDiff;
1597+
if (tabletNodeDomain == objectDomain) {
1598+
Domains[objectDomain].TabletsAliveInObjectDomain += tabletsAliveDiff;
15991599
}
16001600
}
16011601
}

ydb/core/mind/hive/hive_impl.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ class THive : public TActor<THive>, public TTabletExecutedFlat, public THiveShar
323323
ui32 DataCenters = 1;
324324
ui32 RegisteredDataCenters = 1;
325325
TObjectDistributions ObjectDistributions;
326-
std::unordered_map<TSubDomainKey, ui64> TabletsTotalByDomain;
327-
std::unordered_map<TSubDomainKey, ui64> TabletsAliveByDomain;
328-
std::unordered_map<TSubDomainKey, ui64> TabletsAliveInObjectDomainByDomain;
329326

330327
bool AreWeRootHive() const { return RootHiveId == HiveId; }
331328
bool AreWeSubDomainHive() const { return RootHiveId != HiveId; }
@@ -636,8 +633,8 @@ class THive : public TActor<THive>, public TTabletExecutedFlat, public THiveShar
636633
TTabletCategoryInfo& GetTabletCategory(TTabletCategoryId tabletCategoryId);
637634
void KillNode(TNodeId nodeId, const TActorId& local);
638635
void AddToBootQueue(TTabletInfo* tablet);
639-
void UpdateTabletsTotalByDomain(i64 tabletsTotalDiff, const TSubDomainKey& objectDomain);
640-
void UpdateTabletsAliveByDomain(i64 tabletsAliveDiff, const TSubDomainKey& objectDomain, const TSubDomainKey& tabletNodeDomain);
636+
void UpdateDomainTabletsTotal(const TSubDomainKey& objectDomain, i64 tabletsTotalDiff);
637+
void UpdateDomainTabletsAlive(const TSubDomainKey& objectDomain, i64 tabletsAliveDiff, const TSubDomainKey& tabletNodeDomain);
641638
void SetCounterTabletsTotal(ui64 tabletsTotal);
642639
void UpdateCounterTabletsTotal(i64 tabletsTotalDiff);
643640
void UpdateCounterTabletsAlive(i64 tabletsAliveDiff);

ydb/core/mind/hive/leader_tablet_info.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ void TLeaderTabletInfo::AssignDomains(const TSubDomainKey& objectDomain, const T
8686
}
8787

8888
const ui64 leaderAndFollowers = 1 + Followers.size();
89-
Hive.UpdateTabletsTotalByDomain(-leaderAndFollowers, oldObjectDomain);
90-
Hive.UpdateTabletsTotalByDomain(+leaderAndFollowers, ObjectDomain);
89+
Hive.UpdateDomainTabletsTotal(oldObjectDomain, -leaderAndFollowers);
90+
Hive.UpdateDomainTabletsTotal(ObjectDomain, +leaderAndFollowers);
9191

9292
if (IsAlive()) {
93-
Hive.UpdateTabletsAliveByDomain(-1, oldObjectDomain, Node->GetServicedDomain());
94-
Hive.UpdateTabletsAliveByDomain(+1, ObjectDomain, Node->GetServicedDomain());
93+
Hive.UpdateDomainTabletsAlive(oldObjectDomain, -1, Node->GetServicedDomain());
94+
Hive.UpdateDomainTabletsAlive(ObjectDomain, +1, Node->GetServicedDomain());
9595
}
9696

9797
for (const auto& follower : Followers) {
9898
if (follower.IsAlive()) {
99-
Hive.UpdateTabletsAliveByDomain(-1, oldObjectDomain, follower.Node->GetServicedDomain());
100-
Hive.UpdateTabletsAliveByDomain(+1, ObjectDomain, follower.Node->GetServicedDomain());
99+
Hive.UpdateDomainTabletsAlive(oldObjectDomain, -1, follower.Node->GetServicedDomain());
100+
Hive.UpdateDomainTabletsAlive(ObjectDomain, +1, follower.Node->GetServicedDomain());
101101
}
102102
}
103103
}
@@ -145,7 +145,7 @@ TFollowerTabletInfo& TLeaderTabletInfo::AddFollower(TFollowerGroup& followerGrou
145145
follower.Id = followerId;
146146
}
147147
Hive.UpdateCounterTabletsTotal(+1);
148-
Hive.UpdateTabletsTotalByDomain(+1, ObjectDomain);
148+
Hive.UpdateDomainTabletsTotal(ObjectDomain, +1);
149149
return follower;
150150
}
151151

ydb/core/mind/hive/monitoring.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,18 @@ class TTxMonEvent_MemStateDomains : public TTransactionBase<THive> {
490490
out << "<td>-</td>";
491491
out << "<td>-</td>";
492492
}
493-
if (Self->TabletsTotalByDomain[domainKey] > 0) {
494-
out << "<td>" << std::round(Self->TabletsAliveInObjectDomainByDomain[domainKey] * 100.0 / Self->TabletsTotalByDomain[domainKey]) << "%"
495-
<< " (" << Self->TabletsAliveInObjectDomainByDomain[domainKey] << " of " << Self->TabletsTotalByDomain[domainKey] << ")" << "</td>";
493+
if (domainInfo.TabletsTotal > 0) {
494+
out << "<td>" << std::round(domainInfo.TabletsAliveInObjectDomain * 100.0 / domainInfo.TabletsTotal) << "%"
495+
<< " (" << domainInfo.TabletsAliveInObjectDomain << " of " << domainInfo.TabletsTotal << ")" << "</td>";
496496

497-
const ui64 tabletsAliveInOtherDomains = Self->TabletsAliveByDomain[domainKey] - Self->TabletsAliveInObjectDomainByDomain[domainKey];
498-
out << "<td>" << std::round(tabletsAliveInOtherDomains * 100.0 / Self->TabletsTotalByDomain[domainKey]) << "%"
499-
<< " (" << tabletsAliveInOtherDomains << " of " << Self->TabletsTotalByDomain[domainKey] << ")" << "</td>";
497+
const ui64 tabletsAliveInOtherDomains = domainInfo.TabletsAlive - domainInfo.TabletsAliveInObjectDomain;
498+
out << "<td>" << std::round(tabletsAliveInOtherDomains * 100.0 / domainInfo.TabletsTotal) << "%"
499+
<< " (" << tabletsAliveInOtherDomains << " of " << domainInfo.TabletsTotal << ")" << "</td>";
500500
} else {
501501
out << "<td>-</td>";
502502
out << "<td>-</td>";
503503
}
504-
out << "<td>" << Self->TabletsTotalByDomain[domainKey] << "</td>";
504+
out << "<td>" << domainInfo.TabletsTotal << "</td>";
505505
out << "</tr>";
506506
}
507507
out << "</tbody>";

ydb/core/mind/hive/node_info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool TNodeInfo::OnTabletChangeVolatileState(TTabletInfo* tablet, TTabletInfo::EV
6969
TabletsRunningByType[tablet->GetTabletType()].erase(tablet);
7070
TabletsOfObject[tablet->GetObjectId()].erase(tablet);
7171
Hive.UpdateCounterTabletsAlive(-1);
72-
Hive.UpdateTabletsAliveByDomain(-1, tablet->GetLeader().ObjectDomain, GetServicedDomain());
72+
Hive.UpdateDomainTabletsAlive(tablet->GetLeader().ObjectDomain, -1, GetServicedDomain());
7373
if (tablet->HasCounter() && tablet->IsLeader()) {
7474
Hive.UpdateObjectCount(tablet->AsLeader(), *this, -1);
7575
}
@@ -85,7 +85,7 @@ bool TNodeInfo::OnTabletChangeVolatileState(TTabletInfo* tablet, TTabletInfo::EV
8585
TabletsRunningByType[tablet->GetTabletType()].emplace(tablet);
8686
TabletsOfObject[tablet->GetObjectId()].emplace(tablet);
8787
Hive.UpdateCounterTabletsAlive(+1);
88-
Hive.UpdateTabletsAliveByDomain(+1, tablet->GetLeader().ObjectDomain, GetServicedDomain());
88+
Hive.UpdateDomainTabletsAlive(tablet->GetLeader().ObjectDomain, +1, GetServicedDomain());
8989
if (tablet->HasCounter() && tablet->IsLeader()) {
9090
Hive.UpdateObjectCount(tablet->AsLeader(), *this, +1);
9191
}

ydb/core/mind/hive/tx__load_everything.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,8 @@ class TTxLoadEverything : public TTransactionBase<THive> {
713713
ui64 tabletsTotal = 0;
714714
for (auto it = Self->Tablets.begin(); it != Self->Tablets.end(); ++it) {
715715
++tabletsTotal;
716-
Self->UpdateTabletsTotalByDomain(+1, it->second.ObjectDomain);
717716
for (const TTabletInfo& follower : it->second.Followers) {
718717
++tabletsTotal;
719-
Self->UpdateTabletsTotalByDomain(+1, it->second.ObjectDomain);
720718
if (follower.IsLeader()) {
721719
follower.AsLeader();
722720
} else {

0 commit comments

Comments
 (0)