roma 0.8.12 → 0.8.13p1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +34 -1
- data/Gemfile +17 -0
- data/Rakefile +2 -3
- data/ruby/server/lib/roma/async_process.rb +158 -20
- data/ruby/server/lib/roma/command/bg_command_receiver.rb +3 -4
- data/ruby/server/lib/roma/command/rt_command_receiver.rb +133 -5
- data/ruby/server/lib/roma/command/sys_command_receiver.rb +353 -0
- data/ruby/server/lib/roma/command/vn_command_receiver.rb +9 -3
- data/ruby/server/lib/roma/config.rb +6 -0
- data/ruby/server/lib/roma/dns_cache.rb +40 -0
- data/ruby/server/lib/roma/event/con_pool.rb +3 -1
- data/ruby/server/lib/roma/event/handler.rb +18 -3
- data/ruby/server/lib/roma/messaging/con_pool.rb +3 -1
- data/ruby/server/lib/roma/romad.rb +19 -3
- data/ruby/server/lib/roma/routing/cb_rttable.rb +22 -1
- data/ruby/server/lib/roma/routing/random_balancer.rb +76 -0
- data/ruby/server/lib/roma/routing/routing_data.rb +16 -2
- data/ruby/server/lib/roma/routing/rttable.rb +55 -8
- data/ruby/server/lib/roma/stats.rb +32 -0
- data/ruby/server/lib/roma/storage/sqlite3_storage.rb +9 -3
- data/ruby/server/lib/roma/tools/mkconfig.rb +135 -73
- data/ruby/server/lib/roma/tools/mkrecent.rb +3 -4
- data/ruby/server/lib/roma/tools/mkroute.rb +6 -7
- data/ruby/server/lib/roma/tools/multi_commander.rb +3 -4
- data/ruby/server/lib/roma/tools/recoverlost.rb +0 -1
- data/ruby/server/lib/roma/tools/recoverlost_alist.rb +0 -1
- data/ruby/server/lib/roma/tools/recoverlost_lib.rb +10 -11
- data/ruby/server/lib/roma/tools/roma_watcher.rb +0 -1
- data/ruby/server/lib/roma/tools/sample_watcher.rb +3 -4
- data/ruby/server/lib/roma/tools/sample_watcher2.rb +3 -4
- data/ruby/server/lib/roma/tools/sample_watcher3.rb +0 -1
- data/ruby/server/lib/roma/tools/simple_bench.rb +3 -3
- data/ruby/server/lib/roma/tools/simple_bench2.rb +1 -2
- data/ruby/server/lib/roma/tools/ssroute.rb +0 -1
- data/ruby/server/lib/roma/tools/tribunus.rb +5 -6
- data/ruby/server/lib/roma/version.rb +1 -1
- data/ruby/server/lib/roma/write_behind.rb +4 -1
- data/ruby/server/test/rcirb.rb +0 -1
- data/ruby/server/test/t_cpdata.rb +8 -9
- data/ruby/server/test/t_rclient.rb +1 -2
- data/ruby/server/test/t_routing_data.rb +13 -14
- data/ruby/server/test/t_storage.rb +1 -1
- data/ruby/server/test/t_writebehind.rb +29 -30
- metadata +25 -24
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
*0.8.13-p1 (Jan 15 2014)*
|
|
2
|
+
|
|
3
|
+
* add timeout parameter for a vnode copy [junji torii] 0522750
|
|
4
|
+
* remove some debug log [hiroaki-iwase] 94d96dc
|
|
5
|
+
* Add Gemfile. [Hiroki Matsue] 9029bf8
|
|
6
|
+
* Ignore test related files. [Hiroki Matsue] 556a931
|
|
7
|
+
* fix:add rescue in timer_event_1sec [junji torii] 11cc4ea
|
|
8
|
+
|
|
9
|
+
*0.8.13 (Sep 12 2013)*
|
|
10
|
+
|
|
11
|
+
* change target ruby version about encoding problem (upper 1.9.2 => upper 1.9.1) [hiroaki-iwase] e56d2f4
|
|
12
|
+
* modify end message of join. [hiroaki-iwase] a649dfb
|
|
13
|
+
* modify typo [hiroaki-iwase] c47802b
|
|
14
|
+
* fix:for a problem of encording on 1.9.2 [junji torii] 3501622
|
|
15
|
+
* modify ongoing setting changing cmd. [hiroaki-iwase] 190db49
|
|
16
|
+
* Add new async process for calculate latency average & add some commands for change setting. [hiroaki-iwase] 49dc9cb
|
|
17
|
+
* add new function "calculate latency average" [hiroaki-iwase] 40b6266
|
|
18
|
+
* Add command of changing CONNECTION_POOL_EXPTIME & DEFAULT_LOST_ACTION & CONNECTION_DESCRIPTOR_TABLE_SIZE & WRITEBEHIND_SHIFT_SIZE [hiroaki-iwase] de757af
|
|
19
|
+
* add vnode balancing logic [junji torii] bfa16cd
|
|
20
|
+
* add *_rttable_sub_nid commands [junji torii] 8bd4a31
|
|
21
|
+
* add auto_recover function [hiroaki-iwase] 473df72
|
|
22
|
+
* modify message when execute "balse" [hiroaki-iwase] a3d61b1
|
|
23
|
+
* add node-id substitution feature in routingdump command. [junji torii] a3693e8
|
|
24
|
+
* fixed recoverlost_lib's value error [hiroaki-iwase] deb9430
|
|
25
|
+
* add log output(info level) when new wb file was created. [hiroaki-iwase] dcec49a
|
|
26
|
+
* add new function "calculate latency average" [hiroaki-iwase] 4158ccd
|
|
27
|
+
* Add DNS caching function. [Hiroki Matsue] abf4464
|
|
28
|
+
* Modify some default values. Change plugin selecting(plugin_storage.rb is set without question). [hiroaki-iwase] d2542f0
|
|
29
|
+
* add command of changing CONNECTION_EMPOOL_EXPTIME. [hiroaki-iwase] 1d3df93
|
|
30
|
+
* improve mkconfig.rb [hiroaki-iwase] 74be88d
|
|
31
|
+
* remove utf-8 manifesto # -*- coding: utf-8 -*-" # encoding: utf-8 [hiroaki-iwase] d54e30c
|
|
32
|
+
* translate comment JP to ENG [hiroaki-iwase] 1b091fd
|
|
33
|
+
|
|
1
34
|
*0.8.12 (Feb 12 2013)*
|
|
2
35
|
|
|
3
36
|
* refactor: for protocol [Hiroki Matsue] a6f9152
|
|
@@ -171,4 +204,4 @@
|
|
|
171
204
|
* fixed bug in t_rclient.rb. [junji torii] 68880b5
|
|
172
205
|
* support running test with Ruby not named as 'ruby'. [Kouhei Sutou] 6fd1ec2
|
|
173
206
|
|
|
174
|
-
*0.8.0 (Oct 23 2009)*
|
|
207
|
+
*0.8.0 (Oct 23 2009)*
|
data/Gemfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem 'eventmachine'
|
|
4
|
+
|
|
5
|
+
# Back-end storages
|
|
6
|
+
group :tokyocabinet do
|
|
7
|
+
gem 'tokyocabinet', :git => 'https://github.com/roma/tokyocabinet-ruby.git'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
group :gdbm do
|
|
11
|
+
gem 'ffi'
|
|
12
|
+
gem 'gdbm'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
group :sqlite3 do
|
|
16
|
+
gem 'sqlite3'
|
|
17
|
+
end
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
require 'rubygems'
|
|
3
2
|
require 'rake'
|
|
4
3
|
|
|
@@ -40,8 +39,8 @@ EXEC_TABLE = Dir.entries(base + 'bin').reject{ |d| d =~ /^\.+$/ || d =~ /^sample
|
|
|
40
39
|
require File.expand_path(File.join('ruby', 'server', 'lib', 'roma', 'version'), File.dirname(__FILE__))
|
|
41
40
|
VER_NUM = Roma::VERSION
|
|
42
41
|
|
|
43
|
-
if VER_NUM =~ /([0-9.]+)$/
|
|
44
|
-
CURRENT_VERSION = $1
|
|
42
|
+
if VER_NUM =~ /([0-9.p-]+)$/
|
|
43
|
+
CURRENT_VERSION = $1.delete("-")
|
|
45
44
|
else
|
|
46
45
|
CURRENT_VERSION = "0.0.0"
|
|
47
46
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
require 'thread'
|
|
3
2
|
require 'digest/sha1'
|
|
3
|
+
require "timeout"
|
|
4
4
|
|
|
5
5
|
module Roma
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
class AsyncMessage
|
|
8
8
|
attr_accessor :event
|
|
9
9
|
attr_accessor :args
|
|
@@ -34,16 +34,26 @@ module Roma
|
|
|
34
34
|
module AsyncProcess
|
|
35
35
|
|
|
36
36
|
@@async_queue = Queue.new
|
|
37
|
+
@@async_queue_latency = Queue.new
|
|
37
38
|
|
|
38
39
|
def self.queue
|
|
39
40
|
@@async_queue
|
|
40
41
|
end
|
|
41
42
|
|
|
43
|
+
def self.queue_latency
|
|
44
|
+
@@async_queue_latency
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
def start_async_process
|
|
43
48
|
@async_thread = Thread.new{
|
|
44
49
|
async_process_loop
|
|
45
50
|
}
|
|
46
51
|
@async_thread[:name] = __method__
|
|
52
|
+
|
|
53
|
+
@async_thread_latency = Thread.new{
|
|
54
|
+
async_process_loop_for_latency
|
|
55
|
+
}
|
|
56
|
+
@async_thread_latency[:name] = __method__
|
|
47
57
|
rescue =>e
|
|
48
58
|
@log.error("#{e}\n#{$@}")
|
|
49
59
|
end
|
|
@@ -57,6 +67,13 @@ module Roma
|
|
|
57
67
|
sleep 0.1
|
|
58
68
|
end
|
|
59
69
|
@async_thread.exit
|
|
70
|
+
|
|
71
|
+
count = 0
|
|
72
|
+
while @@async_queue_latency.empty? == false && count < 100
|
|
73
|
+
count += 1
|
|
74
|
+
sleep 0.1
|
|
75
|
+
end
|
|
76
|
+
@async_thread_latency.exit
|
|
60
77
|
end
|
|
61
78
|
|
|
62
79
|
def async_process_loop
|
|
@@ -84,6 +101,31 @@ module Roma
|
|
|
84
101
|
retry
|
|
85
102
|
end
|
|
86
103
|
|
|
104
|
+
def async_process_loop_for_latency
|
|
105
|
+
loop {
|
|
106
|
+
while msg = @@async_queue_latency.pop
|
|
107
|
+
if send("asyncev_#{msg.event}",msg.args)
|
|
108
|
+
msg.callback.call(msg,true) if msg.callback
|
|
109
|
+
else
|
|
110
|
+
if msg.retry?
|
|
111
|
+
t = Thread.new{
|
|
112
|
+
msg.wait
|
|
113
|
+
msg.incr_count
|
|
114
|
+
@@async_queue_latency.push(msg)
|
|
115
|
+
}
|
|
116
|
+
t[:name] = __method__
|
|
117
|
+
else
|
|
118
|
+
@log.error("async process retry out:#{msg.inspect}")
|
|
119
|
+
msg.callback.call(msg,false) if msg.callback
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
}
|
|
124
|
+
rescue =>e
|
|
125
|
+
@log.error("#{e}\n#{$@}")
|
|
126
|
+
retry
|
|
127
|
+
end
|
|
128
|
+
|
|
87
129
|
def asyncev_broadcast_cmd(args)
|
|
88
130
|
@log.debug("#{__method__} #{args.inspect}")
|
|
89
131
|
cmd, nids, tout = args
|
|
@@ -120,7 +162,7 @@ module Roma
|
|
|
120
162
|
end
|
|
121
163
|
end
|
|
122
164
|
t[:name] = __method__
|
|
123
|
-
true
|
|
165
|
+
true
|
|
124
166
|
end
|
|
125
167
|
|
|
126
168
|
def asyncev_start_balance_process(args)
|
|
@@ -148,7 +190,7 @@ module Roma
|
|
|
148
190
|
end
|
|
149
191
|
end
|
|
150
192
|
t[:name] = __method__
|
|
151
|
-
true
|
|
193
|
+
true
|
|
152
194
|
end
|
|
153
195
|
|
|
154
196
|
def asyncev_redundant(args)
|
|
@@ -193,7 +235,7 @@ module Roma
|
|
|
193
235
|
@log.warn("async redundant failed:#{k}\e#{hname} #{clk} -> #{nid}")
|
|
194
236
|
return false # retry
|
|
195
237
|
end
|
|
196
|
-
true
|
|
238
|
+
true
|
|
197
239
|
end
|
|
198
240
|
|
|
199
241
|
def asyncev_reqpushv(args)
|
|
@@ -243,6 +285,57 @@ module Roma
|
|
|
243
285
|
t[:name] = __method__
|
|
244
286
|
end
|
|
245
287
|
|
|
288
|
+
def asyncev_start_auto_recover_process(args)
|
|
289
|
+
@log.debug("#{__method__} #{args.inspect}")
|
|
290
|
+
###run_join don't have possibility to be true in this case.
|
|
291
|
+
#if @stats.run_join
|
|
292
|
+
# @log.error("#{__method__}:join process running")
|
|
293
|
+
# return true
|
|
294
|
+
#end
|
|
295
|
+
if @stats.run_recover
|
|
296
|
+
@log.error("#{__method__}:recover process running.")
|
|
297
|
+
return false
|
|
298
|
+
end
|
|
299
|
+
if @stats.run_balance
|
|
300
|
+
@log.error("#{__method__}:balance process running")
|
|
301
|
+
return true
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
@rttable.auto_recover_status = "preparing"
|
|
305
|
+
t = Thread::new do
|
|
306
|
+
begin
|
|
307
|
+
timeout(@rttable.auto_recover_time){
|
|
308
|
+
loop{
|
|
309
|
+
sleep 1
|
|
310
|
+
break if @rttable.auto_recover_status != "preparing"
|
|
311
|
+
#break if @stats.run_join #run_join don't have possibility to be true in this case.
|
|
312
|
+
break if @stats.run_recover
|
|
313
|
+
break if @stats.run_balance
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
@log.debug("inactivated AUTO_RECOVER")
|
|
317
|
+
rescue
|
|
318
|
+
case @rttable.lost_action
|
|
319
|
+
when :auto_assign, :shutdown
|
|
320
|
+
@stats.run_recover = true
|
|
321
|
+
@rttable.auto_recover_status = "executing"
|
|
322
|
+
begin
|
|
323
|
+
@log.debug("auto recover start")
|
|
324
|
+
acquired_recover_process
|
|
325
|
+
rescue => e
|
|
326
|
+
@log.error("#{__method__}:#{e.inspect} #{$@}")
|
|
327
|
+
ensure
|
|
328
|
+
@stats.run_recover = false
|
|
329
|
+
@rttable.auto_recover_status = "waiting"
|
|
330
|
+
end
|
|
331
|
+
when :no_action
|
|
332
|
+
@log.debug("auto recover NOT start. Because lost action is [no_action]")
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
t[:name] = __method__
|
|
337
|
+
end
|
|
338
|
+
|
|
246
339
|
def asyncev_start_release_process(args)
|
|
247
340
|
@log.debug("#{__method__} #{args}")
|
|
248
341
|
if @stats.run_iterate_storage
|
|
@@ -269,7 +362,7 @@ module Roma
|
|
|
269
362
|
@log.info("#{__method__}:start")
|
|
270
363
|
|
|
271
364
|
exclude_nodes = @rttable.exclude_nodes_for_recover(@stats.ap_str, @stats.rep_host)
|
|
272
|
-
|
|
365
|
+
|
|
273
366
|
@do_acquired_recover_process = true
|
|
274
367
|
loop do
|
|
275
368
|
break unless @do_acquired_recover_process
|
|
@@ -293,7 +386,7 @@ module Roma
|
|
|
293
386
|
ensure
|
|
294
387
|
@do_acquired_recover_process = false
|
|
295
388
|
end
|
|
296
|
-
|
|
389
|
+
|
|
297
390
|
def join_process
|
|
298
391
|
@log.info("#{__method__}:start")
|
|
299
392
|
count = 0
|
|
@@ -309,7 +402,7 @@ module Roma
|
|
|
309
402
|
@log.warn("#{__method__}:vnode dose not found")
|
|
310
403
|
return false
|
|
311
404
|
end
|
|
312
|
-
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
|
405
|
+
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
|
313
406
|
if ret == :rejected
|
|
314
407
|
sleep 5
|
|
315
408
|
else
|
|
@@ -317,10 +410,10 @@ module Roma
|
|
|
317
410
|
count += 1
|
|
318
411
|
end
|
|
319
412
|
end
|
|
320
|
-
@log.info("#{__method__} has done.")
|
|
321
413
|
rescue => e
|
|
322
414
|
@log.error("#{e.inspect} #{$@}")
|
|
323
415
|
ensure
|
|
416
|
+
@log.info("#{__method__} has done.")
|
|
324
417
|
@do_join_process = false
|
|
325
418
|
end
|
|
326
419
|
|
|
@@ -339,7 +432,7 @@ module Roma
|
|
|
339
432
|
@log.warn("#{__method__}:vnode dose not found")
|
|
340
433
|
return false
|
|
341
434
|
end
|
|
342
|
-
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
|
435
|
+
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
|
343
436
|
if ret == :rejected
|
|
344
437
|
sleep 5
|
|
345
438
|
else
|
|
@@ -369,11 +462,11 @@ module Roma
|
|
|
369
462
|
Roma::Messaging::ConPool.instance.return_connection(src_nid,con)
|
|
370
463
|
# waiting for pushv
|
|
371
464
|
count = 0
|
|
372
|
-
while @rttable.search_nodes(vn).include?(@stats.ap_str)==false && count <
|
|
465
|
+
while @rttable.search_nodes(vn).include?(@stats.ap_str)==false && count < @stats.reqpushv_timeout_count
|
|
373
466
|
sleep 0.1
|
|
374
467
|
count += 1
|
|
375
468
|
end
|
|
376
|
-
if count >=
|
|
469
|
+
if count >= @stats.reqpushv_timeout_count
|
|
377
470
|
@log.warn("#{__method__}:request has been time-out.vn=#{vn} nid=#{src_nid}")
|
|
378
471
|
return :timeout
|
|
379
472
|
end
|
|
@@ -383,7 +476,7 @@ module Roma
|
|
|
383
476
|
@rttable.proc_failed(src_nid)
|
|
384
477
|
false
|
|
385
478
|
end
|
|
386
|
-
|
|
479
|
+
|
|
387
480
|
def release_process
|
|
388
481
|
@log.info("#{__method__}:start.")
|
|
389
482
|
|
|
@@ -397,7 +490,7 @@ module Roma
|
|
|
397
490
|
@rttable.each_vnode do |vn, nids|
|
|
398
491
|
break unless @do_release_process
|
|
399
492
|
if nids.include?(@stats.ap_str)
|
|
400
|
-
|
|
493
|
+
|
|
401
494
|
to_nid, new_nids = @rttable.select_node_for_release(@stats.ap_str, @stats.rep_host, nids)
|
|
402
495
|
unless sync_a_vnode_for_release(vn, to_nid, new_nids)
|
|
403
496
|
@log.warn("#{__method__}:error at vn=#{vn} to_nid=#{to_nid} new_nid=#{new_nids}")
|
|
@@ -413,10 +506,10 @@ module Roma
|
|
|
413
506
|
@do_release_process = false
|
|
414
507
|
Roma::Messaging::ConPool.instance.close_all
|
|
415
508
|
end
|
|
416
|
-
|
|
509
|
+
|
|
417
510
|
def sync_a_vnode_for_release(vn, to_nid, new_nids)
|
|
418
511
|
nids = @rttable.search_nodes(vn)
|
|
419
|
-
|
|
512
|
+
|
|
420
513
|
if nids.include?(to_nid)==false || (is_primary && nids[0]!=to_nid)
|
|
421
514
|
@log.debug("#{__method__}:#{vn} #{to_nid}")
|
|
422
515
|
# change routing data at the vnode and synchronize a data
|
|
@@ -444,7 +537,7 @@ module Roma
|
|
|
444
537
|
if clk.is_a?(Integer) == false
|
|
445
538
|
clk,new_nids = @rttable.search_nodes_with_clk(vn)
|
|
446
539
|
end
|
|
447
|
-
|
|
540
|
+
|
|
448
541
|
cmd = "setroute #{vn} #{clk - 1}"
|
|
449
542
|
new_nids.each{ |nn| cmd << " #{nn}"}
|
|
450
543
|
res = async_broadcast_cmd("#{cmd}\r\n")
|
|
@@ -459,7 +552,7 @@ module Roma
|
|
|
459
552
|
|
|
460
553
|
def sync_a_vnode(vn, to_nid, is_primary=nil)
|
|
461
554
|
nids = @rttable.search_nodes(vn)
|
|
462
|
-
|
|
555
|
+
|
|
463
556
|
if nids.include?(to_nid)==false || (is_primary && nids[0]!=to_nid)
|
|
464
557
|
@log.debug("#{__method__}:#{vn} #{to_nid} #{is_primary}")
|
|
465
558
|
# change routing data at the vnode and synchronize a data
|
|
@@ -488,7 +581,7 @@ module Roma
|
|
|
488
581
|
if clk.is_a?(Integer) == false
|
|
489
582
|
clk,nids = @rttable.search_nodes_with_clk(vn)
|
|
490
583
|
end
|
|
491
|
-
|
|
584
|
+
|
|
492
585
|
cmd = "setroute #{vn} #{clk - 1}"
|
|
493
586
|
nids.each{ |nn| cmd << " #{nn}"}
|
|
494
587
|
res = async_broadcast_cmd("#{cmd}\r\n")
|
|
@@ -534,7 +627,7 @@ module Roma
|
|
|
534
627
|
con = Roma::Messaging::ConPool.instance.get_connection(nid)
|
|
535
628
|
|
|
536
629
|
@do_push_a_vnode_stream = true
|
|
537
|
-
|
|
630
|
+
|
|
538
631
|
con.write("spushv #{hname} #{vn}\r\n")
|
|
539
632
|
|
|
540
633
|
res = con.gets # READY\r\n or error string
|
|
@@ -631,6 +724,51 @@ module Roma
|
|
|
631
724
|
@log.info("#{__method__}:stop")
|
|
632
725
|
end
|
|
633
726
|
|
|
727
|
+
def asyncev_calc_latency_average(args)
|
|
728
|
+
latency,cmd = args
|
|
729
|
+
#@log.debug(__method__)
|
|
730
|
+
|
|
731
|
+
if !@stats.latency_data.key?(cmd) #only first execute target cmd
|
|
732
|
+
@stats.latency_data[cmd].store("latency", Array.new())
|
|
733
|
+
@stats.latency_data[cmd].store("latency_max", Hash.new())
|
|
734
|
+
@stats.latency_data[cmd]["latency_max"].store("current", 0)
|
|
735
|
+
@stats.latency_data[cmd].store("latency_min", Hash.new())
|
|
736
|
+
@stats.latency_data[cmd]["latency_min"].store("current", 99999)
|
|
737
|
+
@stats.latency_data[cmd].store("time", Time.now.to_i)
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
begin
|
|
741
|
+
@stats.latency_data[cmd]["latency"].delete_at(0) if @stats.latency_data[cmd]["latency"].length >= 10
|
|
742
|
+
@stats.latency_data[cmd]["latency"].push(latency)
|
|
743
|
+
|
|
744
|
+
@stats.latency_data[cmd]["latency_max"]["current"] = latency if latency > @stats.latency_data[cmd]["latency_max"]["current"]
|
|
745
|
+
@stats.latency_data[cmd]["latency_min"]["current"] = latency if latency < @stats.latency_data[cmd]["latency_min"]["current"]
|
|
746
|
+
|
|
747
|
+
rescue =>e
|
|
748
|
+
@log.error("#{__method__}:#{e.inspect} #{$@}")
|
|
749
|
+
|
|
750
|
+
ensure
|
|
751
|
+
if @stats.latency_check_time_count != nil && Time.now.to_i - @stats.latency_data[cmd]["time"] > @stats.latency_check_time_count
|
|
752
|
+
average = @stats.latency_data[cmd]["latency"].inject(0.0){|r,i| r+=i }/@stats.latency_data[cmd]["latency"].size
|
|
753
|
+
max = @stats.latency_data[cmd]["latency_max"]["current"]
|
|
754
|
+
min = @stats.latency_data[cmd]["latency_min"]["current"]
|
|
755
|
+
@log.debug("Latency average[#{cmd}]: #{sprintf("%.8f", average)}"+
|
|
756
|
+
"(denominator=#{@stats.latency_data[cmd]["latency"].length}"+
|
|
757
|
+
" max=#{sprintf("%.8f", max)}"+
|
|
758
|
+
" min=#{sprintf("%.8f", min)})"
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
@stats.latency_data[cmd]["time"] = Time.now.to_i
|
|
762
|
+
@stats.latency_data[cmd]["latency_past"] = @stats.latency_data[cmd]["latency"]
|
|
763
|
+
@stats.latency_data[cmd]["latency"] = []
|
|
764
|
+
@stats.latency_data[cmd]["latency_max"]["past"] = @stats.latency_data[cmd]["latency_max"]["current"]
|
|
765
|
+
@stats.latency_data[cmd]["latency_max"]["current"] = 0
|
|
766
|
+
@stats.latency_data[cmd]["latency_min"]["past"] = @stats.latency_data[cmd]["latency_min"]["current"]
|
|
767
|
+
@stats.latency_data[cmd]["latency_min"]["current"] = 99999
|
|
768
|
+
end
|
|
769
|
+
end
|
|
770
|
+
true
|
|
771
|
+
end
|
|
634
772
|
|
|
635
773
|
end # module AsyncProcess
|
|
636
774
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
require 'roma/async_process'
|
|
3
2
|
require 'roma/messaging/con_pool'
|
|
4
3
|
require 'roma/command/vn_command_receiver'
|
|
@@ -12,7 +11,7 @@ module Roma
|
|
|
12
11
|
def ev_balance(s)
|
|
13
12
|
res = broadcast_cmd("rbalance\r\n")
|
|
14
13
|
if @stats.run_join == false &&
|
|
15
|
-
@stats.run_recover == false &&
|
|
14
|
+
@stats.run_recover == false &&
|
|
16
15
|
@stats.run_balance == false &&
|
|
17
16
|
@rttable.vnode_balance(@stats.ap_str)==:less
|
|
18
17
|
Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_balance_process'))
|
|
@@ -25,7 +24,7 @@ module Roma
|
|
|
25
24
|
|
|
26
25
|
def ev_rbalance(s)
|
|
27
26
|
if @stats.run_join == false &&
|
|
28
|
-
@stats.run_recover == false &&
|
|
27
|
+
@stats.run_recover == false &&
|
|
29
28
|
@stats.run_balance == false &&
|
|
30
29
|
@rttable.vnode_balance(@stats.ap_str)==:less
|
|
31
30
|
Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_balance_process'))
|
|
@@ -37,7 +36,7 @@ module Roma
|
|
|
37
36
|
|
|
38
37
|
def ev_release(s)
|
|
39
38
|
if @stats.run_join == false &&
|
|
40
|
-
@stats.run_recover == false &&
|
|
39
|
+
@stats.run_recover == false &&
|
|
41
40
|
@stats.run_balance == false &&
|
|
42
41
|
@stats.run_release == false &&
|
|
43
42
|
@stats.run_iterate_storage == false
|
|
@@ -36,20 +36,24 @@ module Roma
|
|
|
36
36
|
|
|
37
37
|
# routingdump [yaml|json|yamlbytes|bin]\r\n
|
|
38
38
|
def ev_routingdump(s)
|
|
39
|
+
rt = @rttable
|
|
40
|
+
rd = @rttable.sub_nid_rd(@addr)
|
|
41
|
+
rt = Roma::Routing::RoutingTable.new(rd) if rd
|
|
42
|
+
|
|
39
43
|
if s.length == 1
|
|
40
|
-
dmp =
|
|
44
|
+
dmp = rt.dump
|
|
41
45
|
send_data("#{dmp.length}\r\n#{dmp}\r\nEND\r\n")
|
|
42
46
|
elsif s[1] == 'yaml'
|
|
43
|
-
dmp =
|
|
47
|
+
dmp = rt.dump_yaml
|
|
44
48
|
send_data("#{dmp}\r\nEND\r\n")
|
|
45
49
|
elsif s[1] == 'json'
|
|
46
|
-
dmp =
|
|
50
|
+
dmp = rt.dump_json
|
|
47
51
|
send_data("#{dmp}\r\nEND\r\n")
|
|
48
52
|
elsif s[1] == 'yamlbytes'
|
|
49
|
-
dmp =
|
|
53
|
+
dmp = rt.dump_yaml
|
|
50
54
|
send_data("#{dmp.length + 7}\r\nEND\r\n")
|
|
51
55
|
elsif s[1] == 'bin'
|
|
52
|
-
dmp =
|
|
56
|
+
dmp = rt.dump_binary
|
|
53
57
|
send_data("#{dmp.length}\r\n#{dmp}\r\nEND\r\n")
|
|
54
58
|
else
|
|
55
59
|
send_data("CLIENT_ERROR\r\n")
|
|
@@ -107,6 +111,69 @@ module Roma
|
|
|
107
111
|
send_data("CLIENT_ERROR\r\n")
|
|
108
112
|
end
|
|
109
113
|
|
|
114
|
+
# set_auto_recover [true|false] <sec>
|
|
115
|
+
def ev_set_auto_recover(s)
|
|
116
|
+
#check argument
|
|
117
|
+
if /^true$|^false$/ !~ s[1]
|
|
118
|
+
return send_data("CLIENT_ERROR arguments must be true or false\r\n")
|
|
119
|
+
elsif s.length != 2 && s.length != 3
|
|
120
|
+
return send_data("CLIENT_ERROR number of arguments(0 for 1)\r\n")
|
|
121
|
+
elsif s.length == 3 && s[2].to_i < 1
|
|
122
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
|
123
|
+
end
|
|
124
|
+
res = broadcast_cmd("rset_auto_recover #{s[1]} #{s[2]}\r\n")
|
|
125
|
+
if s[1] == "true"
|
|
126
|
+
@rttable.auto_recover = true
|
|
127
|
+
elsif s[1] == "false"
|
|
128
|
+
@rttable.auto_recover = false
|
|
129
|
+
end
|
|
130
|
+
@rttable.auto_recover_status = "waiting"
|
|
131
|
+
@rttable.auto_recover_time = s[2].to_i if s[2]
|
|
132
|
+
res[@stats.ap_str] = "STORED"
|
|
133
|
+
send_data("#{res}\r\n")
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def ev_rset_auto_recover(s)
|
|
137
|
+
if /^true$|^false$/ !~ s[1]
|
|
138
|
+
return send_data("CLIENT_ERROR arguments must be true or false #{s[1]} #{s[1].class} \r\n")
|
|
139
|
+
elsif s.length != 2 && s.length != 3
|
|
140
|
+
return send_data("CLIENT_ERROR number of arguments(0 for 1)\r\n")
|
|
141
|
+
elsif s.length == 3 && s[2].to_i < 1
|
|
142
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
|
143
|
+
end
|
|
144
|
+
if s[1] == "true"
|
|
145
|
+
@rttable.auto_recover = true
|
|
146
|
+
elsif s[1] == "false"
|
|
147
|
+
@rttable.auto_recover = false
|
|
148
|
+
end
|
|
149
|
+
@rttable.auto_recover_status = "waiting"
|
|
150
|
+
@rttable.auto_recover_time = s[2].to_i if s[2]
|
|
151
|
+
send_data("STORED\r\n")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# set_lost_action [auto_assign|shutdown]
|
|
155
|
+
def ev_set_lost_action(s)
|
|
156
|
+
if s.length != 2 || /^auto_assign$|^shutdown$/ !~ s[1]
|
|
157
|
+
return send_data("CLIENT_ERROR changing lost_action must be auto_assign or shutdown\r\n")
|
|
158
|
+
elsif /^auto_assign$|^shutdown$/ !~ @rttable.lost_action
|
|
159
|
+
return send_data("CLIENT_ERROR can use this command only current lost action is auto_assign or shutdwn mode\r\n")
|
|
160
|
+
end
|
|
161
|
+
res = broadcast_cmd("rset_lost_action #{s[1]}\r\n")
|
|
162
|
+
@rttable.lost_action = s[1].to_sym
|
|
163
|
+
res[@stats.ap_str] = "STORED"
|
|
164
|
+
send_data("#{res}\r\n")
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def ev_rset_lost_action(s)
|
|
168
|
+
if s.length != 2 || /^auto_assign$|^shutdown$/ !~ s[1]
|
|
169
|
+
return send_data("CLIENT_ERROR changing lost_action must be auto_assign or shutdown\r\n")
|
|
170
|
+
elsif /^auto_assign$|^shutdown$/ !~ @rttable.lost_action
|
|
171
|
+
return send_data("CLIENT_ERROR can use this command only current lost action is auto_assign or shutdwn mode\r\n")
|
|
172
|
+
end
|
|
173
|
+
@rttable.lost_action = s[1].to_sym
|
|
174
|
+
send_data("STORED\r\n")
|
|
175
|
+
end
|
|
176
|
+
|
|
110
177
|
# set_threshold_for_failover <n>
|
|
111
178
|
def ev_set_threshold_for_failover(s)
|
|
112
179
|
if s.length != 2 || s[1].to_i == 0
|
|
@@ -147,6 +214,67 @@ module Roma
|
|
|
147
214
|
send_data("STORED\r\n")
|
|
148
215
|
end
|
|
149
216
|
|
|
217
|
+
# cleat RTTABLE_SUB_NID map
|
|
218
|
+
def ev_clear_rttable_sub_nid(s)
|
|
219
|
+
res = broadcast_cmd("rclear_rttable_sub_nid\r\n")
|
|
220
|
+
@rttable.sub_nid.clear()
|
|
221
|
+
res[@stats.ap_str] = "CLEARED"
|
|
222
|
+
send_data("#{res}\r\n")
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def ev_rclear_rttable_sub_nid(s)
|
|
226
|
+
@rttable.sub_nid.clear()
|
|
227
|
+
send_data("CLEARED\r\n")
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# add_rttable_sub_nid <netmask> <regexp> <replace>
|
|
231
|
+
def ev_add_rttable_sub_nid(s)
|
|
232
|
+
if s.length != 4
|
|
233
|
+
return send_data("usage:add_rttable_sub_nid <netmask> <regexp> <replace>\r\n")
|
|
234
|
+
end
|
|
235
|
+
res = broadcast_cmd("radd_rttable_sub_nid #{s[1]} #{s[2]} #{s[3]}\r\n")
|
|
236
|
+
@rttable.sub_nid[s[1]] = {:regexp => "#{s[2]}", :replace => "#{s[3]}"}
|
|
237
|
+
res[@stats.ap_str] = "ADDED"
|
|
238
|
+
send_data("#{res}\r\n")
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# radd_rttable_sub_nid <netmask> <regexp> <replace>
|
|
242
|
+
def ev_radd_rttable_sub_nid(s)
|
|
243
|
+
if s.length != 4
|
|
244
|
+
return send_data("usage:add_rttable_sub_nid <netmask> <regexp> <replace>\r\n")
|
|
245
|
+
end
|
|
246
|
+
@rttable.sub_nid[s[1]] = {:regexp => "#{s[2]}", :replace => "#{s[3]}"}
|
|
247
|
+
send_data("ADDED\r\n")
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# delete_rttable_sub_nid <netmask>
|
|
251
|
+
def ev_delete_rttable_sub_nid(s)
|
|
252
|
+
if s.length != 2
|
|
253
|
+
return send_data("usage:delete_rttable_sub_nid <netmask>\r\n")
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
res = broadcast_cmd("rdelete_rttable_sub_nid #{s[1]}\r\n")
|
|
257
|
+
unless @rttable.sub_nid.delete s[1]
|
|
258
|
+
res[@stats.ap_str] = "NOT_FOUND"
|
|
259
|
+
else
|
|
260
|
+
res[@stats.ap_str] = "DELETED"
|
|
261
|
+
end
|
|
262
|
+
send_data("#{res}\r\n")
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# rdelete_rttable_sub_nid <netmask>
|
|
266
|
+
def ev_rdelete_rttable_sub_nid(s)
|
|
267
|
+
if s.length != 2
|
|
268
|
+
return send_data("usage:delete_rttable_sub_nid <netmask>\r\n")
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
unless @rttable.sub_nid.delete s[1]
|
|
272
|
+
send_data("NOT_FOUND\r\n")
|
|
273
|
+
else
|
|
274
|
+
send_data("DELETED\r\n")
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
150
278
|
end # module RoutingCommandReceiver
|
|
151
279
|
end # module Command
|
|
152
280
|
end # module Roma
|