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
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
require 'roma/client/rclient'
|
5
|
+
require 'roma/messaging/con_pool'
|
5
6
|
|
6
7
|
$dat = {}
|
7
8
|
|
@@ -164,7 +165,7 @@ class CopyDataTest < Test::Unit::TestCase
|
|
164
165
|
push_a_vnode_stream('roma', 0, nid[0], keys)
|
165
166
|
|
166
167
|
keys.each{|k|
|
167
|
-
assert_equal( "#{k}-stream", @rc.get(k))
|
168
|
+
assert_equal( "#{k}-stream", @rc.get(k,true))
|
168
169
|
# puts "#{k} #{@rc.get(k)}"
|
169
170
|
}
|
170
171
|
end
|
@@ -242,8 +243,13 @@ class CopyDataTest < Test::Unit::TestCase
|
|
242
243
|
def reqpushv(hname,vn,is_primary=false)
|
243
244
|
$dat.delete(vn)
|
244
245
|
con = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
|
245
|
-
|
246
|
-
|
246
|
+
res = nil
|
247
|
+
10.times{
|
248
|
+
con.write("reqpushv #{vn} localhost_11213 #{is_primary}\r\n")
|
249
|
+
res = con.gets
|
250
|
+
break if res == "PUSHED\r\n"
|
251
|
+
sleep 0.5
|
252
|
+
}
|
247
253
|
assert_equal( "PUSHED\r\n", res )
|
248
254
|
con.close
|
249
255
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
2
|
require 'roma/client/rclient'
|
5
3
|
require 'roma/plugin/plugin_alist'
|
6
4
|
require 'roma/storage/tc_storage'
|
5
|
+
require 'roma/messaging/con_pool'
|
6
|
+
require 'roma/client/plugin/alist'
|
7
7
|
|
8
8
|
Roma::Client::RomaClient.class_eval{
|
9
9
|
def init_sync_routing_proc
|
@@ -17,7 +17,7 @@ class ListPluginTest < Test::Unit::TestCase
|
|
17
17
|
start_roma
|
18
18
|
@rc=Roma::Client::RomaClient.new(
|
19
19
|
["localhost_11211","localhost_11212"],
|
20
|
-
[
|
20
|
+
[Roma::Client::Plugin::Alist])
|
21
21
|
end
|
22
22
|
|
23
23
|
def teardown
|
@@ -174,6 +174,16 @@ class ListPluginTest < Test::Unit::TestCase
|
|
174
174
|
assert_equal(["55","66","55","44","33"], @rc.alist_to_s("aa")[1])
|
175
175
|
assert_equal('STORED', @rc.alist_sized_insert("aa",3,"22"))
|
176
176
|
assert_equal(["22","55","66"], @rc.alist_to_s("aa")[1] )
|
177
|
+
assert_equal('STORED', @rc.alist_sized_insert("aa",6,"77"))
|
178
|
+
assert_equal(["77","22","55","66"], @rc.alist_to_s("aa")[1] )
|
179
|
+
assert_equal('STORED', @rc.alist_sized_insert("aa",6,"88"))
|
180
|
+
assert_equal(["88","77","22","55","66"], @rc.alist_to_s("aa")[1] )
|
181
|
+
assert_equal('STORED', @rc.alist_sized_insert("aa",6,"99"))
|
182
|
+
assert_equal(["99","88","77","22","55","66"], @rc.alist_to_s("aa")[1] )
|
183
|
+
assert_equal('STORED', @rc.alist_sized_insert("aa",6,"00"))
|
184
|
+
assert_equal(["00","99","88","77","22","55"], @rc.alist_to_s("aa")[1] )
|
185
|
+
assert_equal('STORED', @rc.alist_sized_insert("aa",6,"00"))
|
186
|
+
assert_equal(["00","00","99","88","77","22"], @rc.alist_to_s("aa")[1] )
|
177
187
|
end
|
178
188
|
|
179
189
|
def test_sized_insert2
|
@@ -278,7 +288,7 @@ class ListPluginTest < Test::Unit::TestCase
|
|
278
288
|
t = Time.now.to_i
|
279
289
|
assert( @rc.alist_push("aa","11")=='STORED' )
|
280
290
|
assert( @rc.alist_join("aa","|")[1]=="11" )
|
281
|
-
#
|
291
|
+
# get a time of insert, maybe in 1 sec
|
282
292
|
assert_operator(1,:>,t - @rc.alist_join_with_time("aa","|")[2].to_i)
|
283
293
|
assert_equal('STORED', @rc.alist_push("aa","22"))
|
284
294
|
assert_equal("11|22", @rc.alist_join("aa","|")[1])
|
@@ -468,6 +478,34 @@ class ListPluginTest < Test::Unit::TestCase
|
|
468
478
|
assert_equal(["44"], @rc.alist_to_s("aa")[1])
|
469
479
|
end
|
470
480
|
|
481
|
+
def test_alist_update_at
|
482
|
+
@rc.delete("aa")
|
483
|
+
|
484
|
+
assert_equal('NOT_FOUND', @rc.alist_update_at("aa",0,"a0"))
|
485
|
+
|
486
|
+
assert_equal('STORED', @rc.alist_push("aa","00"))
|
487
|
+
assert_equal('STORED', @rc.alist_push("aa","11"))
|
488
|
+
assert_equal('STORED', @rc.alist_push("aa","22"))
|
489
|
+
assert_equal('STORED', @rc.alist_push("aa","33"))
|
490
|
+
assert_equal('STORED', @rc.alist_push("aa","44"))
|
491
|
+
|
492
|
+
assert_equal(["00","11","22","33","44"], @rc.alist_to_s("aa")[1])
|
493
|
+
|
494
|
+
assert_equal('NOT_FOUND', @rc.alist_update_at("aa",-1,"a0"))
|
495
|
+
assert_equal('NOT_FOUND', @rc.alist_update_at("aa",5,"a0"))
|
496
|
+
|
497
|
+
assert_equal('STORED', @rc.alist_update_at("aa",2,"a2"))
|
498
|
+
assert_equal(["00","11","a2","33","44"], @rc.alist_to_s("aa")[1])
|
499
|
+
assert_equal('STORED', @rc.alist_update_at("aa",0,"a0"))
|
500
|
+
assert_equal(["a0","11","a2","33","44"], @rc.alist_to_s("aa")[1])
|
501
|
+
assert_equal('STORED', @rc.alist_update_at("aa",1,"a1"))
|
502
|
+
assert_equal(["a0","a1","a2","33","44"], @rc.alist_to_s("aa")[1])
|
503
|
+
assert_equal('STORED', @rc.alist_update_at("aa",3,"a3"))
|
504
|
+
assert_equal(["a0","a1","a2","a3","44"], @rc.alist_to_s("aa")[1])
|
505
|
+
assert_equal('STORED', @rc.alist_update_at("aa",4,"a4"))
|
506
|
+
assert_equal(["a0","a1","a2","a3","a4"], @rc.alist_to_s("aa")[1])
|
507
|
+
end
|
508
|
+
|
471
509
|
def test_shift
|
472
510
|
@rc.delete("aa")
|
473
511
|
|
@@ -514,9 +552,7 @@ class ListPluginTest < Test::Unit::TestCase
|
|
514
552
|
|
515
553
|
st, nid, vn = create_storage_and_calc_vn('aa')
|
516
554
|
|
517
|
-
#
|
518
|
-
# 時刻は適当で OK
|
519
|
-
# リストの結合ロジックは delete and push
|
555
|
+
# create a data ,it's a past time
|
520
556
|
pt =Time.now.to_i
|
521
557
|
st.set(vn,'aa',0,0xffffffff,Marshal.dump([['11','22','33','44','55'],[pt,pt,pt,pt,pt]]))
|
522
558
|
|
@@ -529,19 +565,19 @@ class ListPluginTest < Test::Unit::TestCase
|
|
529
565
|
|
530
566
|
assert_equal(["55", "33", "11", "22", "44"], @rc.alist_to_s("aa")[1])
|
531
567
|
|
532
|
-
# list
|
568
|
+
# create a data out of list
|
533
569
|
st.set(vn,'aa',0,0xffffffff,'val-aa')
|
534
570
|
push_a_vnode_stream(st, vn, nid)
|
535
|
-
#
|
571
|
+
# do not write a value
|
536
572
|
assert_equal(["55", "33", "11", "22", "44"], @rc.alist_to_s("aa")[1])
|
537
573
|
|
538
|
-
#
|
574
|
+
# increases to logical clock
|
539
575
|
10.times{
|
540
576
|
st.set(vn,'aa',0,0xffffffff,'val-aa')
|
541
577
|
}
|
542
578
|
push_a_vnode_stream(st, vn, nid)
|
543
|
-
#
|
544
|
-
assert_equal('val-aa', @rc.get("aa"))
|
579
|
+
# write over a value, cause increased a logical clock
|
580
|
+
assert_equal('val-aa', @rc.get("aa",true))
|
545
581
|
end
|
546
582
|
|
547
583
|
def create_storage_and_calc_vn(k)
|
@@ -0,0 +1,231 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'roma/client'
|
3
|
+
require 'roma/client/plugin/mapcount'
|
4
|
+
|
5
|
+
Roma::Client::RomaClient.class_eval{
|
6
|
+
def init_sync_routing_proc
|
7
|
+
end
|
8
|
+
}
|
9
|
+
|
10
|
+
class MapCountPluginTest < Test::Unit::TestCase
|
11
|
+
include RomaTestUtils
|
12
|
+
|
13
|
+
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S +00"
|
14
|
+
|
15
|
+
def setup
|
16
|
+
start_roma
|
17
|
+
@rc=Roma::Client::RomaClient.new(["localhost_11211","localhost_11212"], [Roma::Client::Plugin::MapCount])
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
stop_roma
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_mapcount_get(n = 5)
|
25
|
+
n.times do |i|
|
26
|
+
k = "subkey#{i}"
|
27
|
+
expt = i
|
28
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
29
|
+
|
30
|
+
retc = {"last_updated_date"=>lt}
|
31
|
+
(i+1).times do |j|
|
32
|
+
retc["subkey#{j}"] = 1
|
33
|
+
end
|
34
|
+
assert_equal retc, @rc.mapcount_countup('key1', k, 0)
|
35
|
+
|
36
|
+
retg = {"last_updated_date"=>lt}
|
37
|
+
retg["subkey#{i}"] = 1
|
38
|
+
assert_equal retg, @rc.mapcount_get('key1', k)
|
39
|
+
assert_equal retc, @rc.mapcount_get('key1')
|
40
|
+
end
|
41
|
+
|
42
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
43
|
+
ret = {"last_updated_date"=>lt, "subkey0"=>1, "subkey1"=>1}
|
44
|
+
assert_equal ret, @rc.mapcount_get('key1', 'subkey0,subkey1')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_mapcount_countup_expt
|
48
|
+
k = "subkey1"
|
49
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
50
|
+
ret = {"last_updated_date"=>lt, k=>1}
|
51
|
+
|
52
|
+
assert_nil @rc.mapcount_get('key1', k)
|
53
|
+
assert_equal ret, @rc.mapcount_countup('key1', k, 1)
|
54
|
+
assert_equal ret, @rc.mapcount_get('key1', k)
|
55
|
+
sleep 2
|
56
|
+
assert_nil @rc.mapcount_get('key1', k)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_mapcount_update
|
60
|
+
k = "subkey1"
|
61
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
62
|
+
ret_time = {"last_updated_date"=>lt}
|
63
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
64
|
+
|
65
|
+
assert_nil @rc.mapcount_update('key1')
|
66
|
+
assert_equal ret_all, @rc.mapcount_countup('key1', k, 0)
|
67
|
+
assert_equal ret_all, @rc.mapcount_update('key1')
|
68
|
+
assert_equal ret_time, @rc.mapcount_update('key1', 'subkey2')
|
69
|
+
|
70
|
+
assert_equal ret_all, @rc.mapcount_update('key1', nil, 1)
|
71
|
+
sleep 2
|
72
|
+
assert_nil @rc.mapcount_get('key1')
|
73
|
+
|
74
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
75
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
76
|
+
assert_equal ret_all, @rc.mapcount_countup('key1', k, 0)
|
77
|
+
assert_equal ret_all, @rc.mapcount_update('key1', k, 1)
|
78
|
+
sleep 2
|
79
|
+
assert_nil @rc.mapcount_get('key1')
|
80
|
+
|
81
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
82
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
83
|
+
assert_equal ret_all, @rc.mapcount_countup('key1', k, 0)
|
84
|
+
sleep 2
|
85
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
86
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
87
|
+
assert_equal ret_all, @rc.mapcount_update('key1')
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_counts
|
91
|
+
conn = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
|
92
|
+
if conn
|
93
|
+
conn.write "stat read_count\n"
|
94
|
+
r = conn.gets.split(" ")
|
95
|
+
assert_equal 0, r[1].to_i
|
96
|
+
conn.gets
|
97
|
+
|
98
|
+
@rc.mapcount_get('key')
|
99
|
+
sleep 10
|
100
|
+
conn.write "stat read_count\n"
|
101
|
+
r = conn.gets.split(" ")
|
102
|
+
assert_equal 1, r[1].to_i
|
103
|
+
conn.gets
|
104
|
+
|
105
|
+
conn.write "stat write_count\n"
|
106
|
+
r = conn.gets.split(" ")
|
107
|
+
assert_equal 0, r[1].to_i
|
108
|
+
conn.gets
|
109
|
+
|
110
|
+
@rc.mapcount_countup('key', 'subkey', 0)
|
111
|
+
sleep 10
|
112
|
+
conn.write "stat write_count\n"
|
113
|
+
r = conn.gets.split(" ")
|
114
|
+
assert_equal 1, r[1].to_i
|
115
|
+
conn.gets
|
116
|
+
|
117
|
+
@rc.mapcount_update('key')
|
118
|
+
sleep 10
|
119
|
+
conn.write "stat write_count\n"
|
120
|
+
r = conn.gets.split(" ")
|
121
|
+
assert_equal 2, r[1].to_i
|
122
|
+
conn.gets
|
123
|
+
|
124
|
+
conn.close
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_mapcount_get_ms(n = 5)
|
129
|
+
n.times do |i|
|
130
|
+
k = "subkey#{i}"
|
131
|
+
expt = i
|
132
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
133
|
+
|
134
|
+
retc = {"last_updated_date"=>lt}
|
135
|
+
(i+1).times do |j|
|
136
|
+
retc["subkey#{j}"] = 1
|
137
|
+
end
|
138
|
+
assert_equal retc, @rc.mapcount_countup_ms('key1', k, 0)
|
139
|
+
|
140
|
+
retg = {"last_updated_date"=>lt}
|
141
|
+
retg["subkey#{i}"] = 1
|
142
|
+
assert_equal retg, @rc.mapcount_get_ms('key1', k)
|
143
|
+
assert_equal retc, @rc.mapcount_get_ms('key1')
|
144
|
+
end
|
145
|
+
|
146
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
147
|
+
ret = {"last_updated_date"=>lt, "subkey0"=>1, "subkey1"=>1}
|
148
|
+
assert_equal ret, @rc.mapcount_get_ms('key1', 'subkey0,subkey1')
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_mapcount_countup_ms_expt
|
152
|
+
k = "subkey1"
|
153
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
154
|
+
ret = {"last_updated_date"=>lt, k=>1}
|
155
|
+
|
156
|
+
assert_nil @rc.mapcount_get_ms('key1', k)
|
157
|
+
assert_equal ret, @rc.mapcount_countup_ms('key1', k, 1)
|
158
|
+
assert_equal ret, @rc.mapcount_get_ms('key1', k)
|
159
|
+
sleep 2
|
160
|
+
assert_nil @rc.mapcount_get_ms('key1', k)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_mapcount_update_ms
|
164
|
+
k = "subkey1"
|
165
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
166
|
+
ret_time = {"last_updated_date"=>lt}
|
167
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
168
|
+
|
169
|
+
assert_nil @rc.mapcount_update_ms('key1')
|
170
|
+
assert_equal ret_all, @rc.mapcount_countup_ms('key1', k, 0)
|
171
|
+
assert_equal ret_all, @rc.mapcount_update_ms('key1')
|
172
|
+
assert_equal ret_time, @rc.mapcount_update_ms('key1', 'subkey2')
|
173
|
+
|
174
|
+
assert_equal ret_all, @rc.mapcount_update_ms('key1', nil, 1)
|
175
|
+
sleep 2
|
176
|
+
assert_nil @rc.mapcount_get_ms('key1')
|
177
|
+
|
178
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
179
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
180
|
+
assert_equal ret_all, @rc.mapcount_countup_ms('key1', k, 0)
|
181
|
+
assert_equal ret_all, @rc.mapcount_update_ms('key1', k, 1)
|
182
|
+
sleep 2
|
183
|
+
assert_nil @rc.mapcount_get_ms('key1')
|
184
|
+
|
185
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
186
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
187
|
+
assert_equal ret_all, @rc.mapcount_countup_ms('key1', k, 0)
|
188
|
+
sleep 2
|
189
|
+
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
190
|
+
ret_all = {"last_updated_date"=>lt, k=>1}
|
191
|
+
assert_equal ret_all, @rc.mapcount_update_ms('key1')
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_counts_ms
|
195
|
+
conn = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
|
196
|
+
if conn
|
197
|
+
conn.write "stat read_count\n"
|
198
|
+
r = conn.gets.split(" ")
|
199
|
+
assert_equal 0, r[1].to_i
|
200
|
+
conn.gets
|
201
|
+
|
202
|
+
@rc.mapcount_get_ms('key')
|
203
|
+
sleep 10
|
204
|
+
conn.write "stat read_count\n"
|
205
|
+
r = conn.gets.split(" ")
|
206
|
+
assert_equal 1, r[1].to_i
|
207
|
+
conn.gets
|
208
|
+
|
209
|
+
conn.write "stat write_count\n"
|
210
|
+
r = conn.gets.split(" ")
|
211
|
+
assert_equal 0, r[1].to_i
|
212
|
+
conn.gets
|
213
|
+
|
214
|
+
@rc.mapcount_countup_ms('key', 'subkey', 0)
|
215
|
+
sleep 10
|
216
|
+
conn.write "stat write_count\n"
|
217
|
+
r = conn.gets.split(" ")
|
218
|
+
assert_equal 1, r[1].to_i
|
219
|
+
conn.gets
|
220
|
+
|
221
|
+
@rc.mapcount_update_ms('key')
|
222
|
+
sleep 10
|
223
|
+
conn.write "stat write_count\n"
|
224
|
+
r = conn.gets.split(" ")
|
225
|
+
assert_equal 2, r[1].to_i
|
226
|
+
conn.gets
|
227
|
+
|
228
|
+
conn.close
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end # MapCountPluginTest
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'roma/client/rclient'
|
3
|
+
require 'roma/plugin/plugin_map'
|
4
|
+
require 'roma/client/plugin/map'
|
5
|
+
|
6
|
+
Roma::Client::RomaClient.class_eval{
|
7
|
+
def init_sync_routing_proc
|
8
|
+
end
|
9
|
+
}
|
10
|
+
|
11
|
+
class MapPluginTest < Test::Unit::TestCase
|
12
|
+
include RomaTestUtils
|
13
|
+
|
14
|
+
def setup
|
15
|
+
start_roma
|
16
|
+
@rc=Roma::Client::RomaClient.new(
|
17
|
+
["localhost_11211","localhost_11212"],
|
18
|
+
[Roma::Client::Plugin::Map])
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
stop_roma
|
23
|
+
Roma::Messaging::ConPool::instance.close_all
|
24
|
+
end
|
25
|
+
|
26
|
+
def mk_data(n = 10)
|
27
|
+
n.times do |i|
|
28
|
+
v = "value#{i}"
|
29
|
+
k = "mapkey#{i}"
|
30
|
+
assert_equal 'STORED', @rc.map_set('key1', k, v)
|
31
|
+
assert_equal v, @rc.map_get('key1', k)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_map_set_expt
|
36
|
+
assert_equal 'STORED', @rc.map_set('key1','mapkey1','value1', 1)
|
37
|
+
assert_equal 'value1', @rc.map_get('key1','mapkey1')
|
38
|
+
sleep 2
|
39
|
+
assert_nil @rc.map_get('key1','mapkey1')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_map_set
|
43
|
+
assert_nil @rc.map_get('key1','mapkey1')
|
44
|
+
assert_equal 'STORED', @rc.map_set('key1','mapkey1','value1')
|
45
|
+
assert_equal 'value1', @rc.map_get('key1','mapkey1')
|
46
|
+
|
47
|
+
assert_equal 'STORED', @rc.map_set('key1','mapkey1','value2')
|
48
|
+
assert_equal 'value2', @rc.map_get('key1','mapkey1')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_map_delete
|
52
|
+
mk_data
|
53
|
+
assert_equal 'NOT_FOUND', @rc.map_delete('key2', 'key1')
|
54
|
+
assert_equal 'NOT_DELETED', @rc.map_delete('key1', 'key1')
|
55
|
+
assert_equal 'DELETED', @rc.map_delete('key1', 'mapkey1')
|
56
|
+
assert_nil @rc.map_get('key1', 'mapkey1')
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_map_clear
|
60
|
+
assert_equal 'NOT_FOUND', @rc.map_empty?('key1')
|
61
|
+
assert_equal 'NOT_FOUND', @rc.map_size('key1')
|
62
|
+
assert_equal 'NOT_FOUND', @rc.map_clear('key1')
|
63
|
+
mk_data
|
64
|
+
assert !@rc.map_empty?('key1')
|
65
|
+
assert_equal 10, @rc.map_size('key1')
|
66
|
+
assert_equal 'CLEARED', @rc.map_clear('key1')
|
67
|
+
assert @rc.map_empty?('key1')
|
68
|
+
assert_equal 0, @rc.map_size('key1')
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_map_key?
|
72
|
+
assert_equal 'NOT_FOUND', @rc.map_key?('key1', 'key1')
|
73
|
+
mk_data
|
74
|
+
assert !@rc.map_key?('key1', 'key1')
|
75
|
+
assert @rc.map_key?('key1', 'mapkey1')
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_map_value?
|
79
|
+
assert_equal 'NOT_FOUND', @rc.map_value?('key1', 'value1')
|
80
|
+
mk_data
|
81
|
+
assert !@rc.map_value?('key1', 'key1')
|
82
|
+
assert @rc.map_value?('key1', 'value1')
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_map_keys
|
86
|
+
assert_nil @rc.map_keys('key1')
|
87
|
+
mk_data
|
88
|
+
v = [10]
|
89
|
+
10.times{|i| v << "mapkey#{i}" }
|
90
|
+
assert_equal v, @rc.map_keys('key1')
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_map_values
|
94
|
+
assert_nil @rc.map_values('key1')
|
95
|
+
mk_data
|
96
|
+
v = [10]
|
97
|
+
10.times{|i| v << "value#{i}" }
|
98
|
+
assert_equal v, @rc.map_values('key1')
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_map_to_s
|
102
|
+
assert !@rc.map_to_s('key1')
|
103
|
+
mk_data
|
104
|
+
h = {}
|
105
|
+
10.times do |i|
|
106
|
+
v = "value#{i}"
|
107
|
+
k = "mapkey#{i}"
|
108
|
+
h[k] = v
|
109
|
+
end
|
110
|
+
assert_equal h, eval(@rc.map_to_s('key1'))
|
111
|
+
end
|
112
|
+
|
113
|
+
end # MapPluginTest
|
114
|
+
|
115
|
+
class MapPluginTestForceForward < MapPluginTest
|
116
|
+
def setup
|
117
|
+
super
|
118
|
+
@rc.rttable.instance_eval{
|
119
|
+
undef search_node
|
120
|
+
|
121
|
+
def search_node(key); search_node2(key); end
|
122
|
+
|
123
|
+
def search_node2(key)
|
124
|
+
d = Digest::SHA1.hexdigest(key).hex % @hbits
|
125
|
+
@rd.v_idx[d & @search_mask][1]
|
126
|
+
end
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
|