roma 0.8.2 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANG +326 -0
  2. data/CHANGELOG +132 -0
  3. data/{README.rdoc → FETCH_HEAD} +0 -0
  4. data/{LICENSE.rdoc → LICENSE} +0 -1
  5. data/README +17 -0
  6. data/Rakefile +33 -18
  7. data/ruby/server/bin/chg_redundancy +10 -0
  8. data/ruby/server/bin/key_access +7 -0
  9. data/ruby/server/bin/key_list +7 -0
  10. data/ruby/server/bin/mkconfig +19 -0
  11. data/{bin → ruby/server/bin}/mkrecent +0 -1
  12. data/{bin → ruby/server/bin}/mkroute +0 -1
  13. data/ruby/server/bin/multi_commander +19 -0
  14. data/ruby/server/bin/recoverlost +10 -0
  15. data/ruby/server/bin/recoverlost_alist +10 -0
  16. data/ruby/server/bin/recoverlost_alist_all +10 -0
  17. data/ruby/server/bin/recoverlost_alist_keys +10 -0
  18. data/{bin/recoverlost → ruby/server/bin/roma_watcher} +1 -2
  19. data/ruby/server/bin/romad +36 -0
  20. data/{bin → ruby/server/bin}/sample_watcher +0 -1
  21. data/{bin → ruby/server/bin}/sample_watcher2 +0 -1
  22. data/{bin/simple_bench → ruby/server/bin/sample_watcher3} +1 -2
  23. data/ruby/server/bin/simple_bench +26 -0
  24. data/{bin → ruby/server/bin}/ssroute +0 -1
  25. data/ruby/server/bin/test-scenario +11 -0
  26. data/{bin → ruby/server/bin}/tribunus +0 -1
  27. data/{lib → ruby/server/lib}/roma/async_process.rb +67 -15
  28. data/{lib → ruby/server/lib}/roma/command/bg_command_receiver.rb +1 -1
  29. data/ruby/server/lib/roma/command/command_definition.rb +422 -0
  30. data/ruby/server/lib/roma/command/mh_command_receiver.rb +127 -0
  31. data/ruby/server/lib/roma/command/receiver.rb +64 -0
  32. data/{lib → ruby/server/lib}/roma/command/rt_command_receiver.rb +6 -1
  33. data/ruby/server/lib/roma/command/sys_command_receiver.rb +609 -0
  34. data/{lib → ruby/server/lib}/roma/command/util_command_receiver.rb +15 -5
  35. data/{lib → ruby/server/lib}/roma/command/vn_command_receiver.rb +12 -4
  36. data/{lib → ruby/server/lib}/roma/command_plugin.rb +0 -0
  37. data/ruby/server/lib/roma/config.rb +84 -0
  38. data/{lib → ruby/server/lib}/roma/event/con_pool.rb +12 -1
  39. data/ruby/server/lib/roma/event/handler.rb +256 -0
  40. data/ruby/server/lib/roma/live_patch-20120302-001.rb +107 -0
  41. data/ruby/server/lib/roma/logging/rlogger.rb +163 -0
  42. data/ruby/server/lib/roma/messaging/con_pool.rb +92 -0
  43. data/{lib → ruby/server/lib}/roma/plugin/plugin_alist.rb +118 -240
  44. data/ruby/server/lib/roma/plugin/plugin_debug.rb +31 -0
  45. data/ruby/server/lib/roma/plugin/plugin_map.rb +177 -0
  46. data/ruby/server/lib/roma/plugin/plugin_mapcount.rb +185 -0
  47. data/{lib/roma/command/st_command_receiver.rb → ruby/server/lib/roma/plugin/plugin_storage.rb} +170 -146
  48. data/ruby/server/lib/roma/plugin/plugin_stub.rb +283 -0
  49. data/{lib → ruby/server/lib}/roma/plugin/plugin_test.rb +0 -0
  50. data/{lib → ruby/server/lib}/roma/romad.rb +221 -94
  51. data/{lib → ruby/server/lib}/roma/routing/cb_rttable.rb +4 -6
  52. data/{lib → ruby/server/lib}/roma/routing/merkle_tree.rb +0 -0
  53. data/ruby/server/lib/roma/routing/routing_data.rb +307 -0
  54. data/{lib → ruby/server/lib}/roma/routing/rttable.rb +4 -0
  55. data/{lib → ruby/server/lib}/roma/stats.rb +19 -3
  56. data/{lib → ruby/server/lib}/roma/storage/basic_storage.rb +25 -26
  57. data/{lib → ruby/server/lib}/roma/storage/dbm_storage.rb +1 -23
  58. data/{lib → ruby/server/lib}/roma/storage/dummy_storage.rb +0 -0
  59. data/{lib → ruby/server/lib}/roma/storage/rh_storage.rb +0 -0
  60. data/{lib → ruby/server/lib}/roma/storage/sqlite3_storage.rb +0 -0
  61. data/{lib → ruby/server/lib}/roma/storage/tc_storage.rb +62 -2
  62. data/ruby/server/lib/roma/tools/chg_redundancy.rb +36 -0
  63. data/ruby/server/lib/roma/tools/key_access.rb +105 -0
  64. data/ruby/server/lib/roma/tools/key_list.rb +94 -0
  65. data/ruby/server/lib/roma/tools/mkconfig.rb +535 -0
  66. data/{lib → ruby/server/lib}/roma/tools/mkrecent.rb +0 -0
  67. data/{lib → ruby/server/lib}/roma/tools/mkroute.rb +0 -0
  68. data/ruby/server/lib/roma/tools/multi_commander.rb +45 -0
  69. data/{lib → ruby/server/lib}/roma/tools/recoverlost.rb +0 -0
  70. data/{lib → ruby/server/lib}/roma/tools/recoverlost_alist.rb +0 -0
  71. data/ruby/server/lib/roma/tools/recoverlost_alist_all.rb +8 -0
  72. data/ruby/server/lib/roma/tools/recoverlost_alist_keys.rb +16 -0
  73. data/ruby/server/lib/roma/tools/recoverlost_lib.rb +349 -0
  74. data/ruby/server/lib/roma/tools/roma_watcher.rb +150 -0
  75. data/ruby/server/lib/roma/tools/roma_watcher_config.yml.example +20 -0
  76. data/{lib → ruby/server/lib}/roma/tools/sample_watcher.rb +3 -1
  77. data/{lib → ruby/server/lib}/roma/tools/sample_watcher2.rb +3 -1
  78. data/ruby/server/lib/roma/tools/sample_watcher3.rb +49 -0
  79. data/{lib → ruby/server/lib}/roma/tools/simple_bench.rb +2 -0
  80. data/ruby/server/lib/roma/tools/simple_bench2.rb +78 -0
  81. data/{lib → ruby/server/lib}/roma/tools/ssroute.rb +0 -0
  82. data/ruby/server/lib/roma/tools/test-scenario.rb +327 -0
  83. data/{lib → ruby/server/lib}/roma/tools/tribunus.rb +0 -0
  84. data/ruby/server/lib/roma/version.rb +4 -0
  85. data/{lib → ruby/server/lib}/roma/write_behind.rb +1 -0
  86. data/ruby/server/test/config4mhash.rb +68 -0
  87. data/ruby/server/test/config4storage_error.rb +69 -0
  88. data/{lib/roma/config.rb → ruby/server/test/config4test.rb} +6 -3
  89. data/{test → ruby/server/test}/rcirb.rb +0 -1
  90. data/{test → ruby/server/test}/roma-test-utils.rb +21 -8
  91. data/{test → ruby/server/test}/run-test.rb +3 -2
  92. data/ruby/server/test/storage_error_storage.rb +37 -0
  93. data/ruby/server/test/t_command_definition.rb +326 -0
  94. data/{test → ruby/server/test}/t_cpdata.rb +9 -3
  95. data/{test → ruby/server/test}/t_listplugin.rb +48 -12
  96. data/ruby/server/test/t_mapcountplugin.rb +231 -0
  97. data/ruby/server/test/t_mapplugin.rb +131 -0
  98. data/ruby/server/test/t_mhash.rb +222 -0
  99. data/ruby/server/test/t_rclient.rb +199 -0
  100. data/{test → ruby/server/test}/t_routing_data.rb +56 -0
  101. data/{test → ruby/server/test}/t_storage.rb +107 -111
  102. data/ruby/server/test/t_storage_error.rb +61 -0
  103. data/ruby/server/test/t_writebehind.rb +374 -0
  104. metadata +150 -82
  105. data/bin/recoverlost_alist +0 -8
  106. data/bin/romad +0 -7
  107. data/lib/roma/command/mh_command_receiver.rb +0 -117
  108. data/lib/roma/command/receiver.rb +0 -287
  109. data/lib/roma/event/handler.rb +0 -159
  110. data/lib/roma/plugin/plugin_debug.rb +0 -19
  111. data/lib/roma/tools/recoverlost_lib.rb +0 -217
  112. data/lib/roma/version.rb +0 -4
  113. data/test/t_rclient.rb +0 -318
  114. data/test/t_writebehind.rb +0 -200
@@ -1,19 +0,0 @@
1
-
2
- module Roma
3
- module CommandPlugin
4
-
5
- module PluginOperation
6
- include ::Roma::CommandPlugin
7
-
8
- # DANGER!!
9
- def ev_eval(s)
10
- cmd = s[1..-1].join(' ')
11
- @log.debug("eval(#{cmd})")
12
- send_data("#{eval(cmd)}\r\n")
13
- rescue =>e
14
- send_data("#{e}\r\n")
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,217 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- #
4
- # usage:recoverlost address port storage-path [yyyymmddhhmmss]
5
- #
6
- require 'roma/client/sender'
7
- require 'roma/messaging/con_pool'
8
- require 'roma/routing/routing_data'
9
-
10
- module Roma
11
- module Storage
12
- end
13
- Storage::autoload(:TCStorage,'roma/storage/tc_storage')
14
- Storage::autoload(:DbmStorage,'roma/storage/dbm_storage')
15
- Storage::autoload(:SQLite3Storage,'roma/storage/sqlite3_storage')
16
-
17
- class RecoverLost
18
-
19
- def initialize(pname, pushv_cmd, argv)
20
- if argv.length < 3
21
- puts "usage:#{pname} address port storage-path [yyyymmddhhmmss]"
22
- exit
23
- end
24
-
25
- @addr = argv[0]
26
- @port = argv[1]
27
- @strgpath = argv[2]
28
- @ymdhms = argv[3]
29
-
30
- if @port =~ /\D/
31
- STDERR.puts "port was not numeric."
32
- exit
33
- end
34
-
35
- if @ymdhms && (@ymdhms.length != 14 || @ymdhms =~ /\D/)
36
- STDERR.puts "yyyymmddhhmmss format mismatch."
37
- exit
38
- end
39
- @pushv_cmd = pushv_cmd
40
- @nodeid = "#{@addr}_#{@port}"
41
- @stream_copy_wait_param = 0.0001
42
- end
43
-
44
- def suite
45
- @rd = get_routing_data(@nodeid)
46
- @lost_vnodes = get_lost_vnodes(@rd,@ymdhms)
47
- puts "#{@lost_vnodes.length} vnodes where data was lost."
48
-
49
- exit if @lost_vnodes.length == 0
50
-
51
- each_hash(@strgpath){|hname,dir|
52
- puts "#{hname} #{dir}"
53
- @storage = open_storage(dir,@lost_vnodes)
54
- start_recover(hname)
55
- @storage.closedb
56
- }
57
- end
58
-
59
- def each_hash(path)
60
- Dir::glob("#{path}/*").each{|dir|
61
- next unless File::directory?(dir)
62
- hname = dir[dir.rindex('/')+1..-1]
63
- yield hname,dir
64
- }
65
- end
66
-
67
- def get_routing_data(nid)
68
- sender = Roma::Client::Sender.new
69
- sender.send_routedump_command(nid)
70
- end
71
-
72
- def get_lost_vnodes(rd,ymdhms)
73
- ret = rd.get_lost_vnodes
74
- if ymdhms
75
- ret |= get_history_of_lost(rd.nodes[0],ymdhms)
76
- end
77
- ret
78
- end
79
-
80
- def get_history_of_lost(nid,ymdhms)
81
- ret = []
82
- con = Roma::Messaging::ConPool.instance.get_connection(nid)
83
- con.write("history_of_lost #{ymdhms}\r\n")
84
- while((buf = con.gets) != "END\r\n")
85
- ret << buf.chomp.to_i
86
- end
87
- Roma::Messaging::ConPool.instance.return_connection(nid, con)
88
- ret
89
- end
90
-
91
- def open_storage(path,vn_list)
92
- unless File::directory?(path)
93
- STDERR.puts "#{path} dose not found."
94
- return nil
95
- end
96
-
97
- # get a file extension
98
- ext = File::extname(Dir::glob("#{path}/0.*")[0])[1..-1]
99
- # count a number of divided files
100
- divnum = Dir::glob("#{path}/*.#{ext}").length
101
-
102
- st = new_storage(ext)
103
- st.divnum = divnum
104
- st.vn_list = vn_list
105
- st.storage_path = path
106
- st.opendb
107
- st
108
- end
109
-
110
- def new_storage(ext)
111
- case(ext)
112
- when 'tc'
113
- return ::Roma::Storage::TCStorage.new
114
- when 'dbm'
115
- return Roma::Storage::DbmStorage.new
116
- when 'sql3'
117
- return Roma::Storage::SQLite3Storage.new
118
- else
119
- return nil
120
- end
121
- end
122
-
123
- def start_recover(hname)
124
- @lost_vnodes.each{|vn|
125
- nodes = @rd.v_idx[vn]
126
- if nodes == nil || nodes.length == 0
127
- nid = @rd.nodes[rand(@rd.nodes.length)]
128
- puts "#{vn} assign to #{nid}"
129
- else
130
- nid = nodes[0]
131
- puts "#{vn} was auto assirned at #{nid}"
132
- end
133
-
134
- if push_a_vnode_stream(hname, vn, nid)!="STORED"
135
- STDERR.puts "push_a_vnode_stream aborted in #{vn}"
136
- exit
137
- end
138
-
139
- if nodes == nil || nodes.length == 0
140
- cmd = "setroute #{vn} #{@rd.v_clk[vn]} #{nid}\r\n"
141
- exit unless send_cmd(nid ,cmd)
142
- broadcast_cmd(cmd, nid)
143
- end
144
- }
145
- end
146
-
147
- def push_a_vnode(hname, vn, nid)
148
- dmp = @storage.dump(vn)
149
- return true unless dmp
150
- con = Roma::Messaging::ConPool.instance.get_connection(nid) unless con
151
- con.write("pushv #{hname} #{vn}\r\n")
152
- res = con.gets
153
- con.write("#{dmp.length}\r\n#{dmp}\r\nEND\r\n")
154
- res = con.gets
155
- con.close
156
- res.chomp! if res
157
- res
158
- rescue =>e
159
- STDERR.puts "#{e}\n#{$@}"
160
- nil
161
- end
162
-
163
- def push_a_vnode_stream(hname, vn, nid)
164
- con = Roma::Messaging::ConPool.instance.get_connection(nid)
165
-
166
- # con.write("spushv #{hname} #{vn}\r\n")
167
- con.write("#{@pushv_cmd} #{hname} #{vn}\r\n")
168
-
169
- res = con.gets # READY\r\n or error string
170
- if res != "READY\r\n"
171
- con.close
172
- return res.chomp
173
- end
174
-
175
- @storage.each_vn_dump(vn){|data|
176
- con.write(data)
177
- sleep @stream_copy_wait_param
178
- }
179
- con.write("\0"*20) # end of steram
180
-
181
- res = con.gets # STORED\r\n or error string
182
- Roma::Messaging::ConPool.instance.return_connection(nid,con)
183
- res.chomp! if res
184
- res
185
- rescue =>e
186
- STDERR.puts "#{e}\n#{$@}"
187
- nil
188
- end
189
-
190
- def broadcast_cmd(cmd,without_nids=nil)
191
- without_nids=[] unless without_nids
192
- res = {}
193
- @rd.nodes.each{ |nid|
194
- res[nid] = send_cmd(nid,cmd) unless without_nids.include?(nid)
195
- }
196
- res
197
- rescue => e
198
- STDERR.puts("#{e}\n#{$@}")
199
- nil
200
- end
201
-
202
- def send_cmd(nid, cmd)
203
- con = Roma::Messaging::ConPool.instance.get_connection(nid)
204
- con.write(cmd)
205
- res = con.gets
206
- Roma::Messaging::ConPool.instance.return_connection(nid, con)
207
- if res
208
- res.chomp!
209
- end
210
- res
211
- rescue => e
212
- STDERR.puts("#{__FILE__}:#{__LINE__}:Send command failed that node-id is #{nid},command is #{cmd}.")
213
- nil
214
- end
215
-
216
- end # class RecoverLost
217
- end # module Roma
data/lib/roma/version.rb DELETED
@@ -1,4 +0,0 @@
1
-
2
- module Roma
3
- VERSION = "0.8.2"
4
- end
data/test/t_rclient.rb DELETED
@@ -1,318 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
-
4
- require 'roma/client/rclient'
5
-
6
- Roma::Client::RomaClient.class_eval{
7
- def init_sync_routing_proc
8
- end
9
- }
10
-
11
- class RClientTest < Test::Unit::TestCase
12
- include RomaTestUtils
13
-
14
- def setup
15
- start_roma
16
- @rc=Roma::Client::RomaClient.new(["localhost_11211","localhost_11212"])
17
- end
18
-
19
- def teardown
20
- stop_roma
21
- Roma::Messaging::ConPool::instance.close_all
22
- end
23
-
24
- def test_set_get_delete
25
- @rc.delete("abc")
26
- assert_nil( @rc.get("abc") )
27
- assert_equal("STORED", @rc.set("abc","value abc"))
28
- assert_equal("value abc", @rc.get("abc"))
29
- assert_equal("STORED", @rc.set("abc","value abc")) # 上書きは成功する
30
- assert_equal("DELETED", @rc.delete("abc"))
31
- assert_nil( @rc.get("abc"))
32
- assert_equal("NOT_FOUND", @rc.delete("abc"))
33
- end
34
-
35
- def test_set_get
36
- 10.times{|i|
37
- s = i.to_s * 1024000
38
- assert_equal("STORED", @rc.set("abc", s))
39
- assert(s == @rc.get("abc"))
40
- }
41
- end
42
-
43
- def test_set_gets
44
- keys = []
45
- assert_equal(@rc.gets(["key-1","key-2"]).length,0)
46
- 10.times{|i|
47
- assert_equal("STORED", @rc.set("key-#{i}", "value-#{i}"))
48
- keys << "key-#{i}"
49
- }
50
- ret = @rc.gets(keys)
51
- assert_equal(ret.length,10)
52
- ret.each_pair{|k,v|
53
- assert_equal(k[-1],v[-1])
54
- assert_equal(k[0..3],"key-")
55
- assert_equal(v[0..5],"value-")
56
- }
57
- keys << "key-99"
58
- ret = @rc.gets(keys)
59
- assert_equal(ret.length,10)
60
-
61
- assert_equal("DELETED", @rc.delete("key-5"))
62
- ret = @rc.gets(keys)
63
- assert_equal(ret.length,9)
64
- end
65
-
66
- def test_out
67
- # 本当に消す
68
- @rc.out("key-out")
69
- # 本当にない場合は NOT_DELETED
70
- assert_equal("NOT_DELETED", @rc.out("key-out"))
71
- assert_equal("STORED", @rc.set("key-out","value out"))
72
- assert_equal("DELETED", @rc.out("key-out"))
73
- assert_equal("STORED", @rc.set("key-out","value out"))
74
- # 削除マークをつける
75
- assert_equal("DELETED", @rc.delete("key-out"))
76
- # delete してもマークを消すので DELETED
77
- assert_equal("DELETED", @rc.out("key-out"))
78
- end
79
-
80
- def test_add
81
- assert_nil( @rc.get("add") )
82
- assert_equal("STORED", @rc.add("add","value add"))
83
- assert_equal("NOT_STORED", @rc.add("add","value add")) # 上書きは失敗する
84
- assert_equal("DELETED", @rc.delete("add"))
85
- assert_equal("STORED", @rc.add("add","value add")) # delete 後の add の成功を確認
86
- assert_equal("DELETED", @rc.delete("add"))
87
- end
88
-
89
- def test_replace
90
- assert_nil( @rc.get("replace") )
91
- assert_equal("NOT_STORED", @rc.replace("replace","value replace"))
92
- assert_nil( @rc.get("replace") )
93
- assert_equal("STORED", @rc.add("replace","value add"))
94
- assert_equal("STORED", @rc.replace("replace","value replace"))
95
- assert_equal("DELETED", @rc.delete("replace"))
96
- end
97
-
98
- def test_append
99
- assert_nil( @rc.get("append") )
100
- assert_equal("NOT_STORED", @rc.append("append","append"))
101
- assert_equal("STORED", @rc.set("append","set"))
102
- assert_equal("set", @rc.get("append"))
103
- assert_equal("STORED", @rc.append("append","append"))
104
- assert_equal("setappend", @rc.get("append"))
105
- assert_equal("DELETED", @rc.delete("append"))
106
- end
107
-
108
- def test_prepend
109
- assert_nil( @rc.get("prepend"))
110
- assert_equal("NOT_STORED", @rc.prepend("prepend","prepend"))
111
- assert_equal("STORED", @rc.set("prepend","set"))
112
- assert_equal("set", @rc.get("prepend"))
113
- assert_equal("STORED", @rc.prepend("prepend","prepend"))
114
- assert_equal("prependset", @rc.get("prepend"))
115
- assert_equal("DELETED", @rc.delete("prepend"))
116
- end
117
-
118
- def test_incr
119
- assert_nil( @rc.get("incr"))
120
- assert_equal("NOT_FOUND", @rc.incr("incr"))
121
- assert_equal("STORED", @rc.set("incr","100"))
122
- assert_equal(101, @rc.incr("incr"))
123
- assert_equal(102, @rc.incr("incr"))
124
- assert_equal("DELETED", @rc.delete("incr"))
125
- end
126
-
127
- def test_decr
128
- assert_nil( @rc.get("decr") )
129
- assert_equal("NOT_FOUND", @rc.decr("decr"))
130
- assert_equal("STORED", @rc.set("decr","100"))
131
- assert_equal(99, @rc.decr("decr"))
132
- assert_equal(98, @rc.decr("decr"))
133
- assert_equal("DELETED", @rc.delete("decr"))
134
- end
135
-
136
- def test_createhash
137
- con = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
138
- con.write("hashlist\r\n")
139
- ret = con.gets
140
- assert_equal("roma", ret.chomp )
141
-
142
- con.write("createhash test\r\n")
143
- ret = con.gets
144
- assert_equal("{\"localhost_11212\"=>\"CREATED\", \"localhost_11211\"=>\"CREATED\"}", ret.chomp )
145
-
146
- con.write("hashlist\r\n")
147
- ret = con.gets
148
- assert_equal("roma test", ret.chomp )
149
-
150
- assert_equal("STORED", @rc.set("roma","hname=roma"))
151
- assert_equal("hname=roma", @rc.get("roma"))
152
- @rc.default_hash_name='test'
153
- assert_nil( @rc.get("roma") )
154
- assert_equal("STORED", @rc.set("roma","hname=test"))
155
- assert_equal("hname=test", @rc.get("roma"))
156
- @rc.default_hash_name='roma'
157
- assert_equal("hname=roma", @rc.get("roma"))
158
- assert_equal("DELETED", @rc.delete("roma"))
159
-
160
- @rc.default_hash_name='not_exist_hash' # 存在しないハッシュへのアクセス
161
- begin
162
- @rc.get("roma")
163
- assert(false)
164
- rescue =>e
165
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
166
- end
167
-
168
- begin
169
- @rc.set("roma","hname=roma")
170
- assert(false)
171
- rescue =>e
172
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
173
- end
174
-
175
- begin
176
- @rc.delete("roma")
177
- assert(false)
178
- rescue =>e
179
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
180
- end
181
-
182
- begin
183
- @rc.add("add","value add")
184
- assert(false)
185
- rescue =>e
186
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
187
- end
188
-
189
- begin
190
- @rc.replace("replace","value replace")
191
- assert(false)
192
- rescue =>e
193
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
194
- end
195
-
196
- begin
197
- @rc.append("append","append")
198
- assert(false)
199
- rescue =>e
200
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.', e.message)
201
- end
202
-
203
- begin
204
- @rc.prepend("prepend","prepend")
205
- assert(false)
206
- rescue =>e
207
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
208
- end
209
-
210
- begin
211
- @rc.incr("incr")
212
- assert(false)
213
- rescue =>e
214
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
215
- end
216
-
217
- begin
218
- @rc.decr("decr")
219
- assert(false)
220
- rescue =>e
221
- assert_equal('SERVER_ERROR not_exist_hash dose not exists.',e.message)
222
- end
223
-
224
- con.write("deletehash test\r\n")
225
- ret = con.gets
226
- assert_equal( "{\"localhost_11212\"=>\"DELETED\", \"localhost_11211\"=>\"DELETED\"}", ret.chomp )
227
-
228
- con.close
229
- end
230
-
231
- def test_createhash2
232
- # test ハッシュを追加し終了する
233
- con = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
234
- con.write("hashlist\r\n")
235
- ret = con.gets
236
- assert_equal("roma", ret.chomp)
237
-
238
- con.write("createhash test\r\n")
239
- ret = con.gets
240
- assert_equal("{\"localhost_11212\"=>\"CREATED\", \"localhost_11211\"=>\"CREATED\"}", ret.chomp )
241
-
242
- assert_equal("STORED", @rc.set("roma","hname=roma"))
243
- assert_equal("hname=roma", @rc.get("roma"))
244
- @rc.default_hash_name='test'
245
- assert_equal("STORED", @rc.set("roma","hname=test"))
246
- assert_equal("hname=test", @rc.get("roma"))
247
- con.write("balse\r\n")
248
- con.gets
249
- con.write "yes\r\n"
250
- ret = con.gets
251
- con.close
252
-
253
-
254
- # 再起動
255
- ruby_path = File.join(RbConfig::CONFIG["bindir"],
256
- RbConfig::CONFIG["ruby_install_name"])
257
- path = File.dirname(File.expand_path($PROGRAM_NAME))
258
- sh = Shell.new
259
- sh.system(ruby_path,"#{path}/../bin/romad","localhost","-p","11211","-d","--verbose")
260
- sh.system(ruby_path,"#{path}/../bin/romad","localhost","-p","11212","-d","--verbose")
261
- sleep 2
262
- Roma::Messaging::ConPool.instance.close_all
263
-
264
- @rc=Roma::Client::RomaClient.new(["localhost_11211","localhost_11212"])
265
- @rc.default_hash_name='test'
266
- con = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
267
- con.write("hashlist\r\n")
268
- ret = con.gets
269
-
270
- #
271
- # for file storage
272
- #
273
-
274
- # 停止前のデータが残っていることを確認
275
- #assert_equal("hname=test", @rc.get("roma"))
276
-
277
- # test ハッシュを削除
278
- #con.write("deletehash test\r\n")
279
- #ret = con.gets
280
- #assert_equal("{\"localhost_11212\"=>\"DELETED\", \"localhost_11211\"=>\"DELETED\"}", ret.chomp )
281
-
282
- # デフォルトハッシュに残ったテストデータを削除
283
- #@rc.default_hash_name='roma'
284
- #assert_equal('DELETED', @rc.delete("roma"))
285
-
286
- end
287
-
288
- def test_createhash3
289
- con = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
290
-
291
- # 存在しないハッシュを削除
292
- con.write("deletehash test\r\n")
293
- ret = con.gets
294
- assert_equal("{\"localhost_11212\"=>\"SERVER_ERROR test dose not exists.\", \"localhost_11211\"=>\"SERVER_ERROR test dose not exists.\"}", ret.chomp )
295
-
296
- # デフォルトハッシュを削除
297
- con.write("deletehash roma\r\n")
298
- ret = con.gets
299
- assert_equal("{\"localhost_11212\"=>\"SERVER_ERROR the hash name of 'roma' can't delete.\", \"localhost_11211\"=>\"SERVER_ERROR the hash name of 'roma' can't delete.\"}", ret.chomp )
300
- end
301
- end
302
-
303
- class RClientTestForceForward < RClientTest
304
- def setup
305
- super
306
- @rc.rttable.instance_eval{
307
- undef search_node
308
-
309
- def search_node(key); search_node2(key); end
310
-
311
- def search_node2(key)
312
- d = Digest::SHA1.hexdigest(key).hex % @hbits
313
- @rd.v_idx[d & @search_mask][1]
314
- end
315
- }
316
- end
317
-
318
- end