Skip to content

Commit

Permalink
YDB-647 add media type field (#2441)
Browse files Browse the repository at this point in the history
  • Loading branch information
StekPerepolnen authored Mar 5, 2024
1 parent 31bc37d commit 856e900
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ydb/core/viewer/json_pipe_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ class TViewerPipeClient : public TActorBootstrapped<TDerived> {
SendRequestToPipe(pipeClient, request.Release());
}

void RequestBSControllerConfigWithStoragePools() {
TActorId pipeClient = ConnectTabletPipe(GetBSControllerId());
THolder<TEvBlobStorage::TEvControllerConfigRequest> request = MakeHolder<TEvBlobStorage::TEvControllerConfigRequest>();
request->Record.MutableRequest()->AddCommand()->MutableQueryBaseConfig();
request->Record.MutableRequest()->AddCommand()->MutableReadStoragePool()->SetBoxId(Max<ui64>());
SendRequestToPipe(pipeClient, request.Release());
}

void RequestBSControllerInfo() {
TActorId pipeClient = ConnectTabletPipe(GetBSControllerId());
THolder<TEvBlobStorage::TEvRequestControllerInfo> request = MakeHolder<TEvBlobStorage::TEvRequestControllerInfo>();
Expand Down
12 changes: 11 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 @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -494,7 +504,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
21 changes: 19 additions & 2 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 @@ -172,7 +174,7 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {
return;
}

RequestBSControllerConfig();
RequestBSControllerConfigWithStoragePools();

TBase::Become(&TThis::StateWork);
Schedule(TDuration::MilliSeconds(Timeout / 100 * 70), new TEvents::TEvWakeup(TimeoutBSC)); // 70% timeout (for bsc)
Expand Down Expand Up @@ -205,10 +207,21 @@ 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);

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();
Expand All @@ -232,6 +245,10 @@ class TJsonStorageBase : public TViewerPipeClient<TJsonStorageBase> {
}
}
}
const NKikimrBlobStorage::TConfigResponse::TStatus& spStatus(pbRecord.GetResponse().GetStatus(1));
for (const NKikimrBlobStorage::TDefineStoragePool& pool : spStatus.GetStoragePool()) {
StoragePoolInfo[pool.GetName()].MediaType = GetMediaType(pool);
}
}
RequestDone();
}
Expand Down
1 change: 1 addition & 0 deletions ydb/core/viewer/protos/viewer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ message TStoragePoolInfo {
float MaximumIOPS = 9;
uint64 MaximumThroughput = 10;
uint64 MaximumSize = 11;
string MediaType = 12;
}

message TStorageInfo {
Expand Down

0 comments on commit 856e900

Please sign in to comment.