-
Notifications
You must be signed in to change notification settings - Fork 711
/
operator_controller.go
686 lines (623 loc) · 19.3 KB
/
operator_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
// Copyright 2018 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package schedule
import (
"container/heap"
"container/list"
"fmt"
"strconv"
"sync"
"time"
"github.com/juju/ratelimit"
"github.com/pingcap/kvproto/pkg/eraftpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
log "github.com/pingcap/log"
"github.com/pingcap/pd/server/cache"
"github.com/pingcap/pd/server/core"
"go.uber.org/zap"
)
// The source of dispatched region.
const (
DispatchFromHeartBeat = "heartbeat"
DispatchFromNotifierQueue = "active push"
DispatchFromCreate = "create"
)
var (
historyKeepTime = 5 * time.Minute
slowNotifyInterval = 5 * time.Second
fastNotifyInterval = 2 * time.Second
// PushOperatorTickInterval is the interval try to push the operator.
PushOperatorTickInterval = 500 * time.Millisecond
)
// HeartbeatStreams is an interface of async region heartbeat.
type HeartbeatStreams interface {
SendMsg(region *core.RegionInfo, msg *pdpb.RegionHeartbeatResponse)
}
// OperatorController is used to limit the speed of scheduling.
type OperatorController struct {
sync.RWMutex
cluster Cluster
operators map[uint64]*Operator
hbStreams HeartbeatStreams
histories *list.List
counts map[OperatorKind]uint64
opRecords *OperatorRecords
// TODO: Need to clean up the unused store ID.
storesLimit map[uint64]*ratelimit.Bucket
opNotifierQueue operatorQueue
}
// NewOperatorController creates a OperatorController.
func NewOperatorController(cluster Cluster, hbStreams HeartbeatStreams) *OperatorController {
return &OperatorController{
cluster: cluster,
operators: make(map[uint64]*Operator),
hbStreams: hbStreams,
histories: list.New(),
counts: make(map[OperatorKind]uint64),
opRecords: NewOperatorRecords(),
storesLimit: make(map[uint64]*ratelimit.Bucket),
opNotifierQueue: make(operatorQueue, 0),
}
}
// Dispatch is used to dispatch the operator of a region.
func (oc *OperatorController) Dispatch(region *core.RegionInfo, source string) {
// Check existed operator.
if op := oc.GetOperator(region.GetID()); op != nil {
timeout := op.IsTimeout()
if step := op.Check(region); step != nil && !timeout {
operatorCounter.WithLabelValues(op.Desc(), "check").Inc()
oc.SendScheduleCommand(region, step, source)
return
}
if op.IsFinish() {
log.Info("operator finish", zap.Uint64("region-id", region.GetID()), zap.Reflect("operator", op))
operatorCounter.WithLabelValues(op.Desc(), "finish").Inc()
operatorDuration.WithLabelValues(op.Desc()).Observe(op.ElapsedTime().Seconds())
oc.pushHistory(op)
oc.opRecords.Put(op, pdpb.OperatorStatus_SUCCESS)
oc.RemoveOperator(op)
} else if timeout {
log.Info("operator timeout", zap.Uint64("region-id", region.GetID()), zap.Reflect("operator", op))
oc.RemoveTimeoutOperator(op)
oc.opRecords.Put(op, pdpb.OperatorStatus_TIMEOUT)
}
}
}
func (oc *OperatorController) getNextPushOperatorTime(step OperatorStep, now time.Time) time.Time {
nextTime := slowNotifyInterval
switch step.(type) {
case TransferLeader, PromoteLearner:
nextTime = fastNotifyInterval
}
return now.Add(nextTime)
}
// pollNeedDispatchRegion returns the region need to dispatch,
// "next" is true to indicate that it may exist in next attempt,
// and false is the end for the poll.
func (oc *OperatorController) pollNeedDispatchRegion() (r *core.RegionInfo, next bool) {
oc.Lock()
defer oc.Unlock()
if oc.opNotifierQueue.Len() == 0 {
return nil, false
}
item := heap.Pop(&oc.opNotifierQueue).(*operatorWithTime)
regionID := item.op.regionID
op, ok := oc.operators[regionID]
if !ok || op == nil {
return nil, true
}
r = oc.cluster.GetRegion(regionID)
if r == nil {
return nil, true
}
step := op.Check(r)
if step == nil {
return nil, true
}
now := time.Now()
if now.Before(item.time) {
heap.Push(&oc.opNotifierQueue, item)
return nil, false
}
// pushes with new notify time.
item.time = oc.getNextPushOperatorTime(step, now)
heap.Push(&oc.opNotifierQueue, item)
return r, true
}
// PushOperators periodically pushes the unfinished operator to the executor(TiKV).
func (oc *OperatorController) PushOperators() {
for {
r, next := oc.pollNeedDispatchRegion()
if !next {
break
}
if r == nil {
continue
}
oc.Dispatch(r, DispatchFromNotifierQueue)
}
}
// AddOperator adds operators to the running operators.
func (oc *OperatorController) AddOperator(ops ...*Operator) bool {
oc.Lock()
defer oc.Unlock()
if oc.exceedStoreLimit(ops...) || !oc.checkAddOperator(ops...) {
for _, op := range ops {
operatorCounter.WithLabelValues(op.Desc(), "canceled").Inc()
oc.opRecords.Put(op, pdpb.OperatorStatus_CANCEL)
}
return false
}
for _, op := range ops {
oc.addOperatorLocked(op)
}
return true
}
// checkAddOperator checks if the operator can be added.
// There are several situations that cannot be added:
// - There is no such region in the cluster
// - The epoch of the operator and the epoch of the corresponding region are no longer consistent.
// - The region already has a higher priority or same priority operator.
func (oc *OperatorController) checkAddOperator(ops ...*Operator) bool {
for _, op := range ops {
region := oc.cluster.GetRegion(op.RegionID())
if region == nil {
log.Debug("region not found, cancel add operator", zap.Uint64("region-id", op.RegionID()))
return false
}
if region.GetRegionEpoch().GetVersion() != op.RegionEpoch().GetVersion() || region.GetRegionEpoch().GetConfVer() != op.RegionEpoch().GetConfVer() {
log.Debug("region epoch not match, cancel add operator", zap.Uint64("region-id", op.RegionID()), zap.Reflect("old", region.GetRegionEpoch()), zap.Reflect("new", op.RegionEpoch()))
return false
}
if old := oc.operators[op.RegionID()]; old != nil && !isHigherPriorityOperator(op, old) {
log.Debug("already have operator, cancel add operator", zap.Uint64("region-id", op.RegionID()), zap.Reflect("old", old))
return false
}
}
return true
}
func isHigherPriorityOperator(new, old *Operator) bool {
return new.GetPriorityLevel() < old.GetPriorityLevel()
}
func (oc *OperatorController) addOperatorLocked(op *Operator) bool {
regionID := op.RegionID()
log.Info("add operator", zap.Uint64("region-id", regionID), zap.Reflect("operator", op))
// If there is an old operator, replace it. The priority should be checked
// already.
if old, ok := oc.operators[regionID]; ok {
log.Info("replace old operator", zap.Uint64("region-id", regionID), zap.Reflect("operator", old))
operatorCounter.WithLabelValues(old.Desc(), "replaced").Inc()
oc.opRecords.Put(old, pdpb.OperatorStatus_REPLACE)
oc.removeOperatorLocked(old)
}
oc.operators[regionID] = op
opInfluence := NewTotalOpInfluence([]*Operator{op}, oc.cluster)
for storeID := range opInfluence.storesInfluence {
stepCost := opInfluence.GetStoreInfluence(storeID).StepCost
if stepCost == 0 {
continue
}
storeLimit.WithLabelValues(strconv.FormatUint(storeID, 10), "take").Set(float64(stepCost) / float64(RegionInfluence))
oc.storesLimit[storeID].Take(stepCost)
}
oc.updateCounts(oc.operators)
var step OperatorStep
if region := oc.cluster.GetRegion(op.RegionID()); region != nil {
if step = op.Check(region); step != nil {
oc.SendScheduleCommand(region, step, DispatchFromCreate)
}
}
heap.Push(&oc.opNotifierQueue, &operatorWithTime{op: op, time: oc.getNextPushOperatorTime(step, time.Now())})
operatorCounter.WithLabelValues(op.Desc(), "create").Inc()
return true
}
// RemoveOperator removes a operator from the running operators.
func (oc *OperatorController) RemoveOperator(op *Operator) {
oc.Lock()
defer oc.Unlock()
oc.removeOperatorLocked(op)
}
// RemoveTimeoutOperator removes a operator which is timeout from the running operators.
func (oc *OperatorController) RemoveTimeoutOperator(op *Operator) {
oc.Lock()
defer oc.Unlock()
operatorCounter.WithLabelValues(op.Desc(), "timeout").Inc()
oc.removeOperatorLocked(op)
}
// GetOperatorStatus gets the operator and its status with the specify id.
func (oc *OperatorController) GetOperatorStatus(id uint64) *OperatorWithStatus {
oc.Lock()
defer oc.Unlock()
if op, ok := oc.operators[id]; ok {
return &OperatorWithStatus{
Op: op,
Status: pdpb.OperatorStatus_RUNNING,
}
}
return oc.opRecords.Get(id)
}
func (oc *OperatorController) removeOperatorLocked(op *Operator) {
regionID := op.RegionID()
delete(oc.operators, regionID)
opInfluence := NewTotalOpInfluence([]*Operator{op}, oc.cluster)
for storeID := range opInfluence.storesInfluence {
if opInfluence.GetStoreInfluence(storeID).StepCost == 0 {
continue
}
if oc.cluster.GetStore(storeID).IsOverloaded() &&
oc.storesLimit[storeID].Available() >= RegionInfluence {
oc.cluster.ResetStoreOverload(storeID)
}
}
oc.updateCounts(oc.operators)
operatorCounter.WithLabelValues(op.Desc(), "remove").Inc()
}
// GetOperator gets a operator from the given region.
func (oc *OperatorController) GetOperator(regionID uint64) *Operator {
oc.RLock()
defer oc.RUnlock()
return oc.operators[regionID]
}
// GetOperators gets operators from the running operators.
func (oc *OperatorController) GetOperators() []*Operator {
oc.RLock()
defer oc.RUnlock()
operators := make([]*Operator, 0, len(oc.operators))
for _, op := range oc.operators {
operators = append(operators, op)
}
return operators
}
// SendScheduleCommand sends a command to the region.
func (oc *OperatorController) SendScheduleCommand(region *core.RegionInfo, step OperatorStep, source string) {
log.Info("send schedule command", zap.Uint64("region-id", region.GetID()), zap.Stringer("step", step), zap.String("source", source))
switch st := step.(type) {
case TransferLeader:
cmd := &pdpb.RegionHeartbeatResponse{
TransferLeader: &pdpb.TransferLeader{
Peer: region.GetStorePeer(st.ToStore),
},
}
oc.hbStreams.SendMsg(region, cmd)
case AddPeer:
if region.GetStorePeer(st.ToStore) != nil {
// The newly added peer is pending.
return
}
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
ChangeType: eraftpb.ConfChangeType_AddNode,
Peer: &metapb.Peer{
Id: st.PeerID,
StoreId: st.ToStore,
},
},
}
oc.hbStreams.SendMsg(region, cmd)
case AddLightPeer:
if region.GetStorePeer(st.ToStore) != nil {
// The newly added peer is pending.
return
}
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
ChangeType: eraftpb.ConfChangeType_AddNode,
Peer: &metapb.Peer{
Id: st.PeerID,
StoreId: st.ToStore,
},
},
}
oc.hbStreams.SendMsg(region, cmd)
case AddLearner:
if region.GetStorePeer(st.ToStore) != nil {
// The newly added peer is pending.
return
}
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
ChangeType: eraftpb.ConfChangeType_AddLearnerNode,
Peer: &metapb.Peer{
Id: st.PeerID,
StoreId: st.ToStore,
IsLearner: true,
},
},
}
oc.hbStreams.SendMsg(region, cmd)
case AddLightLearner:
if region.GetStorePeer(st.ToStore) != nil {
// The newly added peer is pending.
return
}
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
ChangeType: eraftpb.ConfChangeType_AddLearnerNode,
Peer: &metapb.Peer{
Id: st.PeerID,
StoreId: st.ToStore,
IsLearner: true,
},
},
}
oc.hbStreams.SendMsg(region, cmd)
case PromoteLearner:
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
// reuse AddNode type
ChangeType: eraftpb.ConfChangeType_AddNode,
Peer: &metapb.Peer{
Id: st.PeerID,
StoreId: st.ToStore,
},
},
}
oc.hbStreams.SendMsg(region, cmd)
case RemovePeer:
cmd := &pdpb.RegionHeartbeatResponse{
ChangePeer: &pdpb.ChangePeer{
ChangeType: eraftpb.ConfChangeType_RemoveNode,
Peer: region.GetStorePeer(st.FromStore),
},
}
oc.hbStreams.SendMsg(region, cmd)
case MergeRegion:
if st.IsPassive {
return
}
cmd := &pdpb.RegionHeartbeatResponse{
Merge: &pdpb.Merge{
Target: st.ToRegion,
},
}
oc.hbStreams.SendMsg(region, cmd)
case SplitRegion:
cmd := &pdpb.RegionHeartbeatResponse{
SplitRegion: &pdpb.SplitRegion{
Policy: st.Policy,
},
}
oc.hbStreams.SendMsg(region, cmd)
default:
log.Error("unknown operator step", zap.Reflect("step", step))
}
}
func (oc *OperatorController) pushHistory(op *Operator) {
oc.Lock()
defer oc.Unlock()
for _, h := range op.History() {
oc.histories.PushFront(h)
}
}
// PruneHistory prunes a part of operators' history.
func (oc *OperatorController) PruneHistory() {
oc.Lock()
defer oc.Unlock()
p := oc.histories.Back()
for p != nil && time.Since(p.Value.(OperatorHistory).FinishTime) > historyKeepTime {
prev := p.Prev()
oc.histories.Remove(p)
p = prev
}
}
// GetHistory gets operators' history.
func (oc *OperatorController) GetHistory(start time.Time) []OperatorHistory {
oc.RLock()
defer oc.RUnlock()
histories := make([]OperatorHistory, 0, oc.histories.Len())
for p := oc.histories.Front(); p != nil; p = p.Next() {
history := p.Value.(OperatorHistory)
if history.FinishTime.Before(start) {
break
}
histories = append(histories, history)
}
return histories
}
// updateCounts updates resource counts using current pending operators.
func (oc *OperatorController) updateCounts(operators map[uint64]*Operator) {
for k := range oc.counts {
delete(oc.counts, k)
}
for _, op := range operators {
oc.counts[op.Kind()]++
}
}
// OperatorCount gets the count of operators filtered by mask.
func (oc *OperatorController) OperatorCount(mask OperatorKind) uint64 {
oc.RLock()
defer oc.RUnlock()
var total uint64
for k, count := range oc.counts {
if k&mask != 0 {
total += count
}
}
return total
}
// GetOpInfluence gets OpInfluence.
func (oc *OperatorController) GetOpInfluence(cluster Cluster) OpInfluence {
oc.RLock()
defer oc.RUnlock()
var res []*Operator
for _, op := range oc.operators {
if !op.IsTimeout() && !op.IsFinish() {
region := cluster.GetRegion(op.RegionID())
if region != nil {
res = append(res, op)
}
}
}
return NewUnfinishedOpInfluence(res, cluster)
}
// NewTotalOpInfluence creates a OpInfluence.
func NewTotalOpInfluence(operators []*Operator, cluster Cluster) OpInfluence {
influence := OpInfluence{
storesInfluence: make(map[uint64]*StoreInfluence),
}
for _, op := range operators {
region := cluster.GetRegion(op.RegionID())
if region != nil {
op.TotalInfluence(influence, region)
}
}
return influence
}
// NewUnfinishedOpInfluence creates a OpInfluence.
func NewUnfinishedOpInfluence(operators []*Operator, cluster Cluster) OpInfluence {
influence := OpInfluence{
storesInfluence: make(map[uint64]*StoreInfluence),
}
for _, op := range operators {
if !op.IsTimeout() && !op.IsFinish() {
region := cluster.GetRegion(op.RegionID())
if region != nil {
op.UnfinishedInfluence(influence, region)
}
}
}
return influence
}
// OpInfluence records the influence of the cluster.
type OpInfluence struct {
storesInfluence map[uint64]*StoreInfluence
}
// GetStoreInfluence get storeInfluence of specific store.
func (m OpInfluence) GetStoreInfluence(id uint64) *StoreInfluence {
storeInfluence, ok := m.storesInfluence[id]
if !ok {
storeInfluence = &StoreInfluence{}
m.storesInfluence[id] = storeInfluence
}
return storeInfluence
}
// StoreInfluence records influences that pending operators will make.
type StoreInfluence struct {
RegionSize int64
RegionCount int64
LeaderSize int64
LeaderCount int64
StepCost int64
}
// ResourceSize returns delta size of leader/region by influence.
func (s StoreInfluence) ResourceSize(kind core.ResourceKind) int64 {
switch kind {
case core.LeaderKind:
return s.LeaderSize
case core.RegionKind:
return s.RegionSize
default:
return 0
}
}
// SetOperator is only used for test.
func (oc *OperatorController) SetOperator(op *Operator) {
oc.Lock()
defer oc.Unlock()
oc.operators[op.RegionID()] = op
}
// OperatorWithStatus records the operator and its status.
type OperatorWithStatus struct {
Op *Operator
Status pdpb.OperatorStatus
}
// MarshalJSON returns the status of operator as a JSON string
func (o *OperatorWithStatus) MarshalJSON() ([]byte, error) {
return []byte(`"` + fmt.Sprintf("status: %s, operator: %s", o.Status.String(), o.Op.String()) + `"`), nil
}
// OperatorRecords remains the operator and its status for a while.
type OperatorRecords struct {
ttl *cache.TTL
}
const operatorStatusRemainTime = 10 * time.Minute
// NewOperatorRecords returns a OperatorRecords.
func NewOperatorRecords() *OperatorRecords {
return &OperatorRecords{
ttl: cache.NewTTL(time.Minute, operatorStatusRemainTime),
}
}
// Get gets the operator and its status.
func (o *OperatorRecords) Get(id uint64) *OperatorWithStatus {
v, exist := o.ttl.Get(id)
if !exist {
return nil
}
return v.(*OperatorWithStatus)
}
// Put puts the operator and its status.
func (o *OperatorRecords) Put(op *Operator, status pdpb.OperatorStatus) {
id := op.regionID
record := &OperatorWithStatus{
Op: op,
Status: status,
}
o.ttl.Put(id, record)
}
// exceedStoreLimit returns true if the store exceeds the cost limit after adding the operator. Otherwise, returns false.
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
if stepCost == 0 {
continue
}
available := oc.storesLimit[storeID].Available()
storeLimit.WithLabelValues(strconv.FormatUint(storeID, 10), "available").Set(float64(available) / float64(RegionInfluence))
if available < stepCost {
oc.cluster.SetStoreOverload(storeID)
return true
}
}
return false
}
// SetAllStoresLimit is used to set limit of all stores.
func (oc *OperatorController) SetAllStoresLimit(rate float64) {
oc.Lock()
defer oc.Unlock()
for storeID := range oc.storesLimit {
oc.newStoreLimit(storeID, rate)
}
}
// SetStoreLimit is used to set the limit of a store.
func (oc *OperatorController) SetStoreLimit(storeID uint64, rate float64) {
oc.Lock()
defer oc.Unlock()
oc.newStoreLimit(storeID, rate)
}
// newStoreLimit is used to create the limit of a store.
func (oc *OperatorController) newStoreLimit(storeID uint64, rate float64) {
capacity := RegionInfluence
if rate > 1 {
capacity = int64(rate * float64(RegionInfluence))
}
rate *= float64(RegionInfluence)
oc.storesLimit[storeID] = ratelimit.NewBucketWithRate(rate, capacity)
}
// GetAllStoresLimit is used to get limit of all stores.
func (oc *OperatorController) GetAllStoresLimit() map[uint64]float64 {
oc.RLock()
defer oc.RUnlock()
ret := make(map[uint64]float64)
for storeID, limit := range oc.storesLimit {
store := oc.cluster.GetStore(storeID)
if !store.IsTombstone() {
ret[storeID] = limit.Rate() / float64(RegionInfluence)
}
}
return ret
}