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
@@ -0,0 +1,64 @@
|
|
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/util_command_receiver'
|
8
|
+
require 'roma/command/mh_command_receiver'
|
9
|
+
require 'roma/command/sys_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 UtilCommandReceiver
|
19
|
+
include MultiHashCommandReceiver
|
20
|
+
include SystemCommandReceiver
|
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
|
+
def self.mk_starting_evlist
|
30
|
+
Event::Handler.ev_list.clear
|
31
|
+
each_system_commands{|m|
|
32
|
+
Event::Handler.ev_list[m.to_s[3..-1]] = m
|
33
|
+
Event::Handler.system_commands[m.to_s[3..-1]] = nil
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.each_system_commands
|
38
|
+
methods = RoutingCommandReceiver::public_instance_methods
|
39
|
+
methods << BackgroundCommandReceiver::public_instance_methods
|
40
|
+
methods << SystemCommandReceiver::public_instance_methods
|
41
|
+
|
42
|
+
if Receiver::public_instance_methods.include?(:ev_eval)
|
43
|
+
methods << :ev_eval
|
44
|
+
end
|
45
|
+
methods.flatten.each{|m|
|
46
|
+
yield m if m.to_s.start_with?('ev_')
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.mk_evlist
|
51
|
+
each_system_commands{|m|
|
52
|
+
Event::Handler.system_commands[m.to_s[3..-1]] = nil
|
53
|
+
}
|
54
|
+
Receiver::public_instance_methods.each{|m|
|
55
|
+
if m.to_s.start_with?('ev_')
|
56
|
+
Event::Handler.ev_list[m.to_s[3..-1]] = m
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
end # class Receiver < Roma::Event::Handler
|
62
|
+
|
63
|
+
end # module Command
|
64
|
+
end # module Roma
|
@@ -34,7 +34,7 @@ module Roma
|
|
34
34
|
send_data("CREATED\r\n")
|
35
35
|
end
|
36
36
|
|
37
|
-
# routingdump [yaml|json|yamlbytes]\r\n
|
37
|
+
# routingdump [yaml|json|yamlbytes|bin]\r\n
|
38
38
|
def ev_routingdump(s)
|
39
39
|
if s.length == 1
|
40
40
|
dmp = @rttable.dump
|
@@ -48,6 +48,11 @@ module Roma
|
|
48
48
|
elsif s[1] == 'yamlbytes'
|
49
49
|
dmp = @rttable.dump_yaml
|
50
50
|
send_data("#{dmp.length + 7}\r\nEND\r\n")
|
51
|
+
elsif s[1] == 'bin'
|
52
|
+
dmp = @rttable.dump_binary
|
53
|
+
send_data("#{dmp.length}\r\n#{dmp}\r\nEND\r\n")
|
54
|
+
else
|
55
|
+
send_data("CLIENT_ERROR\r\n")
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
@@ -0,0 +1,609 @@
|
|
1
|
+
|
2
|
+
module Roma
|
3
|
+
module Command
|
4
|
+
|
5
|
+
module SystemCommandReceiver
|
6
|
+
|
7
|
+
# balse [reason]
|
8
|
+
def ev_balse(s)
|
9
|
+
send_data("Are you sure?(yes/no)\r\n")
|
10
|
+
if gets != "yes\r\n"
|
11
|
+
close_connection_after_writing
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
if s.length == 2
|
16
|
+
@log.info("Receive a balse #{s[1]}")
|
17
|
+
else
|
18
|
+
@log.info("Receive a balse command.")
|
19
|
+
end
|
20
|
+
@rttable.enabled_failover = false
|
21
|
+
res = broadcast_cmd("rbalse\r\n")
|
22
|
+
send_data("#{res.inspect}\r\n")
|
23
|
+
close_connection_after_writing
|
24
|
+
@stop_event_loop = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# rbalse [reason]
|
28
|
+
def ev_rbalse(s)
|
29
|
+
if s.length == 2
|
30
|
+
@log.info("Receive a rbalse #{s[1]}")
|
31
|
+
else
|
32
|
+
@log.info("Receive a rbalse command.")
|
33
|
+
end
|
34
|
+
@rttable.enabled_failover = false
|
35
|
+
send_data("BYE\r\n")
|
36
|
+
close_connection_after_writing
|
37
|
+
@stop_event_loop = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# shutdown_instance [node-id]
|
41
|
+
def ev_shutdown_instance(s)
|
42
|
+
if s.length != 2
|
43
|
+
send_data("usage:shutdown_instance [node-id]\r\n")
|
44
|
+
else
|
45
|
+
if s[1] == @stats.ap_str
|
46
|
+
@rttable.enabled_failover = false
|
47
|
+
send_data("BYE\r\n")
|
48
|
+
@stop_event_loop = true
|
49
|
+
close_connection_after_writing
|
50
|
+
else
|
51
|
+
send_data("invalid [node-id]\r\n")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# version
|
57
|
+
def ev_version(s)
|
58
|
+
send_data("VERSION ROMA-#{Roma::VERSION}\r\n")
|
59
|
+
end
|
60
|
+
|
61
|
+
# quit
|
62
|
+
def ev_quit(s)
|
63
|
+
close_connection
|
64
|
+
end
|
65
|
+
|
66
|
+
def ev_whoami(s)
|
67
|
+
send_data("#{@stats.name}\r\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
# stats [regexp]
|
71
|
+
def ev_stats(s); ev_stat(s); end
|
72
|
+
|
73
|
+
# stat [regexp]
|
74
|
+
def ev_stat(s)
|
75
|
+
regexp = s[1] if s.length == 2
|
76
|
+
h = {}
|
77
|
+
h['version'] = Roma::VERSION
|
78
|
+
send_stat_result(nil,h,regexp)
|
79
|
+
send_stat_result(nil,get_config_stat,regexp)
|
80
|
+
send_stat_result(nil,@stats.get_stat,regexp)
|
81
|
+
@storages.each{|hname,st|
|
82
|
+
send_stat_result("storages[#{hname}].",st.get_stat,regexp)
|
83
|
+
}
|
84
|
+
send_stat_result(nil,$roma.wb_get_stat,regexp)
|
85
|
+
send_stat_result(nil,@rttable.get_stat(@stats.ap_str),regexp)
|
86
|
+
send_stat_result(nil,conn_get_stat,regexp)
|
87
|
+
send_data("END\r\n")
|
88
|
+
end
|
89
|
+
|
90
|
+
def send_stat_result(prefix,h,regexp = nil)
|
91
|
+
h.each{|k,v|
|
92
|
+
if prefix
|
93
|
+
key = "#{prefix}#{k}"
|
94
|
+
else
|
95
|
+
key = "#{k}"
|
96
|
+
end
|
97
|
+
if regexp
|
98
|
+
send_data("#{key} #{v}\r\n") if key =~ /#{regexp}/
|
99
|
+
else
|
100
|
+
send_data("#{key} #{v}\r\n")
|
101
|
+
end
|
102
|
+
}
|
103
|
+
end
|
104
|
+
private :send_stat_result
|
105
|
+
|
106
|
+
# writebehind_rotate [hash_name]
|
107
|
+
def ev_writebehind_rotate(s)
|
108
|
+
if s.length < 2
|
109
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
110
|
+
end
|
111
|
+
res = broadcast_cmd("rwritebehind_rotate #{s[1]}\r\n")
|
112
|
+
|
113
|
+
if $roma.wb_rotate(s[1])
|
114
|
+
res[@stats.ap_str] = "ROTATED"
|
115
|
+
else
|
116
|
+
res[@stats.ap_str] = "NOT_OPEND"
|
117
|
+
end
|
118
|
+
send_data("#{res}\r\n")
|
119
|
+
end
|
120
|
+
|
121
|
+
# rwritebehind_rotate [hash_name]
|
122
|
+
def ev_rwritebehind_rotate(s)
|
123
|
+
if s.length < 2
|
124
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
125
|
+
end
|
126
|
+
if $roma.wb_rotate(s[1])
|
127
|
+
send_data("ROTATED\r\n")
|
128
|
+
else
|
129
|
+
send_data("NOT_OPEND\r\n")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# writebehind_get_path [hash_name]
|
134
|
+
def ev_writebehind_get_path(s)
|
135
|
+
if s.length < 2
|
136
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
137
|
+
end
|
138
|
+
res = broadcast_cmd("rwritebehind_get_path #{s[1]}\r\n")
|
139
|
+
|
140
|
+
ret = $roma.wb_get_path(s[1])
|
141
|
+
res[@stats.ap_str] = ret
|
142
|
+
|
143
|
+
send_data("#{res}\r\n")
|
144
|
+
end
|
145
|
+
|
146
|
+
# rwritebehind_get_path [hash_name]
|
147
|
+
def ev_rwritebehind_get_path(s)
|
148
|
+
if s.length < 2
|
149
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
150
|
+
end
|
151
|
+
|
152
|
+
ret = $roma.wb_get_path(s[1])
|
153
|
+
send_data("#{ret}\r\n")
|
154
|
+
end
|
155
|
+
|
156
|
+
# writebehind_get_current_file [hash_name]
|
157
|
+
def ev_writebehind_get_current_file(s)
|
158
|
+
if s.length < 2
|
159
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
160
|
+
end
|
161
|
+
res = broadcast_cmd("rwritebehind_get_current_file #{s[1]}\r\n")
|
162
|
+
|
163
|
+
ret = $roma.wb_get_current_file_path(s[1])
|
164
|
+
if ret
|
165
|
+
res[@stats.ap_str] = ret
|
166
|
+
else
|
167
|
+
res[@stats.ap_str] = "NOT_OPEND"
|
168
|
+
end
|
169
|
+
send_data("#{res}\r\n")
|
170
|
+
end
|
171
|
+
|
172
|
+
# rwritebehind_get_current_file [hash_name]
|
173
|
+
def ev_rwritebehind_get_current_file(s)
|
174
|
+
if s.length < 2
|
175
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
176
|
+
end
|
177
|
+
ret = $roma.wb_get_current_file_path(s[1])
|
178
|
+
if ret
|
179
|
+
send_data("#{ret}\r\n")
|
180
|
+
else
|
181
|
+
send_data("NOT_OPEND\r\n")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# dcnice command is setting priority for a data-copy thread.
|
186
|
+
# a niceness of 1 is the highest priority and 5 is the lowest priority.
|
187
|
+
# dcnice <priority:1 to 5>
|
188
|
+
def ev_dcnice(s)
|
189
|
+
if s.length < 2
|
190
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
191
|
+
end
|
192
|
+
res = broadcast_cmd("rdcnice #{s[1]}\r\n")
|
193
|
+
res[@stats.ap_str] = dcnice(s[1].to_i)
|
194
|
+
send_data("#{res}\r\n")
|
195
|
+
end
|
196
|
+
|
197
|
+
def ev_rdcnice(s)
|
198
|
+
if s.length < 2
|
199
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
200
|
+
end
|
201
|
+
|
202
|
+
send_data("#{dcnice(s[1].to_i)}\r\n")
|
203
|
+
end
|
204
|
+
|
205
|
+
def ev_restart(s)
|
206
|
+
res = broadcast_cmd("rrestart\r\n")
|
207
|
+
$roma.eventloop = true
|
208
|
+
@rttable.enabled_failover = false
|
209
|
+
Messaging::ConPool.instance.close_all
|
210
|
+
Event::EMConPool::instance.close_all
|
211
|
+
EventMachine::stop_event_loop
|
212
|
+
res[@stats.ap_str] = "RESTARTED"
|
213
|
+
send_data("#{res}\r\n")
|
214
|
+
end
|
215
|
+
|
216
|
+
def ev_rrestart(s)
|
217
|
+
$roma.eventloop = true
|
218
|
+
@rttable.enabled_failover = false
|
219
|
+
Messaging::ConPool.instance.close_all
|
220
|
+
Event::EMConPool::instance.close_all
|
221
|
+
EventMachine::stop_event_loop
|
222
|
+
send_data("RESTARTED\r\n")
|
223
|
+
end
|
224
|
+
|
225
|
+
# set_log_level [ 'debug' | 'info' | 'warn' | 'error' ]
|
226
|
+
def ev_set_log_level(s)
|
227
|
+
if s.length < 2
|
228
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
229
|
+
end
|
230
|
+
|
231
|
+
case s[1].downcase
|
232
|
+
when 'debug'
|
233
|
+
@log.level = Roma::Logging::RLogger::Severity::DEBUG
|
234
|
+
when 'info'
|
235
|
+
@log.level = Roma::Logging::RLogger::Severity::INFO
|
236
|
+
when 'warn'
|
237
|
+
@log.level = Roma::Logging::RLogger::Severity::WARN
|
238
|
+
when 'error'
|
239
|
+
@log.level = Roma::Logging::RLogger::Severity::ERROR
|
240
|
+
else
|
241
|
+
return send_data("CLIENT_ERROR no match log-level string\r\n")
|
242
|
+
end
|
243
|
+
send_data("STORED\r\n")
|
244
|
+
end
|
245
|
+
|
246
|
+
# out <key> <vn>
|
247
|
+
def ev_out(s)
|
248
|
+
key,hname = s[1].split("\e")
|
249
|
+
hname ||= @defhash
|
250
|
+
if s.length >= 3
|
251
|
+
vn = s[2].to_i
|
252
|
+
else
|
253
|
+
d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits
|
254
|
+
vn = @rttable.get_vnode_id(d)
|
255
|
+
end
|
256
|
+
res = @storages[hname].out(vn, key, 0)
|
257
|
+
@stats.out_message_count += 1
|
258
|
+
unless res
|
259
|
+
return send_data("NOT_DELETED\r\n")
|
260
|
+
end
|
261
|
+
send_data("DELETED\r\n")
|
262
|
+
end
|
263
|
+
|
264
|
+
# rset <key> <hash value> <timelimit> <length>
|
265
|
+
# "set" means "store this data".
|
266
|
+
# <command name> <key> <digest> <exptime> <bytes> [noreply]\r\n
|
267
|
+
# <data block>\r\n
|
268
|
+
def ev_rset(s)
|
269
|
+
key,hname = s[1].split("\e")
|
270
|
+
hname ||= @defhash
|
271
|
+
d = s[2].to_i
|
272
|
+
d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits if d == 0
|
273
|
+
data = read_bytes(s[5].to_i)
|
274
|
+
read_bytes(2)
|
275
|
+
vn = @rttable.get_vnode_id(d)
|
276
|
+
unless @storages.key?(hname)
|
277
|
+
send_data("SERVER_ERROR #{hname} dose not exists.\r\n")
|
278
|
+
return
|
279
|
+
end
|
280
|
+
if @storages[hname].rset(vn, key, d, s[3].to_i, s[4].to_i, data)
|
281
|
+
send_data("STORED\r\n")
|
282
|
+
else
|
283
|
+
@log.error("rset NOT_STORED:#{@storages[hname].error_message} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
|
284
|
+
send_data("NOT_STORED\r\n")
|
285
|
+
end
|
286
|
+
@stats.redundant_count += 1
|
287
|
+
end
|
288
|
+
|
289
|
+
# <command name> <key> <digest> <exptime> <bytes> [noreply]\r\n
|
290
|
+
# <compressed data block>\r\n
|
291
|
+
def ev_rzset(s)
|
292
|
+
key,hname = s[1].split("\e")
|
293
|
+
hname ||= @defhash
|
294
|
+
d = s[2].to_i
|
295
|
+
d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits if d == 0
|
296
|
+
zdata = read_bytes(s[5].to_i)
|
297
|
+
read_bytes(2)
|
298
|
+
vn = @rttable.get_vnode_id(d)
|
299
|
+
unless @storages.key?(hname)
|
300
|
+
send_data("SERVER_ERROR #{hname} dose not exists.\r\n")
|
301
|
+
return
|
302
|
+
end
|
303
|
+
|
304
|
+
data = Zlib::Inflate.inflate(zdata)
|
305
|
+
# @log.debug("data = #{data}")
|
306
|
+
if @storages[hname].rset(vn, key, d, s[3].to_i, s[4].to_i, data)
|
307
|
+
send_data("STORED\r\n")
|
308
|
+
else
|
309
|
+
@log.error("rzset NOT_STORED:#{@storages[hname].error_message} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
|
310
|
+
send_data("NOT_STORED\r\n")
|
311
|
+
end
|
312
|
+
@stats.redundant_count += 1
|
313
|
+
rescue Zlib::DataError => e
|
314
|
+
@log.error("rzset NOT_STORED:#{e} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
|
315
|
+
send_data("NOT_STORED\r\n")
|
316
|
+
end
|
317
|
+
|
318
|
+
def ev_forcedly_start(s)
|
319
|
+
@log.info("ROMA forcedly start.")
|
320
|
+
AsyncProcess::queue.clear
|
321
|
+
@rttable.enabled_failover = true
|
322
|
+
Command::Receiver::mk_evlist
|
323
|
+
$roma.startup = false
|
324
|
+
send_data("STARTED\r\n")
|
325
|
+
end
|
326
|
+
|
327
|
+
# switch_failover <on|off>
|
328
|
+
def ev_switch_failover(s)
|
329
|
+
if s.length != 2
|
330
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
331
|
+
end
|
332
|
+
res = broadcast_cmd("rswitch_failover #{s[1]}\r\n")
|
333
|
+
if s[1] == 'on'
|
334
|
+
Messaging::ConPool.instance.close_all
|
335
|
+
Event::EMConPool::instance.close_all
|
336
|
+
@rttable.enabled_failover = true
|
337
|
+
@log.info("failover enabled")
|
338
|
+
res[@stats.ap_str] = "ENABLED"
|
339
|
+
elsif s[1] == 'off'
|
340
|
+
@rttable.enabled_failover = false
|
341
|
+
@log.info("failover disabled")
|
342
|
+
res[@stats.ap_str] = "DISABLED"
|
343
|
+
else
|
344
|
+
res[@stats.ap_str] = "NOTSWITCHED"
|
345
|
+
end
|
346
|
+
send_data("#{res}\r\n")
|
347
|
+
end
|
348
|
+
|
349
|
+
# rswitch_failover <on|off>
|
350
|
+
def ev_rswitch_failover(s)
|
351
|
+
if s.length != 2
|
352
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
353
|
+
end
|
354
|
+
if s[1] == 'on'
|
355
|
+
Messaging::ConPool.instance.close_all
|
356
|
+
Event::EMConPool::instance.close_all
|
357
|
+
@rttable.enabled_failover = true
|
358
|
+
@log.info("failover enabled")
|
359
|
+
return send_data("ENABLED\r\n")
|
360
|
+
elsif s[1] == 'off'
|
361
|
+
@rttable.enabled_failover = false
|
362
|
+
@log.info("failover disabled")
|
363
|
+
return send_data("DISABLED\r\n")
|
364
|
+
else
|
365
|
+
send_data("NOTSWITCHED\r\n")
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
def ev_set_continuous_limit(s)
|
370
|
+
if s.length < 2
|
371
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
372
|
+
end
|
373
|
+
|
374
|
+
res = broadcast_cmd("rset_continuous_limit #{s[1]}\r\n")
|
375
|
+
|
376
|
+
if Event::Handler.set_ccl(s[1])
|
377
|
+
res[@stats.ap_str] = "STORED"
|
378
|
+
else
|
379
|
+
res[@stats.ap_str] = "NOT_STORED"
|
380
|
+
end
|
381
|
+
send_data("#{res}\r\n")
|
382
|
+
end
|
383
|
+
|
384
|
+
def ev_rset_continuous_limit(s)
|
385
|
+
if s.length < 2
|
386
|
+
return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
|
387
|
+
end
|
388
|
+
if Event::Handler.set_ccl(s[1])
|
389
|
+
send_data("STORED\r\n")
|
390
|
+
else
|
391
|
+
send_data("NOT_STORED\r\n")
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
# set_connection_pool_maxlength <length>
|
396
|
+
# set to max length of the connection pool
|
397
|
+
def ev_set_connection_pool_maxlength(s)
|
398
|
+
if s.length != 2
|
399
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
400
|
+
end
|
401
|
+
if s[1].to_i < 1
|
402
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
403
|
+
end
|
404
|
+
|
405
|
+
res = broadcast_cmd("rset_connection_pool_maxlength #{s[1]}\r\n")
|
406
|
+
Messaging::ConPool.instance.maxlength = s[1].to_i
|
407
|
+
res[@stats.ap_str] = "STORED"
|
408
|
+
send_data("#{res}\r\n")
|
409
|
+
end
|
410
|
+
|
411
|
+
# rset_connection_pool_maxlength <length>
|
412
|
+
def ev_rset_connection_pool_maxlength(s)
|
413
|
+
if s.length != 2
|
414
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
415
|
+
end
|
416
|
+
if s[1].to_i < 1
|
417
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
418
|
+
end
|
419
|
+
|
420
|
+
Messaging::ConPool.instance.maxlength = s[1].to_i
|
421
|
+
send_data("STORED\r\n")
|
422
|
+
end
|
423
|
+
|
424
|
+
# set_connection_pool_maxlength <length>
|
425
|
+
# set to max length of the connection pool
|
426
|
+
def ev_set_emconnection_pool_maxlength(s)
|
427
|
+
if s.length != 2
|
428
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
429
|
+
end
|
430
|
+
if s[1].to_i < 1
|
431
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
432
|
+
end
|
433
|
+
|
434
|
+
res = broadcast_cmd("rset_emconnection_pool_maxlength #{s[1]}\r\n")
|
435
|
+
Event::EMConPool.instance.maxlength = s[1].to_i
|
436
|
+
res[@stats.ap_str] = "STORED"
|
437
|
+
send_data("#{res}\r\n")
|
438
|
+
end
|
439
|
+
|
440
|
+
# rset_connection_pool_maxlength <length>
|
441
|
+
def ev_rset_emconnection_pool_maxlength(s)
|
442
|
+
if s.length != 2
|
443
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
444
|
+
end
|
445
|
+
if s[1].to_i < 1
|
446
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
447
|
+
end
|
448
|
+
|
449
|
+
Event::EMConPool.instance.maxlength = s[1].to_i
|
450
|
+
send_data("STORED\r\n")
|
451
|
+
end
|
452
|
+
|
453
|
+
# set_accepted_connection_expire_time <sec>
|
454
|
+
# set to expired time(sec) for accepted connections
|
455
|
+
def ev_set_accepted_connection_expire_time(s)
|
456
|
+
if s.length != 2
|
457
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
458
|
+
end
|
459
|
+
|
460
|
+
res = broadcast_cmd("rset_accepted_connection_expire_time #{s[1]}\r\n")
|
461
|
+
Event::Handler::connection_expire_time = s[1].to_i
|
462
|
+
res[@stats.ap_str] = "STORED"
|
463
|
+
send_data("#{res}\r\n")
|
464
|
+
end
|
465
|
+
|
466
|
+
# rset_accepted_connection_expire_time <sec>
|
467
|
+
def ev_rset_accepted_connection_expire_time(s)
|
468
|
+
if s.length != 2
|
469
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
470
|
+
end
|
471
|
+
Event::Handler::connection_expire_time = s[1].to_i
|
472
|
+
send_data("STORED\r\n")
|
473
|
+
end
|
474
|
+
|
475
|
+
# set_hilatency_warn_time <sec>
|
476
|
+
# set to threshold of warn message into a log when hilatency occured in a command.
|
477
|
+
def ev_set_hilatency_warn_time(s)
|
478
|
+
if s.length != 2
|
479
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
480
|
+
end
|
481
|
+
if s[1].to_f <= 0
|
482
|
+
return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
|
483
|
+
end
|
484
|
+
|
485
|
+
res = broadcast_cmd("rset_hilatency_warn_time #{s[1]}\r\n")
|
486
|
+
@stats.hilatency_warn_time = s[1].to_f
|
487
|
+
res[@stats.ap_str] = "STORED"
|
488
|
+
send_data("#{res}\r\n")
|
489
|
+
end
|
490
|
+
|
491
|
+
# rset_hilatency_warn_time <sec>
|
492
|
+
def ev_rset_hilatency_warn_time(s)
|
493
|
+
if s.length != 2
|
494
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
495
|
+
end
|
496
|
+
if s[1].to_f <= 0
|
497
|
+
return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
|
498
|
+
end
|
499
|
+
@stats.hilatency_warn_time = s[1].to_f
|
500
|
+
send_data("STORED\r\n")
|
501
|
+
end
|
502
|
+
|
503
|
+
# wb_command_map <hash string>
|
504
|
+
# ex.
|
505
|
+
# {:set=>1,:append=>2,:delete=>3}
|
506
|
+
def ev_wb_command_map(s)
|
507
|
+
if s.length < 2
|
508
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
509
|
+
end
|
510
|
+
map = {}
|
511
|
+
cmd = s[1..-1].join
|
512
|
+
if cmd =~ /^\{(.+)\}$/
|
513
|
+
$1.split(',').each do |kv|
|
514
|
+
k, v = kv.split('=>')
|
515
|
+
map[k[1..-1].to_sym] = v.to_i if v && k[0]==':'
|
516
|
+
end
|
517
|
+
|
518
|
+
res = broadcast_cmd("rwb_command_map #{s[1..-1].join}\r\n")
|
519
|
+
@stats.wb_command_map = map
|
520
|
+
res[@stats.ap_str] = map.inspect
|
521
|
+
send_data("#{res}\r\n")
|
522
|
+
else
|
523
|
+
send_data("CLIENT_ERROR hash string parse error\r\n")
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
def ev_rwb_command_map(s)
|
528
|
+
if s.length < 2
|
529
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
530
|
+
end
|
531
|
+
map = {}
|
532
|
+
cmd = s[1..-1].join
|
533
|
+
if cmd =~ /^\{(.+)\}$/
|
534
|
+
$1.split(',').each do |kv|
|
535
|
+
k, v = kv.split('=>')
|
536
|
+
map[k[1..-1].to_sym] = v.to_i if v && k[0]==':'
|
537
|
+
end
|
538
|
+
@stats.wb_command_map = map
|
539
|
+
send_data("#{map}\r\n")
|
540
|
+
else
|
541
|
+
send_data("CLIENT_ERROR hash string parse error\r\n")
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
private
|
546
|
+
|
547
|
+
def dcnice(p)
|
548
|
+
case(p)
|
549
|
+
when 1 # highest priority
|
550
|
+
@stats.stream_copy_wait_param = 0.001
|
551
|
+
@storages.each_value{|st|
|
552
|
+
st.each_vn_dump_sleep = 0.001
|
553
|
+
st.each_vn_dump_sleep_count = 1000
|
554
|
+
}
|
555
|
+
when 2
|
556
|
+
@stats.stream_copy_wait_param = 0.005
|
557
|
+
@storages.each_value{|st|
|
558
|
+
st.each_vn_dump_sleep = 0.005
|
559
|
+
st.each_vn_dump_sleep_count = 100
|
560
|
+
}
|
561
|
+
when 3 # default priority
|
562
|
+
@stats.stream_copy_wait_param = 0.01
|
563
|
+
@storages.each_value{|st|
|
564
|
+
st.each_vn_dump_sleep = 0.001
|
565
|
+
st.each_vn_dump_sleep_count = 10
|
566
|
+
}
|
567
|
+
when 4
|
568
|
+
@stats.stream_copy_wait_param = 0.01
|
569
|
+
@storages.each_value{|st|
|
570
|
+
st.each_vn_dump_sleep = 0.005
|
571
|
+
st.each_vn_dump_sleep_count = 10
|
572
|
+
}
|
573
|
+
when 5 # lowest priority
|
574
|
+
@stats.stream_copy_wait_param = 0.01
|
575
|
+
@storages.each_value{|st|
|
576
|
+
st.each_vn_dump_sleep = 0.01
|
577
|
+
st.each_vn_dump_sleep_count = 10
|
578
|
+
}
|
579
|
+
else
|
580
|
+
return "CLIENT_ERROR You sholud input a priority from 1 to 5."
|
581
|
+
end
|
582
|
+
@stats.dcnice = p
|
583
|
+
"STORED"
|
584
|
+
end
|
585
|
+
|
586
|
+
def get_config_stat
|
587
|
+
ret = {}
|
588
|
+
ret['config.DEFAULT_LOST_ACTION'] = Config::DEFAULT_LOST_ACTION
|
589
|
+
ret['config.LOG_SHIFT_AGE'] = Config::LOG_SHIFT_AGE
|
590
|
+
ret['config.LOG_SHIFT_SIZE'] = Config::LOG_SHIFT_SIZE
|
591
|
+
ret['config.LOG_PATH'] = File.expand_path(Config::LOG_PATH)
|
592
|
+
ret['config.RTTABLE_PATH'] = File.expand_path(Config::RTTABLE_PATH)
|
593
|
+
ret['config.STORAGE_DELMARK_EXPTIME'] = Config::STORAGE_DELMARK_EXPTIME
|
594
|
+
if Config.const_defined?(:STORAGE_EXCEPTION_ACTION)
|
595
|
+
ret['config.STORAGE_EXCEPTION_ACTION'] = Config::STORAGE_EXCEPTION_ACTION
|
596
|
+
end
|
597
|
+
ret['config.DATACOPY_STREAM_COPY_WAIT_PARAM'] = Config::DATACOPY_STREAM_COPY_WAIT_PARAM
|
598
|
+
ret['config.PLUGIN_FILES'] = Config::PLUGIN_FILES.inspect
|
599
|
+
ret['config.WRITEBEHIND_PATH'] = File.expand_path(Config::WRITEBEHIND_PATH)
|
600
|
+
ret['config.WRITEBEHIND_SHIFT_SIZE'] = Config::WRITEBEHIND_SHIFT_SIZE
|
601
|
+
if Config.const_defined?(:CONNECTION_DESCRIPTOR_TABLE_SIZE)
|
602
|
+
ret['config.CONNECTION_DESCRIPTOR_TABLE_SIZE'] = Config::CONNECTION_DESCRIPTOR_TABLE_SIZE
|
603
|
+
end
|
604
|
+
ret
|
605
|
+
end
|
606
|
+
|
607
|
+
end # module SystemCommandReceiver
|
608
|
+
end # module Command
|
609
|
+
end # module Roma
|