bigrecord-driver 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/bin/cassandra-driver +5 -0
- data/bin/hbase-driver +5 -0
- data/bin/launcher +155 -0
- data/conf/log4j.properties +48 -0
- data/lib/big_record_driver/bigrecord_server.rb +119 -0
- data/lib/big_record_driver/cassandra_driver/server.rb +135 -0
- data/lib/big_record_driver/client.rb +36 -0
- data/lib/big_record_driver/column_descriptor.rb +23 -0
- data/lib/big_record_driver/driver_manager.rb +34 -0
- data/lib/big_record_driver/exceptions.rb +12 -0
- data/lib/big_record_driver/hbase_driver/server.rb +396 -0
- data/lib/big_record_driver.rb +6 -0
- data/lib/bigrecord_driver.rb +1 -0
- data/test/abstract_test_client.rb +316 -0
- data/test/test_client_cassandra.rb +63 -0
- data/test/test_client_hbase.rb +26 -0
- data/test/test_driver_manager.rb +46 -0
- data/vendor/java/cassandra/cassandra-0.3.0-dev.jar +0 -0
- data/vendor/java/cassandra/libthrift.jar +0 -0
- data/vendor/java/cassandra/log4j-1.2.15.jar +0 -0
- data/vendor/java/hbase/commons-logging-1.0.4.jar +0 -0
- data/vendor/java/hbase/commons-logging-api-1.0.4.jar +0 -0
- data/vendor/java/hbase/hadoop-0.20.0-core.jar +0 -0
- data/vendor/java/hbase/hbase-0.20.0.jar +0 -0
- data/vendor/java/hbase/log4j-1.2.13.jar +0 -0
- data/vendor/java/hbase/zookeeper-r785019-hbase-1329.jar +0 -0
- metadata +83 -0
@@ -0,0 +1,316 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'big_record_driver'
|
5
|
+
|
6
|
+
module AbstractTestClient #< Test::Unit::TestCase
|
7
|
+
|
8
|
+
TABLE_NAME = :animals
|
9
|
+
|
10
|
+
def test_update_without_timestamps
|
11
|
+
ret = @big_db.update(TABLE_NAME,
|
12
|
+
'dog-key',
|
13
|
+
{'columnfamily1:name' => 'Dog',
|
14
|
+
'columnfamily1:size' => 'medium',
|
15
|
+
'columnfamily2:toto' => 'some value'})
|
16
|
+
|
17
|
+
assert_not_nil ret, "The row was not inserted properly"
|
18
|
+
assert_equal 'Dog', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:name'), "A saved cell couldn't be retrieved"
|
19
|
+
assert_equal 'medium', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size'), "A saved cell couldn't be retrieved"
|
20
|
+
assert_equal 'some value', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily2:toto'), "A saved cell couldn't be retrieved"
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_update_with_timestamps_in_chronological_order
|
24
|
+
t1 = Time.now.to_i
|
25
|
+
t2 = t1 + 1000
|
26
|
+
t3 = t2 + 1000
|
27
|
+
|
28
|
+
ret1 = @big_db.update(TABLE_NAME,
|
29
|
+
'dog-key',
|
30
|
+
{'columnfamily1:name' => 'Dog',
|
31
|
+
'columnfamily1:size' => 'medium',
|
32
|
+
'columnfamily2:toto' => 'some value1'},
|
33
|
+
t1)
|
34
|
+
|
35
|
+
ret2 = @big_db.update(TABLE_NAME,
|
36
|
+
'dog-key',
|
37
|
+
{'columnfamily1:size' => 'small',
|
38
|
+
'columnfamily2:toto' => 'some value2'},
|
39
|
+
t2)
|
40
|
+
|
41
|
+
ret3 = @big_db.update(TABLE_NAME,
|
42
|
+
'dog-key',
|
43
|
+
{'columnfamily1:size' => 'big'},
|
44
|
+
t3)
|
45
|
+
|
46
|
+
assert_not_nil ret1, "A row was not inserted properly"
|
47
|
+
assert_not_nil ret2, "A row was not inserted properly"
|
48
|
+
assert_not_nil ret3, "A row was not inserted properly"
|
49
|
+
|
50
|
+
assert_equal 'Dog', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:name'), "A saved cell couldn't be retrieved"
|
51
|
+
assert_equal 'big', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size'), "A saved cell couldn't be retrieved"
|
52
|
+
assert_equal 'some value2', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily2:toto'), "A saved cell couldn't be retrieved"
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_update_with_timestamps_in_reverse_chronological_order
|
56
|
+
t1 = Time.now.to_i
|
57
|
+
t2 = t1 - 1000
|
58
|
+
t3 = t2 - 1000
|
59
|
+
|
60
|
+
ret1 = @big_db.update(TABLE_NAME,
|
61
|
+
'dog-key',
|
62
|
+
{'columnfamily1:name' => 'Dog',
|
63
|
+
'columnfamily1:size' => 'medium',
|
64
|
+
'columnfamily2:toto' => 'some value1'},
|
65
|
+
t1)
|
66
|
+
|
67
|
+
ret2 = @big_db.update(TABLE_NAME,
|
68
|
+
'dog-key',
|
69
|
+
{'columnfamily1:size' => 'small',
|
70
|
+
'columnfamily2:toto' => 'some value2'},
|
71
|
+
t2)
|
72
|
+
|
73
|
+
ret3 = @big_db.update(TABLE_NAME,
|
74
|
+
'dog-key',
|
75
|
+
{'columnfamily1:size' => 'big'},
|
76
|
+
t3)
|
77
|
+
|
78
|
+
assert_not_nil ret1, "A row was not inserted properly"
|
79
|
+
assert_not_nil ret2, "A row was not inserted properly"
|
80
|
+
assert_not_nil ret3, "A row was not inserted properly"
|
81
|
+
|
82
|
+
assert_equal 'Dog', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:name'), "A saved cell couldn't be retrieved"
|
83
|
+
assert_equal 'medium', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size'), "A saved cell couldn't be retrieved"
|
84
|
+
assert_equal 'some value1', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily2:toto'), "A saved cell couldn't be retrieved"
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_get_and_get_columns
|
88
|
+
t1 = Time.now.to_i
|
89
|
+
t2 = t1 + 1000
|
90
|
+
t3 = t2 + 1000
|
91
|
+
|
92
|
+
@big_db.update(TABLE_NAME,
|
93
|
+
'dog-key',
|
94
|
+
{'columnfamily1:name' => 'Dog',
|
95
|
+
'columnfamily1:size' => 'medium',
|
96
|
+
'columnfamily2:toto' => 'some value1'},
|
97
|
+
t1)
|
98
|
+
|
99
|
+
@big_db.update(TABLE_NAME,
|
100
|
+
'dog-key',
|
101
|
+
{'columnfamily1:size' => 'small',
|
102
|
+
'columnfamily2:toto' => 'some value2'},
|
103
|
+
t2)
|
104
|
+
|
105
|
+
@big_db.update(TABLE_NAME,
|
106
|
+
'dog-key',
|
107
|
+
{'columnfamily1:size' => 'big'},
|
108
|
+
t3)
|
109
|
+
|
110
|
+
# normal calls
|
111
|
+
assert_equal 'big', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size'), "Didn't retrieved the last version of the cell"
|
112
|
+
assert_nil @big_db.get(TABLE_NAME, 'dog-key-that-does-not-exist', 'columnfamily1:size'), "Got a value for a cell that doesn't even exist"
|
113
|
+
|
114
|
+
# timestamps
|
115
|
+
assert_equal 'medium', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t1), "Didn't retrieved the requested version of the cell"
|
116
|
+
assert_equal 'small', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t2), "Didn't retrieved the requested version of the cell"
|
117
|
+
assert_equal 'small', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t2+500), "Didn't retrieved the requested version of the cell"
|
118
|
+
assert_equal 'big', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t3), "Didn't retrieved the requested version of the cell"
|
119
|
+
assert_equal 'big', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t3+1000), "Didn't retrieved the last version of the cell"
|
120
|
+
assert_nil @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :timestamp => t1-1000), "Got a value for a cell that was not even existing at that time"
|
121
|
+
|
122
|
+
# num_versions
|
123
|
+
assert_raises ArgumentError, "Specifying a number of version = 0 should be forbidden" do
|
124
|
+
@big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 0)
|
125
|
+
end
|
126
|
+
assert_raises ArgumentError, "Specifying a number of version < 0 should be forbidden" do
|
127
|
+
@big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => -10)
|
128
|
+
end
|
129
|
+
assert_instance_of String, @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 1)
|
130
|
+
assert_instance_of Array, @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 2)
|
131
|
+
assert_equal 2, @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 2).size
|
132
|
+
assert_equal 3, @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 3).size
|
133
|
+
assert_equal 3, @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10).size
|
134
|
+
assert_equal ['big', 'small', 'medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10)
|
135
|
+
|
136
|
+
# timestamps + num_versions
|
137
|
+
assert_equal ['big', 'small', 'medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t3+1000)
|
138
|
+
assert_equal ['big', 'small', 'medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t3)
|
139
|
+
assert_equal ['small', 'medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t2+500)
|
140
|
+
assert_equal ['small', 'medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t2)
|
141
|
+
assert_equal ['medium'], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t1)
|
142
|
+
assert_equal [], @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 10, :timestamp => t1-1000)
|
143
|
+
assert_equal 'small', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 1, :timestamp => t2+500)
|
144
|
+
assert_nil @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size', :num_versions => 1, :timestamp => t1-500)
|
145
|
+
|
146
|
+
|
147
|
+
###################### GET COLUMNS ######################
|
148
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'big', 'columnfamily2:toto' => 'some value2'}
|
149
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:name', 'columnfamily1:size', 'columnfamily2:toto']), "Didn't retrieved the expected data"
|
150
|
+
|
151
|
+
expected = {'id' => 'dog-key', 'columnfamily2:toto' => 'some value2'}
|
152
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily2:toto']), "Didn't retrieved the expected data"
|
153
|
+
|
154
|
+
assert_nil @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily2:toto that does not exists']), "Didn't retrieved the expected data"
|
155
|
+
|
156
|
+
assert_nil @big_db.get_columns(TABLE_NAME, 'dog-key-akdfjlka', ['columnfamily2:toto']), "Retrieved values for a row that doesn't even exist"
|
157
|
+
|
158
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'big', 'columnfamily2:toto' => 'some value2'}
|
159
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:', 'columnfamily2:']), "Didn't retrieved the expected data"
|
160
|
+
|
161
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'big', 'columnfamily2:toto' => 'some value2'}
|
162
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:', 'columnfamily2:']), "Didn't retrieved the expected data"
|
163
|
+
|
164
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily2:toto' => 'some value2'}
|
165
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:name', 'columnfamily2:']), "Didn't retrieved the expected data"
|
166
|
+
|
167
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'big'}
|
168
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:']), "Didn't retrieved the expected data"
|
169
|
+
|
170
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'small'}
|
171
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:'], :timestamp => t2), "Didn't retrieved the expected data"
|
172
|
+
|
173
|
+
assert_nil @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:'], :timestamp => t1-500), "Didn't retrieved the expected data"
|
174
|
+
|
175
|
+
expected = {'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'big'}
|
176
|
+
assert_equal expected, @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:'], :timestamp => t3+500), "Didn't retrieved the expected data"
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_get_consecutive_rows
|
180
|
+
@big_db.update(TABLE_NAME,
|
181
|
+
'dog-key',
|
182
|
+
{'columnfamily1:name' => 'Dog',
|
183
|
+
'columnfamily1:size' => 'medium',
|
184
|
+
'columnfamily2:description' => 'lives on earth',
|
185
|
+
'columnfamily2:$pt-707' => '343220'})
|
186
|
+
@big_db.update(TABLE_NAME,
|
187
|
+
'fish-key',
|
188
|
+
{'columnfamily1:name' => 'Fish',
|
189
|
+
'columnfamily1:size' => 'varies but usually small',
|
190
|
+
'columnfamily2:description' => 'must stay in water'})
|
191
|
+
@big_db.update(TABLE_NAME,
|
192
|
+
'mouse-key',
|
193
|
+
{'columnfamily1:name' => 'Mouse',
|
194
|
+
'columnfamily1:size' => 'small',
|
195
|
+
'columnfamily2:description' => 'cats love them'})
|
196
|
+
@big_db.update(TABLE_NAME,
|
197
|
+
'cat-key',
|
198
|
+
{'columnfamily1:name' => 'Cat',
|
199
|
+
'columnfamily1:size' => 'small but bigger than a mouse and smaller than a dog',
|
200
|
+
'columnfamily2:description' => 'likes mice'})
|
201
|
+
|
202
|
+
# find(:all)
|
203
|
+
expected = [{'id' => 'cat-key', 'columnfamily1:name' => 'Cat', 'columnfamily1:size' => 'small but bigger than a mouse and smaller than a dog', 'columnfamily2:description' => 'likes mice'},
|
204
|
+
{'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'medium', 'columnfamily2:description' => 'lives on earth', 'columnfamily2:$pt-707' => '343220'},
|
205
|
+
{'id' => 'fish-key', 'columnfamily1:name' => 'Fish', 'columnfamily1:size' => 'varies but usually small', 'columnfamily2:description' => 'must stay in water'},
|
206
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse', 'columnfamily1:size' => 'small', 'columnfamily2:description' => 'cats love them'}]
|
207
|
+
|
208
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, nil, ['columnfamily1:', 'columnfamily2:']), "Didn't retrieved the expected data"
|
209
|
+
|
210
|
+
# find(:all, :condition => ...)
|
211
|
+
expected = [{'id' => 'cat-key', 'columnfamily1:name' => 'Cat', 'columnfamily2:description' => 'likes mice'},
|
212
|
+
{'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily2:description' => 'lives on earth', 'columnfamily2:$pt-707' => '343220'},
|
213
|
+
{'id' => 'fish-key', 'columnfamily1:name' => 'Fish', 'columnfamily2:description' => 'must stay in water'},
|
214
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse', 'columnfamily2:description' => 'cats love them'}]
|
215
|
+
|
216
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, nil, ['columnfamily1:name', 'columnfamily2:']), "Didn't retrieved the expected data"
|
217
|
+
|
218
|
+
# find(:all, :offset => before_first_row)
|
219
|
+
expected = [{'id' => 'cat-key', 'columnfamily1:name' => 'Cat'},
|
220
|
+
{'id' => 'dog-key', 'columnfamily1:name' => 'Dog'},
|
221
|
+
{'id' => 'fish-key', 'columnfamily1:name' => 'Fish'},
|
222
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse'}]
|
223
|
+
|
224
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, 'aaa-key', nil, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
225
|
+
|
226
|
+
# find(:all, :offset => n_row)
|
227
|
+
expected = [{'id' => 'fish-key', 'columnfamily1:name' => 'Fish'},
|
228
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse'}]
|
229
|
+
|
230
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, 'fish-key', nil, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
231
|
+
|
232
|
+
# find(:all, :limit > highest key)
|
233
|
+
expected = [{'id' => 'cat-key', 'columnfamily1:name' => 'Cat'},
|
234
|
+
{'id' => 'dog-key', 'columnfamily1:name' => 'Dog'},
|
235
|
+
{'id' => 'fish-key', 'columnfamily1:name' => 'Fish'},
|
236
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse'}]
|
237
|
+
|
238
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, 1000, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
239
|
+
|
240
|
+
# find(:all, :limit => x)
|
241
|
+
expected = [{'id' => 'cat-key', 'columnfamily1:name' => 'Cat'},
|
242
|
+
{'id' => 'dog-key', 'columnfamily1:name' => 'Dog'}]
|
243
|
+
|
244
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, 2, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
245
|
+
|
246
|
+
# find(:all, :offset => n_row, :limit => x)
|
247
|
+
expected = [{'id' => 'fish-key', 'columnfamily1:name' => 'Fish'},
|
248
|
+
{'id' => 'mouse-key', 'columnfamily1:name' => 'Mouse'}]
|
249
|
+
|
250
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, 'fish-key', 2, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
251
|
+
|
252
|
+
# find(:all, :offset => n_row, :limit => 1)
|
253
|
+
expected = [{'id' => 'fish-key', 'columnfamily1:name' => 'Fish'}]
|
254
|
+
|
255
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, 'fish-key', 1, ['columnfamily1:name']), "Didn't retrieved the expected data"
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_delete
|
259
|
+
@big_db.update(TABLE_NAME,
|
260
|
+
'dog-key',
|
261
|
+
{'columnfamily1:name' => 'Dog',
|
262
|
+
'columnfamily1:size' => 'medium',
|
263
|
+
'columnfamily2:description' => 'lives on earth'})
|
264
|
+
@big_db.update(TABLE_NAME,
|
265
|
+
'fish-key',
|
266
|
+
{'columnfamily1:name' => 'Fish',
|
267
|
+
'columnfamily1:size' => 'varies but usually small',
|
268
|
+
'columnfamily2:description' => 'must stay in water'})
|
269
|
+
|
270
|
+
# make sure the cells are there
|
271
|
+
expected = [{'id' => 'dog-key', 'columnfamily1:name' => 'Dog', 'columnfamily1:size' => 'medium', 'columnfamily2:description' => 'lives on earth'},
|
272
|
+
{'id' => 'fish-key', 'columnfamily1:name' => 'Fish', 'columnfamily1:size' => 'varies but usually small', 'columnfamily2:description' => 'must stay in water'}]
|
273
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, nil, ['columnfamily1:', 'columnfamily2:']), "The test data was not inserted properly"
|
274
|
+
|
275
|
+
# actual test
|
276
|
+
@big_db.delete(TABLE_NAME, 'dog-key')
|
277
|
+
|
278
|
+
expected = [{'id' => 'fish-key', 'columnfamily1:name' => 'Fish', 'columnfamily1:size' => 'varies but usually small', 'columnfamily2:description' => 'must stay in water'}]
|
279
|
+
assert_equal expected, @big_db.get_consecutive_rows(TABLE_NAME, nil, nil, ['columnfamily1:', 'columnfamily2:']), "The deleted data was found by a scanner"
|
280
|
+
|
281
|
+
assert_nil @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:name'), "The deleted data was found by a get()"
|
282
|
+
|
283
|
+
assert_nil @big_db.get_columns(TABLE_NAME, 'dog-key', ['columnfamily1:']), "The deleted data was found by a get_columns()"
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_ping
|
287
|
+
db = nil
|
288
|
+
assert_nothing_raised("Couldn't initialize the client") do
|
289
|
+
db = BigRecordDriver::Client.new(:drb_port => 40005)
|
290
|
+
end
|
291
|
+
assert_not_nil db, "Couldn't initialize the client"
|
292
|
+
assert db.ping, "The client was initialized but we cannot communicate with the db itself"
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_table_exists
|
296
|
+
assert @big_db.table_exists?(TABLE_NAME)
|
297
|
+
assert !@big_db.table_exists?(:some_non_existent_table)
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_table_names
|
301
|
+
assert @big_db.table_names.include?(TABLE_NAME.to_s)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_method_missing
|
305
|
+
assert_raises NoMethodError do
|
306
|
+
@big_db.akdfjlajfl
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_invalid_column_family
|
311
|
+
assert_raises BigRecordDriver::JavaError do
|
312
|
+
@big_db.get(TABLE_NAME, 'dog-key', 'nonexistentcolumnfamily:name')
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/abstract_test_client'
|
2
|
+
|
3
|
+
class TestCassandraClient < Test::Unit::TestCase
|
4
|
+
include AbstractTestClient
|
5
|
+
|
6
|
+
def setup
|
7
|
+
unless @big_db
|
8
|
+
BigRecordDriver::DriverManager.set_cmd('cassandra')
|
9
|
+
unless BigRecordDriver::DriverManager.running?(40005)
|
10
|
+
BigRecordDriver::DriverManager.restart(40005)
|
11
|
+
end
|
12
|
+
#TODO: don't use hard coded values for the config
|
13
|
+
@big_db = BigRecordDriver::Client.new(:drb_port => 40005)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_update_without_timestamps
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_update_with_timestamps_in_chronological_order
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_update_with_timestamps_in_reverse_chronological_order
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_and_get_columns
|
28
|
+
t1 = Time.now.to_i
|
29
|
+
t2 = t1 + 1000
|
30
|
+
t3 = t2 + 1000
|
31
|
+
# Temporary copy-paste until all tests passes
|
32
|
+
@big_db.update(TABLE_NAME,
|
33
|
+
'dog-key',
|
34
|
+
{'columnfamily1:name' => 'Dog',
|
35
|
+
'columnfamily1:size' => 'medium',
|
36
|
+
'columnfamily2:toto' => 'some value1'},
|
37
|
+
t1)
|
38
|
+
|
39
|
+
@big_db.update(TABLE_NAME,
|
40
|
+
'dog-key',
|
41
|
+
{'columnfamily1:size' => 'small',
|
42
|
+
'columnfamily2:toto' => 'some value2'},
|
43
|
+
t2)
|
44
|
+
|
45
|
+
@big_db.update(TABLE_NAME,
|
46
|
+
'dog-key',
|
47
|
+
{'columnfamily1:size' => 'big'},
|
48
|
+
t3)
|
49
|
+
|
50
|
+
# normal calls
|
51
|
+
assert_equal 'big', @big_db.get(TABLE_NAME, 'dog-key', 'columnfamily1:size'), "Didn't retrieved the last version of the cell"
|
52
|
+
assert_nil @big_db.get(TABLE_NAME, 'dog-key-that-does-not-exist', 'columnfamily1:size'), "Got a value for a cell that doesn't even exist"
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_consecutive_rows
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_delete
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_invalid_column_family
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/abstract_test_client'
|
2
|
+
|
3
|
+
class TestHbaseClient < Test::Unit::TestCase #TestClient
|
4
|
+
include AbstractTestClient
|
5
|
+
# Prepare the connection and the test tables.
|
6
|
+
def setup
|
7
|
+
unless @big_db
|
8
|
+
unless BigRecordDriver::DriverManager.running?(40005)
|
9
|
+
BigRecordDriver::DriverManager.restart(40005)
|
10
|
+
end
|
11
|
+
|
12
|
+
#TODO: don't use hard coded values for the config
|
13
|
+
@big_db = BigRecordDriver::Client.new(:zookeeper_quorum=> 'localhost', :zookeeper_client_port => '2181',:drb_port => 40005)
|
14
|
+
end
|
15
|
+
|
16
|
+
@big_db.drop_table(TABLE_NAME) if @big_db.table_exists?(TABLE_NAME)
|
17
|
+
|
18
|
+
# Create the test table
|
19
|
+
# unless @big_db.table_exists?(TABLE_NAME)
|
20
|
+
columns_descriptors = []
|
21
|
+
columns_descriptors << BigRecordDriver::ColumnDescriptor.new(:columnfamily1)
|
22
|
+
columns_descriptors << BigRecordDriver::ColumnDescriptor.new(:columnfamily2)
|
23
|
+
@big_db.create_table(TABLE_NAME, columns_descriptors)
|
24
|
+
# end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'big_record_driver'
|
5
|
+
|
6
|
+
class TestDriverManager < Test::Unit::TestCase
|
7
|
+
|
8
|
+
# everything is in a sequence and therefore there's only 1 test
|
9
|
+
def test_all
|
10
|
+
port = 40000
|
11
|
+
|
12
|
+
# stop the driver if it's already running
|
13
|
+
assert_nothing_raised do
|
14
|
+
BigRecordDriver::DriverManager.stop(port) if BigRecordDriver::DriverManager.running?(port)
|
15
|
+
end
|
16
|
+
assert !BigRecordDriver::DriverManager.running?(port), "The driver is already running and it couldn't be stopped"
|
17
|
+
|
18
|
+
# start the real tests
|
19
|
+
assert_nothing_raised do
|
20
|
+
BigRecordDriver::DriverManager.start(port)
|
21
|
+
end
|
22
|
+
assert BigRecordDriver::DriverManager.running?(port), "The driver couldn't be started"
|
23
|
+
|
24
|
+
assert_nothing_raised do
|
25
|
+
BigRecordDriver::DriverManager.restart(port)
|
26
|
+
end
|
27
|
+
assert BigRecordDriver::DriverManager.running?(port), "The driver couldn't be restarted"
|
28
|
+
|
29
|
+
assert_nothing_raised("The driver should be able to do a silent start when it's already running") do
|
30
|
+
BigRecordDriver::DriverManager.silent_start(port)
|
31
|
+
end
|
32
|
+
assert BigRecordDriver::DriverManager.running?(port), "The driver stopped during a silent start instead of staying alive"
|
33
|
+
|
34
|
+
assert_nothing_raised do
|
35
|
+
BigRecordDriver::DriverManager.stop(port)
|
36
|
+
end
|
37
|
+
assert !BigRecordDriver::DriverManager.running?(port), "The driver couldn't be stopped"
|
38
|
+
|
39
|
+
assert_nothing_raised("The driver should be able to do a silent start when it's not running") do
|
40
|
+
BigRecordDriver::DriverManager.silent_start(port)
|
41
|
+
end
|
42
|
+
assert BigRecordDriver::DriverManager.running?(port), "The driver couldn't be started silently"
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bigrecord-driver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- openplaces.org
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-12 00:00:00 -04:00
|
13
|
+
default_executable: hbase-driver
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Bigrecord drivers that use JRuby DRb servers to connect with databases through their native Java APIs. Currently supported databases are HBase and Cassandra.
|
17
|
+
email: bigrecord@openplaces.org
|
18
|
+
executables:
|
19
|
+
- hbase-driver
|
20
|
+
- cassandra-driver
|
21
|
+
- launcher
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files:
|
25
|
+
- README
|
26
|
+
files:
|
27
|
+
- bin/cassandra-driver
|
28
|
+
- bin/hbase-driver
|
29
|
+
- bin/launcher
|
30
|
+
- conf/log4j.properties
|
31
|
+
- lib/big_record_driver.rb
|
32
|
+
- lib/big_record_driver/bigrecord_server.rb
|
33
|
+
- lib/big_record_driver/cassandra_driver/server.rb
|
34
|
+
- lib/big_record_driver/client.rb
|
35
|
+
- lib/big_record_driver/column_descriptor.rb
|
36
|
+
- lib/big_record_driver/driver_manager.rb
|
37
|
+
- lib/big_record_driver/exceptions.rb
|
38
|
+
- lib/big_record_driver/hbase_driver/server.rb
|
39
|
+
- lib/bigrecord_driver.rb
|
40
|
+
- test/abstract_test_client.rb
|
41
|
+
- test/test_client_cassandra.rb
|
42
|
+
- test/test_client_hbase.rb
|
43
|
+
- test/test_driver_manager.rb
|
44
|
+
- vendor/java/cassandra/cassandra-0.3.0-dev.jar
|
45
|
+
- vendor/java/cassandra/libthrift.jar
|
46
|
+
- vendor/java/cassandra/log4j-1.2.15.jar
|
47
|
+
- vendor/java/hbase/commons-logging-1.0.4.jar
|
48
|
+
- vendor/java/hbase/commons-logging-api-1.0.4.jar
|
49
|
+
- vendor/java/hbase/hadoop-0.20.0-core.jar
|
50
|
+
- vendor/java/hbase/hbase-0.20.0.jar
|
51
|
+
- vendor/java/hbase/log4j-1.2.13.jar
|
52
|
+
- vendor/java/hbase/zookeeper-r785019-hbase-1329.jar
|
53
|
+
- README
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://www.bigrecord.org
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Bigrecord drivers implemented as JRuby DRb servers
|
82
|
+
test_files: []
|
83
|
+
|