@@ -839,24 +839,32 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
839
839
void Handle (TEvWhiteboard::TEvTabletStateRequest::TPtr &ev, const TActorContext &ctx) {
840
840
auto now = TMonotonic::Now ();
841
841
const auto & request = ev->Get ()->Record ;
842
+ auto matchesFilter = [
843
+ changedSince = request.has_changedsince () ? request.changedsince () : 0 ,
844
+ filterTenantId = request.has_filtertenantid () ? NKikimr::TSubDomainKey (request.filtertenantid ()) : NKikimr::TSubDomainKey ()
845
+ ](const NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo) {
846
+ return tabletStateInfo.changetime () >= changedSince
847
+ && (!filterTenantId || filterTenantId == NKikimr::TSubDomainKey (tabletStateInfo.tenantid ()));
848
+ };
842
849
std::unique_ptr<TEvWhiteboard::TEvTabletStateResponse> response = std::make_unique<TEvWhiteboard::TEvTabletStateResponse>();
843
850
auto & record = response->Record ;
844
851
if (request.format () == " packed5" ) {
845
852
TEvWhiteboard::TEvTabletStateResponsePacked5* ptr = response->AllocatePackedResponse (TabletStateInfo.size ());
846
853
for (const auto & [tabletId, tabletInfo] : TabletStateInfo) {
847
- ptr->TabletId = tabletInfo.tabletid ();
848
- ptr->FollowerId = tabletInfo.followerid ();
849
- ptr->Generation = tabletInfo.generation ();
850
- ptr->Type = tabletInfo.type ();
851
- ptr->State = tabletInfo.state ();
852
- ++ptr;
854
+ if (matchesFilter (tabletInfo)) {
855
+ ptr->TabletId = tabletInfo.tabletid ();
856
+ ptr->FollowerId = tabletInfo.followerid ();
857
+ ptr->Generation = tabletInfo.generation ();
858
+ ptr->Type = tabletInfo.type ();
859
+ ptr->State = tabletInfo.state ();
860
+ ++ptr;
861
+ }
853
862
}
854
863
} else {
855
864
if (request.groupby ().empty ()) {
856
- ui64 changedSince = request.has_changedsince () ? request.changedsince () : 0 ;
857
865
if (request.filtertabletid_size () == 0 ) {
858
866
for (const auto & pr : TabletStateInfo) {
859
- if (pr.second . changetime () >= changedSince ) {
867
+ if (matchesFilter ( pr.second ) ) {
860
868
NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo = *record.add_tabletstateinfo ();
861
869
Copy (tabletStateInfo, pr.second , request);
862
870
}
@@ -865,7 +873,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
865
873
for (auto tabletId : request.filtertabletid ()) {
866
874
auto it = TabletStateInfo.find ({tabletId, 0 });
867
875
if (it != TabletStateInfo.end ()) {
868
- if (it->second . changetime () >= changedSince ) {
876
+ if (matchesFilter ( it->second ) ) {
869
877
NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo = *record.add_tabletstateinfo ();
870
878
Copy (tabletStateInfo, it->second , request);
871
879
}
@@ -876,6 +884,9 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
876
884
std::unordered_map<std::pair<NKikimrTabletBase::TTabletTypes::EType,
877
885
NKikimrWhiteboard::TTabletStateInfo::ETabletState>, NKikimrWhiteboard::TTabletStateInfo> stateGroupBy;
878
886
for (const auto & [id, stateInfo] : TabletStateInfo) {
887
+ if (!matchesFilter (stateInfo)) {
888
+ continue ;
889
+ }
879
890
NKikimrWhiteboard::TTabletStateInfo& state = stateGroupBy[{stateInfo.type (), stateInfo.state ()}];
880
891
auto count = state.count ();
881
892
if (count == 0 ) {
0 commit comments