Skip to content

Commit

Permalink
Merge ca3b86f into 2d5f041
Browse files Browse the repository at this point in the history
  • Loading branch information
StekPerepolnen authored Mar 4, 2024
2 parents 2d5f041 + ca3b86f commit 1fd04a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ydb/core/viewer/json_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TJsonStorage : public TJsonStorageBase {
enum class EGroupSort {
PoolName,
Kind,
MediaType,
Erasure,
Degraded,
Usage,
Expand All @@ -46,6 +47,7 @@ class TJsonStorage : public TJsonStorageBase {
TString PoolName;
TString GroupId;
TString Kind;
TString MediaType;
TString Erasure;
ui32 Degraded;
float Usage;
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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 << "\",";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -391,6 +397,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;
Expand Down Expand Up @@ -494,7 +503,7 @@ struct TJsonRequestParameters<TJsonStorage> {
{"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"}])___";
Expand Down
16 changes: 16 additions & 0 deletions ydb/core/viewer/json_storage_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {

struct TStoragePoolInfo {
TString Kind;
TString MediaType;
TSet<TString> Groups;
NKikimrViewer::EFlag Overall = NKikimrViewer::EFlag::Grey;
};
Expand Down Expand Up @@ -98,6 +99,7 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {
TString PoolName;
TString GroupId;
TString Kind;
TString MediaType;
TString Erasure;
ui32 Degraded;
float Usage;
Expand Down Expand Up @@ -205,6 +207,17 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {
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);

Expand All @@ -231,6 +244,9 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {
SendNodeRequests(nodeId);
}
}
for (const NKikimrBlobStorage::TDefineStoragePool& pool : pbStatus.GetStoragePool()) {
StoragePoolInfo[pool.GetName()].MediaType = GetMediaType(pool);
}
}
}
RequestDone();
Expand Down

0 comments on commit 1fd04a1

Please sign in to comment.