-
Notifications
You must be signed in to change notification settings - Fork 0
/
mockcluster.go
626 lines (551 loc) · 20.2 KB
/
mockcluster.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
// Copyright 2017 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 (
"fmt"
"time"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
log "github.com/pingcap/log"
"github.com/pingcap/pd/server/core"
"github.com/pingcap/pd/server/namespace"
"go.uber.org/zap"
)
// MockCluster is used to mock clusterInfo for test use
type MockCluster struct {
*BasicCluster
id *core.MockIDAllocator
*MockSchedulerOptions
}
// NewMockCluster creates a new MockCluster
func NewMockCluster(opt *MockSchedulerOptions) *MockCluster {
return &MockCluster{
BasicCluster: NewBasicCluster(),
id: core.NewMockIDAllocator(),
MockSchedulerOptions: opt,
}
}
func (mc *MockCluster) allocID() (uint64, error) {
return mc.id.Alloc()
}
// ScanRegions scan region with start key, until number greater than limit.
func (mc *MockCluster) ScanRegions(startKey []byte, limit int) []*core.RegionInfo {
return mc.Regions.ScanRange(startKey, limit)
}
// LoadRegion put region info without leader
func (mc *MockCluster) LoadRegion(regionID uint64, followerIds ...uint64) {
// regions load from etcd will have no leader
r := mc.newMockRegionInfo(regionID, 0, followerIds...).Clone(core.WithLeader(nil))
mc.PutRegion(r)
}
// IsRegionHot checks if the region is hot
func (mc *MockCluster) IsRegionHot(id uint64) bool {
return mc.BasicCluster.IsRegionHot(id, mc.GetHotRegionCacheHitsThreshold())
}
// RandHotRegionFromStore random picks a hot region in specify store.
func (mc *MockCluster) RandHotRegionFromStore(store uint64, kind FlowKind) *core.RegionInfo {
r := mc.HotCache.RandHotRegionFromStore(store, kind, mc.GetHotRegionCacheHitsThreshold())
if r == nil {
return nil
}
return mc.GetRegion(r.RegionID)
}
// AllocPeer allocs a new peer on a store.
func (mc *MockCluster) AllocPeer(storeID uint64) (*metapb.Peer, error) {
peerID, err := mc.allocID()
if err != nil {
log.Error("failed to alloc peer", zap.Error(err))
return nil, err
}
peer := &metapb.Peer{
Id: peerID,
StoreId: storeID,
}
return peer, nil
}
// SetStoreUp sets store state to be up.
func (mc *MockCluster) SetStoreUp(storeID uint64) {
store := mc.GetStore(storeID)
store.State = metapb.StoreState_Up
store.LastHeartbeatTS = time.Now()
mc.PutStore(store)
}
// SetStoreDisconnect changes a store's state to disconnected.
func (mc *MockCluster) SetStoreDisconnect(storeID uint64) {
store := mc.GetStore(storeID)
store.State = metapb.StoreState_Up
store.LastHeartbeatTS = time.Now().Add(-time.Second * 30)
mc.PutStore(store)
}
// SetStoreDown sets store down.
func (mc *MockCluster) SetStoreDown(storeID uint64) {
store := mc.GetStore(storeID)
store.State = metapb.StoreState_Up
store.LastHeartbeatTS = time.Time{}
mc.PutStore(store)
}
// SetStoreOffline sets store state to be offline.
func (mc *MockCluster) SetStoreOffline(storeID uint64) {
store := mc.GetStore(storeID)
store.State = metapb.StoreState_Offline
mc.PutStore(store)
}
// SetStoreBusy sets store busy.
func (mc *MockCluster) SetStoreBusy(storeID uint64, busy bool) {
store := mc.GetStore(storeID)
store.Stats.IsBusy = busy
store.LastHeartbeatTS = time.Now()
mc.PutStore(store)
}
// AddLeaderStore adds store with specified count of leader.
func (mc *MockCluster) AddLeaderStore(storeID uint64, leaderCount int) {
store := core.NewStoreInfo(&metapb.Store{Id: storeID})
store.Stats = &pdpb.StoreStats{}
store.LastHeartbeatTS = time.Now()
store.LeaderCount = leaderCount
store.LeaderSize = int64(leaderCount) * 10
store.Stats.Capacity = 1000 * (1 << 20)
store.Stats.Available = store.Stats.Capacity - uint64(store.LeaderSize)
mc.PutStore(store)
}
// AddRegionStore adds store with specified count of region.
func (mc *MockCluster) AddRegionStore(storeID uint64, regionCount int) {
store := core.NewStoreInfo(&metapb.Store{Id: storeID})
store.Stats = &pdpb.StoreStats{}
store.LastHeartbeatTS = time.Now()
store.RegionCount = regionCount
store.RegionSize = int64(regionCount) * 10
store.Stats.Capacity = 1000 * (1 << 20)
store.Stats.Available = store.Stats.Capacity - uint64(store.RegionSize)
mc.PutStore(store)
}
// AddLabelsStore adds store with specified count of region and labels.
func (mc *MockCluster) AddLabelsStore(storeID uint64, regionCount int, labels map[string]string) {
mc.AddRegionStore(storeID, regionCount)
store := mc.GetStore(storeID)
for k, v := range labels {
store.Labels = append(store.Labels, &metapb.StoreLabel{Key: k, Value: v})
}
mc.PutStore(store)
}
// AddLeaderRegion adds region with specified leader and followers.
func (mc *MockCluster) AddLeaderRegion(regionID uint64, leaderID uint64, followerIds ...uint64) {
origin := mc.newMockRegionInfo(regionID, leaderID, followerIds...)
region := origin.Clone(core.SetApproximateSize(10), core.SetApproximateKeys(10))
mc.PutRegion(region)
}
// AddLeaderRegionWithRange adds region with specified leader, followers and key range.
func (mc *MockCluster) AddLeaderRegionWithRange(regionID uint64, startKey string, endKey string, leaderID uint64, followerIds ...uint64) {
o := mc.newMockRegionInfo(regionID, leaderID, followerIds...)
r := o.Clone(
core.WithStartKey([]byte(startKey)),
core.WithEndKey([]byte(endKey)),
)
mc.PutRegion(r)
}
// AddLeaderRegionWithReadInfo adds region with specified leader, followers and read info.
func (mc *MockCluster) AddLeaderRegionWithReadInfo(regionID uint64, leaderID uint64, readBytes uint64, followerIds ...uint64) {
r := mc.newMockRegionInfo(regionID, leaderID, followerIds...)
r = r.Clone(core.SetReadBytes(readBytes))
isUpdate, item := mc.BasicCluster.CheckReadStatus(r)
if isUpdate {
mc.HotCache.Update(regionID, item, ReadFlow)
}
mc.PutRegion(r)
}
// AddLeaderRegionWithWriteInfo adds region with specified leader, followers and write info.
func (mc *MockCluster) AddLeaderRegionWithWriteInfo(regionID uint64, leaderID uint64, writtenBytes uint64, followerIds ...uint64) {
r := mc.newMockRegionInfo(regionID, leaderID, followerIds...)
r = r.Clone(core.SetWrittenBytes(writtenBytes))
isUpdate, item := mc.BasicCluster.CheckWriteStatus(r)
if isUpdate {
mc.HotCache.Update(regionID, item, WriteFlow)
}
mc.PutRegion(r)
}
// UpdateStoreLeaderWeight updates store leader weight.
func (mc *MockCluster) UpdateStoreLeaderWeight(storeID uint64, weight float64) {
store := mc.GetStore(storeID)
store.LeaderWeight = weight
mc.PutStore(store)
}
// UpdateStoreRegionWeight updates store region weight.
func (mc *MockCluster) UpdateStoreRegionWeight(storeID uint64, weight float64) {
store := mc.GetStore(storeID)
store.RegionWeight = weight
mc.PutStore(store)
}
// UpdateStoreLeaderSize updates store leader size.
func (mc *MockCluster) UpdateStoreLeaderSize(storeID uint64, size int64) {
store := mc.GetStore(storeID)
store.LeaderSize = size
store.Stats.Available = store.Stats.Capacity - uint64(store.LeaderSize)
mc.PutStore(store)
}
// UpdateStoreRegionSize updates store region size.
func (mc *MockCluster) UpdateStoreRegionSize(storeID uint64, size int64) {
store := mc.GetStore(storeID)
store.RegionSize = size
store.Stats.Available = store.Stats.Capacity - uint64(store.RegionSize)
mc.PutStore(store)
}
// UpdateLeaderCount updates store leader count.
func (mc *MockCluster) UpdateLeaderCount(storeID uint64, leaderCount int) {
store := mc.GetStore(storeID)
store.LeaderCount = leaderCount
store.LeaderSize = int64(leaderCount) * 10
mc.PutStore(store)
}
// UpdateRegionCount updates store region count.
func (mc *MockCluster) UpdateRegionCount(storeID uint64, regionCount int) {
store := mc.GetStore(storeID)
store.RegionCount = regionCount
store.RegionSize = int64(regionCount) * 10
mc.PutStore(store)
}
// UpdateSnapshotCount updates store snapshot count.
func (mc *MockCluster) UpdateSnapshotCount(storeID uint64, snapshotCount int) {
store := mc.GetStore(storeID)
store.Stats.ApplyingSnapCount = uint32(snapshotCount)
mc.PutStore(store)
}
// UpdatePendingPeerCount updates store pending peer count.
func (mc *MockCluster) UpdatePendingPeerCount(storeID uint64, pendingPeerCount int) {
store := mc.GetStore(storeID)
store.PendingPeerCount = pendingPeerCount
mc.PutStore(store)
}
// UpdateStorageRatio updates store storage ratio count.
func (mc *MockCluster) UpdateStorageRatio(storeID uint64, usedRatio, availableRatio float64) {
store := mc.GetStore(storeID)
store.Stats.Capacity = 1000 * (1 << 20)
store.Stats.UsedSize = uint64(float64(store.Stats.Capacity) * usedRatio)
store.Stats.Available = uint64(float64(store.Stats.Capacity) * availableRatio)
mc.PutStore(store)
}
// UpdateStorageWrittenBytes updates store written bytes.
func (mc *MockCluster) UpdateStorageWrittenBytes(storeID uint64, BytesWritten uint64) {
store := mc.GetStore(storeID)
store.Stats.BytesWritten = BytesWritten
now := time.Now().Second()
interval := &pdpb.TimeInterval{StartTimestamp: uint64(now - storeHeartBeatReportInterval), EndTimestamp: uint64(now)}
store.Stats.Interval = interval
mc.PutStore(store)
}
// UpdateStorageReadBytes updates store read bytes.
func (mc *MockCluster) UpdateStorageReadBytes(storeID uint64, BytesRead uint64) {
store := mc.GetStore(storeID)
now := time.Now().Second()
interval := &pdpb.TimeInterval{StartTimestamp: uint64(now - storeHeartBeatReportInterval), EndTimestamp: uint64(now)}
store.Stats.Interval = interval
store.Stats.BytesRead = BytesRead
mc.PutStore(store)
}
// UpdateStoreStatus updates store status.
func (mc *MockCluster) UpdateStoreStatus(id uint64) {
mc.Stores.SetLeaderCount(id, mc.Regions.GetStoreLeaderCount(id))
mc.Stores.SetRegionCount(id, mc.Regions.GetStoreRegionCount(id))
mc.Stores.SetPendingPeerCount(id, mc.Regions.GetStorePendingPeerCount(id))
mc.Stores.SetLeaderSize(id, mc.Regions.GetStoreLeaderRegionSize(id))
mc.Stores.SetRegionSize(id, mc.Regions.GetStoreRegionSize(id))
store := mc.Stores.GetStore(id)
store.Stats = &pdpb.StoreStats{}
store.Stats.Capacity = 1000 * (1 << 20)
store.Stats.Available = store.Stats.Capacity - uint64(store.RegionSize)
store.Stats.UsedSize = uint64(store.RegionSize)
mc.PutStore(store)
}
func (mc *MockCluster) newMockRegionInfo(regionID uint64, leaderID uint64, followerIds ...uint64) *core.RegionInfo {
region := &metapb.Region{
Id: regionID,
StartKey: []byte(fmt.Sprintf("%20d", regionID)),
EndKey: []byte(fmt.Sprintf("%20d", regionID+1)),
}
leader, _ := mc.AllocPeer(leaderID)
region.Peers = []*metapb.Peer{leader}
for _, id := range followerIds {
peer, _ := mc.AllocPeer(id)
region.Peers = append(region.Peers, peer)
}
return core.NewRegionInfo(region, leader)
}
// ApplyOperatorStep mocks apply operator step.
func (mc *MockCluster) ApplyOperatorStep(region *core.RegionInfo, op *Operator) *core.RegionInfo {
if step := op.Check(region); step != nil {
switch s := step.(type) {
case TransferLeader:
region = region.Clone(core.WithLeader(region.GetStorePeer(s.ToStore)))
case AddPeer:
if region.GetStorePeer(s.ToStore) != nil {
panic("Add peer that exists")
}
peer := &metapb.Peer{
Id: s.PeerID,
StoreId: s.ToStore,
}
region = region.Clone(core.WithAddPeer(peer))
case RemovePeer:
if region.GetStorePeer(s.FromStore) == nil {
panic("Remove peer that doesn't exist")
}
if region.GetLeader().GetStoreId() == s.FromStore {
panic("Cannot remove the leader peer")
}
region = region.Clone(core.WithRemoveStorePeer(s.FromStore))
case AddLearner:
if region.GetStorePeer(s.ToStore) != nil {
panic("Add learner that exists")
}
peer := &metapb.Peer{
Id: s.PeerID,
StoreId: s.ToStore,
IsLearner: true,
}
region = region.Clone(core.WithAddPeer(peer))
case PromoteLearner:
if region.GetStoreLearner(s.ToStore) == nil {
panic("Promote peer that doesn't exist")
}
peer := &metapb.Peer{
Id: s.PeerID,
StoreId: s.ToStore,
}
region = region.Clone(core.WithRemoveStorePeer(s.ToStore), core.WithAddPeer(peer))
default:
panic("Unknown operator step")
}
}
return region
}
// ApplyOperator mocks apply operator.
func (mc *MockCluster) ApplyOperator(op *Operator) {
origin := mc.GetRegion(op.RegionID())
region := origin
for !op.IsFinish() {
region = mc.ApplyOperatorStep(region, op)
}
mc.PutRegion(region)
for id := range region.GetStoreIds() {
mc.UpdateStoreStatus(id)
}
for id := range origin.GetStoreIds() {
mc.UpdateStoreStatus(id)
}
}
// GetOpt mocks method.
func (mc *MockCluster) GetOpt() NamespaceOptions {
return mc.MockSchedulerOptions
}
// GetLeaderScheduleLimit mocks method.
func (mc *MockCluster) GetLeaderScheduleLimit() uint64 {
return mc.MockSchedulerOptions.GetLeaderScheduleLimit(namespace.DefaultNamespace)
}
// GetRegionScheduleLimit mocks method.
func (mc *MockCluster) GetRegionScheduleLimit() uint64 {
return mc.MockSchedulerOptions.GetRegionScheduleLimit(namespace.DefaultNamespace)
}
// GetReplicaScheduleLimit mocks method.
func (mc *MockCluster) GetReplicaScheduleLimit() uint64 {
return mc.MockSchedulerOptions.GetReplicaScheduleLimit(namespace.DefaultNamespace)
}
// GetMergeScheduleLimit mocks method.
func (mc *MockCluster) GetMergeScheduleLimit() uint64 {
return mc.MockSchedulerOptions.GetMergeScheduleLimit(namespace.DefaultNamespace)
}
// GetHotRegionScheduleLimit mocks method.
func (mc *MockCluster) GetHotRegionScheduleLimit() uint64 {
return mc.MockSchedulerOptions.GetHotRegionScheduleLimit(namespace.DefaultNamespace)
}
// GetMaxReplicas mocks method.
func (mc *MockCluster) GetMaxReplicas() int {
return mc.MockSchedulerOptions.GetMaxReplicas(namespace.DefaultNamespace)
}
// CheckLabelProperty checks label property.
func (mc *MockCluster) CheckLabelProperty(typ string, labels []*metapb.StoreLabel) bool {
for _, cfg := range mc.LabelProperties[typ] {
for _, l := range labels {
if l.Key == cfg.Key && l.Value == cfg.Value {
return true
}
}
}
return false
}
const (
defaultMaxReplicas = 3
defaultMaxSnapshotCount = 3
defaultMaxPendingPeerCount = 16
defaultMaxMergeRegionSize = 0
defaultMaxMergeRegionKeys = 0
defaultSplitMergeInterval = 0
defaultMaxStoreDownTime = 30 * time.Minute
defaultLeaderScheduleLimit = 4
defaultRegionScheduleLimit = 4
defaultReplicaScheduleLimit = 8
defaultMergeScheduleLimit = 8
defaultHotRegionScheduleLimit = 2
defaultTolerantSizeRatio = 2.5
defaultLowSpaceRatio = 0.8
defaultHighSpaceRatio = 0.6
defaultHotRegionCacheHitsThreshold = 3
)
// MockSchedulerOptions is a mock of SchedulerOptions
// which implements Options interface
type MockSchedulerOptions struct {
RegionScheduleLimit uint64
LeaderScheduleLimit uint64
ReplicaScheduleLimit uint64
MergeScheduleLimit uint64
HotRegionScheduleLimit uint64
MaxSnapshotCount uint64
MaxPendingPeerCount uint64
MaxMergeRegionSize uint64
MaxMergeRegionKeys uint64
SplitMergeInterval time.Duration
MaxStoreDownTime time.Duration
MaxReplicas int
LocationLabels []string
HotRegionCacheHitsThreshold int
TolerantSizeRatio float64
LowSpaceRatio float64
HighSpaceRatio float64
DisableLearner bool
DisableRemoveDownReplica bool
DisableReplaceOfflineReplica bool
DisableMakeUpReplica bool
DisableRemoveExtraReplica bool
DisableLocationReplacement bool
DisableNamespaceRelocation bool
LabelProperties map[string][]*metapb.StoreLabel
}
// NewMockSchedulerOptions creates a mock schedule option.
func NewMockSchedulerOptions() *MockSchedulerOptions {
mso := &MockSchedulerOptions{}
mso.RegionScheduleLimit = defaultRegionScheduleLimit
mso.LeaderScheduleLimit = defaultLeaderScheduleLimit
mso.ReplicaScheduleLimit = defaultReplicaScheduleLimit
mso.MergeScheduleLimit = defaultMergeScheduleLimit
mso.HotRegionScheduleLimit = defaultHotRegionScheduleLimit
mso.MaxSnapshotCount = defaultMaxSnapshotCount
mso.MaxMergeRegionSize = defaultMaxMergeRegionSize
mso.MaxMergeRegionKeys = defaultMaxMergeRegionKeys
mso.SplitMergeInterval = defaultSplitMergeInterval
mso.MaxStoreDownTime = defaultMaxStoreDownTime
mso.MaxReplicas = defaultMaxReplicas
mso.HotRegionCacheHitsThreshold = defaultHotRegionCacheHitsThreshold
mso.MaxPendingPeerCount = defaultMaxPendingPeerCount
mso.TolerantSizeRatio = defaultTolerantSizeRatio
mso.LowSpaceRatio = defaultLowSpaceRatio
mso.HighSpaceRatio = defaultHighSpaceRatio
return mso
}
// GetLeaderScheduleLimit mock method
func (mso *MockSchedulerOptions) GetLeaderScheduleLimit(name string) uint64 {
return mso.LeaderScheduleLimit
}
// GetRegionScheduleLimit mock method
func (mso *MockSchedulerOptions) GetRegionScheduleLimit(name string) uint64 {
return mso.RegionScheduleLimit
}
// GetReplicaScheduleLimit mock method
func (mso *MockSchedulerOptions) GetReplicaScheduleLimit(name string) uint64 {
return mso.ReplicaScheduleLimit
}
// GetMergeScheduleLimit mock method
func (mso *MockSchedulerOptions) GetMergeScheduleLimit(name string) uint64 {
return mso.MergeScheduleLimit
}
// GetHotRegionScheduleLimit mock method
func (mso *MockSchedulerOptions) GetHotRegionScheduleLimit(name string) uint64 {
return mso.HotRegionScheduleLimit
}
// GetMaxSnapshotCount mock method
func (mso *MockSchedulerOptions) GetMaxSnapshotCount() uint64 {
return mso.MaxSnapshotCount
}
// GetMaxPendingPeerCount mock method
func (mso *MockSchedulerOptions) GetMaxPendingPeerCount() uint64 {
return mso.MaxPendingPeerCount
}
// GetMaxMergeRegionSize mock method
func (mso *MockSchedulerOptions) GetMaxMergeRegionSize() uint64 {
return mso.MaxMergeRegionSize
}
// GetMaxMergeRegionKeys mock method
func (mso *MockSchedulerOptions) GetMaxMergeRegionKeys() uint64 {
return mso.MaxMergeRegionKeys
}
// GetSplitMergeInterval mock method
func (mso *MockSchedulerOptions) GetSplitMergeInterval() time.Duration {
return mso.SplitMergeInterval
}
// GetMaxStoreDownTime mock method
func (mso *MockSchedulerOptions) GetMaxStoreDownTime() time.Duration {
return mso.MaxStoreDownTime
}
// GetMaxReplicas mock method
func (mso *MockSchedulerOptions) GetMaxReplicas(name string) int {
return mso.MaxReplicas
}
// GetLocationLabels mock method
func (mso *MockSchedulerOptions) GetLocationLabels() []string {
return mso.LocationLabels
}
// GetHotRegionCacheHitsThreshold mock method
func (mso *MockSchedulerOptions) GetHotRegionCacheHitsThreshold() int {
return mso.HotRegionCacheHitsThreshold
}
// GetTolerantSizeRatio mock method
func (mso *MockSchedulerOptions) GetTolerantSizeRatio() float64 {
return mso.TolerantSizeRatio
}
// GetLowSpaceRatio mock method
func (mso *MockSchedulerOptions) GetLowSpaceRatio() float64 {
return mso.LowSpaceRatio
}
// GetHighSpaceRatio mock method
func (mso *MockSchedulerOptions) GetHighSpaceRatio() float64 {
return mso.HighSpaceRatio
}
// SetMaxReplicas mock method
func (mso *MockSchedulerOptions) SetMaxReplicas(replicas int) {
mso.MaxReplicas = replicas
}
// IsRaftLearnerEnabled mock method
func (mso *MockSchedulerOptions) IsRaftLearnerEnabled() bool {
return !mso.DisableLearner
}
// IsRemoveDownReplicaEnabled mock method.
func (mso *MockSchedulerOptions) IsRemoveDownReplicaEnabled() bool {
return !mso.DisableRemoveDownReplica
}
// IsReplaceOfflineReplicaEnabled mock method.
func (mso *MockSchedulerOptions) IsReplaceOfflineReplicaEnabled() bool {
return !mso.DisableReplaceOfflineReplica
}
// IsMakeUpReplicaEnabled mock method.
func (mso *MockSchedulerOptions) IsMakeUpReplicaEnabled() bool {
return !mso.DisableMakeUpReplica
}
// IsRemoveExtraReplicaEnabled mock method.
func (mso *MockSchedulerOptions) IsRemoveExtraReplicaEnabled() bool {
return !mso.DisableRemoveExtraReplica
}
// IsLocationReplacementEnabled mock method.
func (mso *MockSchedulerOptions) IsLocationReplacementEnabled() bool {
return !mso.DisableLocationReplacement
}
// IsNamespaceRelocationEnabled mock method.
func (mso *MockSchedulerOptions) IsNamespaceRelocationEnabled() bool {
return !mso.DisableNamespaceRelocation
}