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
f639f991
Commit
f639f991
authored
Sep 29, 2011
by
antirez
Browse files
redis-trib cluster check command: check that all the 4096 slots are covered
parent
0cae060a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
f639f991
...
...
@@ -26,6 +26,14 @@ class ClusterNode
@friends
=
[]
end
def
friends
@friends
end
def
slots
@slots
end
def
to_s
"
#{
@host
}
:
#{
@port
}
"
end
...
...
@@ -187,6 +195,16 @@ class RedisTrib
def
check_cluster
puts
"Performing Cluster Check (using node
#{
@nodes
[
0
]
}
)"
show_nodes
# Check if all the slots are covered
slots
=
{}
@nodes
.
each
{
|
n
|
slots
=
slots
.
merge
(
n
.
slots
)
}
if
slots
.
length
==
4096
puts
"[OK] All 4096 slots covered."
else
puts
"[ERR] Not all 4096 slots are covered by nodes."
end
end
def
alloc_slots
...
...
@@ -241,8 +259,14 @@ class RedisTrib
node
=
ClusterNode
.
new
(
ARGV
[
1
])
node
.
connect
(
:abort
=>
true
)
node
.
assert_cluster
node
.
load_info
node
.
load_info
(
:getfriends
=>
true
)
add_node
(
node
)
node
.
friends
.
each
{
|
f
|
fnode
=
ClusterNode
.
new
(
f
[
:addr
])
fnode
.
connect
()
fnode
.
load_info
()
add_node
(
fnode
)
}
check_cluster
end
...
...
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