redis_ring_client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -42,17 +42,26 @@ module RedisRing
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def get_shards_json_string(retries = 0)
|
45
|
-
@zookeeper ||=
|
45
|
+
@zookeeper ||= self.class.zookeeper(zookeeper_addr)
|
46
46
|
@watcher = Zookeeper::WatcherCallback.new
|
47
47
|
resp = @zookeeper.get(:path => "/cluster_status", :watcher => @watcher, :watcher_context => "/cluster_status")
|
48
48
|
return resp[:data]
|
49
49
|
rescue ZookeeperExceptions::ZookeeperException::ConnectionClosed
|
50
50
|
raise if retries == 4
|
51
|
-
puts "reopening"
|
52
51
|
@zookeeper.reopen
|
53
52
|
return get_shards_json_string(retries + 1)
|
54
53
|
end
|
55
54
|
|
55
|
+
def self.zookeepers
|
56
|
+
@zookeepers ||= {}
|
57
|
+
end
|
58
|
+
|
59
|
+
# it appears that only a very limited number of zookeeper connections can be opened by a single client
|
60
|
+
# so we have to cache/share them between RingMetaData instances
|
61
|
+
def self.zookeeper(address)
|
62
|
+
self.zookeepers[address] ||= Zookeeper.new(address)
|
63
|
+
end
|
64
|
+
|
56
65
|
end
|
57
66
|
|
58
67
|
class ShardMetaData
|
@@ -36,11 +36,8 @@ describe RedisRing::Client::RingProxy do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context "with real RedisRing" do
|
39
|
-
before(:all) do
|
40
|
-
@proxy = RedisRing::Client::RingProxy.new
|
41
|
-
end
|
42
|
-
|
43
39
|
before(:each) do
|
40
|
+
@proxy = RedisRing::Client::RingProxy.new
|
44
41
|
@proxy.flushdb
|
45
42
|
end
|
46
43
|
|