summaryrefslogtreecommitdiff
path: root/src/redis-trib.rb
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-09-29 12:50:46 +0200
committerantirez <antirez@gmail.com>2011-09-29 12:50:46 +0200
commitf639f99180c304e8eb4f4d063a7aff309b6b1056 (patch)
tree8d5e495df53b2cc1d0add93d17dfd74e60ddb325 /src/redis-trib.rb
parent0cae060a26745e1cb06700f7878ffe647db8ddd4 (diff)
downloadredis-f639f99180c304e8eb4f4d063a7aff309b6b1056.tar.gz
redis-trib cluster check command: check that all the 4096 slots are covered
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-xsrc/redis-trib.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index c8daac376..daa5a78a8 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -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