roma 1.1.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +21 -0
- data/Gemfile.lock +47 -0
- data/bin/check_tc_flag +39 -0
- data/bin/roma-adm +43 -0
- data/bin/ssroute +0 -3
- data/lib/roma/async_process.rb +203 -208
- data/lib/roma/command/sys_command_receiver.rb +52 -10
- data/lib/roma/config.rb +3 -0
- data/lib/roma/event/handler.rb +11 -4
- data/lib/roma/event/jaro_winkler.rb +23 -0
- data/lib/roma/event/levenshtein.rb +23 -0
- data/lib/roma/plugin/plugin_cmd_aliases.rb +1 -32
- data/lib/roma/romad.rb +23 -0
- data/lib/roma/routing/cb_rttable.rb +2 -0
- data/lib/roma/routing/random_partitioner.rb +43 -36
- data/lib/roma/routing/rttable.rb +5 -3
- data/lib/roma/stats.rb +4 -1
- data/lib/roma/tools/check_tc_flag.rb +25 -0
- data/lib/roma/tools/cpdb.rb +3 -2
- data/lib/roma/tools/mkconfig.rb +22 -13
- data/lib/roma/tools/roma-adm.rb +82 -0
- data/lib/roma/version.rb +1 -1
- data/test/config4mhash.rb +2 -0
- data/test/config4storage_error.rb +2 -0
- data/test/config4test.rb +2 -0
- data/test/cpdbtest/config4cpdb_base.rb +67 -0
- data/test/cpdbtest/config4cpdb_dbm.rb +9 -0
- data/test/cpdbtest/config4cpdb_groonga.rb +9 -0
- data/test/cpdbtest/config4cpdb_rh.rb +9 -0
- data/test/cpdbtest/config4cpdb_sqlite3.rb +9 -0
- data/test/cpdbtest/config4cpdb_tc.rb +9 -0
- data/test/cpdbtest/config4cpdb_tcmem.rb +9 -0
- data/test/roma-test-utils.rb +140 -40
- data/test/t_cpdata.rb +76 -80
- data/test/t_cpdb.rb +95 -0
- data/test/t_logshift.rb +86 -0
- data/test/t_mhash.rb +56 -54
- data/test/t_routing_logic.rb +121 -0
- data/test/t_writebehind.rb +202 -207
- metadata +25 -8
- data/bin/tc_data_restore.rb +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a17bad1bbf7dabab9d9833e7458902691dae3117
|
4
|
+
data.tar.gz: e97e8fb05d535d000d276dcea350317629ef9a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5dc132fd3475bcd2a4edceaa579bbf9b18319a84dda1ce7c443b1e40ab1cdb538e7bb791cb693d497b98867990ad31c294ee4f7969f1b20616b31a6bcb05de3
|
7
|
+
data.tar.gz: 3d2854df8f09147235a49a5891037fa65e5be84a59c73bacbfb3739decd8f0a3c728bdac2d44fb69e7aa2026c53ffef1abbe898695e62e5a098d7fcd9e76df59
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
*1.1.0 (Aug 19 2015)*
|
2
|
+
|
3
|
+
* Change gemspec [Hiroaki Iwase] db2bb42
|
4
|
+
* Modify unit-test [Hiroaki Iwase] 7479034
|
5
|
+
* Adjust secondary node to redundancy over3 [Hiroaki Iwase] a6fafd8
|
6
|
+
* Add new func to check tokyo cabinet additional flag [Hiroaki Iwase] e17b3af
|
7
|
+
* Make new tool(roma-adm) [Hiroaki Iwase] 8cf2a03
|
8
|
+
* Add new func to check config.rb version when booting [Hiroaki Iwase] 1befb8f
|
9
|
+
* Add new func to check command miss spell by jaro-winkler [Hiroaki Iwase] 607c96e
|
10
|
+
* Enable to check failover status on stats[Hiroaki Iwase] d5a6a9f
|
11
|
+
* Enable to check log level on stats [Hiroaki Iwase] 14b1455
|
12
|
+
* Modify duplicate problem(plugin_storage.rb) of mkconfig script [Hiroaki Iwase] c057191
|
13
|
+
* Adjust groonga [Hiroaki Iwase] 0ee097c
|
14
|
+
* Add new command(shutdown_self) [Hiroaki Iwase] 8bb0aa5
|
15
|
+
* add new testcase about cpdb as Groonga msg [ooeyoshinori] 6744580
|
16
|
+
* Fix random routing logic for join [Hiroki Matsue] ea29af3
|
17
|
+
* Support new stats interface of client and refactor codes. [Hiroki Matsue] fd65292
|
18
|
+
* Add tests for routing logic and refactor tests [Hiroki Matsue] 1d52cbe
|
19
|
+
* Add Dynamic Log Shift size and age Test Script [Paras Patel] 081ebd2
|
20
|
+
* Remove unnecessary path in ssroute booting file [Hiroaki Iwase] 4f678cd
|
21
|
+
|
1
22
|
*1.1.0 (Mar 30 2015)*
|
2
23
|
|
3
24
|
* I improved connection performance during booting [Takahiro Tokunaga] ee411f0
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
roma (1.2.0)
|
5
|
+
eventmachine (~> 1.0.0)
|
6
|
+
jaro_winkler (~> 1.3.5)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
archive-zip (0.7.0)
|
12
|
+
io-like (~> 0.3.0)
|
13
|
+
eventmachine (1.0.3)
|
14
|
+
ffi (1.9.6)
|
15
|
+
gdbm (1.2)
|
16
|
+
gqtp (1.0.6)
|
17
|
+
groonga-client (0.1.0)
|
18
|
+
gqtp (>= 1.0.4)
|
19
|
+
groonga-command (>= 1.0.8)
|
20
|
+
groonga-command (1.0.9)
|
21
|
+
json
|
22
|
+
io-like (0.3.0)
|
23
|
+
jaro_winkler (1.3.5)
|
24
|
+
json (1.8.1)
|
25
|
+
pkg-config (1.1.6)
|
26
|
+
power_assert (0.2.2)
|
27
|
+
rake (10.2.2)
|
28
|
+
rroonga (4.0.8)
|
29
|
+
archive-zip
|
30
|
+
groonga-client (>= 0.0.3)
|
31
|
+
json
|
32
|
+
pkg-config
|
33
|
+
sqlite3 (1.3.9)
|
34
|
+
test-unit (3.1.2)
|
35
|
+
power_assert
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
ffi
|
42
|
+
gdbm
|
43
|
+
rake
|
44
|
+
roma!
|
45
|
+
rroonga
|
46
|
+
sqlite3
|
47
|
+
test-unit
|
data/bin/check_tc_flag
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
base_path = Pathname(__FILE__).dirname.parent.expand_path
|
6
|
+
$LOAD_PATH.unshift("#{base_path}/lib")
|
7
|
+
|
8
|
+
require 'roma/tools/check_tc_flag'
|
9
|
+
|
10
|
+
begin
|
11
|
+
# argument check
|
12
|
+
if ARGV.size <= 0 || ARGV.size > 4
|
13
|
+
puts "Argument Error: check_tc_flag --storage [TC storage path] --library [TC library path]"
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
# opt parse
|
18
|
+
options = {}
|
19
|
+
opts = OptionParser.new
|
20
|
+
opts.banner="usage:#{File.basename($0)} --path [directory path]"
|
21
|
+
opts.on("-h", "--help", "Show this message") { puts opts; exit }
|
22
|
+
|
23
|
+
opts.on("--storage <dir_path>", "Specify the TC Storage directory", "Ex.)/roma/ds/localhost_10001/roma") {|v| options[:storage] = v}
|
24
|
+
opts.on("--library <dir_path>", "Specify the TC library directory", "Ex.)/roma/libexec") {|v| options[:library] = v}
|
25
|
+
opts.parse!(ARGV)
|
26
|
+
|
27
|
+
# add default path(current directory)
|
28
|
+
options[:storage] = '.' unless options.has_key?(:storage)
|
29
|
+
options[:library] = '.' unless options.has_key?(:library)
|
30
|
+
|
31
|
+
tc = Roma::CheckTc.new(options[:storage], options[:library])
|
32
|
+
res = tc.check_flag
|
33
|
+
res.each{|f, flag|
|
34
|
+
flag = "(no flag)" if flag.empty?
|
35
|
+
puts "#{f} : #{flag}"
|
36
|
+
}
|
37
|
+
rescue => e
|
38
|
+
puts e.message
|
39
|
+
end
|
data/bin/roma-adm
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
base_path = Pathname(__FILE__).dirname.parent.expand_path
|
6
|
+
$LOAD_PATH.unshift("#{base_path}/lib")
|
7
|
+
|
8
|
+
require 'roma/tools/roma-adm'
|
9
|
+
|
10
|
+
begin
|
11
|
+
# opt parse
|
12
|
+
opts = OptionParser.new
|
13
|
+
opts.banner="usage:#{File.basename($0)} [command] [port No.]"
|
14
|
+
opts.on("-h", "--help", "Show this message") {
|
15
|
+
puts opts; exit
|
16
|
+
}
|
17
|
+
opts.parse!(ARGV)
|
18
|
+
|
19
|
+
# argument check
|
20
|
+
if ARGV.size < 1 || ARGV.size > 2
|
21
|
+
puts "Argument Error: roma-adm [adm-command] [port No.]"
|
22
|
+
exit
|
23
|
+
elsif ARGV.size == 2 && ARGV[1] !~ /^\d+$/
|
24
|
+
puts "Argument Error: roma-adm [adm-command] [port No.]"
|
25
|
+
puts "[port No.] should be Interger"
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
cmd = ARGV[0]
|
30
|
+
if ARGV[1]
|
31
|
+
port = ARGV[1]
|
32
|
+
else
|
33
|
+
port = "12000" # defaul port
|
34
|
+
end
|
35
|
+
|
36
|
+
adm = Roma::Adm.new(cmd, port)
|
37
|
+
adm.check_type
|
38
|
+
res = adm.send_command
|
39
|
+
puts "\r\n"
|
40
|
+
puts res
|
41
|
+
rescue => e
|
42
|
+
puts e.message
|
43
|
+
end
|
data/bin/ssroute
CHANGED
@@ -4,7 +4,4 @@ require 'pathname'
|
|
4
4
|
base_path = Pathname(__FILE__).dirname.parent.expand_path
|
5
5
|
$LOAD_PATH.unshift("#{base_path}/lib")
|
6
6
|
|
7
|
-
client_base_path = Pathname(__FILE__).dirname.parent.parent.expand_path
|
8
|
-
$LOAD_PATH.unshift("#{client_base_path}/roma-ruby-client/lib")
|
9
|
-
|
10
7
|
require 'roma/tools/ssroute'
|
data/lib/roma/async_process.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'digest/sha1'
|
3
|
-
require
|
3
|
+
require 'timeout'
|
4
4
|
|
5
5
|
module Roma
|
6
|
-
|
7
6
|
class AsyncMessage
|
8
7
|
attr_accessor :event
|
9
8
|
attr_accessor :args
|
10
9
|
attr_accessor :callback
|
11
10
|
|
12
|
-
def initialize(ev,ag=nil
|
11
|
+
def initialize(ev, ag = nil, &cb)
|
13
12
|
@event = ev
|
14
13
|
@args = ag
|
15
14
|
@callback = cb
|
@@ -32,7 +31,6 @@ module Roma
|
|
32
31
|
end
|
33
32
|
|
34
33
|
module AsyncProcess
|
35
|
-
|
36
34
|
@@async_queue = Queue.new
|
37
35
|
@@async_queue_latency = Queue.new
|
38
36
|
|
@@ -45,17 +43,17 @@ module Roma
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def start_async_process
|
48
|
-
@async_thread = Thread.new
|
46
|
+
@async_thread = Thread.new do
|
49
47
|
async_process_loop
|
50
|
-
|
48
|
+
end
|
51
49
|
@async_thread[:name] = __method__
|
52
50
|
|
53
|
-
@async_thread_latency = Thread.new
|
51
|
+
@async_thread_latency = Thread.new do
|
54
52
|
async_process_loop_for_latency
|
55
|
-
|
53
|
+
end
|
56
54
|
@async_thread_latency[:name] = __method__
|
57
|
-
rescue =>e
|
58
|
-
@log.error("#{e}\n#{
|
55
|
+
rescue => e
|
56
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
59
57
|
end
|
60
58
|
|
61
59
|
private
|
@@ -77,66 +75,66 @@ module Roma
|
|
77
75
|
end
|
78
76
|
|
79
77
|
def async_process_loop
|
80
|
-
loop
|
78
|
+
loop do
|
81
79
|
while msg = @@async_queue.pop
|
82
|
-
if send("asyncev_#{msg.event}",msg.args)
|
83
|
-
msg.callback.call(msg,true) if msg.callback
|
80
|
+
if send("asyncev_#{msg.event}", msg.args)
|
81
|
+
msg.callback.call(msg, true) if msg.callback
|
84
82
|
else
|
85
83
|
if msg.retry?
|
86
|
-
t = Thread.new
|
84
|
+
t = Thread.new do
|
87
85
|
msg.wait
|
88
86
|
msg.incr_count
|
89
87
|
@@async_queue.push(msg)
|
90
|
-
|
88
|
+
end
|
91
89
|
t[:name] = __method__
|
92
90
|
else
|
93
91
|
@log.error("async process retry out:#{msg.inspect}")
|
94
|
-
msg.callback.call(msg,false) if msg.callback
|
92
|
+
msg.callback.call(msg, false) if msg.callback
|
95
93
|
end
|
96
94
|
end
|
97
95
|
end
|
98
|
-
|
99
|
-
rescue =>e
|
100
|
-
@log.error("#{e}\n#{
|
96
|
+
end
|
97
|
+
rescue => e
|
98
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
101
99
|
retry
|
102
100
|
end
|
103
101
|
|
104
102
|
def async_process_loop_for_latency
|
105
|
-
loop
|
103
|
+
loop do
|
106
104
|
while msg = @@async_queue_latency.pop
|
107
|
-
if send("asyncev_#{msg.event}",msg.args)
|
108
|
-
msg.callback.call(msg,true) if msg.callback
|
105
|
+
if send("asyncev_#{msg.event}", msg.args)
|
106
|
+
msg.callback.call(msg, true) if msg.callback
|
109
107
|
else
|
110
108
|
if msg.retry?
|
111
|
-
t = Thread.new
|
109
|
+
t = Thread.new do
|
112
110
|
msg.wait
|
113
111
|
msg.incr_count
|
114
112
|
@@async_queue_latency.push(msg)
|
115
|
-
|
113
|
+
end
|
116
114
|
t[:name] = __method__
|
117
115
|
else
|
118
116
|
@log.error("async process retry out:#{msg.inspect}")
|
119
|
-
msg.callback.call(msg,false) if msg.callback
|
117
|
+
msg.callback.call(msg, false) if msg.callback
|
120
118
|
end
|
121
119
|
end
|
122
120
|
end
|
123
|
-
|
124
|
-
rescue =>e
|
125
|
-
@log.error("#{e}\n#{
|
121
|
+
end
|
122
|
+
rescue => e
|
123
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
126
124
|
retry
|
127
125
|
end
|
128
126
|
|
129
127
|
def asyncev_broadcast_cmd(args)
|
130
128
|
@log.debug("#{__method__} #{args.inspect}")
|
131
129
|
cmd, nids, tout = args
|
132
|
-
t = Thread
|
130
|
+
t = Thread.new do
|
133
131
|
async_broadcast_cmd("#{cmd}\r\n", nids, tout)
|
134
|
-
|
132
|
+
end
|
135
133
|
t[:name] = __method__
|
136
134
|
true
|
137
135
|
end
|
138
136
|
|
139
|
-
def asyncev_start_join_process(
|
137
|
+
def asyncev_start_join_process(_args)
|
140
138
|
@log.debug(__method__)
|
141
139
|
if @stats.run_join
|
142
140
|
@log.error("#{__method__}:join process running")
|
@@ -151,11 +149,11 @@ module Roma
|
|
151
149
|
return true
|
152
150
|
end
|
153
151
|
@stats.run_join = true
|
154
|
-
t = Thread
|
152
|
+
t = Thread.new do
|
155
153
|
begin
|
156
154
|
join_process
|
157
|
-
rescue =>e
|
158
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
155
|
+
rescue => e
|
156
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
159
157
|
ensure
|
160
158
|
@stats.run_join = false
|
161
159
|
@stats.join_ap = nil
|
@@ -165,7 +163,7 @@ module Roma
|
|
165
163
|
true
|
166
164
|
end
|
167
165
|
|
168
|
-
def asyncev_start_balance_process(
|
166
|
+
def asyncev_start_balance_process(_args)
|
169
167
|
@log.debug(__method__)
|
170
168
|
if @stats.run_join
|
171
169
|
@log.error("#{__method__}:join process running")
|
@@ -180,11 +178,11 @@ module Roma
|
|
180
178
|
return true
|
181
179
|
end
|
182
180
|
@stats.run_balance = true
|
183
|
-
t = Thread
|
181
|
+
t = Thread.new do
|
184
182
|
begin
|
185
183
|
balance_process
|
186
|
-
rescue =>e
|
187
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
184
|
+
rescue => e
|
185
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
188
186
|
ensure
|
189
187
|
@stats.run_balance = false
|
190
188
|
end
|
@@ -194,14 +192,14 @@ module Roma
|
|
194
192
|
end
|
195
193
|
|
196
194
|
def asyncev_redundant(args)
|
197
|
-
nid,hname,k,d,clk,expt,v = args
|
195
|
+
nid, hname, k, d, clk, expt, v = args
|
198
196
|
@log.debug("#{__method__} #{args.inspect}")
|
199
197
|
unless @rttable.nodes.include?(nid)
|
200
198
|
@log.warn("async redundant failed:#{nid} does not found in routing table.#{k}\e#{hname} #{d} #{clk} #{expt} #{v.length}")
|
201
199
|
return true # no retry
|
202
200
|
end
|
203
|
-
res = async_send_cmd(nid,"rset #{k}\e#{hname} #{d} #{clk} #{expt} #{v.length}\r\n#{v}\r\n",10)
|
204
|
-
if res
|
201
|
+
res = async_send_cmd(nid, "rset #{k}\e#{hname} #{d} #{clk} #{expt} #{v.length}\r\n#{v}\r\n", 10)
|
202
|
+
if res.nil? || res.start_with?('ERROR')
|
205
203
|
@log.warn("async redundant failed:#{k}\e#{hname} #{d} #{clk} #{expt} #{v.length} -> #{nid}")
|
206
204
|
return false # retry
|
207
205
|
end
|
@@ -209,14 +207,14 @@ module Roma
|
|
209
207
|
end
|
210
208
|
|
211
209
|
def asyncev_zredundant(args)
|
212
|
-
nid,hname,k,d,clk,expt,zv = args
|
210
|
+
nid, hname, k, d, clk, expt, zv = args
|
213
211
|
@log.debug("#{__method__} #{args.inspect}")
|
214
212
|
unless @rttable.nodes.include?(nid)
|
215
213
|
@log.warn("async zredundant failed:#{nid} does not found in routing table.#{k}\e#{hname} #{d} #{clk} #{expt} #{zv.length}")
|
216
214
|
return true # no retry
|
217
215
|
end
|
218
|
-
res = async_send_cmd(nid,"rzset #{k}\e#{hname} #{d} #{clk} #{expt} #{zv.length}\r\n#{zv}\r\n",10)
|
219
|
-
if res
|
216
|
+
res = async_send_cmd(nid, "rzset #{k}\e#{hname} #{d} #{clk} #{expt} #{zv.length}\r\n#{zv}\r\n", 10)
|
217
|
+
if res.nil? || res.start_with?('ERROR')
|
220
218
|
@log.warn("async zredundant failed:#{k}\e#{hname} #{d} #{clk} #{expt} #{v.length} -> #{nid}")
|
221
219
|
return false # retry
|
222
220
|
end
|
@@ -224,13 +222,13 @@ module Roma
|
|
224
222
|
end
|
225
223
|
|
226
224
|
def asyncev_rdelete(args)
|
227
|
-
nid,hname,k,clk = args
|
225
|
+
nid, hname, k, clk = args
|
228
226
|
@log.debug("#{__method__} #{args.inspect}")
|
229
227
|
unless @rttable.nodes.include?(nid)
|
230
228
|
@log.warn("async rdelete failed:#{nid} does not found in routing table.#{k}\e#{hname} #{clk}")
|
231
229
|
return true # no retry
|
232
230
|
end
|
233
|
-
res = async_send_cmd(nid,"rdelete #{k}\e#{hname} #{clk}\r\n",10)
|
231
|
+
res = async_send_cmd(nid, "rdelete #{k}\e#{hname} #{clk}\r\n", 10)
|
234
232
|
unless res
|
235
233
|
@log.warn("async redundant failed:#{k}\e#{hname} #{clk} -> #{nid}")
|
236
234
|
return false # retry
|
@@ -245,11 +243,11 @@ module Roma
|
|
245
243
|
@log.warn("#{__method__}:already be iterated storage process.")
|
246
244
|
else
|
247
245
|
@stats.run_iterate_storage = true
|
248
|
-
t = Thread
|
246
|
+
t = Thread.new do
|
249
247
|
begin
|
250
248
|
sync_a_vnode(vn.to_i, nid, p == 'true')
|
251
|
-
rescue =>e
|
252
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
249
|
+
rescue => e
|
250
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
253
251
|
ensure
|
254
252
|
@stats.run_iterate_storage = false
|
255
253
|
end
|
@@ -273,11 +271,11 @@ module Roma
|
|
273
271
|
return true
|
274
272
|
end
|
275
273
|
@stats.run_recover = true
|
276
|
-
t = Thread
|
274
|
+
t = Thread.new do
|
277
275
|
begin
|
278
276
|
acquired_recover_process
|
279
277
|
rescue => e
|
280
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
278
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
281
279
|
ensure
|
282
280
|
@stats.run_recover = false
|
283
281
|
end
|
@@ -287,11 +285,11 @@ module Roma
|
|
287
285
|
|
288
286
|
def asyncev_start_auto_recover_process(args)
|
289
287
|
@log.debug("#{__method__} #{args.inspect}")
|
290
|
-
|
291
|
-
#if @stats.run_join
|
288
|
+
# ##run_join don't have possibility to be true in this case.
|
289
|
+
# if @stats.run_join
|
292
290
|
# @log.error("#{__method__}:join process running")
|
293
291
|
# return true
|
294
|
-
#end
|
292
|
+
# end
|
295
293
|
if @stats.run_recover
|
296
294
|
@log.error("#{__method__}:recover process running.")
|
297
295
|
return false
|
@@ -301,35 +299,35 @@ module Roma
|
|
301
299
|
return true
|
302
300
|
end
|
303
301
|
|
304
|
-
@rttable.auto_recover_status =
|
305
|
-
t = Thread
|
302
|
+
@rttable.auto_recover_status = 'preparing'
|
303
|
+
t = Thread.new do
|
306
304
|
begin
|
307
|
-
timeout(@rttable.auto_recover_time)
|
308
|
-
loop
|
305
|
+
timeout(@rttable.auto_recover_time)do
|
306
|
+
loop do
|
309
307
|
sleep 1
|
310
|
-
break if @rttable.auto_recover_status !=
|
311
|
-
#break if @stats.run_join #run_join don't have possibility to be true in this case.
|
308
|
+
break if @rttable.auto_recover_status != 'preparing'
|
309
|
+
# break if @stats.run_join #run_join don't have possibility to be true in this case.
|
312
310
|
break if @stats.run_recover
|
313
311
|
break if @stats.run_balance
|
314
|
-
|
315
|
-
|
316
|
-
@log.debug(
|
312
|
+
end
|
313
|
+
end
|
314
|
+
@log.debug('inactivated AUTO_RECOVER')
|
317
315
|
rescue
|
318
316
|
case @rttable.lost_action
|
319
317
|
when :auto_assign, :shutdown
|
320
318
|
@stats.run_recover = true
|
321
|
-
@rttable.auto_recover_status =
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
319
|
+
@rttable.auto_recover_status = 'executing'
|
320
|
+
begin
|
321
|
+
@log.debug('auto recover start')
|
322
|
+
acquired_recover_process
|
323
|
+
rescue => e
|
324
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
325
|
+
ensure
|
326
|
+
@stats.run_recover = false
|
327
|
+
@rttable.auto_recover_status = 'waiting'
|
328
|
+
end
|
331
329
|
when :no_action
|
332
|
-
@log.debug(
|
330
|
+
@log.debug('auto recover NOT start. Because lost action is [no_action]')
|
333
331
|
end
|
334
332
|
end
|
335
333
|
end
|
@@ -344,11 +342,11 @@ module Roma
|
|
344
342
|
@stats.run_release = true
|
345
343
|
@stats.run_iterate_storage = true
|
346
344
|
@stats.spushv_protection = true
|
347
|
-
t = Thread
|
345
|
+
t = Thread.new do
|
348
346
|
begin
|
349
347
|
release_process
|
350
348
|
rescue => e
|
351
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
349
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
352
350
|
ensure
|
353
351
|
@stats.run_iterate_storage = false
|
354
352
|
@stats.run_release = false
|
@@ -368,7 +366,7 @@ module Roma
|
|
368
366
|
break unless @do_acquired_recover_process
|
369
367
|
break if @rttable.num_of_vn(@stats.ap_str)[2] == 0 # short vnodes
|
370
368
|
|
371
|
-
vn, nodes, is_primary = @rttable.select_vn_for_recover(exclude_nodes)
|
369
|
+
vn, nodes, is_primary = @rttable.select_vn_for_recover(exclude_nodes, @stats.rep_host)
|
372
370
|
break unless vn
|
373
371
|
|
374
372
|
if nodes.length != 0
|
@@ -383,7 +381,7 @@ module Roma
|
|
383
381
|
end
|
384
382
|
@log.info("#{__method__} has done.")
|
385
383
|
rescue => e
|
386
|
-
@log.error("#{e.inspect} #{
|
384
|
+
@log.error("#{e.inspect} #{$ERROR_POSITION}")
|
387
385
|
ensure
|
388
386
|
@do_acquired_recover_process = false
|
389
387
|
end
|
@@ -395,10 +393,10 @@ module Roma
|
|
395
393
|
exclude_nodes = @rttable.exclude_nodes_for_join(@stats.ap_str, @stats.rep_host)
|
396
394
|
|
397
395
|
@do_join_process = true
|
398
|
-
while
|
396
|
+
while @rttable.vnode_balance(@stats.ap_str) == :less && count < nv
|
399
397
|
break unless @do_join_process
|
400
398
|
|
401
|
-
vn, nodes, is_primary = @rttable.select_vn_for_join(exclude_nodes)
|
399
|
+
vn, nodes, is_primary = @rttable.select_vn_for_join(exclude_nodes, @stats.rep_host)
|
402
400
|
unless vn
|
403
401
|
@log.warn("#{__method__}:vnode does not found")
|
404
402
|
return false
|
@@ -412,7 +410,7 @@ module Roma
|
|
412
410
|
end
|
413
411
|
end
|
414
412
|
rescue => e
|
415
|
-
@log.error("#{e.inspect} #{
|
413
|
+
@log.error("#{e.inspect} #{$ERROR_POSITION}")
|
416
414
|
ensure
|
417
415
|
@log.info("#{__method__} has done.")
|
418
416
|
@do_join_process = false
|
@@ -425,10 +423,10 @@ module Roma
|
|
425
423
|
exclude_nodes = @rttable.exclude_nodes_for_balance(@stats.ap_str, @stats.rep_host)
|
426
424
|
|
427
425
|
@do_balance_process = true
|
428
|
-
while
|
426
|
+
while @rttable.vnode_balance(@stats.ap_str) == :less && count < nv
|
429
427
|
break unless @do_balance_process
|
430
428
|
|
431
|
-
vn, nodes, is_primary = @rttable.select_vn_for_balance(exclude_nodes)
|
429
|
+
vn, nodes, is_primary = @rttable.select_vn_for_balance(exclude_nodes, @stats.rep_host)
|
432
430
|
unless vn
|
433
431
|
@log.warn("#{__method__}:vnode does not found")
|
434
432
|
return false
|
@@ -443,7 +441,7 @@ module Roma
|
|
443
441
|
end
|
444
442
|
@log.info("#{__method__} has done.")
|
445
443
|
rescue => e
|
446
|
-
@log.error("#{e.inspect} #{
|
444
|
+
@log.error("#{e.inspect} #{$ERROR_POSITION}")
|
447
445
|
ensure
|
448
446
|
@do_balance_process = false
|
449
447
|
end
|
@@ -454,16 +452,16 @@ module Roma
|
|
454
452
|
res = con.gets # receive 'PUSHED\r\n' | 'REJECTED\r\n' | 'ERROR\r\n'
|
455
453
|
if res == "REJECTED\r\n"
|
456
454
|
@log.warn("#{__method__}:request was rejected from #{src_nid}.")
|
457
|
-
Roma::Messaging::ConPool.instance.return_connection(src_nid,con)
|
455
|
+
Roma::Messaging::ConPool.instance.return_connection(src_nid, con)
|
458
456
|
return :rejected
|
459
457
|
elsif res != "PUSHED\r\n"
|
460
458
|
@log.warn("#{__method__}:#{res}")
|
461
459
|
return :rejected
|
462
460
|
end
|
463
|
-
Roma::Messaging::ConPool.instance.return_connection(src_nid,con)
|
461
|
+
Roma::Messaging::ConPool.instance.return_connection(src_nid, con)
|
464
462
|
# waiting for pushv
|
465
463
|
count = 0
|
466
|
-
while @rttable.search_nodes(vn).include?(@stats.ap_str)==false && count < @stats.reqpushv_timeout_count
|
464
|
+
while @rttable.search_nodes(vn).include?(@stats.ap_str) == false && count < @stats.reqpushv_timeout_count
|
467
465
|
sleep 0.1
|
468
466
|
count += 1
|
469
467
|
end
|
@@ -472,8 +470,8 @@ module Roma
|
|
472
470
|
return :timeout
|
473
471
|
end
|
474
472
|
true
|
475
|
-
rescue =>e
|
476
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
473
|
+
rescue => e
|
474
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
477
475
|
@rttable.proc_failed(src_nid)
|
478
476
|
false
|
479
477
|
end
|
@@ -487,7 +485,7 @@ module Roma
|
|
487
485
|
end
|
488
486
|
|
489
487
|
@do_release_process = true
|
490
|
-
while
|
488
|
+
while @rttable.has_node?(@stats.ap_str)
|
491
489
|
break unless @do_release_process
|
492
490
|
@rttable.each_vnode do |vn, nids|
|
493
491
|
break unless @do_release_process
|
@@ -507,8 +505,8 @@ module Roma
|
|
507
505
|
end
|
508
506
|
end
|
509
507
|
@log.info("#{__method__} has done.")
|
510
|
-
rescue =>e
|
511
|
-
@log.error("#{e}\n#{
|
508
|
+
rescue => e
|
509
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
512
510
|
ensure
|
513
511
|
@do_release_process = false
|
514
512
|
Roma::Messaging::ConPool.instance.close_all
|
@@ -517,23 +515,23 @@ module Roma
|
|
517
515
|
def sync_a_vnode_for_release(vn, to_nid, new_nids)
|
518
516
|
nids = @rttable.search_nodes(vn)
|
519
517
|
|
520
|
-
if nids.include?(to_nid)==false
|
518
|
+
if nids.include?(to_nid) == false
|
521
519
|
@log.debug("#{__method__}:#{vn} #{to_nid}")
|
522
520
|
# change routing data at the vnode and synchronize a data
|
523
521
|
nids << to_nid
|
524
522
|
return false unless @rttable.transaction(vn, nids)
|
525
523
|
|
526
524
|
# synchronize a data
|
527
|
-
@storages.each_key
|
525
|
+
@storages.each_key do |hname|
|
528
526
|
res = push_a_vnode_stream(hname, vn, to_nid)
|
529
527
|
|
530
|
-
if res !=
|
528
|
+
if res != 'STORED'
|
531
529
|
@rttable.rollback(vn)
|
532
530
|
@log.error("#{__method__}:push_a_vnode was failed:hname=#{hname} vn=#{vn}:#{res}")
|
533
|
-
return :abort if res.start_with?(
|
531
|
+
return :abort if res.start_with?('SERVER_ERROR')
|
534
532
|
return false
|
535
533
|
end
|
536
|
-
|
534
|
+
end
|
537
535
|
|
538
536
|
if (clk = @rttable.commit(vn)) == false
|
539
537
|
@rttable.rollback(vn)
|
@@ -543,40 +541,40 @@ module Roma
|
|
543
541
|
|
544
542
|
clk = @rttable.set_route(vn, clk, new_nids)
|
545
543
|
if clk.is_a?(Integer) == false
|
546
|
-
clk,new_nids = @rttable.search_nodes_with_clk(vn)
|
544
|
+
clk, new_nids = @rttable.search_nodes_with_clk(vn)
|
547
545
|
end
|
548
546
|
|
549
547
|
cmd = "setroute #{vn} #{clk - 1}"
|
550
|
-
new_nids.each{ |nn| cmd << " #{nn}"}
|
548
|
+
new_nids.each { |nn| cmd << " #{nn}" }
|
551
549
|
res = async_broadcast_cmd("#{cmd}\r\n")
|
552
550
|
@log.debug("#{__method__}:async_broadcast_cmd(#{cmd}) #{res}")
|
553
551
|
end
|
554
552
|
|
555
553
|
return true
|
556
|
-
rescue =>e
|
557
|
-
@log.error("#{e}\n#{
|
554
|
+
rescue => e
|
555
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
558
556
|
false
|
559
557
|
end
|
560
558
|
|
561
|
-
def sync_a_vnode(vn, to_nid, is_primary=nil)
|
559
|
+
def sync_a_vnode(vn, to_nid, is_primary = nil)
|
562
560
|
nids = @rttable.search_nodes(vn)
|
563
561
|
|
564
|
-
if nids.include?(to_nid)==false || (is_primary && nids[0]!=to_nid)
|
562
|
+
if nids.include?(to_nid) == false || (is_primary && nids[0] != to_nid)
|
565
563
|
@log.debug("#{__method__}:#{vn} #{to_nid} #{is_primary}")
|
566
564
|
# change routing data at the vnode and synchronize a data
|
567
565
|
nids << to_nid
|
568
566
|
return false unless @rttable.transaction(vn, nids)
|
569
567
|
|
570
568
|
# synchronize a data
|
571
|
-
@storages.each_key
|
569
|
+
@storages.each_key do |hname|
|
572
570
|
res = push_a_vnode_stream(hname, vn, to_nid)
|
573
571
|
|
574
|
-
if res !=
|
572
|
+
if res != 'STORED'
|
575
573
|
@rttable.rollback(vn)
|
576
574
|
@log.error("#{__method__}:push_a_vnode was failed:hname=#{hname} vn=#{vn}:#{res}")
|
577
575
|
return false
|
578
576
|
end
|
579
|
-
|
577
|
+
end
|
580
578
|
|
581
579
|
if (clk = @rttable.commit(vn)) == false
|
582
580
|
@rttable.rollback(vn)
|
@@ -587,27 +585,27 @@ module Roma
|
|
587
585
|
nids = edit_nodes(nids, to_nid, is_primary)
|
588
586
|
clk = @rttable.set_route(vn, clk, nids)
|
589
587
|
if clk.is_a?(Integer) == false
|
590
|
-
clk,nids = @rttable.search_nodes_with_clk(vn)
|
588
|
+
clk, nids = @rttable.search_nodes_with_clk(vn)
|
591
589
|
end
|
592
590
|
|
593
591
|
cmd = "setroute #{vn} #{clk - 1}"
|
594
|
-
nids.each{ |nn| cmd << " #{nn}"}
|
592
|
+
nids.each { |nn| cmd << " #{nn}" }
|
595
593
|
res = async_broadcast_cmd("#{cmd}\r\n")
|
596
594
|
@log.debug("#{__method__}:async_broadcast_cmd(#{cmd}) #{res}")
|
597
595
|
else
|
598
596
|
# synchronize a data
|
599
|
-
@storages.each_key
|
597
|
+
@storages.each_key do |hname|
|
600
598
|
res = push_a_vnode_stream(hname, vn, to_nid)
|
601
|
-
if res !=
|
599
|
+
if res != 'STORED'
|
602
600
|
@log.error("#{__method__}:push_a_vnode was failed:hname=#{hname} vn=#{vn}:#{res}")
|
603
601
|
return false
|
604
602
|
end
|
605
|
-
|
603
|
+
end
|
606
604
|
end
|
607
605
|
|
608
606
|
return true
|
609
|
-
rescue =>e
|
610
|
-
@log.error("#{e}\n#{
|
607
|
+
rescue => e
|
608
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
611
609
|
false
|
612
610
|
end
|
613
611
|
|
@@ -636,7 +634,7 @@ module Roma
|
|
636
634
|
|
637
635
|
if is_primary
|
638
636
|
# [new_nid, node_a]
|
639
|
-
nodes.insert(0,new_nid)
|
637
|
+
nodes.insert(0, new_nid)
|
640
638
|
else
|
641
639
|
# [node_a, new_nid]
|
642
640
|
nodes << new_nid
|
@@ -666,64 +664,63 @@ module Roma
|
|
666
664
|
unless @do_push_a_vnode_stream
|
667
665
|
con.close
|
668
666
|
@log.error("#{__method__}:canceled in hname=#{hname} vn=#{vn} nid=#{nid}")
|
669
|
-
return
|
667
|
+
return 'CANCELED'
|
670
668
|
end
|
671
669
|
|
672
670
|
con.write(data)
|
673
671
|
sleep @stats.stream_copy_wait_param
|
674
672
|
end
|
675
|
-
con.write("\0"*20) # end of steram
|
673
|
+
con.write("\0" * 20) # end of steram
|
676
674
|
|
677
675
|
res = con.gets # STORED\r\n or error string
|
678
|
-
Roma::Messaging::ConPool.instance.return_connection(nid,con)
|
676
|
+
Roma::Messaging::ConPool.instance.return_connection(nid, con)
|
679
677
|
res.chomp! if res
|
680
678
|
if res_dump == false
|
681
679
|
@log.error("#{__method__}:each_vn_dump in hname=#{hname} vn=#{vn} nid=#{nid}")
|
682
|
-
return
|
680
|
+
return 'CANCELED'
|
683
681
|
end
|
684
682
|
res
|
685
|
-
rescue =>e
|
686
|
-
@log.error("#{e}\n#{
|
683
|
+
rescue => e
|
684
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
687
685
|
e.to_s
|
688
686
|
end
|
689
687
|
|
690
|
-
|
691
|
-
|
692
|
-
# @log.info("#{__method__}")
|
688
|
+
def asyncev_start_storage_clean_up_process(_args)
|
689
|
+
# @log.info("#{__method__}")
|
693
690
|
if @stats.run_storage_clean_up
|
694
691
|
@log.error("#{__method__}:already in being")
|
695
692
|
return
|
696
693
|
end
|
697
694
|
@stats.run_storage_clean_up = true
|
698
|
-
t = Thread
|
695
|
+
t = Thread.new do
|
699
696
|
begin
|
700
697
|
storage_clean_up_process
|
701
|
-
rescue =>e
|
702
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
698
|
+
rescue => e
|
699
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
703
700
|
ensure
|
704
701
|
@stats.last_clean_up = Time.now
|
705
702
|
@stats.run_storage_clean_up = false
|
706
703
|
end
|
707
|
-
|
704
|
+
end
|
708
705
|
t[:name] = __method__
|
709
706
|
end
|
710
707
|
|
711
708
|
def storage_clean_up_process
|
712
709
|
@log.info("#{__method__}:start")
|
713
710
|
me = @stats.ap_str
|
714
|
-
vnhash={}
|
711
|
+
vnhash = {}
|
715
712
|
@rttable.each_vnode do |vn, nids|
|
716
713
|
if nids.include?(me)
|
717
714
|
if nids[0] == me
|
718
715
|
vnhash[vn] = :primary
|
719
716
|
else
|
720
|
-
vnhash[vn] =
|
717
|
+
vnhash[vn] = "secondary#{nids.index(me)}".to_sym
|
721
718
|
end
|
722
719
|
end
|
723
720
|
end
|
724
721
|
t = Time.now.to_i - Roma::Config::STORAGE_DELMARK_EXPTIME
|
725
722
|
count = 0
|
726
|
-
@storages.each_pair do |hname,st|
|
723
|
+
@storages.each_pair do |hname, st|
|
727
724
|
break unless @stats.do_clean_up?
|
728
725
|
st.each_clean_up(t, vnhash) do |key, vn|
|
729
726
|
# @log.debug("#{__method__}:key=#{key} vn=#{vn}")
|
@@ -733,7 +730,7 @@ module Roma
|
|
733
730
|
nodes = @rttable.search_nodes_for_write(vn)
|
734
731
|
if nodes && nodes.length > 1
|
735
732
|
nodes[1..-1].each do |nid|
|
736
|
-
res = async_send_cmd(nid,"out #{key}\e#{hname} #{vn}\r\n")
|
733
|
+
res = async_send_cmd(nid, "out #{key}\e#{hname} #{vn}\r\n")
|
737
734
|
unless res
|
738
735
|
@log.warn("send out command failed:#{key}\e#{hname} #{vn} -> #{nid}")
|
739
736
|
end
|
@@ -746,7 +743,7 @@ module Roma
|
|
746
743
|
end
|
747
744
|
end
|
748
745
|
end
|
749
|
-
if count>0
|
746
|
+
if count > 0
|
750
747
|
@log.info("#{__method__}:#{count} keys deleted.")
|
751
748
|
end
|
752
749
|
|
@@ -763,46 +760,46 @@ module Roma
|
|
763
760
|
end
|
764
761
|
|
765
762
|
def asyncev_calc_latency_average(args)
|
766
|
-
latency,cmd = args
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
@stats.latency_data[cmd].store(
|
771
|
-
@stats.latency_data[cmd].store(
|
772
|
-
@stats.latency_data[cmd][
|
773
|
-
@stats.latency_data[cmd].store(
|
774
|
-
@stats.latency_data[cmd][
|
775
|
-
@stats.latency_data[cmd].store(
|
763
|
+
latency, cmd = args
|
764
|
+
# @log.debug(__method__)
|
765
|
+
|
766
|
+
unless @stats.latency_data.key?(cmd) # only first execute target cmd
|
767
|
+
@stats.latency_data[cmd].store('latency', [])
|
768
|
+
@stats.latency_data[cmd].store('latency_max', {})
|
769
|
+
@stats.latency_data[cmd]['latency_max'].store('current', 0)
|
770
|
+
@stats.latency_data[cmd].store('latency_min', {})
|
771
|
+
@stats.latency_data[cmd]['latency_min'].store('current', 99_999)
|
772
|
+
@stats.latency_data[cmd].store('time', Time.now.to_i)
|
776
773
|
end
|
777
774
|
|
778
775
|
begin
|
779
|
-
@stats.latency_data[cmd][
|
780
|
-
@stats.latency_data[cmd][
|
776
|
+
@stats.latency_data[cmd]['latency'].delete_at(0) if @stats.latency_data[cmd]['latency'].length >= 10
|
777
|
+
@stats.latency_data[cmd]['latency'].push(latency)
|
781
778
|
|
782
|
-
@stats.latency_data[cmd][
|
783
|
-
@stats.latency_data[cmd][
|
779
|
+
@stats.latency_data[cmd]['latency_max']['current'] = latency if latency > @stats.latency_data[cmd]['latency_max']['current']
|
780
|
+
@stats.latency_data[cmd]['latency_min']['current'] = latency if latency < @stats.latency_data[cmd]['latency_min']['current']
|
784
781
|
|
785
|
-
rescue =>e
|
786
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
782
|
+
rescue => e
|
783
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
787
784
|
|
788
785
|
ensure
|
789
|
-
if @stats.latency_check_time_count && Time.now.to_i - @stats.latency_data[cmd][
|
790
|
-
average = @stats.latency_data[cmd][
|
791
|
-
max = @stats.latency_data[cmd][
|
792
|
-
min = @stats.latency_data[cmd][
|
793
|
-
@log.debug("Latency average[#{cmd}]: #{sprintf(
|
794
|
-
"(denominator=#{@stats.latency_data[cmd][
|
795
|
-
" max=#{sprintf(
|
796
|
-
" min=#{sprintf(
|
786
|
+
if @stats.latency_check_time_count && Time.now.to_i - @stats.latency_data[cmd]['time'] > @stats.latency_check_time_count
|
787
|
+
average = @stats.latency_data[cmd]['latency'].inject(0.0) { |r, i| r += i } / @stats.latency_data[cmd]['latency'].size
|
788
|
+
max = @stats.latency_data[cmd]['latency_max']['current']
|
789
|
+
min = @stats.latency_data[cmd]['latency_min']['current']
|
790
|
+
@log.debug("Latency average[#{cmd}]: #{sprintf('%.8f', average)}"\
|
791
|
+
"(denominator=#{@stats.latency_data[cmd]['latency'].length}"\
|
792
|
+
" max=#{sprintf('%.8f', max)}"\
|
793
|
+
" min=#{sprintf('%.8f', min)})"
|
797
794
|
)
|
798
795
|
|
799
|
-
@stats.latency_data[cmd][
|
800
|
-
@stats.latency_data[cmd][
|
801
|
-
@stats.latency_data[cmd][
|
802
|
-
@stats.latency_data[cmd][
|
803
|
-
@stats.latency_data[cmd][
|
804
|
-
@stats.latency_data[cmd][
|
805
|
-
@stats.latency_data[cmd][
|
796
|
+
@stats.latency_data[cmd]['time'] = Time.now.to_i
|
797
|
+
@stats.latency_data[cmd]['latency_past'] = @stats.latency_data[cmd]['latency']
|
798
|
+
@stats.latency_data[cmd]['latency'] = []
|
799
|
+
@stats.latency_data[cmd]['latency_max']['past'] = @stats.latency_data[cmd]['latency_max']['current']
|
800
|
+
@stats.latency_data[cmd]['latency_max']['current'] = 0
|
801
|
+
@stats.latency_data[cmd]['latency_min']['past'] = @stats.latency_data[cmd]['latency_min']['current']
|
802
|
+
@stats.latency_data[cmd]['latency_min']['current'] = 99_999
|
806
803
|
end
|
807
804
|
end
|
808
805
|
true
|
@@ -817,13 +814,13 @@ module Roma
|
|
817
814
|
@log.error("Can not flush storage. stat = #{st.dbs[dn]}")
|
818
815
|
return true
|
819
816
|
end
|
820
|
-
t = Thread
|
817
|
+
t = Thread.new do
|
821
818
|
begin
|
822
819
|
st.flush_db(dn)
|
823
|
-
st.set_db_stat(dn
|
820
|
+
st.set_db_stat(dn, :safecopy_flushed)
|
824
821
|
@log.info("#{__method__}:storage has flushed. (#{hname}, #{dn})")
|
825
|
-
rescue =>e
|
826
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
822
|
+
rescue => e
|
823
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
827
824
|
ensure
|
828
825
|
end
|
829
826
|
end
|
@@ -840,11 +837,11 @@ module Roma
|
|
840
837
|
@log.error("Can not start cachecleaning process. stat = #{st.dbs[dn]}")
|
841
838
|
return true
|
842
839
|
end
|
843
|
-
t = Thread
|
840
|
+
t = Thread.new do
|
844
841
|
begin
|
845
842
|
storage_cachecleaning_process(hname, dn)
|
846
|
-
rescue =>e
|
847
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
843
|
+
rescue => e
|
844
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
848
845
|
ensure
|
849
846
|
end
|
850
847
|
end
|
@@ -861,7 +858,7 @@ module Roma
|
|
861
858
|
loop do
|
862
859
|
# get keys in a cache up to 100 kyes
|
863
860
|
keys = st.get_keys_in_cache(dn)
|
864
|
-
break if keys
|
861
|
+
break if keys.nil? || keys.length == 0
|
865
862
|
break unless @do_storage_cachecleaning_process
|
866
863
|
|
867
864
|
# @log.debug("#{__method__}:#{keys.length} keys found")
|
@@ -884,7 +881,7 @@ module Roma
|
|
884
881
|
if @do_storage_cachecleaning_process == false
|
885
882
|
@log.warn("#{__method__}:uncompleted")
|
886
883
|
else
|
887
|
-
st.set_db_stat(dn
|
884
|
+
st.set_db_stat(dn, :normal)
|
888
885
|
end
|
889
886
|
@log.debug("#{__method__}:#{count} keys loaded.")
|
890
887
|
@log.debug("#{__method__}:#{rcount} keys rejected.") if rcount > 0
|
@@ -894,11 +891,11 @@ module Roma
|
|
894
891
|
|
895
892
|
def asyncev_start_get_routing_event(args)
|
896
893
|
@log.debug("#{__method__} #{args}")
|
897
|
-
t = Thread
|
894
|
+
t = Thread.new do
|
898
895
|
begin
|
899
896
|
get_routing_event
|
900
897
|
rescue => e
|
901
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
898
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
902
899
|
ensure
|
903
900
|
end
|
904
901
|
end
|
@@ -911,27 +908,27 @@ module Roma
|
|
911
908
|
routing_path = Config::RTTABLE_PATH
|
912
909
|
f_list = Dir.glob("#{routing_path}/#{@stats.ap_str}*")
|
913
910
|
|
914
|
-
f_list.each
|
915
|
-
IO.foreach(fname)
|
911
|
+
f_list.each do|fname|
|
912
|
+
IO.foreach(fname)do|line|
|
916
913
|
if line =~ /join|leave/
|
917
914
|
@rttable.event.shift if @rttable.event.size >= @rttable.event_limit_line
|
918
|
-
@rttable.event << line.chomp
|
915
|
+
@rttable.event << line.chomp
|
919
916
|
end
|
920
|
-
|
921
|
-
|
917
|
+
end
|
918
|
+
end
|
922
919
|
|
923
920
|
@log.info("#{__method__} has done.")
|
924
|
-
rescue =>e
|
925
|
-
@log.error("#{e}\n#{
|
921
|
+
rescue => e
|
922
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
926
923
|
end
|
927
924
|
|
928
925
|
def asyncev_start_get_logs(args)
|
929
926
|
@log.debug("#{__method__} #{args}")
|
930
|
-
t = Thread
|
927
|
+
t = Thread.new do
|
931
928
|
begin
|
932
929
|
get_logs(args)
|
933
930
|
rescue => e
|
934
|
-
@log.error("#{__method__}:#{e.inspect} #{
|
931
|
+
@log.error("#{__method__}:#{e.inspect} #{$ERROR_POSITION}")
|
935
932
|
ensure
|
936
933
|
@stats.gui_run_gather_logs = false
|
937
934
|
end
|
@@ -946,7 +943,7 @@ module Roma
|
|
946
943
|
log_file = "#{log_path}/#{@stats.ap_str}.log"
|
947
944
|
|
948
945
|
target_logs = []
|
949
|
-
File.open(log_file)
|
946
|
+
File.open(log_file)do|f|
|
950
947
|
start_point = get_point(f, args[0], 'start')
|
951
948
|
end_point = get_point(f, args[1], 'end')
|
952
949
|
|
@@ -955,26 +952,26 @@ module Roma
|
|
955
952
|
target_logs = f.read(end_point - start_point)
|
956
953
|
target_logs = target_logs.each_line.map(&:chomp)
|
957
954
|
target_logs.delete('.')
|
958
|
-
|
955
|
+
end
|
959
956
|
|
960
957
|
@rttable.logs = target_logs
|
961
958
|
# set gathered date for expiration
|
962
959
|
@rttable.logs.unshift(Time.now)
|
963
960
|
|
964
961
|
@log.debug("#{__method__} has done.")
|
965
|
-
rescue =>e
|
962
|
+
rescue => e
|
966
963
|
@rttable.logs = []
|
967
|
-
@log.error("#{e}\n#{
|
964
|
+
@log.error("#{e}\n#{$ERROR_POSITION}")
|
968
965
|
ensure
|
969
966
|
@stats.gui_run_gather_logs = false
|
970
967
|
end
|
971
968
|
|
972
|
-
def get_point(f, target_time, type, latency_time=Time.now, current_pos=0, new_pos=f.size/2)
|
969
|
+
def get_point(f, target_time, type, latency_time = Time.now, current_pos = 0, new_pos = f.size / 2)
|
973
970
|
# hilatency check
|
974
|
-
ps = Time.now - latency_time
|
971
|
+
ps = Time.now - latency_time
|
975
972
|
if ps > 5
|
976
|
-
@log.warn(
|
977
|
-
|
973
|
+
@log.warn('gather_logs process was failed.')
|
974
|
+
fail
|
978
975
|
end
|
979
976
|
|
980
977
|
# initialize read size
|
@@ -986,33 +983,33 @@ module Roma
|
|
986
983
|
return f.size if target_time == 'current'
|
987
984
|
|
988
985
|
target_time =~ (/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)/)
|
989
|
-
target_time = Time.mktime(
|
990
|
-
|
986
|
+
target_time = Time.mktime(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3], Regexp.last_match[4], Regexp.last_match[5], Regexp.last_match[6], 000000)
|
987
|
+
|
991
988
|
# check outrange or not
|
992
989
|
f.seek(0, IO::SEEK_SET)
|
993
990
|
begining_log = f.read(read_size)
|
994
991
|
pos = begining_log.index(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
995
|
-
begining_time = Time.mktime(
|
992
|
+
begining_time = Time.mktime(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3], Regexp.last_match[4], Regexp.last_match[5], Regexp.last_match[6], Regexp.last_match[7])
|
996
993
|
|
997
994
|
f.seek(-read_size, IO::SEEK_END)
|
998
995
|
end_log = f.read(read_size)
|
999
996
|
pos = end_log.rindex(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
1000
|
-
end_time = Time.mktime(
|
997
|
+
end_time = Time.mktime(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3], Regexp.last_match[4], Regexp.last_match[5], Regexp.last_match[6], Regexp.last_match[7])
|
1001
998
|
|
1002
999
|
case type
|
1003
1000
|
when 'start'
|
1004
1001
|
if target_time < begining_time
|
1005
1002
|
return 0
|
1006
1003
|
elsif target_time > end_time
|
1007
|
-
@log.error(
|
1008
|
-
|
1004
|
+
@log.error('irregular time was set.')
|
1005
|
+
fail
|
1009
1006
|
end
|
1010
1007
|
when 'end'
|
1011
1008
|
if target_time > end_time
|
1012
1009
|
return f.size
|
1013
1010
|
elsif target_time < begining_time
|
1014
|
-
@log.error(
|
1015
|
-
|
1011
|
+
@log.error('irregular time was set.')
|
1012
|
+
fail
|
1016
1013
|
end
|
1017
1014
|
end
|
1018
1015
|
end
|
@@ -1024,20 +1021,20 @@ module Roma
|
|
1024
1021
|
date_a = sector_log.scan(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
1025
1022
|
|
1026
1023
|
time_a = []
|
1027
|
-
date_a.each
|
1024
|
+
date_a.each do|time|
|
1028
1025
|
time_a.push(Time.mktime(time[0], time[1], time[2], time[3], time[4], time[5], time[6]))
|
1029
|
-
|
1026
|
+
end
|
1030
1027
|
sector_time_first = time_a[0]
|
1031
1028
|
sector_time_last = time_a[-1]
|
1032
|
-
|
1029
|
+
|
1033
1030
|
if target_time.between?(sector_time_first, sector_time_last)
|
1034
|
-
time_a.each
|
1031
|
+
time_a.each do|time|
|
1035
1032
|
if target_time <= time
|
1036
|
-
time_string = time.strftime(
|
1033
|
+
time_string = time.strftime('%Y-%m-%dT%H:%M:%S')
|
1037
1034
|
target_index = sector_log.index(/[IDEW],\s\[#{time_string}/)
|
1038
1035
|
return new_pos + target_index
|
1039
|
-
end
|
1040
|
-
|
1036
|
+
end
|
1037
|
+
end
|
1041
1038
|
elsif sector_time_first > target_time
|
1042
1039
|
target_pos = new_pos - ((new_pos - current_pos).abs / 2)
|
1043
1040
|
elsif sector_time_first < target_time
|
@@ -1046,7 +1043,5 @@ module Roma
|
|
1046
1043
|
|
1047
1044
|
get_point(f, target_time, type, latency_time, new_pos, target_pos)
|
1048
1045
|
end
|
1049
|
-
|
1050
1046
|
end # module AsyncProcess
|
1051
|
-
|
1052
1047
|
end # module Roma
|