Skip to content

Commit

Permalink
remove IsAttached function
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Jun 19, 2019
1 parent e559eff commit f10e108
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
3 changes: 0 additions & 3 deletions server/coordinator_test.go
Expand Up @@ -783,9 +783,6 @@ func (s *testOperatorControllerSuite) TestStoreOverloaded(c *C) {
op1 := lb.Schedule(tc)[0]
c.Assert(op1, NotNil)
c.Assert(oc.AddOperator(op1), IsTrue)
op2 := lb.Schedule(tc)[0]
c.Assert(op2, NotNil)
c.Assert(oc.AddOperator(op2), IsFalse)
for i := 0; i < 10; i++ {
c.Assert(lb.Schedule(tc), IsNil)
}
Expand Down
5 changes: 0 additions & 5 deletions server/core/store.go
Expand Up @@ -93,11 +93,6 @@ 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
29 changes: 15 additions & 14 deletions server/schedule/operator_controller.go
Expand Up @@ -617,24 +617,25 @@ func (o *OperatorRecords) Put(op *Operator, status pdpb.OperatorStatus) {
func (oc *OperatorController) exceedStoreLimit(ops ...*Operator) bool {
opInfluence := NewTotalOpInfluence(ops, oc.cluster)
for storeID := range opInfluence.storesInfluence {
if oc.storesLimit[storeID] == nil {
rate := oc.cluster.GetStoreBalanceRate()
oc.newStoreLimit(storeID, rate)
}
stepCost := opInfluence.GetStoreInfluence(storeID).StepCost
id := storeID
stepCost := opInfluence.GetStoreInfluence(id).StepCost
if stepCost == 0 {
continue
}
available := oc.storesLimit[storeID].Available()
storeLimit.WithLabelValues(strconv.FormatUint(storeID, 10), "available").Set(float64(available) / float64(RegionInfluence))

if oc.storesLimit[id] == nil {
rate := oc.cluster.GetStoreBalanceRate()
oc.newStoreLimit(id, rate)
oc.cluster.AttachOverloadStatus(id, func() bool {
oc.RLock()
defer oc.RUnlock()
return oc.storesLimit[id].Available() < RegionInfluence
})
}

available := oc.storesLimit[id].Available()
storeLimit.WithLabelValues(strconv.FormatUint(id, 10), "available").Set(float64(available) / float64(RegionInfluence))
if available < stepCost {
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 f10e108

Please sign in to comment.