client, resource_manager: resource manager client#5810
client, resource_manager: resource manager client#5810ti-chi-bot merged 21 commits intotikv:masterfrom
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
|
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by submitting an approval review. |
Codecov ReportBase: 75.35% // Head: 74.91% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5810 +/- ##
==========================================
- Coverage 75.35% 74.91% -0.44%
==========================================
Files 338 337 -1
Lines 33858 33941 +83
==========================================
- Hits 25514 25428 -86
- Misses 6137 6329 +192
+ Partials 2207 2184 -23
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
| @@ -0,0 +1,265 @@ | |||
| package pd | |||
There was a problem hiding this comment.
file name need to be resource rather than resouce
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
client/resoucemanager_client.go
Outdated
| // ListResourceGroups loads and returns target keyspace's metadata. | ||
| func (c *client) ListResourceGroups(ctx context.Context) ([]*rmpb.ResourceGroup, error) { | ||
| req := &rmpb.ListResourceGroupsRequest{} | ||
| resp, err := c.resouceManagerClient().ListResourceGroups(ctx, req) |
There was a problem hiding this comment.
Won't this cause panic if the c.resouceManagerClient() return nil?
There was a problem hiding this comment.
Like leaderClient, I don't think c.resouceManagerClient() is going to return nil
client/resoucemanager_client.go
Outdated
| } | ||
|
|
||
| func (c *client) AddResourceGroup(ctx context.Context, resourceGroupName string, settings *rmpb.GroupSettings) (string, error) { | ||
| return c.putResourceGroup(ctx, resourceGroupName, settings, 0 /* type add resource group */) |
There was a problem hiding this comment.
What about using an enum type to distinguish the type rather than the comment?
| clientCtx: c.ctx, | ||
| } | ||
| req.Requeset = request | ||
| c.tokenDispatcher.tokenBatchController.tokenRequestCh <- req |
There was a problem hiding this comment.
It seems that this will easily be blocked since the tokenRequestCh's capacity is 1.
There was a problem hiding this comment.
Currently we have not implemented batch, so it will also be blocked by Wait()?
| dispatcher := &tokenDispatcher{ | ||
| dispatcherCancel: dispatcherCancel, | ||
| tokenBatchController: newTokenBatchController( | ||
| make(chan *tokenRequest, 1)), |
There was a problem hiding this comment.
What about using a larger size?
There was a problem hiding this comment.
Currently we have not implemented batch and do not seem to need a larger size
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
| const defaultInitialTokens = 10 * 10000 | ||
|
|
||
| const defaultMaxTokens = 1e7 |
There was a problem hiding this comment.
| const defaultInitialTokens = 10 * 10000 | |
| const defaultMaxTokens = 1e7 | |
| const ( | |
| defaultInitialTokens = 10 * 10000 | |
| defaultMaxTokens = 1e7 | |
| ) |
| t.Tokens += float64(t.Settings.FillRate) * delta.Seconds() | ||
| t.LastUpdate = &now | ||
| } | ||
| if t.Tokens > t.MaxTokens { |
There was a problem hiding this comment.
Do we also need to check the max tokens when it has not been initialized below?
| var res rmpb.TokenBucket | ||
| res.Settings = &rmpb.TokenLimitSettings{} | ||
| // FillRate is used for the token server unavailable in abnormal situation. | ||
| res.Settings.FillRate = 0 |
There was a problem hiding this comment.
I think this initialization is unnecessary.
| var trickleTime = time.Duration(targetPeriodMs) * time.Millisecond | ||
| availableRate := float64(t.Settings.FillRate) | ||
| if debt := -t.Tokens; debt > 0 { | ||
| fmt.Println(debt) |
There was a problem hiding this comment.
| fmt.Println(debt) |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
client/resourcemanager_client.go
Outdated
| AcquireTokenBuckets(ctx context.Context, request *rmpb.TokenBucketsRequest) ([]*rmpb.TokenBucketResponse, error) | ||
| } | ||
|
|
||
| // resouceManagerClient gets the ResourceManager client of current PD leader. |
There was a problem hiding this comment.
I'm resouce killer!!!🤣can found 10 resouce by Ctrl-F
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
client/resourcemanager_client.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // ListResourceGroups loads and returns target keyspace's metadata. |
client/resourcemanager_client.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // ListResourceGroups loads and returns target keyspace's metadata. |
There was a problem hiding this comment.
The comment is incorrect.
| // ListResourceGroups loads and returns target keyspace's metadata. | |
| // ListResourceGroups loads and returns xxx. |
client/resourcemanager_client.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (c *client) finishTokenRequest(t *tokenRequest, tokenBuckets []*rmpb.TokenBucketResponse, err error) { |
There was a problem hiding this comment.
It seems that this function is too simple to exist. Maybe we can just remove it to avoid some data copying.
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com> merge master Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
62b275c to
6115bc6
Compare
| ) | ||
|
|
||
| // ResourceManagerClient manages resource group info and token request. | ||
| type ResourceManagerClient interface { |
There was a problem hiding this comment.
you can replace the client in tests/msc/resource_manager_test.go to add the tests.
|
/merge |
|
@CabinfeverB: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
This pull request has been accepted and is ready to merge. DetailsCommit hash: d776fca |
|
@CabinfeverB: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: Ref #5851
impl resource manager client
What is changed and how does it work?
Check List
Tests
Related changes
pingcap/docs/pingcap/docs-cn:pingcap/tiup:Release note