Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jun 18, 2019
1 parent 7507c45 commit e559eff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions server/core/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func (s *StoreInfo) IsOverloaded() bool {
return s.overloaded()
}

// IsAttached returns if the store is attached with the overloaded status.
func (s *StoreInfo) IsAttached() bool {
return s.overloaded != nil
}

// IsUp checks if the store's state is Up.
func (s *StoreInfo) IsUp() bool {
return s.GetState() == metapb.StoreState_Up
Expand Down
12 changes: 7 additions & 5 deletions server/schedule/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,13 @@ func (oc *OperatorController) exceedStoreLimit(ops ...*Operator) bool {
available := oc.storesLimit[storeID].Available()
storeLimit.WithLabelValues(strconv.FormatUint(storeID, 10), "available").Set(float64(available) / float64(RegionInfluence))
if available < stepCost {
oc.cluster.AttachOverloadStatus(storeID, func() bool {
oc.RLock()
defer oc.RUnlock()
return oc.storesLimit[storeID].Available() < RegionInfluence
})
if !oc.cluster.GetStore(storeID).IsAttached() {
oc.cluster.AttachOverloadStatus(storeID, func() bool {
oc.RLock()
defer oc.RUnlock()
return oc.storesLimit[storeID].Available() < RegionInfluence
})
}
return true
}
}
Expand Down

0 comments on commit e559eff

Please sign in to comment.