roma 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/LICENSE.rdoc +675 -0
  2. data/README.rdoc +0 -0
  3. data/Rakefile +70 -0
  4. data/bin/mkrecent +7 -0
  5. data/bin/mkroute +7 -0
  6. data/bin/recoverlost +8 -0
  7. data/bin/recoverlost_alist +8 -0
  8. data/bin/romad +7 -0
  9. data/bin/sample_watcher +8 -0
  10. data/bin/sample_watcher2 +8 -0
  11. data/bin/simple_bench +8 -0
  12. data/bin/ssroute +7 -0
  13. data/bin/tribunus +7 -0
  14. data/lib/roma/async_process.rb +696 -0
  15. data/lib/roma/command/bg_command_receiver.rb +188 -0
  16. data/lib/roma/command/mh_command_receiver.rb +117 -0
  17. data/lib/roma/command/receiver.rb +287 -0
  18. data/lib/roma/command/rt_command_receiver.rb +147 -0
  19. data/lib/roma/command/st_command_receiver.rb +564 -0
  20. data/lib/roma/command/util_command_receiver.rb +67 -0
  21. data/lib/roma/command/vn_command_receiver.rb +143 -0
  22. data/lib/roma/command_plugin.rb +11 -0
  23. data/lib/roma/config.rb +64 -0
  24. data/lib/roma/event/con_pool.rb +140 -0
  25. data/lib/roma/event/handler.rb +159 -0
  26. data/lib/roma/plugin/plugin_alist.rb +1572 -0
  27. data/lib/roma/plugin/plugin_debug.rb +19 -0
  28. data/lib/roma/plugin/plugin_test.rb +14 -0
  29. data/lib/roma/romad.rb +582 -0
  30. data/lib/roma/routing/cb_rttable.rb +326 -0
  31. data/lib/roma/routing/merkle_tree.rb +54 -0
  32. data/lib/roma/routing/rttable.rb +148 -0
  33. data/lib/roma/stats.rb +112 -0
  34. data/lib/roma/storage/basic_storage.rb +510 -0
  35. data/lib/roma/storage/dbm_storage.rb +80 -0
  36. data/lib/roma/storage/dummy_storage.rb +44 -0
  37. data/lib/roma/storage/rh_storage.rb +35 -0
  38. data/lib/roma/storage/sqlite3_storage.rb +73 -0
  39. data/lib/roma/storage/tc_storage.rb +133 -0
  40. data/lib/roma/tools/mkrecent.rb +138 -0
  41. data/lib/roma/tools/mkroute.rb +52 -0
  42. data/lib/roma/tools/recoverlost.rb +9 -0
  43. data/lib/roma/tools/recoverlost_alist.rb +9 -0
  44. data/lib/roma/tools/recoverlost_lib.rb +217 -0
  45. data/lib/roma/tools/sample_watcher.rb +38 -0
  46. data/lib/roma/tools/sample_watcher2.rb +38 -0
  47. data/lib/roma/tools/simple_bench.rb +57 -0
  48. data/lib/roma/tools/ssroute.rb +23 -0
  49. data/lib/roma/tools/tribunus.rb +299 -0
  50. data/lib/roma/version.rb +4 -0
  51. data/lib/roma/write_behind.rb +179 -0
  52. data/test/rcirb.rb +16 -0
  53. data/test/roma-test-utils.rb +65 -0
  54. data/test/run-test.rb +16 -0
  55. data/test/t_cpdata.rb +277 -0
  56. data/test/t_listplugin.rb +592 -0
  57. data/test/t_rclient.rb +318 -0
  58. data/test/t_routing_data.rb +100 -0
  59. data/test/t_storage.rb +644 -0
  60. data/test/t_writebehind.rb +200 -0
  61. metadata +134 -0
@@ -0,0 +1,188 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'roma/async_process'
3
+ require 'roma/messaging/con_pool'
4
+ require 'roma/command/vn_command_receiver'
5
+
6
+ module Roma
7
+ module Command
8
+
9
+ module BackgroundCommandReceiver
10
+ include VnodeCommandReceiver
11
+
12
+ def ev_balance(s)
13
+ res = broadcast_cmd("rbalance\r\n")
14
+ if @stats.run_recover==false &&
15
+ @stats.run_acquire_vnodes == false &&
16
+ @rttable.vnode_balance(@stats.ap_str)==:less
17
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_acquire_vnodes_process'))
18
+ res[@stats.ap_str] = 'STARTED'
19
+ else
20
+ res[@stats.ap_str] = 'SERVER_ERROR Not unbalance or Balance/Recover/Sync process is already running.'
21
+ end
22
+ send_data("#{res}\r\n")
23
+ end
24
+
25
+ def ev_rbalance(s)
26
+ if @stats.run_recover==false &&
27
+ @stats.run_acquire_vnodes == false &&
28
+ @rttable.vnode_balance(@stats.ap_str)==:less
29
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_acquire_vnodes_process'))
30
+ send_data("STARTED\r\n")
31
+ else
32
+ send_data("SERVER_ERROR Not unbalance or Balance/Recover/Sync process is already running.\r\n")
33
+ end
34
+ end
35
+
36
+ def ev_release(s)
37
+ if @stats.run_recover==false &&
38
+ @stats.run_acquire_vnodes == false &&
39
+ @stats.run_release == false &&
40
+ @stats.run_iterate_storage == false
41
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_release_process'))
42
+ send_data("STARTED\r\n")
43
+ else
44
+ send_data("SERVER_ERROR Release/Balance/Recover/Sync process is already running.\r\n")
45
+ end
46
+ end
47
+
48
+ # recover [-r]
49
+ def ev_recover(s)
50
+ option = s[1] if s.length == 2
51
+ if @rttable.can_i_recover?
52
+ cmd = "rrecover"
53
+ cmd << " #{option}" if option
54
+ res = broadcast_cmd("#{cmd}\r\n")
55
+ unless @stats.run_recover
56
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_recover_process',[option]))
57
+ res[@nid] = "STARTED"
58
+ else
59
+ res[@nid] = "SERVER_ERROR Recover/Sync process is already running."
60
+ end
61
+ send_data("#{res}\r\n")
62
+ else
63
+ send_data("SERVER_ERROR nodes num < redundant num\r\n")
64
+ end
65
+ end
66
+
67
+ # rrecover [-r|-s]
68
+ def ev_rrecover(s)
69
+ option = s[1] if s.length == 2
70
+ if @rttable.can_i_recover?
71
+ unless @stats.run_recover
72
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_recover_process',[option]))
73
+ send_data("STARTED\r\n")
74
+ else
75
+ send_data("SERVER_ERROR Recover process is already running.\r\n")
76
+ end
77
+ else
78
+ send_data("SERVER_ERROR nodes num < redundant num\r\n")
79
+ end
80
+ end
81
+
82
+ # sync <hname>
83
+ def ev_sync(s)
84
+ res = nil
85
+ if s.length==1
86
+ res = broadcast_cmd("rsync\r\n")
87
+ else
88
+ res = broadcast_cmd("rsync #{s[1]}\r\n")
89
+ end
90
+ unless @stats.run_recover
91
+ if s.length==1
92
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_sync_process',@storages.keys))
93
+ else
94
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_sync_process',[s[1]]))
95
+ end
96
+ res[@nid] = "STARTED"
97
+ else
98
+ res[@nid] = "SERVER_ERROR Recover/Sync process is already running."
99
+ end
100
+ send_data("#{res}\r\n")
101
+ rescue => e
102
+ @log.error("#{e}\n#{$@}")
103
+ end
104
+
105
+ # rsync <hname>
106
+ def ev_rsync(s)
107
+ unless @stats.run_recover
108
+ if s.length==1
109
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_sync_process',@storages.keys))
110
+ else
111
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_sync_process',[s[1]]))
112
+ end
113
+ send_data("STARTED\r\n")
114
+ else
115
+ send_data("SERVER_ERROR Recover/Sync process is already running.\r\n")
116
+ end
117
+ rescue => e
118
+ @log.error("#{e}\n#{$@}")
119
+ end
120
+
121
+ # dumpfile <key> <path>
122
+ def ev_dumpfile(s)
123
+ if s.length != 3
124
+ send_data("CLIENT_ERROR usage:dumpfile <key> <path>\r\n")
125
+ return
126
+ end
127
+
128
+ res = broadcast_cmd("rdumpfile #{s[1]} #{s[2]}\r\n")
129
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_dumpfile_process',[s[1],s[2],:dumpfile]))
130
+ path = Roma::Config::STORAGE_DUMP_PATH + '/' + s[2]
131
+ res[@nid] = "STARTED #{path}/#{@nid}"
132
+ send_data("#{res}\r\n")
133
+ rescue => e
134
+ @log.error("#{e}\n#{$@}")
135
+ end
136
+
137
+ # rdumpfile <key> <path>
138
+ def ev_rdumpfile(s)
139
+ if s.length != 3
140
+ send_data("CLIENT_ERROR usage:rdumpfile <key> <path>\r\n")
141
+ return
142
+ end
143
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_dumpfile_process',[s[1],s[2],:rdumpfile]))
144
+ path = Roma::Config::STORAGE_DUMP_PATH + '/' + s[2]
145
+ send_data("STARTED #{path}/#{@nid}\r\n")
146
+ rescue => e
147
+ @log.error("#{e}\n#{$@}")
148
+ end
149
+
150
+ def acquire_vnodes
151
+ count = 0
152
+ nv = @rttable.v_idx.length
153
+ while (@rttable.vnode_balance(@nid) == :less && count < nv) do
154
+ count += 1
155
+ break unless acquire_vnode
156
+ end
157
+ @log.info("acquire_vnodes has done.")
158
+ rescue => e
159
+ @log.error("#{e}\n#{$@}")
160
+ end
161
+
162
+ def acquire_vnode
163
+ widthout_nodes = @rttable.nodes
164
+
165
+ unless @stats.enabled_repetition_host_in_routing
166
+ myhost = @stats.ap_str.split(/[:_]/)[0]
167
+ widthout_nodes.delete_if{|nid| nid.split(/[:_]/)[0] != myhost }
168
+ else
169
+ widthout_nodes = [@stats.ap_str]
170
+ end
171
+
172
+ vn, nodes = @rttable.sample_vnode(widthout_nodes)
173
+ unless vn
174
+ @log.warn("acquire_vnode:sample_vnode dose not found")
175
+ return false
176
+ end
177
+ #
178
+ # tunning point
179
+ # sleep 0.1
180
+ #
181
+ req_push_a_vnode(vn, nodes[0], rand(@rttable.rn) == 0)
182
+ true
183
+ end
184
+
185
+ end # module BackgroundCommandReceiver
186
+
187
+ end # module Command
188
+ end # module Roma
@@ -0,0 +1,117 @@
1
+ require 'roma/stats'
2
+ require 'roma/command/util_command_receiver'
3
+
4
+ module Roma
5
+ module Command
6
+
7
+ module MultiHashCommandReceiver
8
+
9
+ # defhash hashname
10
+ def ev_defhash(s)
11
+ if s.length!=2
12
+ send_data("CLIENT_ERROR usage:defhash hashname\r\n")
13
+ return
14
+ end
15
+ @defhash=s[1]
16
+ send_data("STORED\r\n")
17
+ end
18
+
19
+ # hashlist
20
+ def ev_hashlist(s)
21
+ ret=''
22
+ @storages.each_key{|hn| ret << hn << ' ' }
23
+ send_data("#{ret[0...-1]}\r\n")
24
+ end
25
+
26
+ # createhash hashname
27
+ def ev_createhash(s)
28
+ if s.length != 2
29
+ send_data("CLIENT_ERROR usage:createhash hashname\r\n")
30
+ return
31
+ end
32
+ res = broadcast_cmd("rcreatehash #{s[1]}\r\n")
33
+ res[@stats.ap_str] = createhash(s[1])
34
+ send_data("#{res.inspect}\r\n")
35
+ end
36
+
37
+ # rcreatehash hashname
38
+ def ev_rcreatehash(s)
39
+ if s.length != 2
40
+ send_data("CLIENT_ERROR usage:createhash hashname\r\n")
41
+ return
42
+ end
43
+ send_data("#{createhash(s[1])}\r\n")
44
+ end
45
+
46
+ def createhash(hname)
47
+ if @storages.key?(hname)
48
+ return "SERVER_ERROR #{hname} already exists."
49
+ end
50
+ st = Roma::Config::STORAGE_CLASS.new
51
+ st.storage_path = "#{@stats.ap_str}/#{hname}"
52
+ st.vn_list = @rttable.vnodes
53
+ st.divnum = Roma::Config::STORAGE_DIVNUM
54
+ st.option = Roma::Config::STORAGE_OPTION
55
+ @storages[hname] = st
56
+ @storages[hname].opendb
57
+ @log.info("createhash #{hname}")
58
+ return "CREATED"
59
+ rescue =>e
60
+ @log.error("#{e}")
61
+ end
62
+ private :createhash
63
+
64
+ # deletehash hashname
65
+ def ev_deletehash(s)
66
+ if s.length != 2
67
+ send_data("CLIENT_ERROR usage:deletehash hashname\r\n")
68
+ return
69
+ end
70
+ res = broadcast_cmd("rdeletehash #{s[1]}\r\n")
71
+ res[@stats.ap_str] = deletehash(s[1])
72
+ send_data("#{res.inspect}\r\n")
73
+ end
74
+
75
+ # rdeletehash hashname
76
+ def ev_rdeletehash(s)
77
+ if s.length != 2
78
+ send_data("CLIENT_ERROR usage:rdeletehash hashname\r\n")
79
+ return
80
+ end
81
+ send_data("#{deletehash(s[1])}\r\n")
82
+ end
83
+
84
+ def deletehash(hname)
85
+ unless @storages.key?(hname)
86
+ return "SERVER_ERROR #{hname} dose not exists."
87
+ end
88
+ if hname == 'roma'
89
+ return "SERVER_ERROR the hash name of 'roma' can't delete."
90
+ end
91
+ st = @storages[hname]
92
+ @storages.delete(hname)
93
+ st.closedb
94
+ rm_rf("#{@stats.ap_str}/#{hname}")
95
+ @log.info("deletehash #{hname}")
96
+ return "DELETED"
97
+ rescue =>e
98
+ @log.error("#{e}")
99
+ end
100
+ private :deletehash
101
+
102
+ # looked like a "rm -rf" command
103
+ def rm_rf(fname)
104
+ return unless File.exists?(fname)
105
+ if File::directory?(fname)
106
+ Dir["#{fname}/*"].each{|f| rm_rf(f) }
107
+ Dir.rmdir(fname)
108
+ else
109
+ File.delete(fname)
110
+ end
111
+ end
112
+ private :rm_rf
113
+
114
+ end # MultiHashCommandReceiver
115
+
116
+ end # module Command
117
+ end # module Roma
@@ -0,0 +1,287 @@
1
+ require 'roma/stats'
2
+ require 'roma/version'
3
+ require 'roma/event/handler'
4
+ require 'roma/messaging/con_pool'
5
+ require 'roma/command/bg_command_receiver'
6
+ require 'roma/command/rt_command_receiver'
7
+ require 'roma/command/st_command_receiver'
8
+ require 'roma/command/util_command_receiver'
9
+ require 'roma/command/mh_command_receiver'
10
+
11
+ module Roma
12
+ module Command
13
+
14
+ class Receiver < Roma::Event::Handler
15
+
16
+ include BackgroundCommandReceiver
17
+ include RoutingCommandReceiver
18
+ include StorageCommandReceiver
19
+ include UtilCommandReceiver
20
+ include MultiHashCommandReceiver
21
+
22
+ def initialize(storages, rttable)
23
+ super(storages, rttable)
24
+ @stats = Roma::Stats.instance
25
+ @nid = @stats.ap_str
26
+ @defhash = 'roma'
27
+ end
28
+
29
+ # balse [reason]
30
+ def ev_balse(s)
31
+ send_data("Are you sure?(yes/no)\r\n")
32
+ if gets != "yes\r\n"
33
+ close_connection_after_writing
34
+ return
35
+ end
36
+
37
+ if s.length == 2
38
+ @log.info("Receive a balse #{s[1]}")
39
+ else
40
+ @log.info("Receive a balse command.")
41
+ end
42
+ @rttable.enabled_failover = false
43
+ res = broadcast_cmd("rbalse\r\n")
44
+ send_data("#{res.inspect}\r\n")
45
+ close_connection_after_writing
46
+ @stop_event_loop = true
47
+ end
48
+
49
+ # rbalse [reason]
50
+ def ev_rbalse(s)
51
+ if s.length == 2
52
+ @log.info("Receive a rbalse #{s[1]}")
53
+ else
54
+ @log.info("Receive a rbalse command.")
55
+ end
56
+ @rttable.enabled_failover = false
57
+ send_data("BYE\r\n")
58
+ close_connection_after_writing
59
+ @stop_event_loop = true
60
+ end
61
+
62
+ # version
63
+ def ev_version(s)
64
+ send_data("VERSION #{Roma::VERSION}\r\n")
65
+ end
66
+
67
+ # quit
68
+ def ev_quit(s)
69
+ close_connection
70
+ end
71
+
72
+ def ev_whoami(s)
73
+ send_data("#{@stats.name}\r\n")
74
+ end
75
+
76
+ # stats [regexp]
77
+ def ev_stats(s); ev_stat(s); end
78
+
79
+ # stat [regexp]
80
+ def ev_stat(s)
81
+ regexp = s[1] if s.length == 2
82
+ h = {}
83
+ h['version'] = Roma::VERSION
84
+ send_stat_result(nil,h,regexp)
85
+ send_stat_result(nil,Roma::Config.get_stat,regexp)
86
+ send_stat_result(nil,@stats.get_stat,regexp)
87
+ @storages.each{|hname,st|
88
+ send_stat_result("storages[#{hname}].",st.get_stat,regexp)
89
+ }
90
+ send_stat_result(nil,$roma.wb_get_stat,regexp)
91
+ send_stat_result(nil,@rttable.get_stat(@stats.ap_str),regexp)
92
+ send_data("END\r\n")
93
+ end
94
+
95
+ def send_stat_result(prefix,h,regexp = nil)
96
+ h.each{|k,v|
97
+ if prefix
98
+ key = "#{prefix}#{k}"
99
+ else
100
+ key = "#{k}"
101
+ end
102
+ if regexp
103
+ send_data("#{key} #{v}\r\n") if key =~ /#{regexp}/
104
+ else
105
+ send_data("#{key} #{v}\r\n")
106
+ end
107
+ }
108
+ end
109
+ private :send_stat_result
110
+
111
+ # writebehind_rotate [hash_name]
112
+ def ev_writebehind_rotate(s)
113
+ if s.length < 2
114
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
115
+ end
116
+ res = broadcast_cmd("rwritebehind_rotate #{s[1]}\r\n")
117
+
118
+ if $roma.wb_rotate(s[1])
119
+ res[@stats.ap_str] = "ROTATED"
120
+ else
121
+ res[@stats.ap_str] = "NOT_OPEND"
122
+ end
123
+ send_data("#{res}\r\n")
124
+ end
125
+
126
+ # rwritebehind_rotate [hash_name]
127
+ def ev_rwritebehind_rotate(s)
128
+ if s.length < 2
129
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
130
+ end
131
+ if $roma.wb_rotate(s[1])
132
+ send_data("ROTATED\r\n")
133
+ else
134
+ send_data("NOT_OPEND\r\n")
135
+ end
136
+ end
137
+
138
+ # writebehind_get_path [hash_name]
139
+ def ev_writebehind_get_path(s)
140
+ if s.length < 2
141
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
142
+ end
143
+ res = broadcast_cmd("rwritebehind_get_path #{s[1]}\r\n")
144
+
145
+ ret = $roma.wb_get_path(s[1])
146
+ res[@stats.ap_str] = ret
147
+
148
+ send_data("#{res}\r\n")
149
+ end
150
+
151
+ # rwritebehind_get_path [hash_name]
152
+ def ev_rwritebehind_get_path(s)
153
+ if s.length < 2
154
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
155
+ end
156
+
157
+ ret = $roma.wb_get_path(s[1])
158
+ send_data("#{ret}\r\n")
159
+ end
160
+
161
+ # writebehind_get_current_file [hash_name]
162
+ def ev_writebehind_get_current_file(s)
163
+ if s.length < 2
164
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
165
+ end
166
+ res = broadcast_cmd("rwritebehind_get_current_file #{s[1]}\r\n")
167
+
168
+ ret = $roma.wb_get_current_file_path(s[1])
169
+ if ret
170
+ res[@stats.ap_str] = ret
171
+ else
172
+ res[@stats.ap_str] = "NOT_OPEND"
173
+ end
174
+ send_data("#{res}\r\n")
175
+ end
176
+
177
+ # rwritebehind_get_current_file [hash_name]
178
+ def ev_rwritebehind_get_current_file(s)
179
+ if s.length < 2
180
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
181
+ end
182
+ ret = $roma.wb_get_current_file_path(s[1])
183
+ if ret
184
+ send_data("#{ret}\r\n")
185
+ else
186
+ send_data("NOT_OPEND\r\n")
187
+ end
188
+ end
189
+
190
+ # dcnice command is setting priority for a data-copy thread.
191
+ # a niceness of 1 is the highest priority and 5 is the lowest priority.
192
+ # dcnice <priority:1 to 5>
193
+ def ev_dcnice(s)
194
+ if s.length < 2
195
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
196
+ end
197
+ res = broadcast_cmd("rdcnice #{s[1]}\r\n")
198
+ res[@stats.ap_str] = dcnice(s[1].to_i)
199
+ send_data("#{res}\r\n")
200
+ end
201
+
202
+ def ev_rdcnice(s)
203
+ if s.length < 2
204
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
205
+ end
206
+
207
+ send_data("#{dcnice(s[1].to_i)}\r\n")
208
+ end
209
+
210
+ def ev_restart(s)
211
+ res = broadcast_cmd("rrestart\r\n")
212
+ $roma.eventloop = true
213
+ EventMachine::stop_event_loop
214
+ res[@stats.ap_str] = "RESTARTED"
215
+ send_data("#{res}\r\n")
216
+ end
217
+
218
+ def ev_rrestart(s)
219
+ $roma.eventloop = true
220
+ EventMachine::stop_event_loop
221
+ send_data("RESTARTED\r\n")
222
+ end
223
+
224
+ # set_log_level [ 'debug' | 'info' | 'warn' | 'error' ]
225
+ def ev_set_log_level(s)
226
+ if s.length < 2
227
+ return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
228
+ end
229
+
230
+ case s[1].downcase
231
+ when 'debug'
232
+ @log.level = Roma::Logging::RLogger::Severity::DEBUG
233
+ when 'info'
234
+ @log.level = Roma::Logging::RLogger::Severity::INFO
235
+ when 'warn'
236
+ @log.level = Roma::Logging::RLogger::Severity::WARN
237
+ when 'error'
238
+ @log.level = Roma::Logging::RLogger::Severity::ERROR
239
+ else
240
+ return send_data("CLIENT_ERROR no match log-level string\r\n")
241
+ end
242
+ send_data("STORED\r\n")
243
+ end
244
+
245
+ private
246
+
247
+ def dcnice(p)
248
+ case(p)
249
+ when 1 # highest priority
250
+ @stats.stream_copy_wait_param = 0.001
251
+ @storages.each_value{|st|
252
+ st.each_vn_dump_sleep = 0.001
253
+ st.each_vn_dump_sleep_count = 1000
254
+ }
255
+ when 2
256
+ @stats.stream_copy_wait_param = 0.005
257
+ @storages.each_value{|st|
258
+ st.each_vn_dump_sleep = 0.005
259
+ st.each_vn_dump_sleep_count = 100
260
+ }
261
+ when 3 # default priority
262
+ @stats.stream_copy_wait_param = 0.01
263
+ @storages.each_value{|st|
264
+ st.each_vn_dump_sleep = 0.001
265
+ st.each_vn_dump_sleep_count = 10
266
+ }
267
+ when 4
268
+ @stats.stream_copy_wait_param = 0.01
269
+ @storages.each_value{|st|
270
+ st.each_vn_dump_sleep = 0.005
271
+ st.each_vn_dump_sleep_count = 10
272
+ }
273
+ when 5 # lowest priority
274
+ @stats.stream_copy_wait_param = 0.01
275
+ @storages.each_value{|st|
276
+ st.each_vn_dump_sleep = 0.01
277
+ st.each_vn_dump_sleep_count = 10
278
+ }
279
+ else
280
+ return "CLIENT_ERROR You sholud input a priority from 1 to 5."
281
+ end
282
+ "STORED"
283
+ end
284
+ end # class Receiver < Roma::Event::Handler
285
+
286
+ end # module Command
287
+ end # module Roma