Skip to content

Instantly share code, notes, and snippets.

@shaliko
Created July 13, 2013 21:01
Show Gist options
  • Save shaliko/5992198 to your computer and use it in GitHub Desktop.
Save shaliko/5992198 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'consistent_hashr'
servers = {:s1 => "s1", :s2 => "s2", :s3 => "s3", :s4 => "s4", :s5 => "s5", :s6 => "s6"}
servers.each do |n, s|
ConsistentHashr.add_server(n,s)
end
keys = []
1000.times do |idx|
keys << rand(100000).to_s
end
before = keys.map() { |k| ConsistentHashr.get(k)}
ConsistentHashr.add_server(:s7, "s7")
after = keys.map() { |k| ConsistentHashr.get(k)}
diff = before.zip(after).find_all {|a| a[0] == a[1] }.size
puts diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment