@@ -52,8 +52,10 @@ 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
+ // defaultLTBTokenRPCMaxDelay is the upper bound of backoff delay for local token bucket RPC.
56
+ defaultLTBTokenRPCMaxDelay = 1 * time .Second
55
57
// defaultWaitRetryTimes is the times to retry when waiting for the token.
56
- defaultWaitRetryTimes = 10
58
+ defaultWaitRetryTimes = 20
57
59
// defaultWaitRetryInterval is the interval to retry when waiting for the token.
58
60
defaultWaitRetryInterval = 50 * time .Millisecond
59
61
)
@@ -77,23 +79,35 @@ const (
77
79
78
80
// Because the resource manager has not been deployed in microservice mode,
79
81
// do not enable this function.
80
- defaultDegradedModeWaitDuration = 0
82
+ defaultDegradedModeWaitDuration = time . Duration ( 0 )
81
83
defaultAvgBatchProportion = 0.7
82
84
)
83
85
84
- // Config is the configuration of the resource manager controller which includes some option for client needed.
85
- type Config struct {
86
+ // LocalBucketRPCParams is the parameters for local bucket RPC.
87
+ type TokenRPCParams struct {
88
+ // WaitRetryInterval is the interval to retry when waiting for the token.
89
+ WaitRetryInterval Duration `toml:"wait-retry-interval" json:"wait-retry-interval"`
90
+
91
+ // WaitRetryTimes is the times to retry when waiting for the token.
92
+ WaitRetryTimes int `toml:"wait-retry-times" json:"wait-retry-times"`
93
+ }
94
+
95
+ // LocalBucketConfig is the configuration for local bucket. not export to server side.
96
+ type LocalBucketConfig struct {
97
+ TokenRPCParams `toml:"token-rpc-params" json:"token-rpc-params"`
98
+ }
99
+
100
+ // BaseConfig is the configuration of the resource manager controller which includes some option for client needed.
101
+ // TODO: unified the configuration for client and server, server side in pkg/mcs/resourcemanger/config.go.
102
+ type BaseConfig struct {
86
103
// EnableDegradedMode is to control whether resource control client enable degraded mode when server is disconnect.
87
104
DegradedModeWaitDuration Duration `toml:"degraded-mode-wait-duration" json:"degraded-mode-wait-duration"`
88
105
89
106
// LTBMaxWaitDuration is the max wait time duration for local token bucket.
90
107
LTBMaxWaitDuration Duration `toml:"ltb-max-wait-duration" json:"ltb-max-wait-duration"`
91
108
92
- // WaitRetryInterval is the interval to retry when waiting for the token.
93
- WaitRetryInterval Duration `toml:"wait-retry-interval" json:"wait-retry-interval"`
94
-
95
- // WaitRetryTimes is the times to retry when waiting for the token.
96
- WaitRetryTimes int `toml:"wait-retry-times" json:"wait-retry-times"`
109
+ // LTBTokenRPCMaxDelay is the upper bound of backoff delay for local token bucket RPC.
110
+ LTBTokenRPCMaxDelay Duration `toml:"ltb-token-rpc-max-delay" json:"ltb-token-rpc-max-delay"`
97
111
98
112
// RequestUnit is the configuration determines the coefficients of the RRU and WRU cost.
99
113
// This configuration should be modified carefully.
@@ -103,15 +117,35 @@ type Config struct {
103
117
EnableControllerTraceLog bool `toml:"enable-controller-trace-log" json:"enable-controller-trace-log,string"`
104
118
}
105
119
120
+ // Config is the configuration of the resource manager controller.
121
+ type Config struct {
122
+ BaseConfig
123
+ LocalBucketConfig
124
+ }
125
+
126
+ // Adjust adjusts the configuration.
127
+ func (c * Config ) Adjust () {
128
+ if int (c .BaseConfig .LTBTokenRPCMaxDelay .Duration ) != int (c .LocalBucketConfig .WaitRetryInterval .Duration )* c .LocalBucketConfig .WaitRetryTimes {
129
+ c .LocalBucketConfig .WaitRetryTimes = int (c .BaseConfig .LTBTokenRPCMaxDelay .Duration / c .LocalBucketConfig .WaitRetryInterval .Duration )
130
+ }
131
+ }
132
+
106
133
// DefaultConfig returns the default resource manager controller configuration.
107
134
func DefaultConfig () * Config {
108
135
return & Config {
109
- DegradedModeWaitDuration : NewDuration (defaultDegradedModeWaitDuration ),
110
- LTBMaxWaitDuration : NewDuration (defaultMaxWaitDuration ),
111
- WaitRetryInterval : NewDuration (defaultWaitRetryInterval ),
112
- WaitRetryTimes : defaultWaitRetryTimes ,
113
- RequestUnit : DefaultRequestUnitConfig (),
114
- EnableControllerTraceLog : false ,
136
+ BaseConfig : BaseConfig {
137
+ DegradedModeWaitDuration : NewDuration (defaultDegradedModeWaitDuration ),
138
+ RequestUnit : DefaultRequestUnitConfig (),
139
+ EnableControllerTraceLog : false ,
140
+ LTBMaxWaitDuration : NewDuration (defaultMaxWaitDuration ),
141
+ LTBTokenRPCMaxDelay : NewDuration (defaultLTBTokenRPCMaxDelay ),
142
+ },
143
+ LocalBucketConfig : LocalBucketConfig {
144
+ TokenRPCParams : TokenRPCParams {
145
+ WaitRetryInterval : NewDuration (defaultWaitRetryInterval ),
146
+ WaitRetryTimes : defaultWaitRetryTimes ,
147
+ },
148
+ },
115
149
}
116
150
}
117
151
0 commit comments