-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pd-ctl: list all regions in a specified store #1231
Conversation
server/core/region.go
Outdated
// GetStoreRegions gets all RegionInfo with a given storeID | ||
func (r *RegionsInfo) GetStoreRegions(storeID uint64) []*RegionInfo { | ||
var regions []*RegionInfo | ||
for _, region := range r.regions.m { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better to iterate leaders
and followers
.
The rest LGTM. |
Oh, don't forget to update api.raml file. |
59aa9f7
to
6529db7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
server/core/region.go
Outdated
@@ -630,6 +630,22 @@ func (r *RegionsInfo) GetRegions() []*RegionInfo { | |||
return regions | |||
} | |||
|
|||
// GetStoreRegions gets all RegionInfo with a given storeID | |||
func (r *RegionsInfo) GetStoreRegions(storeID uint64) []*RegionInfo { | |||
var regions []*RegionInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pre-allocates the slice with capacity?
server/core/region.go
Outdated
var regions []*RegionInfo | ||
if leaders, ok := r.leaders[storeID]; ok { | ||
for _, region := range leaders.m { | ||
regions = append(regions, region.Clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems no need to Clone
any more after the refactor of RegionInfo
. /cc @nolouch
What problem does this PR solve?
Closes #511.
What is changed and how it works?
This PR adds API to list all regions in a specified store. After this PR is merged, we can use
region store <id>
to print all regions in a specified store by usingpd-ctl
.Check List
Tests