Skip to content

Commit

Permalink
add node name filter, improve filter behavior (#10585)
Browse files Browse the repository at this point in the history
  • Loading branch information
adameat authored Oct 18, 2024
1 parent 5f23c89 commit cebe29d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
31 changes: 20 additions & 11 deletions ydb/core/viewer/storage_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -1042,20 +1042,29 @@ class TStorageGroups : public TViewerPipeClient {
With = EWith::Everything;
GroupsByGroupId.clear();
}
if (!Filter.empty() && FieldsAvailable.test(+EGroupFields::PoolName) && FieldsAvailable.test(+EGroupFields::GroupId)) {
TVector<TString> filterWords = SplitString(Filter, " ");
TGroupView groupView;
for (TGroup* group : GroupView) {
for (const TString& word : filterWords) {
if (group->PoolName.Contains(word) || ::ToString(group->GroupId).Contains(word)) {
groupView.push_back(group);
break;
if (!Filter.empty()) {
bool allFieldsPresent =
(!FieldsRequired.test(+EGroupFields::GroupId) || FieldsAvailable.test(+EGroupFields::GroupId)) &&
(!FieldsRequired.test(+EGroupFields::PoolName) || FieldsAvailable.test(+EGroupFields::PoolName));
if (allFieldsPresent) {
TVector<TString> filterWords = SplitString(Filter, " ");
TGroupView groupView;
for (TGroup* group : GroupView) {
for (const TString& word : filterWords) {
if (FieldsRequired.test(+EGroupFields::GroupId) && ::ToString(group->GroupId).Contains(word)) {
groupView.push_back(group);
break;
}
if (FieldsRequired.test(+EGroupFields::PoolName) && group->PoolName.Contains(word)) {
groupView.push_back(group);
break;
}
}
}
GroupView.swap(groupView);
Filter.clear();
GroupsByGroupId.clear();
}
GroupView.swap(groupView);
Filter.clear();
GroupsByGroupId.clear();
}
if (!FilterGroup.empty() && FieldsAvailable.test(+FilterGroupBy)) {
TGroupView groupView;
Expand Down
38 changes: 26 additions & 12 deletions ydb/core/viewer/viewer_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class TJsonNodes : public TViewerPipeClient {
ENodeFields result = ENodeFields::COUNT;
if (field == "NodeId" || field == "Id") {
result = ENodeFields::NodeId;
} else if (field == "Host") {
} else if (field == "Host" || field == "HostName") {
result = ENodeFields::HostName;
} else if (field == "NodeName") {
result = ENodeFields::NodeName;
Expand Down Expand Up @@ -1023,20 +1023,34 @@ class TJsonNodes : public TViewerPipeClient {
UptimeSeconds = 0;
InvalidateNodes();
}
if (!Filter.empty() && FieldsAvailable.test(+ENodeFields::NodeInfo)) {
TVector<TString> filterWords = SplitString(Filter, " ");
TNodeView nodeView;
for (TNode* node : NodeView) {
for (const TString& word : filterWords) {
if (node->GetHostName().Contains(word) || ::ToString(node->GetNodeId()).Contains(word)) {
nodeView.push_back(node);
break;
if (!Filter.empty()) {
bool allFieldsPresent =
(!FieldsRequired.test(+ENodeFields::NodeId) || FieldsAvailable.test(+ENodeFields::NodeId)) &&
(!FieldsRequired.test(+ENodeFields::HostName) || FieldsAvailable.test(+ENodeFields::HostName)) &&
(!FieldsRequired.test(+ENodeFields::NodeName) || FieldsAvailable.test(+ENodeFields::NodeName));
if (allFieldsPresent) {
TVector<TString> filterWords = SplitString(Filter, " ");
TNodeView nodeView;
for (TNode* node : NodeView) {
for (const TString& word : filterWords) {
if (FieldsRequired.test(+ENodeFields::NodeId) && ::ToString(node->GetNodeId()).Contains(word)) {
nodeView.push_back(node);
break;
}
if (FieldsRequired.test(+ENodeFields::HostName) && node->GetHostName().Contains(word)) {
nodeView.push_back(node);
break;
}
if (FieldsRequired.test(+ENodeFields::NodeName) && node->GetNodeName().Contains(word)) {
nodeView.push_back(node);
break;
}
}
}
NodeView.swap(nodeView);
Filter.clear();
InvalidateNodes();
}
NodeView.swap(nodeView);
Filter.clear();
InvalidateNodes();
}
if (!FilterGroup.empty() && FieldsAvailable.test(+FilterGroupBy)) {
TNodeView nodeView;
Expand Down

0 comments on commit cebe29d

Please sign in to comment.