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
7b81e5a1
Commit
7b81e5a1
authored
Nov 15, 2011
by
Salvatore Sanfilippo
Browse files
Merge pull request #181 from redsquirrel/unstable
Fixing inject: it was failing when there was 1 or >2 sources
parents
3c5680ed
57f8021c
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
7b81e5a1
...
...
@@ -319,7 +319,7 @@ 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
}
source_tot_slots
=
sources
.
inject
(
0
)
{
|
sum
,
source
|
sum
+
source
.
slots
.
length
}
sources
.
each_with_index
{
|
s
,
i
|
# Every node will provide a number of slots proportional to the
# slots it has assigned.
...
...
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