@@ -52,6 +52,15 @@ const (
52
52
defaultTargetPeriod = 5 * time .Second
53
53
// defaultMaxWaitDuration is the max duration to wait for the token before throwing error.
54
54
defaultMaxWaitDuration = 30 * time .Second
55
+ << << << < HEAD
56
+ == == == =
57
+ // defaultLTBTokenRPCMaxDelay is the upper bound of backoff delay for local token bucket RPC.
58
+ defaultLTBTokenRPCMaxDelay = 1 * time .Second
59
+ // defaultWaitRetryTimes is the times to retry when waiting for the token.
60
+ defaultWaitRetryTimes = 20
61
+ // defaultWaitRetryInterval is the interval to retry when waiting for the token.
62
+ defaultWaitRetryInterval = 50 * time .Millisecond
63
+ >> >> >> > 6 b25787af (resource_control : allow configuration of the maximum retry time for the local bucket (#8352 ))
55
64
)
56
65
57
66
const (
@@ -73,18 +82,39 @@ const (
73
82
74
83
// Because the resource manager has not been deployed in microservice mode,
75
84
// do not enable this function.
76
- defaultDegradedModeWaitDuration = 0
85
+ defaultDegradedModeWaitDuration = time . Duration ( 0 )
77
86
defaultAvgBatchProportion = 0.7
78
87
)
79
88
80
- // Config is the configuration of the resource manager controller which includes some option for client needed.
81
- type Config struct {
89
+ // TokenRPCParams is the parameters for local bucket RPC.
90
+ type TokenRPCParams struct {
91
+ // WaitRetryInterval is the interval to retry when waiting for the token.
92
+ WaitRetryInterval Duration `toml:"wait-retry-interval" json:"wait-retry-interval"`
93
+
94
+ // WaitRetryTimes is the times to retry when waiting for the token.
95
+ WaitRetryTimes int `toml:"wait-retry-times" json:"wait-retry-times"`
96
+ }
97
+
98
+ // LocalBucketConfig is the configuration for local bucket. not export to server side.
99
+ type LocalBucketConfig struct {
100
+ TokenRPCParams `toml:"token-rpc-params" json:"token-rpc-params"`
101
+ }
102
+
103
+ // BaseConfig is the configuration of the resource manager controller which includes some option for client needed.
104
+ // TODO: unified the configuration for client and server, server side in pkg/mcs/resourcemanger/config.go.
105
+ type BaseConfig struct {
82
106
// EnableDegradedMode is to control whether resource control client enable degraded mode when server is disconnect.
83
107
DegradedModeWaitDuration Duration `toml:"degraded-mode-wait-duration" json:"degraded-mode-wait-duration"`
84
108
85
109
// LTBMaxWaitDuration is the max wait time duration for local token bucket.
86
110
LTBMaxWaitDuration Duration `toml:"ltb-max-wait-duration" json:"ltb-max-wait-duration"`
87
111
112
+ << << << < HEAD
113
+ == == == =
114
+ // LTBTokenRPCMaxDelay is the upper bound of backoff delay for local token bucket RPC.
115
+ LTBTokenRPCMaxDelay Duration `toml:"ltb-token-rpc-max-delay" json:"ltb-token-rpc-max-delay"`
116
+
117
+ >> >> >> > 6 b25787af (resource_control : allow configuration of the maximum retry time for the local bucket (#8352 ))
88
118
// RequestUnit is the configuration determines the coefficients of the RRU and WRU cost.
89
119
// This configuration should be modified carefully.
90
120
RequestUnit RequestUnitConfig `toml:"request-unit" json:"request-unit"`
@@ -93,13 +123,50 @@ type Config struct {
93
123
EnableControllerTraceLog bool `toml:"enable-controller-trace-log" json:"enable-controller-trace-log,string"`
94
124
}
95
125
126
+ // Config is the configuration of the resource manager controller.
127
+ type Config struct {
128
+ BaseConfig
129
+ LocalBucketConfig
130
+ }
131
+
132
+ // Adjust adjusts the configuration.
133
+ func (c * Config ) Adjust () {
134
+ // valid the configuration, TODO: separately add the valid function.
135
+ if c .BaseConfig .LTBMaxWaitDuration .Duration == 0 {
136
+ c .BaseConfig .LTBMaxWaitDuration = NewDuration (defaultMaxWaitDuration )
137
+ }
138
+ if c .LocalBucketConfig .WaitRetryInterval .Duration == 0 {
139
+ c .LocalBucketConfig .WaitRetryInterval = NewDuration (defaultWaitRetryInterval )
140
+ }
141
+ // adjust the client settings. calculate the retry times.
142
+ if int (c .BaseConfig .LTBTokenRPCMaxDelay .Duration ) != int (c .LocalBucketConfig .WaitRetryInterval .Duration )* c .LocalBucketConfig .WaitRetryTimes {
143
+ c .LocalBucketConfig .WaitRetryTimes = int (c .BaseConfig .LTBTokenRPCMaxDelay .Duration / c .LocalBucketConfig .WaitRetryInterval .Duration )
144
+ }
145
+ }
146
+
96
147
// DefaultConfig returns the default resource manager controller configuration.
97
148
func DefaultConfig () * Config {
98
149
return & Config {
150
+ << << << < HEAD
99
151
DegradedModeWaitDuration: NewDuration (defaultDegradedModeWaitDuration ),
100
152
LTBMaxWaitDuration : NewDuration (defaultMaxWaitDuration ),
101
153
RequestUnit : DefaultRequestUnitConfig (),
102
154
EnableControllerTraceLog : false ,
155
+ == == == =
156
+ BaseConfig : BaseConfig {
157
+ DegradedModeWaitDuration : NewDuration (defaultDegradedModeWaitDuration ),
158
+ RequestUnit : DefaultRequestUnitConfig (),
159
+ EnableControllerTraceLog : false ,
160
+ LTBMaxWaitDuration : NewDuration (defaultMaxWaitDuration ),
161
+ LTBTokenRPCMaxDelay : NewDuration (defaultLTBTokenRPCMaxDelay ),
162
+ },
163
+ LocalBucketConfig : LocalBucketConfig {
164
+ TokenRPCParams : TokenRPCParams {
165
+ WaitRetryInterval : NewDuration (defaultWaitRetryInterval ),
166
+ WaitRetryTimes : defaultWaitRetryTimes ,
167
+ },
168
+ },
169
+ >> >> >> > 6 b25787af (resource_control : allow configuration of the maximum retry time for the local bucket (#8352 ))
103
170
}
104
171
}
105
172
0 commit comments