voldemort-rb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/connection/connection.rb +8 -3
- data/lib/connection/tcp_connection.rb +11 -1
- metadata +3 -3
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rexml/document'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
class Connection
|
4
5
|
include REXML
|
@@ -29,9 +30,13 @@ class Connection
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def bootstrap
|
32
|
-
|
33
|
-
|
34
|
-
self.nodes = self.parse_nodes_from(
|
33
|
+
cluster_response = self.get_from("metadata", "cluster.xml", false)
|
34
|
+
cluster_xml = cluster_response[1][0][1]
|
35
|
+
self.nodes = self.parse_nodes_from(cluster_xml)
|
36
|
+
|
37
|
+
stores_response = self.get_from("metadata", "stores.xml", false)
|
38
|
+
stores_xml = stores_response[1][0][1]
|
39
|
+
|
35
40
|
self.connect_to_random_node
|
36
41
|
rescue StandardError => e
|
37
42
|
raise("There was an error trying to bootstrap from the specified servers: #{e}")
|
@@ -128,7 +128,17 @@ class TCPConnection < Connection
|
|
128
128
|
def receive
|
129
129
|
raw_size = self.socket.recv(4)
|
130
130
|
size = raw_size.unpack('N')
|
131
|
-
|
131
|
+
|
132
|
+
# Read until we get to size
|
133
|
+
read = 0
|
134
|
+
buffer = ""
|
135
|
+
|
136
|
+
while read < size[0] and size[0] > 0
|
137
|
+
data = self.socket.recv(size[0] - read)
|
138
|
+
buffer << data
|
139
|
+
read += data.length
|
140
|
+
end
|
141
|
+
return buffer
|
132
142
|
rescue
|
133
143
|
self.reconnect!
|
134
144
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alejandro Crosa
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|