-
Notifications
You must be signed in to change notification settings - Fork 725
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
*: store balance weight. #713
Conversation
} | ||
|
||
func newStoreInfo(store *metapb.Store) *StoreInfo { | ||
return &StoreInfo{ | ||
Store: store, | ||
Store: store, | ||
LeaderWeight: 1.0, |
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.
How about set default value as 100?
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.
If the weight is unset, the score will be the same as old score, because newScore = oldScore / weight.
server/balancer_test.go
Outdated
func (s *testBalanceLeaderSchedulerSuite) TestLeaderWeight(c *C) { | ||
// Stores: 1 2 3 4 | ||
// Leaders: 10 10 10 10 | ||
// Weight: 0.5 0.5 1 2 |
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.
s/0.5 0.5/0.5 0.9/
@@ -169,8 +180,20 @@ func (kv *kv) loadStores(stores *storesInfo, rangeLimit int64) error { | |||
return errors.Trace(err) | |||
} | |||
|
|||
storeInfo := newStoreInfo(store) | |||
leaderWeight, err := kv.loadFloatWithDefaultValue(kv.storeLeaderWeightPath(storeInfo.GetId()), 1.0) |
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.
Consider extracting a loadStoreWeight
and test them.
return errors.Trace(errStoreNotFound(storeID)) | ||
} | ||
|
||
if err := c.s.kv.saveStoreWeight(storeID, leader, region); err != nil { |
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.
Consider moving this inside clusterInfo.putStore
.
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.
clusterInfo.putStore
has other callers, SetStoreLabel
, DeleteStore
, etc. They won't change the weight, so I think put saveStoreWeight
outside is more suitable.
Will this affect |
If |
Maybe |
There are too many hacks in |
I still think that |
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. maybe we can add hot region weight later.
Hi. Could anyone explain the actual meaning of |
No description provided.