]> git.saurik.com Git - redis.git/commitdiff
assert_empty in redis-trib
authorSalvatore Sanfilippo <antirez@gmail.com>
Mon, 11 Apr 2011 16:26:00 +0000 (18:26 +0200)
committerSalvatore Sanfilippo <antirez@gmail.com>
Mon, 11 Apr 2011 16:26:00 +0000 (18:26 +0200)
src/redis-trib.rb

index 8456ed29f884e988ada61982a7f723799b83ef67..98ed0a0e1777379515079d9915b2496919cce529 100755 (executable)
@@ -43,6 +43,14 @@ class ClusterNode
         end
     end
 
+    def assert_empty
+        if !(@r.cluster("info").split("\r\n").index("cluster_known_nodes:1")) ||
+            (@r.info['db0'])
+            puts "Error: Node #{self} is not empty. Either the node already knows other nodes (check with nodes-info) or contains some key in database 0."
+            exit 1
+        end
+    end
+
     def r
         @r
     end
@@ -63,7 +71,7 @@ class RedisTrib
             node = ClusterNode.new(n)
             node.connect
             node.assert_cluster
-            node.assert_empty
+            node.assert_empty
         }
     end
 end