From 856e900053afe3d69f4e78622d7c404a91e76f86 Mon Sep 17 00:00:00 2001 From: Andrei Rykov Date: Tue, 5 Mar 2024 18:00:36 +0100 Subject: [PATCH] YDB-647 add media type field (#2441) --- ydb/core/viewer/json_pipe_req.h | 8 ++++++++ ydb/core/viewer/json_storage.h | 12 +++++++++++- ydb/core/viewer/json_storage_base.h | 21 +++++++++++++++++++-- ydb/core/viewer/protos/viewer.proto | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ydb/core/viewer/json_pipe_req.h b/ydb/core/viewer/json_pipe_req.h index e169eb117203..2f8574a4322c 100644 --- a/ydb/core/viewer/json_pipe_req.h +++ b/ydb/core/viewer/json_pipe_req.h @@ -142,6 +142,14 @@ class TViewerPipeClient : public TActorBootstrapped { SendRequestToPipe(pipeClient, request.Release()); } + void RequestBSControllerConfigWithStoragePools() { + TActorId pipeClient = ConnectTabletPipe(GetBSControllerId()); + THolder request = MakeHolder(); + request->Record.MutableRequest()->AddCommand()->MutableQueryBaseConfig(); + request->Record.MutableRequest()->AddCommand()->MutableReadStoragePool()->SetBoxId(Max()); + SendRequestToPipe(pipeClient, request.Release()); + } + void RequestBSControllerInfo() { TActorId pipeClient = ConnectTabletPipe(GetBSControllerId()); THolder request = MakeHolder(); diff --git a/ydb/core/viewer/json_storage.h b/ydb/core/viewer/json_storage.h index 7b29d68c89fa..7cdae84bb4de 100644 --- a/ydb/core/viewer/json_storage.h +++ b/ydb/core/viewer/json_storage.h @@ -20,6 +20,7 @@ class TJsonStorage : public TJsonStorageBase { enum class EGroupSort { PoolName, Kind, + MediaType, Erasure, Degraded, Usage, @@ -46,6 +47,7 @@ class TJsonStorage : public TJsonStorageBase { TString PoolName; TString GroupId; TString Kind; + TString MediaType; TString Erasure; ui32 Degraded; float Usage; @@ -100,6 +102,8 @@ class TJsonStorage : public TJsonStorageBase { GroupSort = EGroupSort::PoolName; } else if (sort == "Kind") { GroupSort = EGroupSort::Kind; + } else if (sort == "MediaType") { + GroupSort = EGroupSort::MediaType; } else if (sort == "Erasure") { GroupSort = EGroupSort::Erasure; } else if (sort == "Degraded") { @@ -142,6 +146,7 @@ class TJsonStorage : public TJsonStorageBase { const auto& groupRow = GroupRowsByGroupId[groupId]; json << "\"PoolName\":\"" << groupRow.PoolName << "\","; json << "\"Kind\":\"" << groupRow.Kind << "\","; + json << "\"MediaType\":\"" << groupRow.MediaType << "\","; json << "\"Erasure\":\"" << groupRow.Erasure << "\","; json << "\"Degraded\":\"" << groupRow.Degraded << "\","; json << "\"Usage\":\"" << groupRow.Usage << "\","; @@ -310,6 +315,7 @@ class TJsonStorage : public TJsonStorageBase { row.PoolName = poolName; row.GroupId = groupId; row.Kind = poolInfo.Kind; + row.MediaType = poolInfo.MediaType; auto ib = BSGroupIndex.find(groupId); if (ib != BSGroupIndex.end()) { row.Erasure = ib->second.GetErasureSpecies(); @@ -349,6 +355,7 @@ class TJsonStorage : public TJsonStorageBase { ++foundGroups; if (Version == EVersion::v1) { pool->AddGroups()->SetGroupId(groupId); + pool->SetMediaType(poolInfo.MediaType); } else if (Version == EVersion::v2) { if (!UsageBuckets.empty() && !BinarySearch(UsageBuckets.begin(), UsageBuckets.end(), (ui32)(row.Usage * 100) / UsagePace)) { continue; @@ -391,6 +398,9 @@ class TJsonStorage : public TJsonStorageBase { case EGroupSort::Kind: SortCollection(GroupRows, [](const TGroupRow& node) { return node.Kind;}, ReverseSort); break; + case EGroupSort::MediaType: + SortCollection(GroupRows, [](const TGroupRow& node) { return node.MediaType;}, ReverseSort); + break; case EGroupSort::Erasure: SortCollection(GroupRows, [](const TGroupRow& node) { return node.Erasure;}, ReverseSort); break; @@ -494,7 +504,7 @@ struct TJsonRequestParameters { {"name":"version","in":"query","description":"query version (v1, v2)","required":false,"type":"string"}, {"name":"usage_pace","in":"query","description":"bucket size as a percentage","required":false,"type":"integer","default":5}, {"name":"usage_buckets","in":"query","description":"filter groups by usage buckets","required":false,"type":"integer"}, - {"name":"sort","in":"query","description":"sort by (PoolName,Type,Erasure,Degraded,Usage,GroupId,Used,Limit,Read,Write)","required":false,"type":"string"}, + {"name":"sort","in":"query","description":"sort by (PoolName,Kind,MediaType,Erasure,Degraded,Usage,GroupId,Used,Limit,Read,Write)","required":false,"type":"string"}, {"name":"offset","in":"query","description":"skip N nodes","required":false,"type":"integer"}, {"name":"limit","in":"query","description":"limit to N nodes","required":false,"type":"integer"}, {"name":"timeout","in":"query","description":"timeout in ms","required":false,"type":"integer"}])___"; diff --git a/ydb/core/viewer/json_storage_base.h b/ydb/core/viewer/json_storage_base.h index 26046561476f..c89a6668e7be 100644 --- a/ydb/core/viewer/json_storage_base.h +++ b/ydb/core/viewer/json_storage_base.h @@ -62,6 +62,7 @@ class TJsonStorageBase : public TViewerPipeClient { struct TStoragePoolInfo { TString Kind; + TString MediaType; TSet Groups; NKikimrViewer::EFlag Overall = NKikimrViewer::EFlag::Grey; }; @@ -98,6 +99,7 @@ class TJsonStorageBase : public TViewerPipeClient { TString PoolName; TString GroupId; TString Kind; + TString MediaType; TString Erasure; ui32 Degraded; float Usage; @@ -172,7 +174,7 @@ class TJsonStorageBase : public TViewerPipeClient { return; } - RequestBSControllerConfig(); + RequestBSControllerConfigWithStoragePools(); TBase::Become(&TThis::StateWork); Schedule(TDuration::MilliSeconds(Timeout / 100 * 70), new TEvents::TEvWakeup(TimeoutBSC)); // 70% timeout (for bsc) @@ -205,10 +207,21 @@ class TJsonStorageBase : public TViewerPipeClient { RequestDone(); } + TString GetMediaType(const NKikimrBlobStorage::TDefineStoragePool& pool) const { + for (const NKikimrBlobStorage::TPDiskFilter& filter : pool.GetPDiskFilter()) { + for (const NKikimrBlobStorage::TPDiskFilter::TRequiredProperty& property : filter.GetProperty()) { + if (property.HasType()) { + return ToString(property.GetType()); + } + } + } + return TString(); + } + void Handle(TEvBlobStorage::TEvControllerConfigResponse::TPtr& ev) { const NKikimrBlobStorage::TEvControllerConfigResponse& pbRecord(ev->Get()->Record); - if (pbRecord.HasResponse() && pbRecord.GetResponse().StatusSize() > 0) { + if (pbRecord.HasResponse() && pbRecord.GetResponse().StatusSize() > 1) { const NKikimrBlobStorage::TConfigResponse::TStatus& pbStatus(pbRecord.GetResponse().GetStatus(0)); if (pbStatus.HasBaseConfig()) { BaseConfig = ev->Release(); @@ -232,6 +245,10 @@ class TJsonStorageBase : public TViewerPipeClient { } } } + const NKikimrBlobStorage::TConfigResponse::TStatus& spStatus(pbRecord.GetResponse().GetStatus(1)); + for (const NKikimrBlobStorage::TDefineStoragePool& pool : spStatus.GetStoragePool()) { + StoragePoolInfo[pool.GetName()].MediaType = GetMediaType(pool); + } } RequestDone(); } diff --git a/ydb/core/viewer/protos/viewer.proto b/ydb/core/viewer/protos/viewer.proto index 73f57cf09b8d..e5fdfe30b022 100644 --- a/ydb/core/viewer/protos/viewer.proto +++ b/ydb/core/viewer/protos/viewer.proto @@ -402,6 +402,7 @@ message TStoragePoolInfo { float MaximumIOPS = 9; uint64 MaximumThroughput = 10; uint64 MaximumSize = 11; + string MediaType = 12; } message TStorageInfo {