-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_provider.go
153 lines (130 loc) · 4.52 KB
/
config_provider.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
// Copyright 2023 TiKV Project Authors.
//
// 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config
import (
"sync"
"time"
"github.com/coreos/go-semver/semver"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/tikv/pd/pkg/core/constant"
"github.com/tikv/pd/pkg/core/storelimit"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage/endpoint"
)
// RejectLeader is the label property type that suggests a store should not
// have any region leaders.
const RejectLeader = "reject-leader"
var schedulerMap sync.Map
// RegisterScheduler registers the scheduler type.
func RegisterScheduler(typ types.CheckerSchedulerType) {
schedulerMap.Store(typ, struct{}{})
}
// IsSchedulerRegistered checks if the named scheduler type is registered.
func IsSchedulerRegistered(typ types.CheckerSchedulerType) bool {
_, ok := schedulerMap.Load(typ)
return ok
}
// SchedulerConfigProvider is the interface for scheduler configurations.
type SchedulerConfigProvider interface {
SharedConfigProvider
SetSchedulingAllowanceStatus(bool, string)
GetStoresLimit() map[uint64]StoreLimitConfig
IsSchedulerDisabled(types.CheckerSchedulerType) bool
AddSchedulerCfg(types.CheckerSchedulerType, []string)
RemoveSchedulerCfg(types.CheckerSchedulerType)
Persist(endpoint.ConfigStorage) error
GetRegionScheduleLimit() uint64
GetLeaderScheduleLimit() uint64
GetHotRegionScheduleLimit() uint64
GetWitnessScheduleLimit() uint64
GetHotRegionCacheHitsThreshold() int
GetMaxMovableHotPeerSize() int64
IsTraceRegionFlow() bool
GetTolerantSizeRatio() float64
IsDebugMetricsEnabled() bool
IsDiagnosticAllowed() bool
GetSlowStoreEvictingAffectedStoreRatioThreshold() float64
GetScheduleConfig() *ScheduleConfig
SetScheduleConfig(*ScheduleConfig)
}
// CheckerConfigProvider is the interface for checker configurations.
type CheckerConfigProvider interface {
SharedConfigProvider
StoreConfigProvider
GetSwitchWitnessInterval() time.Duration
IsRemoveExtraReplicaEnabled() bool
IsRemoveDownReplicaEnabled() bool
IsReplaceOfflineReplicaEnabled() bool
IsMakeUpReplicaEnabled() bool
IsLocationReplacementEnabled() bool
GetIsolationLevel() string
GetSplitMergeInterval() time.Duration
GetPatrolRegionInterval() time.Duration
GetPatrolRegionWorkerCount() int
GetMaxMergeRegionSize() uint64
GetMaxMergeRegionKeys() uint64
GetReplicaScheduleLimit() uint64
}
// SharedConfigProvider is the interface for shared configurations.
type SharedConfigProvider interface {
GetMaxReplicas() int
IsPlacementRulesEnabled() bool
GetMaxSnapshotCount() uint64
GetMaxPendingPeerCount() uint64
GetLowSpaceRatio() float64
GetHighSpaceRatio() float64
GetMaxStoreDownTime() time.Duration
GetLocationLabels() []string
CheckLabelProperty(string, []*metapb.StoreLabel) bool
GetClusterVersion() *semver.Version
IsUseJointConsensus() bool
GetKeyType() constant.KeyType
IsCrossTableMergeEnabled() bool
IsOneWayMergeEnabled() bool
GetMergeScheduleLimit() uint64
GetLeaderSchedulePolicy() constant.SchedulePolicy
GetRegionScoreFormulaVersion() string
GetSchedulerMaxWaitingOperator() uint64
GetStoreLimitByType(uint64, storelimit.Type) float64
IsWitnessAllowed() bool
IsPlacementRulesCacheEnabled() bool
SetHaltScheduling(bool, string)
GetHotRegionCacheHitsThreshold() int
// for test purpose
SetPlacementRuleEnabled(bool)
SetPlacementRulesCacheEnabled(bool)
SetEnableWitness(bool)
}
// ConfProvider is the interface that wraps the ConfProvider related methods.
type ConfProvider interface {
SchedulerConfigProvider
CheckerConfigProvider
StoreConfigProvider
// for test purpose
SetPlacementRuleEnabled(bool)
SetSplitMergeInterval(time.Duration)
SetMaxReplicas(int)
SetAllStoresLimit(storelimit.Type, float64)
}
// StoreConfigProvider is the interface that wraps the StoreConfigProvider related methods.
type StoreConfigProvider interface {
GetRegionMaxSize() uint64
GetRegionMaxKeys() uint64
GetRegionSplitSize() uint64
GetRegionSplitKeys() uint64
CheckRegionSize(uint64, uint64) error
CheckRegionKeys(uint64, uint64) error
IsEnableRegionBucket() bool
IsRaftKV2() bool
}