]> git.saurik.com Git - redis.git/blobdiff - src/redis-trib.rb
If the computer running the Redis test is slow, we revert to --clients 1 to avoid...
[redis.git] / src / redis-trib.rb
index 666399fae43dee8f0a06f052849fab8e26acf0df..1b83e19c2768c20d78f33c4f2d9f31a38f78630f 100755 (executable)
@@ -319,10 +319,11 @@ 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(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.
-            n = (numslots.to_f/4096*s.slots.length)
+            n = (numslots.to_f/source_tot_slots*s.slots.length)
             if i == 0
                 n = n.ceil
             else
@@ -356,7 +357,7 @@ class RedisTrib
             keys = source.r.cluster("getkeysinslot",slot,10)
             break if keys.length == 0
             keys.each{|key|
-                source.r.migrate(target.info[:host],target.info[:port],key,0,1)
+                source.r.migrate(target.info[:host],target.info[:port],key,0,1000)
                 print "." if o[:verbose]
                 STDOUT.flush
             }
@@ -446,6 +447,7 @@ class RedisTrib
             node = ClusterNode.new(n)
             node.connect(:abort => true)
             node.assert_cluster
+            node.load_info
             node.assert_empty
             add_node(node)
         }