Skip to content

Commit

Permalink
Add exclusive nodes to new json/nodes endpoint KIKIMR-20675
Browse files Browse the repository at this point in the history
  • Loading branch information
pixcc committed Jan 23, 2024
1 parent e3e5ca6 commit fa31b2a
Show file tree
Hide file tree
Showing 4 changed files with 451 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ydb/core/viewer/json_compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ class TJsonCompute : public TViewerPipeClient<TJsonCompute> {
auto nodeId = nodeStat.GetNodeId();
if (IsRequiredNode(nodeId)) {
const auto& nodeDomain = nodeStat.GetNodeDomain();
TPathId subDomainKey(nodeDomain.GetSchemeShard(), nodeDomain.GetPathId());
if (FilterSubDomain && FilterSubDomain != subDomainKey) {
const TPathId subDomain(nodeDomain.GetSchemeShard(), nodeDomain.GetPathId());
if (FilterSubDomain && FilterSubDomain != subDomain) {
continue;
}
NodeIds.emplace_back(nodeId); // order is important
Expand Down
16 changes: 15 additions & 1 deletion ydb/core/viewer/json_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TJsonNodes : public TViewerPipeClient<TJsonNodes> {
TJsonSettings JsonSettings;
ui32 Timeout = 0;
TString FilterTenant;
TSubDomainKey FilterSubDomainKey;
TString FilterPath;
TString FilterStoragePool;
std::unordered_set<TNodeId> FilterNodeIds;
Expand Down Expand Up @@ -405,6 +406,11 @@ class TJsonNodes : public TViewerPipeClient<TJsonNodes> {
if (HiveId == 0) {
HiveId = entry.DomainInfo->Params.GetHive();
}
if (!FilterSubDomainKey) {
const auto ownerId = entry.DomainInfo->DomainKey.OwnerId;
const auto localPathId = entry.DomainInfo->DomainKey.LocalPathId;
FilterSubDomainKey = TSubDomainKey(ownerId, localPathId);
}
if (entry.DomainInfo->ResourcesDomainKey && entry.DomainInfo->DomainKey != entry.DomainInfo->ResourcesDomainKey) {
TPathId resourceDomainKey(entry.DomainInfo->ResourcesDomainKey);
BLOG_TRACE("Requesting navigate for resource domain " << resourceDomainKey);
Expand Down Expand Up @@ -461,6 +467,10 @@ class TJsonNodes : public TViewerPipeClient<TJsonNodes> {
void Handle(TEvHive::TEvResponseHiveNodeStats::TPtr& ev) {
BLOG_TRACE("ResponseHiveNodeStats()");
for (const NKikimrHive::THiveNodeStats& nodeStats : ev->Get()->Record.GetNodeStats()) {
const TSubDomainKey nodeSubDomainKey = TSubDomainKey(nodeStats.GetNodeDomain());
if (FilterSubDomainKey && FilterSubDomainKey != nodeSubDomainKey) {
continue;
}
ui32 nodeId = nodeStats.GetNodeId();
auto& tabletInfo(TabletInfo[nodeId]);
for (const NKikimrHive::THiveDomainStatsStateCount& stateStats : nodeStats.GetStateStats()) {
Expand Down Expand Up @@ -514,14 +524,18 @@ class TJsonNodes : public TViewerPipeClient<TJsonNodes> {
}

void Handle(TEvStateStorage::TEvBoardInfo::TPtr& ev) {
BLOG_TRACE("Received TEvBoardInfo");
if (ev->Get()->Status == TEvStateStorage::TEvBoardInfo::EStatus::Ok) {
BLOG_TRACE("Received TEvBoardInfo");
for (const auto& [actorId, infoEntry] : ev->Get()->InfoEntries) {
auto nodeId(actorId.NodeId());
BLOG_TRACE("BoardInfo filter node by " << nodeId);
FilterNodeIds.insert(nodeId);
}
} else {
BLOG_TRACE("Error receiving TEvBoardInfo response");
FilterNodeIds = { 0 };
}

if (--RequestsBeforeNodeList == 0) {
ProcessNodeIds();
}
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/viewer/json_tenantinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {

if (tenant.GetType() == NKikimrViewer::Serverless) {
tenant.SetStorageAllocatedSize(tenant.GetMetrics().GetStorage());
if (tenant.NodeIdsSize() == 0) {
const bool noExclusiveNodes = tenantNodes.empty();
if (noExclusiveNodes) {
tenant.SetMemoryUsed(tenant.GetMetrics().GetMemory());
tenant.ClearMemoryLimit();
tenant.SetCoresUsed(static_cast<double>(tenant.GetMetrics().GetCPU()) / 1000000);
Expand Down
Loading

0 comments on commit fa31b2a

Please sign in to comment.