roma 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +42 -2
- data/Gemfile +1 -15
- data/LICENSE +1 -1
- data/README.md +78 -0
- data/Rakefile +1 -62
- data/bin/chg_redundancy +10 -0
- data/bin/cpdb +7 -0
- data/bin/key_access +7 -0
- data/bin/key_list +7 -0
- data/bin/log_merger +7 -0
- data/{ruby/server/bin → bin}/mkconfig +3 -1
- data/bin/mkrecent +7 -0
- data/bin/mkroute +7 -0
- data/{ruby/server/bin → bin}/multi_commander +4 -3
- data/bin/recoverlost +11 -0
- data/bin/recoverlost_alist +10 -0
- data/bin/recoverlost_alist_all +10 -0
- data/bin/recoverlost_alist_keys +10 -0
- data/bin/roma_watcher +10 -0
- data/{ruby/server/bin → bin}/romad +3 -2
- data/bin/safecopy_integration_test +10 -0
- data/bin/safecopy_test +10 -0
- data/bin/sample_watcher +10 -0
- data/bin/sample_watcher2 +10 -0
- data/bin/sample_watcher3 +10 -0
- data/bin/simple_bench +11 -0
- data/bin/ssroute +10 -0
- data/bin/tc_data_restore.rb +123 -0
- data/bin/test-scenario +11 -0
- data/bin/tribunus +7 -0
- data/{ruby/server/lib → lib}/roma/async_process.rb +105 -26
- data/{ruby/server/lib → lib}/roma/command/bg_command_receiver.rb +0 -0
- data/{ruby/server/lib → lib}/roma/command/command_definition.rb +12 -12
- data/{ruby/server/lib → lib}/roma/command/mh_command_receiver.rb +4 -4
- data/{ruby/server/lib → lib}/roma/command/receiver.rb +0 -0
- data/{ruby/server/lib → lib}/roma/command/rt_command_receiver.rb +7 -0
- data/{ruby/server/lib → lib}/roma/command/sys_command_receiver.rb +68 -3
- data/{ruby/server/lib → lib}/roma/command/util_command_receiver.rb +0 -0
- data/{ruby/server/lib → lib}/roma/command/vn_command_receiver.rb +0 -0
- data/{ruby/server/lib → lib}/roma/command_plugin.rb +0 -0
- data/{ruby/server/lib → lib}/roma/config.rb +4 -1
- data/{ruby/server/lib → lib}/roma/dns_cache.rb +0 -0
- data/{ruby/server/lib → lib}/roma/event/con_pool.rb +0 -0
- data/{ruby/server/lib → lib}/roma/event/handler.rb +0 -0
- data/{ruby/server/lib → lib}/roma/logging/rlogger.rb +61 -2
- data/{ruby/server/lib → lib}/roma/messaging/con_pool.rb +14 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_alist.rb +0 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_cmd_aliases.rb +0 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_debug.rb +0 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_gui.rb +12 -13
- data/{ruby/server/lib → lib}/roma/plugin/plugin_map.rb +0 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_mapcount.rb +0 -0
- data/{ruby/server/lib → lib}/roma/plugin/plugin_storage.rb +11 -11
- data/{ruby/server/lib → lib}/roma/plugin/plugin_test.rb +0 -0
- data/{ruby/server/lib → lib}/roma/romad.rb +25 -1
- data/{ruby/server/lib → lib}/roma/routing/cb_rttable.rb +0 -0
- data/{ruby/server/lib → lib}/roma/routing/merkle_tree.rb +0 -0
- data/{ruby/server/lib → lib}/roma/routing/random_balancer.rb +0 -0
- data/{ruby/server/lib → lib}/roma/routing/random_partitioner.rb +0 -0
- data/{ruby/server/lib → lib}/roma/routing/routing_data.rb +0 -0
- data/{ruby/server/lib → lib}/roma/routing/rttable.rb +0 -0
- data/{ruby/server/lib → lib}/roma/stats.rb +11 -0
- data/{ruby/server/lib → lib}/roma/storage/basic_storage.rb +3 -0
- data/{ruby/server/lib → lib}/roma/storage/dbm_storage.rb +0 -0
- data/{ruby/server/lib → lib}/roma/storage/dummy_storage.rb +0 -0
- data/lib/roma/storage/groonga_storage.rb +101 -0
- data/{ruby/server/lib → lib}/roma/storage/rh_storage.rb +0 -0
- data/{ruby/server/lib → lib}/roma/storage/sqlite3_storage.rb +0 -0
- data/{ruby/server/lib → lib}/roma/storage/tc_storage.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/chg_redundancy.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/cpdb.rb +13 -2
- data/{ruby/server/lib → lib}/roma/tools/key_access.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/key_list.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/log_merger.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/mkconfig.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/mkrecent.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/mkroute.rb +5 -1
- data/{ruby/server/lib → lib}/roma/tools/multi_commander.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/recoverlost.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/recoverlost_alist.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/recoverlost_alist_all.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/recoverlost_alist_keys.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/recoverlost_lib.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/roma_watcher.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/roma_watcher_config.yml.example +0 -0
- data/{ruby/server/lib → lib}/roma/tools/safecopy_integration_test.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/safecopy_test.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/sample_watcher.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/sample_watcher2.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/sample_watcher3.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/simple_bench.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/simple_bench2.rb +0 -0
- data/{ruby/server/lib → lib}/roma/tools/ssroute.rb +1 -1
- data/{ruby/server/lib → lib}/roma/tools/test-scenario.rb +3 -3
- data/{ruby/server/lib → lib}/roma/tools/tribunus.rb +1 -1
- data/lib/roma/version.rb +4 -0
- data/{ruby/server/lib → lib}/roma/write_behind.rb +0 -0
- data/{ruby/server/test → test}/config4mhash.rb +0 -0
- data/{ruby/server/test → test}/config4storage_error.rb +0 -0
- data/{ruby/server/test → test}/config4test.rb +0 -0
- data/{ruby/server/test → test}/rcirb.rb +0 -0
- data/{ruby/server/test → test}/roma-test-utils.rb +10 -14
- data/test/run-test.rb +20 -0
- data/{ruby/server/test → test}/storage_error_storage.rb +0 -0
- data/{ruby/server/test → test}/t_command_definition.rb +10 -10
- data/{ruby/server/test → test}/t_cpdata.rb +0 -0
- data/{ruby/server/test → test}/t_eventmachine.rb +0 -0
- data/{ruby/server/test → test}/t_listplugin.rb +9 -3
- data/{ruby/server/test → test}/t_mapcountplugin.rb +0 -0
- data/{ruby/server/test → test}/t_mapplugin.rb +9 -3
- data/{ruby/server/test → test}/t_mhash.rb +7 -7
- data/{ruby/server/test → test}/t_protocol.rb +0 -0
- data/{ruby/server/test → test}/t_rclient.rb +8 -2
- data/{ruby/server/test → test}/t_routing_data.rb +0 -0
- data/{ruby/server/test → test}/t_storage.rb +58 -26
- data/{ruby/server/test → test}/t_storage_error.rb +5 -3
- data/{ruby/server/test → test}/t_writebehind.rb +17 -17
- metadata +225 -122
- data/README +0 -17
- data/ruby/server/bin/chg_redundancy +0 -10
- data/ruby/server/bin/cpdb +0 -6
- data/ruby/server/bin/key_access +0 -7
- data/ruby/server/bin/key_list +0 -7
- data/ruby/server/bin/log_merger +0 -6
- data/ruby/server/bin/mkrecent +0 -6
- data/ruby/server/bin/mkroute +0 -6
- data/ruby/server/bin/recoverlost +0 -10
- data/ruby/server/bin/recoverlost_alist +0 -10
- data/ruby/server/bin/recoverlost_alist_all +0 -10
- data/ruby/server/bin/recoverlost_alist_keys +0 -10
- data/ruby/server/bin/roma_watcher +0 -7
- data/ruby/server/bin/safecopy_integration_test +0 -10
- data/ruby/server/bin/safecopy_test +0 -10
- data/ruby/server/bin/sample_watcher +0 -7
- data/ruby/server/bin/sample_watcher2 +0 -7
- data/ruby/server/bin/sample_watcher3 +0 -7
- data/ruby/server/bin/simple_bench +0 -11
- data/ruby/server/bin/ssroute +0 -6
- data/ruby/server/bin/test-scenario +0 -11
- data/ruby/server/bin/tribunus +0 -6
- data/ruby/server/lib/roma/version.rb +0 -4
- data/ruby/server/test/run-test.rb +0 -17
@@ -197,7 +197,7 @@ module Roma
|
|
197
197
|
nid,hname,k,d,clk,expt,v = args
|
198
198
|
@log.debug("#{__method__} #{args.inspect}")
|
199
199
|
unless @rttable.nodes.include?(nid)
|
200
|
-
@log.warn("async redundant failed:#{nid}
|
200
|
+
@log.warn("async redundant failed:#{nid} does not found in routing table.#{k}\e#{hname} #{d} #{clk} #{expt} #{v.length}")
|
201
201
|
return true # no retry
|
202
202
|
end
|
203
203
|
res = async_send_cmd(nid,"rset #{k}\e#{hname} #{d} #{clk} #{expt} #{v.length}\r\n#{v}\r\n",10)
|
@@ -212,7 +212,7 @@ module Roma
|
|
212
212
|
nid,hname,k,d,clk,expt,zv = args
|
213
213
|
@log.debug("#{__method__} #{args.inspect}")
|
214
214
|
unless @rttable.nodes.include?(nid)
|
215
|
-
@log.warn("async zredundant failed:#{nid}
|
215
|
+
@log.warn("async zredundant failed:#{nid} does not found in routing table.#{k}\e#{hname} #{d} #{clk} #{expt} #{zv.length}")
|
216
216
|
return true # no retry
|
217
217
|
end
|
218
218
|
res = async_send_cmd(nid,"rzset #{k}\e#{hname} #{d} #{clk} #{expt} #{zv.length}\r\n#{zv}\r\n",10)
|
@@ -227,7 +227,7 @@ module Roma
|
|
227
227
|
nid,hname,k,clk = args
|
228
228
|
@log.debug("#{__method__} #{args.inspect}")
|
229
229
|
unless @rttable.nodes.include?(nid)
|
230
|
-
@log.warn("async rdelete failed:#{nid}
|
230
|
+
@log.warn("async rdelete failed:#{nid} does not found in routing table.#{k}\e#{hname} #{clk}")
|
231
231
|
return true # no retry
|
232
232
|
end
|
233
233
|
res = async_send_cmd(nid,"rdelete #{k}\e#{hname} #{clk}\r\n",10)
|
@@ -400,7 +400,7 @@ module Roma
|
|
400
400
|
|
401
401
|
vn, nodes, is_primary = @rttable.select_vn_for_join(exclude_nodes)
|
402
402
|
unless vn
|
403
|
-
@log.warn("#{__method__}:vnode
|
403
|
+
@log.warn("#{__method__}:vnode does not found")
|
404
404
|
return false
|
405
405
|
end
|
406
406
|
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
@@ -430,7 +430,7 @@ module Roma
|
|
430
430
|
|
431
431
|
vn, nodes, is_primary = @rttable.select_vn_for_balance(exclude_nodes)
|
432
432
|
unless vn
|
433
|
-
@log.warn("#{__method__}:vnode
|
433
|
+
@log.warn("#{__method__}:vnode does not found")
|
434
434
|
return false
|
435
435
|
end
|
436
436
|
ret = req_push_a_vnode(vn, nodes[0], is_primary)
|
@@ -749,6 +749,15 @@ module Roma
|
|
749
749
|
if count>0
|
750
750
|
@log.info("#{__method__}:#{count} keys deleted.")
|
751
751
|
end
|
752
|
+
|
753
|
+
# delete @rttable.logs
|
754
|
+
if @stats.gui_run_gather_logs || @rttable.logs.empty?
|
755
|
+
false
|
756
|
+
else
|
757
|
+
gathered_time = @rttable.logs[0]
|
758
|
+
# delete gathering log data after 5min
|
759
|
+
@rttable.logs.clear if gathered_time.to_i < Time.now.to_i - (60 * 5)
|
760
|
+
end
|
752
761
|
ensure
|
753
762
|
@log.info("#{__method__}:stop")
|
754
763
|
end
|
@@ -936,31 +945,23 @@ module Roma
|
|
936
945
|
log_path = Config::LOG_PATH
|
937
946
|
log_file = "#{log_path}/#{@stats.ap_str}.log"
|
938
947
|
|
939
|
-
|
940
|
-
start_time = Time.now
|
948
|
+
target_logs = []
|
941
949
|
File.open(log_file){|f|
|
942
|
-
f
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
raw_logs << line unless line.chomp == '.'
|
951
|
-
}
|
950
|
+
start_point = get_point(f, args[0], 'start')
|
951
|
+
end_point = get_point(f, args[1], 'end')
|
952
|
+
|
953
|
+
## read target logs
|
954
|
+
f.seek(start_point, IO::SEEK_SET)
|
955
|
+
target_logs = f.read(end_point - start_point)
|
956
|
+
target_logs = target_logs.each_line.map(&:chomp)
|
957
|
+
target_logs.delete('.')
|
952
958
|
}
|
953
959
|
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
else
|
958
|
-
raw_logs.shift # remove first line(date of log file was created)
|
959
|
-
sliced_logs = raw_logs
|
960
|
-
end
|
960
|
+
@rttable.logs = target_logs
|
961
|
+
# set gathered date for expiration
|
962
|
+
@rttable.logs.unshift(Time.now)
|
961
963
|
|
962
|
-
@
|
963
|
-
@log.info("#{__method__} has done.")
|
964
|
+
@log.debug("#{__method__} has done.")
|
964
965
|
rescue =>e
|
965
966
|
@rttable.logs = []
|
966
967
|
@log.error("#{e}\n#{$@}")
|
@@ -968,6 +969,84 @@ module Roma
|
|
968
969
|
@stats.gui_run_gather_logs = false
|
969
970
|
end
|
970
971
|
|
972
|
+
def get_point(f, target_time, type, latency_time=Time.now, current_pos=0, new_pos=f.size/2)
|
973
|
+
# hilatency check
|
974
|
+
ps = Time.now - latency_time
|
975
|
+
if ps > 5
|
976
|
+
@log.warn("gather_logs process was failed.")
|
977
|
+
raise
|
978
|
+
end
|
979
|
+
|
980
|
+
# initialize read size
|
981
|
+
read_size = 2048
|
982
|
+
|
983
|
+
# first check
|
984
|
+
unless target_time.class == Time
|
985
|
+
# in case of not set end_date
|
986
|
+
return f.size if target_time == 'current'
|
987
|
+
|
988
|
+
target_time =~ (/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)/)
|
989
|
+
target_time = Time.mktime($1, $2, $3, $4, $5, $6, 000000)
|
990
|
+
|
991
|
+
# check outrange or not
|
992
|
+
f.seek(0, IO::SEEK_SET)
|
993
|
+
begining_log = f.read(read_size)
|
994
|
+
pos = begining_log.index(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
995
|
+
begining_time = Time.mktime($1, $2, $3, $4, $5, $6, $7)
|
996
|
+
|
997
|
+
f.seek(-read_size, IO::SEEK_END)
|
998
|
+
end_log = f.read(read_size)
|
999
|
+
pos = end_log.rindex(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
1000
|
+
end_time = Time.mktime($1, $2, $3, $4, $5, $6, $7)
|
1001
|
+
|
1002
|
+
case type
|
1003
|
+
when 'start'
|
1004
|
+
if target_time < begining_time
|
1005
|
+
return 0
|
1006
|
+
elsif target_time > end_time
|
1007
|
+
@log.error("irregular time was set.")
|
1008
|
+
raise
|
1009
|
+
end
|
1010
|
+
when 'end'
|
1011
|
+
if target_time > end_time
|
1012
|
+
return f.size
|
1013
|
+
elsif target_time < begining_time
|
1014
|
+
@log.error("irregular time was set.")
|
1015
|
+
raise
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
# read half sector size
|
1021
|
+
f.seek(new_pos, IO::SEEK_SET)
|
1022
|
+
sector_log = f.read(read_size)
|
1023
|
+
# grep date
|
1024
|
+
date_a = sector_log.scan(/[IDEW],\s\[(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.(\d+)/)
|
1025
|
+
|
1026
|
+
time_a = []
|
1027
|
+
date_a.each{|time|
|
1028
|
+
time_a.push(Time.mktime(time[0], time[1], time[2], time[3], time[4], time[5], time[6]))
|
1029
|
+
}
|
1030
|
+
sector_time_first = time_a[0]
|
1031
|
+
sector_time_last = time_a[-1]
|
1032
|
+
|
1033
|
+
if target_time.between?(sector_time_first, sector_time_last)
|
1034
|
+
time_a.each{|time|
|
1035
|
+
if target_time <= time
|
1036
|
+
time_string = time.strftime("%Y-%m-%dT%H:%M:%S")
|
1037
|
+
target_index = sector_log.index(/[IDEW],\s\[#{time_string}/)
|
1038
|
+
return new_pos + target_index
|
1039
|
+
end
|
1040
|
+
}
|
1041
|
+
elsif sector_time_first > target_time
|
1042
|
+
target_pos = new_pos - ((new_pos - current_pos).abs / 2)
|
1043
|
+
elsif sector_time_first < target_time
|
1044
|
+
target_pos = new_pos + ((new_pos - current_pos).abs / 2)
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
get_point(f, target_time, type, latency_time, new_pos, target_pos)
|
1048
|
+
end
|
1049
|
+
|
971
1050
|
end # module AsyncProcess
|
972
1051
|
|
973
1052
|
end # module Roma
|
File without changes
|
@@ -57,7 +57,7 @@ module Roma
|
|
57
57
|
|
58
58
|
def def_read_command_with_key(cmd, forward = :one_line, &block)
|
59
59
|
define_method "ev_#{cmd}" do |s|
|
60
|
-
return send_data("CLIENT_ERROR
|
60
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
61
61
|
begin
|
62
62
|
params = CommandParams.new
|
63
63
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -74,7 +74,7 @@ module Roma
|
|
74
74
|
end
|
75
75
|
stored = StoredData.new
|
76
76
|
unless @storages[params.hash_name]
|
77
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
77
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
78
78
|
end
|
79
79
|
|
80
80
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -96,7 +96,7 @@ module Roma
|
|
96
96
|
|
97
97
|
def def_write_command_with_key(cmd, forward = :one_line, &block)
|
98
98
|
define_method "ev_#{cmd}" do |s|
|
99
|
-
return send_data("CLIENT_ERROR
|
99
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
100
100
|
begin
|
101
101
|
params = CommandParams.new
|
102
102
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -113,7 +113,7 @@ module Roma
|
|
113
113
|
end
|
114
114
|
stored = StoredData.new
|
115
115
|
unless @storages[params.hash_name]
|
116
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
116
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
117
117
|
end
|
118
118
|
|
119
119
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -167,7 +167,7 @@ module Roma
|
|
167
167
|
|
168
168
|
def def_command_with_key(cmd, forward = :one_line, &block)
|
169
169
|
define_method "ev_#{cmd}" do |s|
|
170
|
-
return send_data("CLIENT_ERROR
|
170
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
171
171
|
begin
|
172
172
|
params = CommandParams.new
|
173
173
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -184,7 +184,7 @@ module Roma
|
|
184
184
|
end
|
185
185
|
stored = StoredData.new
|
186
186
|
unless @storages[params.hash_name]
|
187
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
187
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
188
188
|
end
|
189
189
|
|
190
190
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -205,7 +205,7 @@ module Roma
|
|
205
205
|
|
206
206
|
def def_write_command_with_key_value(cmd, idx_of_val_len, forward = :one_line, &block)
|
207
207
|
define_method "ev_#{cmd}" do |s|
|
208
|
-
return send_data("CLIENT_ERROR
|
208
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
209
209
|
begin
|
210
210
|
params = CommandParams.new
|
211
211
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -224,7 +224,7 @@ module Roma
|
|
224
224
|
end
|
225
225
|
stored = StoredData.new
|
226
226
|
unless @storages[params.hash_name]
|
227
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
227
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
228
228
|
end
|
229
229
|
|
230
230
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -280,7 +280,7 @@ module Roma
|
|
280
280
|
|
281
281
|
def def_read_command_with_key_value(cmd, idx_of_val_len, forward = :one_line, &block)
|
282
282
|
define_method "ev_#{cmd}" do |s|
|
283
|
-
return send_data("CLIENT_ERROR
|
283
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
284
284
|
begin
|
285
285
|
params = CommandParams.new
|
286
286
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -299,7 +299,7 @@ module Roma
|
|
299
299
|
end
|
300
300
|
stored = StoredData.new
|
301
301
|
unless @storages[params.hash_name]
|
302
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
302
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
303
303
|
end
|
304
304
|
|
305
305
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -322,7 +322,7 @@ module Roma
|
|
322
322
|
|
323
323
|
def def_command_with_key_value(cmd, idx_of_val_len, forward = :one_line, &block)
|
324
324
|
define_method "ev_#{cmd}" do |s|
|
325
|
-
return send_data("CLIENT_ERROR
|
325
|
+
return send_data("CLIENT_ERROR does not find key\r\n") if s.length < 2
|
326
326
|
begin
|
327
327
|
params = CommandParams.new
|
328
328
|
params.key, params.hash_name = s[1].split("\e")
|
@@ -341,7 +341,7 @@ module Roma
|
|
341
341
|
end
|
342
342
|
stored = StoredData.new
|
343
343
|
unless @storages[params.hash_name]
|
344
|
-
return send_data("SERVER_ERROR #{params.hash_name}
|
344
|
+
return send_data("SERVER_ERROR #{params.hash_name} does not exists.\r\n")
|
345
345
|
end
|
346
346
|
|
347
347
|
stored.vn, stored.last, stored.clk, stored.expt, stored.value =
|
@@ -16,7 +16,7 @@ module Roma
|
|
16
16
|
else
|
17
17
|
unless @storages.key?(s[1])
|
18
18
|
raise(Roma::Command::Definition::ClientErrorException,
|
19
|
-
"#{s[1]}
|
19
|
+
"#{s[1]} does not find.")
|
20
20
|
end
|
21
21
|
@defhash = s[1]
|
22
22
|
"STORED"
|
@@ -36,7 +36,7 @@ module Roma
|
|
36
36
|
# check a directory existence
|
37
37
|
unless File.directory? "#{Config::STORAGE_PATH}/#{@stats.ap_str}/#{s[1]}"
|
38
38
|
raise(Roma::Command::Definition::ServerErrorException,
|
39
|
-
"#{s[1]}
|
39
|
+
"#{s[1]} does not find.")
|
40
40
|
end
|
41
41
|
createhash(s[1], 'MOUNTED')
|
42
42
|
end
|
@@ -49,7 +49,7 @@ module Roma
|
|
49
49
|
end
|
50
50
|
unless @storages.key?(s[1])
|
51
51
|
raise(Roma::Command::Definition::ServerErrorException,
|
52
|
-
"#{s[1]}
|
52
|
+
"#{s[1]} does not find.")
|
53
53
|
end
|
54
54
|
umounthash(s[1])
|
55
55
|
end
|
@@ -112,7 +112,7 @@ module Roma
|
|
112
112
|
return "SERVER_ERROR default hash can't unmount."
|
113
113
|
end
|
114
114
|
unless @storages.key?(hname)
|
115
|
-
return "SERVER_ERROR #{hname}
|
115
|
+
return "SERVER_ERROR #{hname} does not exists."
|
116
116
|
end
|
117
117
|
st = @storages[hname]
|
118
118
|
@storages.delete(hname)
|
File without changes
|
@@ -80,6 +80,13 @@ module Roma
|
|
80
80
|
else
|
81
81
|
nids=[]
|
82
82
|
s[3..-1].each{ |nid| nids << nid }
|
83
|
+
# check irregular node name
|
84
|
+
nids.each{ |nid|
|
85
|
+
if !nid.ascii_only? || nid.empty?
|
86
|
+
send_data("CLIENT_ERROR : irregular node name was input.[\"#{nid}\"]\r\n")
|
87
|
+
return
|
88
|
+
end
|
89
|
+
}
|
83
90
|
res=@rttable.set_route(s[1].to_i, s[2].to_i, nids)
|
84
91
|
if res.is_a?(Integer)
|
85
92
|
send_data("STORED\r\n")
|
@@ -277,7 +277,7 @@ module Roma
|
|
277
277
|
read_bytes(2)
|
278
278
|
vn = @rttable.get_vnode_id(d)
|
279
279
|
unless @storages.key?(hname)
|
280
|
-
send_data("SERVER_ERROR #{hname}
|
280
|
+
send_data("SERVER_ERROR #{hname} does not exists.\r\n")
|
281
281
|
return
|
282
282
|
end
|
283
283
|
if @storages[hname].rset(vn, key, d, s[3].to_i, s[4].to_i, data)
|
@@ -300,7 +300,7 @@ module Roma
|
|
300
300
|
read_bytes(2)
|
301
301
|
vn = @rttable.get_vnode_id(d)
|
302
302
|
unless @storages.key?(hname)
|
303
|
-
send_data("SERVER_ERROR #{hname}
|
303
|
+
send_data("SERVER_ERROR #{hname} does not exists.\r\n")
|
304
304
|
return
|
305
305
|
end
|
306
306
|
|
@@ -1041,7 +1041,7 @@ module Roma
|
|
1041
1041
|
end
|
1042
1042
|
st = @storages[hname]
|
1043
1043
|
unless st
|
1044
|
-
return send_data("CLIENT_ERROR hash_name = #{hanme}
|
1044
|
+
return send_data("CLIENT_ERROR hash_name = #{hanme} does not found\r\n")
|
1045
1045
|
end
|
1046
1046
|
dn = s[1].to_i
|
1047
1047
|
if st.divnum <= dn
|
@@ -1132,6 +1132,71 @@ module Roma
|
|
1132
1132
|
}
|
1133
1133
|
end
|
1134
1134
|
|
1135
|
+
# set_log_shift_size <size>
|
1136
|
+
def ev_set_log_shift_size(s)
|
1137
|
+
if s.length != 2
|
1138
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
1139
|
+
elsif s[1].to_i < 1
|
1140
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
res = broadcast_cmd("rset_log_shift_size #{s[1]}\r\n")
|
1144
|
+
@log.set_log_shift_size(s[1].to_i)
|
1145
|
+
@stats.log_shift_size = s[1].to_i
|
1146
|
+
res[@stats.ap_str] = "STORED"
|
1147
|
+
send_data("#{res}\r\n")
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def ev_rset_log_shift_size(s)
|
1151
|
+
if s.length != 2
|
1152
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
1153
|
+
elsif s[1].to_i < 1
|
1154
|
+
return send_data("CLIENT_ERROR length must be greater than zero\r\n")
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
@log.set_log_shift_size(s[1].to_i)
|
1158
|
+
@stats.log_shift_size = s[1].to_i
|
1159
|
+
send_data("STORED\r\n")
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
# set_log_shift_age <age>
|
1163
|
+
def ev_set_log_shift_age(s)
|
1164
|
+
if s.length != 2
|
1165
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
1166
|
+
elsif s[1].to_i < 1 && !['0', 'min', 'hour', 'daily', 'weekly', 'monthly'].include?(s[1])
|
1167
|
+
return send_data("CLIENT_ERROR invalid arguments\r\n")
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
res = broadcast_cmd("rset_log_shift_age #{s[1]}\r\n")
|
1171
|
+
|
1172
|
+
if s[1].to_i > 0 || s[1] == '0'
|
1173
|
+
@log.set_log_shift_age(s[1].to_i)
|
1174
|
+
@stats.log_shift_age = s[1].to_i
|
1175
|
+
else
|
1176
|
+
@log.set_log_shift_age(s[1])
|
1177
|
+
@stats.log_shift_age = s[1]
|
1178
|
+
end
|
1179
|
+
res[@stats.ap_str] = "STORED"
|
1180
|
+
send_data("#{res}\r\n")
|
1181
|
+
end
|
1182
|
+
|
1183
|
+
def ev_rset_log_shift_age(s)
|
1184
|
+
if s.length != 2
|
1185
|
+
return send_data("CLIENT_ERROR number of arguments\r\n")
|
1186
|
+
elsif s[1].to_i < 1 && !['0', 'min', 'hour', 'daily', 'weekly', 'monthly'].include?(s[1])
|
1187
|
+
return send_data("CLIENT_ERROR invalid arguments\r\n")
|
1188
|
+
end
|
1189
|
+
|
1190
|
+
if s[1].to_i > 0 || s[1] == '0'
|
1191
|
+
@log.set_log_shift_age(s[1].to_i)
|
1192
|
+
@stats.log_shift_age = s[1].to_i
|
1193
|
+
else
|
1194
|
+
@log.set_log_shift_age(s[1])
|
1195
|
+
@stats.log_shift_age = s[1]
|
1196
|
+
end
|
1197
|
+
send_data("STORED\r\n")
|
1198
|
+
end
|
1199
|
+
|
1135
1200
|
private
|
1136
1201
|
|
1137
1202
|
def dcnice(p)
|
File without changes
|
File without changes
|
File without changes
|
@@ -75,6 +75,9 @@ module Roma
|
|
75
75
|
# data copy setting
|
76
76
|
DATACOPY_STREAM_COPY_WAIT_PARAM = 0.001
|
77
77
|
|
78
|
+
# show logs setting
|
79
|
+
LOG_STREAM_SHOW_WAIT_PARAM = 0.001
|
80
|
+
|
78
81
|
# plugin setting
|
79
82
|
PLUGIN_FILES = ['plugin_storage.rb']
|
80
83
|
|
@@ -85,7 +88,7 @@ module Roma
|
|
85
88
|
# redundant setting
|
86
89
|
# REDUNDANT_ZREDUNDANT_SIZE is a option for a redundancy of compressed data.
|
87
90
|
# when the data size is more then REDUNDANT_ZREDUNDANT_SIZE, data compression is done.
|
88
|
-
# however, it
|
91
|
+
# however, it does't in case of REDUNDANT_ZREDUNDANT_SIZE is zero.
|
89
92
|
REDUNDANT_ZREDUNDANT_SIZE = 0
|
90
93
|
|
91
94
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -24,13 +24,64 @@ module Roma
|
|
24
24
|
module ExtLogDev
|
25
25
|
def extendLogDev()
|
26
26
|
if @logdev
|
27
|
+
@logdev.extend(ExtCheckShift)
|
27
28
|
@logdev.extend(ExtShiftAge)
|
29
|
+
@logdev.extend(AddSetShiftAge)
|
30
|
+
@logdev.extend(AddSetShiftSize)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_shift_age(age)
|
35
|
+
if @logdev
|
36
|
+
@logdev.set_shift_age(age)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_shift_size(size)
|
41
|
+
if @logdev
|
42
|
+
@logdev.set_shift_size(size)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module AddSetShiftAge
|
48
|
+
def set_shift_age(age)
|
49
|
+
if @shift_age
|
50
|
+
@shift_age = age
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module AddSetShiftSize
|
56
|
+
def set_shift_size(size)
|
57
|
+
if @shift_size
|
58
|
+
@shift_size = size
|
28
59
|
end
|
29
60
|
end
|
30
61
|
end
|
62
|
+
|
63
|
+
module ExtCheckShift
|
64
|
+
private
|
65
|
+
|
66
|
+
def check_shift_log
|
67
|
+
if @shift_age.is_a?(Integer)
|
68
|
+
# Note: always returns false if '0'.
|
69
|
+
if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
|
70
|
+
lock_shift_log { shift_log_age }
|
71
|
+
end
|
72
|
+
else
|
73
|
+
now = Time.now
|
74
|
+
period_end = previous_period_end(now)
|
75
|
+
if @dev.stat.mtime.to_i <= period_end.to_i
|
76
|
+
lock_shift_log { shift_log_period(period_end) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
31
81
|
|
32
82
|
module ExtShiftAge
|
33
83
|
private
|
84
|
+
|
34
85
|
def shift_log_period(now)
|
35
86
|
postfix = previous_period_end(now).strftime("%Y%m%d%H%M")
|
36
87
|
age_file = "#{@filename}.#{postfix}"
|
@@ -95,7 +146,7 @@ module Roma
|
|
95
146
|
@wrap_logger.extend(ExtLogDev)
|
96
147
|
@wrap_logger.extendLogDev()
|
97
148
|
end
|
98
|
-
|
149
|
+
|
99
150
|
def level=(severity)
|
100
151
|
@wrap_logger.level = severity
|
101
152
|
end
|
@@ -141,7 +192,15 @@ module Roma
|
|
141
192
|
end
|
142
193
|
|
143
194
|
def close; @wrap_logger.close; end
|
144
|
-
|
195
|
+
|
196
|
+
def set_log_shift_size(size)
|
197
|
+
@wrap_logger.set_shift_size(size)
|
198
|
+
end
|
199
|
+
|
200
|
+
def set_log_shift_age(age)
|
201
|
+
@wrap_logger.set_shift_age(age)
|
202
|
+
end
|
203
|
+
|
145
204
|
end # class RLogger
|
146
205
|
|
147
206
|
|
@@ -33,6 +33,20 @@ module Roma
|
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
|
36
|
+
def check_connection(ap)
|
37
|
+
unless @pool.key?(ap)
|
38
|
+
host, port = ap.split(/[:_]/)
|
39
|
+
addr = DNSCache.instance.resolve_name(host)
|
40
|
+
sock = TCPSocket.open(addr, port)
|
41
|
+
sock.close
|
42
|
+
end
|
43
|
+
true
|
44
|
+
rescue Errno::ECONNREFUSED => e
|
45
|
+
false
|
46
|
+
rescue => e
|
47
|
+
Logging::RLogger.instance.error("#{__FILE__}:#{__LINE__}:#{e}")
|
48
|
+
end
|
49
|
+
|
36
50
|
def return_connection(ap, con)
|
37
51
|
if select([con],nil,nil,0.0001)
|
38
52
|
con.gets
|
File without changes
|
File without changes
|
File without changes
|
@@ -9,10 +9,9 @@ module Roma
|
|
9
9
|
# get_routing_history
|
10
10
|
def ev_get_routing_history(s)
|
11
11
|
routing_path = get_config_stat["config.RTTABLE_PATH"]
|
12
|
-
f_list = Dir.glob("#{routing_path}/*")
|
13
12
|
contents = ""
|
14
|
-
|
15
|
-
contents << File.read(fname)
|
13
|
+
Dir.glob("#{routing_path}/*").each{|fname|
|
14
|
+
contents << File.read(fname) if !FileTest::directory?(fname) && fname =~ /#{@stats.ap_str}\.route*/
|
16
15
|
}
|
17
16
|
routing_list = contents.scan(/[-\.a-zA-Z\d]+_[\d]+/).uniq.sort
|
18
17
|
routing_list.each{|routing|
|
@@ -21,16 +20,15 @@ module Roma
|
|
21
20
|
send_data("END\r\n")
|
22
21
|
end
|
23
22
|
|
24
|
-
#
|
23
|
+
# gather_logs [start_date(YYYY-MM-DDThh:mm:ss)] <end_date(YYYY-MM-DDThh:mm:ss)>
|
25
24
|
def ev_gather_logs(s)
|
26
|
-
if s.length
|
27
|
-
return send_data("CLIENT_ERROR number of arguments (#{s.length-1} for
|
25
|
+
if s.length < 2 || s.length > 3
|
26
|
+
return send_data("CLIENT_ERROR number of arguments (#{s.length-1} for 2-3)\r\n")
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
29
|
+
start_date = s[1]
|
30
|
+
end_date = s[2]
|
31
|
+
end_date ||= 'current'
|
34
32
|
|
35
33
|
if @stats.gui_run_gather_logs
|
36
34
|
return send_data("CLIENT_ERROR gathering process is already going\r\n")
|
@@ -38,7 +36,7 @@ module Roma
|
|
38
36
|
|
39
37
|
begin
|
40
38
|
@stats.gui_run_gather_logs = true
|
41
|
-
Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_get_logs', [
|
39
|
+
Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_get_logs', [start_date, end_date]))
|
42
40
|
|
43
41
|
send_data("STARTED\r\n")
|
44
42
|
rescue
|
@@ -53,8 +51,9 @@ module Roma
|
|
53
51
|
if @stats.gui_run_gather_logs
|
54
52
|
send_data("Not finished gathering\r\n")
|
55
53
|
else
|
56
|
-
@rttable.logs.
|
57
|
-
send_data(log)
|
54
|
+
@rttable.logs.each_with_index{|log, index|
|
55
|
+
send_data("#{log}\r\n")
|
56
|
+
sleep @stats.stream_show_wait_param if index % 10 == 0
|
58
57
|
}
|
59
58
|
send_data("END\r\n")
|
60
59
|
@rttable.logs.clear
|
File without changes
|
File without changes
|