Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Add region context to aggr stats
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Chacon <[email protected]>
  • Loading branch information
rafael committed Dec 17, 2018
1 parent c8023fe commit ac8d661
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions go/vt/discovery/tablet_stats_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,28 @@ func (tc *TabletStatsCache) GetAggregateStats(target *querypb.Target) (*querypb.
return agg, nil
}
}
agg, ok := e.aggregates[target.Cell]
if !ok {
targetRegion := tc.getRegionByCell(target.Cell)
regionAggregateStats := &querypb.AggregateStats{SecondsBehindMasterMin: math.MaxUint32}
regionAggrFound := false
for cell, agg := range e.aggregates {
cellRegion := tc.getRegionByCell(cell)
if cellRegion == targetRegion {
regionAggrFound = true
regionAggregateStats.HealthyTabletCount += agg.HealthyTabletCount
regionAggregateStats.UnhealthyTabletCount += agg.UnhealthyTabletCount
if agg.SecondsBehindMasterMin < regionAggregateStats.SecondsBehindMasterMin {
regionAggregateStats.SecondsBehindMasterMin = agg.SecondsBehindMasterMin
}
if regionAggregateStats.SecondsBehindMasterMax > agg.SecondsBehindMasterMax {
regionAggregateStats.SecondsBehindMasterMax = agg.SecondsBehindMasterMax
}
}
}
if !regionAggrFound {
return nil, topo.NewError(topo.NoNode, topotools.TargetIdent(target))
}
return agg, nil
return regionAggregateStats, nil

}

// GetMasterCell is part of the TargetStatsListener interface.
Expand Down

0 comments on commit ac8d661

Please sign in to comment.