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
a81c598f
Commit
a81c598f
authored
Feb 22, 2013
by
antirez
Browse files
redis-trib: handle slot coverage fix in the "no nodes with keys" case.
parent
392e0fa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
a81c598f
...
...
@@ -287,11 +287,23 @@ class RedisTrib
single
=
slots
.
select
{
|
k
,
v
|
v
.
length
==
1
}
multi
=
slots
.
select
{
|
k
,
v
|
v
.
length
>
1
}
# TODO: Handle none and single cases as well.
if
single
.
length
# Handle case "1": keys in no node.
if
none
.
length
>
0
puts
"The folowing uncovered slots have no keys across the cluster:"
puts
none
.
keys
.
join
(
","
)
yes_or_die
"Fix these slots by covering with a random node?"
none
.
each
{
|
slot
,
nodes
|
node
=
@nodes
.
sample
puts
"Covering slot
#{
slot
}
with
#{
node
}
"
node
.
r
.
cluster
(
"addslots"
,
slot
)
}
end
# Handle case "2": keys only in one node.
if
single
.
length
>
0
puts
"The folowing uncovered slots have keys in just one node:"
puts
single
.
keys
.
join
(
","
)
yes_or_die
"Fix th
is
slots by covering with those nodes?"
yes_or_die
"Fix th
ese
slots by covering with those nodes?"
single
.
each
{
|
slot
,
nodes
|
puts
"Covering slot
#{
slot
}
with
#{
nodes
[
0
]
}
"
nodes
[
0
].
r
.
cluster
(
"addslots"
,
slot
)
...
...
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