Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YDB 647 add media type field #2405

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -148,6 +148,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
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 @@ -143,6 +147,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 @@ -311,6 +316,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 @@ -392,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 @@ -495,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
18 changes: 17 additions & 1 deletion 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,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
Loading