Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
dd9ad570
Commit
dd9ad570
authored
Oct 13, 2011
by
antirez
Browse files
redis-trib: fix for a slot allocation bug.
parent
2b9ce019
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
dd9ad570
...
...
@@ -319,10 +319,11 @@ class RedisTrib
# divisibility. Like we have 3 nodes and need to get 10 slots, we take
# 4 from the first, and 3 from the rest. So the biggest is always the first.
sources
=
sources
.
sort
{
|
a
,
b
|
b
.
slots
.
length
<=>
a
.
slots
.
length
}
source_tot_slots
=
sources
.
inject
{
|
a
,
b
|
a
.
slots
.
length
+
b
.
slots
.
length
}
sources
.
each_with_index
{
|
s
,
i
|
# Every node will provide a number of slots proportional to the
# slots it has assigned.
n
=
(
numslots
.
to_f
/
4096
*
s
.
slots
.
length
)
n
=
(
numslots
.
to_f
/
source_tot_slots
*
s
.
slots
.
length
)
if
i
==
0
n
=
n
.
ceil
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment