roma 0.8.2 → 0.8.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANG +326 -0
- data/CHANGELOG +132 -0
- data/{README.rdoc → FETCH_HEAD} +0 -0
- data/{LICENSE.rdoc → LICENSE} +0 -1
- data/README +17 -0
- data/Rakefile +33 -18
- data/ruby/server/bin/chg_redundancy +10 -0
- data/ruby/server/bin/key_access +7 -0
- data/ruby/server/bin/key_list +7 -0
- data/ruby/server/bin/mkconfig +19 -0
- data/{bin → ruby/server/bin}/mkrecent +0 -1
- data/{bin → ruby/server/bin}/mkroute +0 -1
- data/ruby/server/bin/multi_commander +19 -0
- data/ruby/server/bin/recoverlost +10 -0
- data/ruby/server/bin/recoverlost_alist +10 -0
- data/ruby/server/bin/recoverlost_alist_all +10 -0
- data/ruby/server/bin/recoverlost_alist_keys +10 -0
- data/{bin/recoverlost → ruby/server/bin/roma_watcher} +1 -2
- data/ruby/server/bin/romad +36 -0
- data/{bin → ruby/server/bin}/sample_watcher +0 -1
- data/{bin → ruby/server/bin}/sample_watcher2 +0 -1
- data/{bin/simple_bench → ruby/server/bin/sample_watcher3} +1 -2
- data/ruby/server/bin/simple_bench +26 -0
- data/{bin → ruby/server/bin}/ssroute +0 -1
- data/ruby/server/bin/test-scenario +11 -0
- data/{bin → ruby/server/bin}/tribunus +0 -1
- data/{lib → ruby/server/lib}/roma/async_process.rb +67 -15
- data/{lib → ruby/server/lib}/roma/command/bg_command_receiver.rb +1 -1
- data/ruby/server/lib/roma/command/command_definition.rb +422 -0
- data/ruby/server/lib/roma/command/mh_command_receiver.rb +127 -0
- data/ruby/server/lib/roma/command/receiver.rb +64 -0
- data/{lib → ruby/server/lib}/roma/command/rt_command_receiver.rb +6 -1
- data/ruby/server/lib/roma/command/sys_command_receiver.rb +609 -0
- data/{lib → ruby/server/lib}/roma/command/util_command_receiver.rb +15 -5
- data/{lib → ruby/server/lib}/roma/command/vn_command_receiver.rb +12 -4
- data/{lib → ruby/server/lib}/roma/command_plugin.rb +0 -0
- data/ruby/server/lib/roma/config.rb +84 -0
- data/{lib → ruby/server/lib}/roma/event/con_pool.rb +12 -1
- data/ruby/server/lib/roma/event/handler.rb +256 -0
- data/ruby/server/lib/roma/live_patch-20120302-001.rb +107 -0
- data/ruby/server/lib/roma/logging/rlogger.rb +163 -0
- data/ruby/server/lib/roma/messaging/con_pool.rb +92 -0
- data/{lib → ruby/server/lib}/roma/plugin/plugin_alist.rb +118 -240
- data/ruby/server/lib/roma/plugin/plugin_debug.rb +31 -0
- data/ruby/server/lib/roma/plugin/plugin_map.rb +177 -0
- data/ruby/server/lib/roma/plugin/plugin_mapcount.rb +185 -0
- data/{lib/roma/command/st_command_receiver.rb → ruby/server/lib/roma/plugin/plugin_storage.rb} +170 -146
- data/ruby/server/lib/roma/plugin/plugin_stub.rb +283 -0
- data/{lib → ruby/server/lib}/roma/plugin/plugin_test.rb +0 -0
- data/{lib → ruby/server/lib}/roma/romad.rb +221 -94
- data/{lib → ruby/server/lib}/roma/routing/cb_rttable.rb +4 -6
- data/{lib → ruby/server/lib}/roma/routing/merkle_tree.rb +0 -0
- data/ruby/server/lib/roma/routing/routing_data.rb +307 -0
- data/{lib → ruby/server/lib}/roma/routing/rttable.rb +4 -0
- data/{lib → ruby/server/lib}/roma/stats.rb +19 -3
- data/{lib → ruby/server/lib}/roma/storage/basic_storage.rb +25 -26
- data/{lib → ruby/server/lib}/roma/storage/dbm_storage.rb +1 -23
- data/{lib → ruby/server/lib}/roma/storage/dummy_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/rh_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/sqlite3_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/tc_storage.rb +62 -2
- data/ruby/server/lib/roma/tools/chg_redundancy.rb +36 -0
- data/ruby/server/lib/roma/tools/key_access.rb +105 -0
- data/ruby/server/lib/roma/tools/key_list.rb +94 -0
- data/ruby/server/lib/roma/tools/mkconfig.rb +535 -0
- data/{lib → ruby/server/lib}/roma/tools/mkrecent.rb +0 -0
- data/{lib → ruby/server/lib}/roma/tools/mkroute.rb +0 -0
- data/ruby/server/lib/roma/tools/multi_commander.rb +45 -0
- data/{lib → ruby/server/lib}/roma/tools/recoverlost.rb +0 -0
- data/{lib → ruby/server/lib}/roma/tools/recoverlost_alist.rb +0 -0
- data/ruby/server/lib/roma/tools/recoverlost_alist_all.rb +8 -0
- data/ruby/server/lib/roma/tools/recoverlost_alist_keys.rb +16 -0
- data/ruby/server/lib/roma/tools/recoverlost_lib.rb +349 -0
- data/ruby/server/lib/roma/tools/roma_watcher.rb +150 -0
- data/ruby/server/lib/roma/tools/roma_watcher_config.yml.example +20 -0
- data/{lib → ruby/server/lib}/roma/tools/sample_watcher.rb +3 -1
- data/{lib → ruby/server/lib}/roma/tools/sample_watcher2.rb +3 -1
- data/ruby/server/lib/roma/tools/sample_watcher3.rb +49 -0
- data/{lib → ruby/server/lib}/roma/tools/simple_bench.rb +2 -0
- data/ruby/server/lib/roma/tools/simple_bench2.rb +78 -0
- data/{lib → ruby/server/lib}/roma/tools/ssroute.rb +0 -0
- data/ruby/server/lib/roma/tools/test-scenario.rb +327 -0
- data/{lib → ruby/server/lib}/roma/tools/tribunus.rb +0 -0
- data/ruby/server/lib/roma/version.rb +4 -0
- data/{lib → ruby/server/lib}/roma/write_behind.rb +1 -0
- data/ruby/server/test/config4mhash.rb +68 -0
- data/ruby/server/test/config4storage_error.rb +69 -0
- data/{lib/roma/config.rb → ruby/server/test/config4test.rb} +6 -3
- data/{test → ruby/server/test}/rcirb.rb +0 -1
- data/{test → ruby/server/test}/roma-test-utils.rb +21 -8
- data/{test → ruby/server/test}/run-test.rb +3 -2
- data/ruby/server/test/storage_error_storage.rb +37 -0
- data/ruby/server/test/t_command_definition.rb +326 -0
- data/{test → ruby/server/test}/t_cpdata.rb +9 -3
- data/{test → ruby/server/test}/t_listplugin.rb +48 -12
- data/ruby/server/test/t_mapcountplugin.rb +231 -0
- data/ruby/server/test/t_mapplugin.rb +131 -0
- data/ruby/server/test/t_mhash.rb +222 -0
- data/ruby/server/test/t_rclient.rb +199 -0
- data/{test → ruby/server/test}/t_routing_data.rb +56 -0
- data/{test → ruby/server/test}/t_storage.rb +107 -111
- data/ruby/server/test/t_storage_error.rb +61 -0
- data/ruby/server/test/t_writebehind.rb +374 -0
- metadata +150 -82
- data/bin/recoverlost_alist +0 -8
- data/bin/romad +0 -7
- data/lib/roma/command/mh_command_receiver.rb +0 -117
- data/lib/roma/command/receiver.rb +0 -287
- data/lib/roma/event/handler.rb +0 -159
- data/lib/roma/plugin/plugin_debug.rb +0 -19
- data/lib/roma/tools/recoverlost_lib.rb +0 -217
- data/lib/roma/version.rb +0 -4
- data/test/t_rclient.rb +0 -318
- data/test/t_writebehind.rb +0 -200
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
|
4
3
|
require 'roma/storage/tc_storage'
|
5
4
|
require 'roma/storage/dbm_storage'
|
@@ -35,26 +34,28 @@ class TCStorageTest < Test::Unit::TestCase
|
|
35
34
|
rmtestdir('storage_test')
|
36
35
|
end
|
37
36
|
|
38
|
-
# 普通のset get
|
39
37
|
def test_set_get
|
40
38
|
assert_equal( 'abc_data',@st.set(0,'abc',0,0xffffffff,'abc_data')[4])
|
41
39
|
assert_equal( 'abc_data', @st.get(0,'abc',0) )
|
42
40
|
end
|
43
41
|
|
44
|
-
# 普通のset delete
|
45
42
|
def test_set_delete
|
46
43
|
@st.set(0,'abc',0,0xffffffff,'abc_data')
|
47
|
-
|
44
|
+
# delete method returns a value
|
45
|
+
assert_equal( 'abc_data', @st.delete(0,'abc',0)[4])
|
48
46
|
assert_nil( @st.get(0,'abc',0) )
|
49
|
-
|
47
|
+
# delete method returns :deletemark with deleted key
|
48
|
+
assert_equal(:deletemark, @st.delete(0,'abc',0))
|
50
49
|
end
|
51
50
|
|
52
|
-
# 有効期限
|
53
51
|
def test_set_exptime
|
54
52
|
@st.set(0,'abc',0,Time.now.to_i,'abc_data')
|
55
|
-
|
56
|
-
@st.
|
57
|
-
|
53
|
+
# returns a value within a fixed time limit
|
54
|
+
assert_equal('abc_data', @st.get(0,'abc',0) )
|
55
|
+
# expire time is a second ago
|
56
|
+
@st.set(0,'abc',0,Time.now.to_i-1,'abc_data')
|
57
|
+
# returns a nil when expired
|
58
|
+
assert_nil( @st.get(0,'abc',0))
|
58
59
|
end
|
59
60
|
|
60
61
|
def test_set_get_raw
|
@@ -70,35 +71,36 @@ class TCStorageTest < Test::Unit::TestCase
|
|
70
71
|
}
|
71
72
|
end
|
72
73
|
|
73
|
-
# 期限切れデータの削除
|
74
74
|
def test_exp_delete
|
75
75
|
assert_nil( @st.delete(0,'abc',0)[4])
|
76
|
-
|
77
|
-
|
76
|
+
# expire time is a second ago
|
77
|
+
assert_equal('abc_data' , @st.set(0,'abc',0,Time.now.to_i-1,'abc_data')[4])
|
78
|
+
# delete method returns a nil in expired
|
79
|
+
assert_nil( @st.delete(0,'abc',0)[4])
|
78
80
|
end
|
79
81
|
|
80
82
|
def test_rset
|
81
|
-
#
|
83
|
+
# increase a logical clock
|
82
84
|
assert_equal(0, @st.set(0,'abc',0,Time.now.to_i,'abc_data')[2] )
|
83
85
|
assert_equal(1, @st.set(0,'abc',0,Time.now.to_i,'abc_data')[2] )
|
84
86
|
assert_equal(2, @st.set(0,'abc',0,Time.now.to_i,'abc_data')[2] )
|
85
|
-
#
|
87
|
+
# rset method returns a inputed clock value
|
86
88
|
assert_equal(4, @st.rset(0,'abc',0,4,Time.now.to_i,'new_data')[2] )
|
87
|
-
#
|
89
|
+
# but if input clock value is old then not store the data
|
88
90
|
assert_nil( @st.rset(0,'abc',0,4,Time.now.to_i,'new_data') )
|
89
91
|
assert_nil( @st.rset(0,'abc',0,3,Time.now.to_i,'new_data') )
|
90
92
|
end
|
91
93
|
|
92
94
|
def test_rdelete
|
93
|
-
#
|
95
|
+
# save a clock value in the deletemark
|
94
96
|
assert_equal(2, @st.rdelete(0,'abc',0,2)[2] )
|
95
|
-
#
|
97
|
+
# reject a old clock value in rset method
|
96
98
|
assert_nil( @st.rset(0,'abc',0,1,Time.now.to_i,'new_data'))
|
97
99
|
assert_nil( @st.rset(0,'abc',0,2,Time.now.to_i,'new_data'))
|
98
|
-
#
|
100
|
+
# also reject a old clock value in rdelete method
|
99
101
|
assert_nil( @st.rdelete(0,'abc',0,1) )
|
100
102
|
assert_nil( @st.rdelete(0,'abc',0,2) )
|
101
|
-
#
|
103
|
+
# but input the new clock to allow
|
102
104
|
assert_equal( 3, @st.rdelete(0,'abc',0,3)[2] )
|
103
105
|
end
|
104
106
|
|
@@ -108,7 +110,7 @@ class TCStorageTest < Test::Unit::TestCase
|
|
108
110
|
assert( @st.out(0,'abc',0) )
|
109
111
|
end
|
110
112
|
|
111
|
-
#
|
113
|
+
# on boundary of a clock
|
112
114
|
def test_clock_count
|
113
115
|
assert_equal( 0xfffffffe, @st.rset(0,'set',0,0xfffffffe,Time.now.to_i,'new_data')[2])
|
114
116
|
assert_equal(0xffffffff, @st.set(0,'set',0,Time.now.to_i,'abc_data')[2])
|
@@ -135,9 +137,10 @@ class TCStorageTest < Test::Unit::TestCase
|
|
135
137
|
|
136
138
|
def test_add
|
137
139
|
assert_equal('abc_data',@st.add(0,'abc',0,Time.now.to_i+1,'abc_data')[4])
|
138
|
-
|
140
|
+
# deny a over write
|
141
|
+
assert_nil( @st.add(0,'abc',0,Time.now.to_i+1,'abc_data') )
|
139
142
|
assert_equal( 'abc_data', @st.delete(0,'abc',0)[4])
|
140
|
-
assert_equal('abc_data', @st.add(0,'abc',0,Time.now.to_i,'abc_data')[4])
|
143
|
+
assert_equal('abc_data', @st.add(0,'abc',0,Time.now.to_i,'abc_data')[4])
|
141
144
|
end
|
142
145
|
|
143
146
|
def test_replace
|
@@ -169,7 +172,7 @@ class TCStorageTest < Test::Unit::TestCase
|
|
169
172
|
assert_equal('100', @st.incr(0,'abc',0,-6)[4]) # 106 + (-6) = 100
|
170
173
|
assert_equal('0', @st.incr(0,'abc',0,-200)[4] ) # 100 + (-200) = 0
|
171
174
|
assert_equal('0', @st.incr(0,'abc',0,-200)[4] ) # 0 + (-200) = 0
|
172
|
-
#
|
175
|
+
# set to max value
|
173
176
|
assert_equal('18446744073709551615', @st.set(0,'abc',0,Time.now.to_i,
|
174
177
|
'18446744073709551615')[4])
|
175
178
|
assert_equal('1', @st.incr(0,'abc',0,2)[4] ) # max + 2 = 1
|
@@ -183,21 +186,20 @@ class TCStorageTest < Test::Unit::TestCase
|
|
183
186
|
assert_equal('100', @st.decr(0,'abc',0,-6)[4] ) # 94 - (-6) = 100
|
184
187
|
assert_equal('0', @st.decr(0,'abc',0,200)[4] ) # 100 - 200 = 0
|
185
188
|
assert_equal('0', @st.decr(0,'abc',0,200)[4] ) # 0 - 200 = 0
|
186
|
-
#
|
189
|
+
# set to max value
|
187
190
|
assert_equal('18446744073709551615', @st.set(0,'abc',0,Time.now.to_i,
|
188
191
|
'18446744073709551615')[4])
|
189
192
|
assert_equal('2', @st.decr(0,'abc',0,-3)[4]) # max - (-2) = 2
|
190
193
|
end
|
191
194
|
|
192
195
|
def test_dump
|
193
|
-
assert_nil( @st.dump(0) )
|
196
|
+
assert_nil( @st.dump(0) )
|
194
197
|
@st.set(0,'abc',0,0xffffffff,'abc_data')
|
195
198
|
assert_equal(1, Marshal.load(@st.dump(0)).length )
|
196
199
|
@st.set(0,'def',0,0xffffffff,'def_data')
|
197
200
|
assert_equal(2, Marshal.load(@st.dump(0)).length )
|
198
|
-
assert_nil( @st.dump(1) ) #
|
201
|
+
assert_nil( @st.dump(1) ) # another vnode is empty
|
199
202
|
|
200
|
-
# 10万件いれてみる
|
201
203
|
n=@ndat
|
202
204
|
n.times{|i|
|
203
205
|
@st.set(2,i.to_s,0,0xffffffff,'abc_data')
|
@@ -205,7 +207,6 @@ class TCStorageTest < Test::Unit::TestCase
|
|
205
207
|
assert_equal(n, Marshal.load(@st.dump(2)).length )
|
206
208
|
end
|
207
209
|
|
208
|
-
# 10万件程度
|
209
210
|
def test_volume
|
210
211
|
n=@ndat
|
211
212
|
n.times{|i|
|
@@ -217,33 +218,10 @@ class TCStorageTest < Test::Unit::TestCase
|
|
217
218
|
n.times{|i|
|
218
219
|
assert_equal('abc_data', @st.delete(0,i.to_s,0)[4])
|
219
220
|
}
|
220
|
-
#
|
221
|
+
# true_length value is included in number of deletemark
|
221
222
|
assert_equal(n, @st.true_length )
|
222
223
|
end
|
223
224
|
|
224
|
-
def test_clean_up
|
225
|
-
@st.each_clean_up_sleep = 0
|
226
|
-
n=@ndat
|
227
|
-
n.times{|i|
|
228
|
-
@st.set(0,i.to_s,0,0xffffffff,'abc_data')
|
229
|
-
}
|
230
|
-
# 指定時刻より以前 and 有効期限切れを削除
|
231
|
-
# 全てのデータは現在よりも以前だが、有効期限内なので0件
|
232
|
-
assert_equal(0, @st.clean_up(Time.now.to_i+100) )
|
233
|
-
# 10件を削除(削除は有効期限を0する)
|
234
|
-
10.times{|i|
|
235
|
-
assert_equal('abc_data', @st.delete(0,i.to_s,0)[4])
|
236
|
-
}
|
237
|
-
assert_nil( @st.get(0,'0',0) )
|
238
|
-
assert_equal('abc_data', @st.get(0,'19',0) )
|
239
|
-
# 削除時刻よりも以前を指定すると、0件
|
240
|
-
assert_equal(0, @st.clean_up(Time.now.to_i-100) )
|
241
|
-
# 削除時刻よりも進ませると、10件
|
242
|
-
assert_equal(10, @st.clean_up(Time.now.to_i+100) )
|
243
|
-
# 残は n-10
|
244
|
-
assert_equal(n-10, Marshal.load(@st.dump(0)).length )
|
245
|
-
end
|
246
|
-
|
247
225
|
def test_each_clean_up
|
248
226
|
n=10
|
249
227
|
|
@@ -256,21 +234,21 @@ class TCStorageTest < Test::Unit::TestCase
|
|
256
234
|
}
|
257
235
|
# ---------+------+---------------------
|
258
236
|
# last < now+100
|
259
|
-
#
|
237
|
+
# all data within a fixed time limit
|
260
238
|
@st.each_clean_up_sleep = 0
|
261
239
|
@st.each_clean_up(Time.now.to_i+100,vnhash){|k,vn|
|
262
240
|
puts "k=#{k} vn=#{vn}"
|
263
241
|
assert(false)
|
264
242
|
}
|
265
243
|
|
266
|
-
# vn=0
|
244
|
+
# delete data in vn=0
|
267
245
|
n.times{|i| @st.delete(0,"key0-#{i}",0) }
|
268
|
-
#
|
246
|
+
# time is 100 second ago
|
269
247
|
@st.each_clean_up(Time.now.to_i-100,vnhash){|k,vn|
|
270
248
|
assert(false)
|
271
249
|
}
|
272
250
|
|
273
|
-
#
|
251
|
+
# time is 100 second later
|
274
252
|
cnt=0
|
275
253
|
@st.each_clean_up(Time.now.to_i+100,vnhash){|k,vn|
|
276
254
|
assert_equal(0, vn)
|
@@ -279,17 +257,17 @@ class TCStorageTest < Test::Unit::TestCase
|
|
279
257
|
}
|
280
258
|
assert_equal(10,cnt )
|
281
259
|
|
282
|
-
# vn=1
|
260
|
+
# delete data in vn=1
|
283
261
|
n.times{|i| @st.delete(1,"key1-#{i}",0) }
|
284
|
-
# vn=1
|
262
|
+
# set to :secondary in vn=1
|
285
263
|
vnhash[1]=:secondary
|
286
|
-
#
|
264
|
+
# :secondary was not deleted
|
287
265
|
@st.each_clean_up(Time.now.to_i-100,vnhash){|k,vn|
|
288
266
|
assert(false)
|
289
267
|
}
|
290
|
-
# vn=1
|
268
|
+
# set to :primary in vn=1
|
291
269
|
vnhash[1]=:primary
|
292
|
-
#
|
270
|
+
# in :primary data was deleted
|
293
271
|
cnt=0
|
294
272
|
@st.each_clean_up(Time.now.to_i+100,vnhash){|k,vn|
|
295
273
|
assert_equal(1, vn)
|
@@ -298,18 +276,18 @@ class TCStorageTest < Test::Unit::TestCase
|
|
298
276
|
}
|
299
277
|
assert_equal(10,cnt)
|
300
278
|
|
301
|
-
#
|
279
|
+
# deletemark was empty
|
302
280
|
@st.each_clean_up(Time.now.to_i-100,vnhash){|k,vn|
|
303
281
|
assert(false)
|
304
282
|
}
|
305
283
|
|
306
|
-
# vn=2
|
284
|
+
# vn=2 is not taken of charge
|
307
285
|
vnhash.delete(2)
|
308
|
-
# vn=2
|
286
|
+
# but still have a data in vn=2
|
309
287
|
n.times{|i|
|
310
288
|
assert_match(/val2-/,@st.get(2,"key2-#{i}",0) )
|
311
289
|
}
|
312
|
-
# vn=2
|
290
|
+
# data was deleted in vn=2
|
313
291
|
cnt=0
|
314
292
|
@st.each_clean_up(Time.now.to_i+100,vnhash){|k,vn|
|
315
293
|
assert_equal(2, vn)
|
@@ -317,16 +295,16 @@ class TCStorageTest < Test::Unit::TestCase
|
|
317
295
|
cnt += 1
|
318
296
|
}
|
319
297
|
assert_equal(10,cnt)
|
320
|
-
# vn=2
|
298
|
+
# confirm it in vn=2
|
321
299
|
n.times{|i|
|
322
300
|
assert_nil( @st.get(2,"key2-#{i}",0) )
|
323
301
|
}
|
324
302
|
|
325
|
-
# vn=3
|
303
|
+
# time is 100 second ago in vn=3
|
326
304
|
n.times{|i|
|
327
305
|
@st.set(3,"key3-#{i}",0,Time.now.to_i-100,"val3-#{i}")
|
328
306
|
}
|
329
|
-
#
|
307
|
+
# 10 kyes deleted
|
330
308
|
cnt=0
|
331
309
|
@st.each_clean_up(Time.now.to_i-100,vnhash){|k,vn|
|
332
310
|
assert_equal(3, vn)
|
@@ -336,11 +314,10 @@ class TCStorageTest < Test::Unit::TestCase
|
|
336
314
|
assert_equal(10,cnt)
|
337
315
|
end
|
338
316
|
|
339
|
-
# 途中で止めるテスト
|
340
317
|
def test_each_clean_up2
|
341
318
|
n=10
|
342
319
|
|
343
|
-
#
|
320
|
+
# set and delete is repeated 100 times
|
344
321
|
vnhash={}
|
345
322
|
n.times{|i|
|
346
323
|
n.times{|j|
|
@@ -350,7 +327,7 @@ class TCStorageTest < Test::Unit::TestCase
|
|
350
327
|
vnhash[i]=:primary
|
351
328
|
}
|
352
329
|
|
353
|
-
#
|
330
|
+
# each waite is 10 msec
|
354
331
|
cnt = 0
|
355
332
|
th = Thread.new{
|
356
333
|
@st.each_clean_up_sleep = 0.01
|
@@ -358,60 +335,66 @@ class TCStorageTest < Test::Unit::TestCase
|
|
358
335
|
cnt += 1
|
359
336
|
}
|
360
337
|
}
|
361
|
-
# 500msec
|
338
|
+
# in 500msec later will stop
|
362
339
|
sleep 0.5
|
363
340
|
@st.stop_clean_up
|
364
341
|
th.join
|
365
|
-
#
|
342
|
+
# should cnt is less than 100
|
366
343
|
assert_operator(100, :>, cnt)
|
367
|
-
#
|
344
|
+
# delete a remain keys
|
368
345
|
@st.each_clean_up_sleep = 0
|
369
346
|
@st.each_clean_up(Time.now.to_i+100,vnhash){|k,vn|
|
370
347
|
cnt += 1
|
371
348
|
}
|
372
|
-
#
|
349
|
+
# after all cnt is 100
|
373
350
|
assert_equal(100, cnt)
|
374
351
|
end
|
375
352
|
|
376
353
|
def test_dump_and_load
|
377
354
|
n=10
|
378
355
|
n.times{|i|
|
356
|
+
# clock = 0
|
379
357
|
@st.set(0,i.to_s,0,0xffffffff,'abc_data')
|
380
|
-
|
381
358
|
}
|
382
|
-
|
359
|
+
# not loaded
|
360
|
+
assert_equal(0, @st.load(@st.dump(0)) )
|
383
361
|
|
384
|
-
# 進んだ論理クロックのデータを n 件作成
|
385
362
|
h={}
|
386
363
|
n.times{|i|
|
364
|
+
# clock = 1
|
387
365
|
h[i.to_s]=[0,Time.now.to_i,1,0xffffffff].pack('NNNN')+'new data'
|
388
366
|
}
|
389
367
|
dmp=Marshal.dump(h)
|
390
368
|
|
391
|
-
|
369
|
+
# loaded
|
370
|
+
assert_equal(n, @st.load(dmp) )
|
392
371
|
assert_equal('new data', @st.get(0,'0',0))
|
393
372
|
end
|
394
373
|
|
395
374
|
def test_dump_and_load2
|
396
375
|
n=10
|
376
|
+
# create a deletemark
|
397
377
|
n.times{|i|
|
398
|
-
assert_nil( @st.delete(0,i.to_s,0)[4] )
|
378
|
+
assert_nil( @st.delete(0,i.to_s,0)[4] )
|
399
379
|
}
|
380
|
+
# dump a deletemark
|
400
381
|
dmp=@st.dump(0)
|
401
|
-
assert_equal(n, Marshal.load(dmp).length )
|
402
|
-
|
382
|
+
assert_equal(n, Marshal.load(dmp).length )
|
383
|
+
# not loaded, it's same data
|
384
|
+
assert_equal(0, @st.load(@st.dump(0)) )
|
403
385
|
|
404
|
-
#
|
386
|
+
# create a old clock data
|
405
387
|
h={}
|
406
388
|
n.times{|i|
|
407
389
|
h[i.to_s]=[0,Time.now.to_i,0xffffffff,0xffffffff].pack('NNNN')+'old data'
|
408
390
|
}
|
409
391
|
dmp=Marshal.dump(h)
|
410
|
-
|
392
|
+
# not loaded
|
393
|
+
assert_equal(0, @st.load(dmp) )
|
411
394
|
assert_nil( @st.get(0,'0',0) )
|
412
395
|
end
|
413
396
|
|
414
|
-
#
|
397
|
+
# access after close
|
415
398
|
def test_close
|
416
399
|
@st.closedb
|
417
400
|
|
@@ -437,31 +420,19 @@ class TCStorageTest < Test::Unit::TestCase
|
|
437
420
|
@st.load(dmp)
|
438
421
|
end
|
439
422
|
|
440
|
-
|
441
|
-
assert_equal(0,@st.clean_up(Time.now.to_i+100) )
|
423
|
+
end
|
442
424
|
|
443
|
-
|
444
|
-
#
|
445
|
-
# わざわざユニットテストを行う理由 => レアケースなだけにバグも発見しにくい。
|
446
|
-
#
|
447
|
-
# バッチによる clean_up 処理中に deletehash を行ったときこの状態になる。
|
448
|
-
# NoMethodError を判定した retry を保証するためテストを行う。
|
449
|
-
#
|
450
|
-
@st.opendb
|
425
|
+
def test_close_after_each_clean_up
|
451
426
|
h={}
|
452
|
-
|
453
|
-
h[i.to_s]=[
|
427
|
+
100.times{|i|
|
428
|
+
h[i.to_s]=[i%10,Time.now.to_i,0,Time.now.to_i].pack('NNNN')+'old data'
|
454
429
|
}
|
455
430
|
dmp=Marshal.dump(h)
|
456
431
|
@st.load(dmp)
|
457
432
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
end
|
462
|
-
|
463
|
-
# 次のテストのために再度 open
|
464
|
-
@st.opendb
|
433
|
+
@st.each_clean_up(Time.now.to_i-100, Hash.new(:primary) ){|k,vn|
|
434
|
+
@st.closedb
|
435
|
+
}
|
465
436
|
end
|
466
437
|
|
467
438
|
def test_dump_file
|
@@ -550,19 +521,31 @@ class DbmStorageTest < TCStorageTest
|
|
550
521
|
def setup
|
551
522
|
rmtestdir('storage_test')
|
552
523
|
@st=Roma::Storage::DbmStorage.new
|
553
|
-
@st.vn_list = [0]
|
524
|
+
@st.vn_list = [0,1,2,3,4,5,6,7,8,9]
|
554
525
|
@st.storage_path = 'storage_test'
|
555
526
|
@st.opendb
|
556
527
|
end
|
557
528
|
|
558
|
-
|
559
|
-
|
529
|
+
def test_close_after_each_clean_up
|
530
|
+
h={}
|
531
|
+
1000.times{|i|
|
532
|
+
h[i.to_s]=[i%10,Time.now.to_i,0,Time.now.to_i].pack('NNNN')+'old data'
|
533
|
+
}
|
534
|
+
dmp=Marshal.dump(h)
|
535
|
+
@st.load(dmp)
|
536
|
+
|
537
|
+
assert_raise RuntimeError do
|
538
|
+
@st.each_clean_up(Time.now.to_i-100, Hash.new(:primary) ){|k,vn|
|
539
|
+
@st.closedb
|
540
|
+
}
|
541
|
+
end
|
542
|
+
end
|
560
543
|
end
|
561
544
|
|
562
545
|
class RubyHashStorageTest < TCStorageTest
|
563
546
|
def setup
|
564
547
|
@st=Roma::Storage::RubyHashStorage.new
|
565
|
-
@st.vn_list = [0]
|
548
|
+
@st.vn_list = [0,1,2,3,4,5,6,7,8,9]
|
566
549
|
@st.opendb
|
567
550
|
end
|
568
551
|
|
@@ -625,19 +608,32 @@ class SQLite3StorageTest < TCStorageTest
|
|
625
608
|
def setup
|
626
609
|
rmtestdir('storage_test')
|
627
610
|
@st=Roma::Storage::SQLite3Storage.new
|
628
|
-
@st.vn_list = [0]
|
611
|
+
@st.vn_list = [0,1,2,3,4,5,6,7,8,9]
|
629
612
|
@st.storage_path = 'storage_test'
|
630
613
|
@st.opendb
|
631
614
|
end
|
632
615
|
|
633
|
-
|
616
|
+
def test_close_after_each_clean_up
|
617
|
+
h={}
|
618
|
+
1000.times{|i|
|
619
|
+
h[i.to_s]=[i%10,Time.now.to_i,0,Time.now.to_i].pack('NNNN')+'old data'
|
620
|
+
}
|
621
|
+
dmp=Marshal.dump(h)
|
622
|
+
@st.load(dmp)
|
623
|
+
|
624
|
+
assert_raise SQLite3::BusyException do
|
625
|
+
@st.each_clean_up(Time.now.to_i-100, Hash.new(:primary) ){|k,vn|
|
626
|
+
@st.closedb
|
627
|
+
}
|
628
|
+
end
|
629
|
+
end
|
634
630
|
end
|
635
631
|
|
636
632
|
class TCMemStorageTest < TCStorageTest
|
637
633
|
def setup
|
638
634
|
rmtestdir('storage_test')
|
639
635
|
@st=Roma::Storage::TCMemStorage.new
|
640
|
-
@st.vn_list = [0]
|
636
|
+
@st.vn_list = [0,1,2,3,4,5,6,7,8,9]
|
641
637
|
@st.storage_path = 'storage_test'
|
642
638
|
@st.opendb
|
643
639
|
end
|