roma 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junji Torii
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: eventmachine
|
@@ -27,19 +27,19 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 1.0.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: jaro_winkler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.
|
36
|
-
type: :
|
35
|
+
version: 1.3.5
|
36
|
+
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 1.3.5
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: ffi
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,12 +132,13 @@ executables:
|
|
132
132
|
- cpdb
|
133
133
|
- recoverlost_alist_all
|
134
134
|
- log_merger
|
135
|
+
- check_tc_flag
|
135
136
|
- ssroute
|
136
137
|
- safecopy_test
|
137
138
|
- mkconfig
|
138
139
|
- safecopy_integration_test
|
140
|
+
- roma-adm
|
139
141
|
- simple_bench
|
140
|
-
- tc_data_restore.rb
|
141
142
|
- mkrecent
|
142
143
|
- recoverlost
|
143
144
|
- mkroute
|
@@ -157,9 +158,11 @@ extra_rdoc_files:
|
|
157
158
|
files:
|
158
159
|
- CHANGELOG
|
159
160
|
- Gemfile
|
161
|
+
- Gemfile.lock
|
160
162
|
- LICENSE
|
161
163
|
- README.md
|
162
164
|
- Rakefile
|
165
|
+
- bin/check_tc_flag
|
163
166
|
- bin/chg_redundancy
|
164
167
|
- bin/cpdb
|
165
168
|
- bin/key_access
|
@@ -173,6 +176,7 @@ files:
|
|
173
176
|
- bin/recoverlost_alist
|
174
177
|
- bin/recoverlost_alist_all
|
175
178
|
- bin/recoverlost_alist_keys
|
179
|
+
- bin/roma-adm
|
176
180
|
- bin/roma_watcher
|
177
181
|
- bin/romad
|
178
182
|
- bin/safecopy_integration_test
|
@@ -182,7 +186,6 @@ files:
|
|
182
186
|
- bin/sample_watcher3
|
183
187
|
- bin/simple_bench
|
184
188
|
- bin/ssroute
|
185
|
-
- bin/tc_data_restore.rb
|
186
189
|
- bin/test-scenario
|
187
190
|
- bin/tribunus
|
188
191
|
- lib/roma/async_process.rb
|
@@ -199,6 +202,8 @@ files:
|
|
199
202
|
- lib/roma/dns_cache.rb
|
200
203
|
- lib/roma/event/con_pool.rb
|
201
204
|
- lib/roma/event/handler.rb
|
205
|
+
- lib/roma/event/jaro_winkler.rb
|
206
|
+
- lib/roma/event/levenshtein.rb
|
202
207
|
- lib/roma/logging/rlogger.rb
|
203
208
|
- lib/roma/messaging/con_pool.rb
|
204
209
|
- lib/roma/plugin/plugin_alist.rb
|
@@ -224,6 +229,7 @@ files:
|
|
224
229
|
- lib/roma/storage/rh_storage.rb
|
225
230
|
- lib/roma/storage/sqlite3_storage.rb
|
226
231
|
- lib/roma/storage/tc_storage.rb
|
232
|
+
- lib/roma/tools/check_tc_flag.rb
|
227
233
|
- lib/roma/tools/chg_redundancy.rb
|
228
234
|
- lib/roma/tools/cpdb.rb
|
229
235
|
- lib/roma/tools/key_access.rb
|
@@ -238,6 +244,7 @@ files:
|
|
238
244
|
- lib/roma/tools/recoverlost_alist_all.rb
|
239
245
|
- lib/roma/tools/recoverlost_alist_keys.rb
|
240
246
|
- lib/roma/tools/recoverlost_lib.rb
|
247
|
+
- lib/roma/tools/roma-adm.rb
|
241
248
|
- lib/roma/tools/roma_watcher.rb
|
242
249
|
- lib/roma/tools/roma_watcher_config.yml.example
|
243
250
|
- lib/roma/tools/safecopy_integration_test.rb
|
@@ -255,20 +262,30 @@ files:
|
|
255
262
|
- test/config4mhash.rb
|
256
263
|
- test/config4storage_error.rb
|
257
264
|
- test/config4test.rb
|
265
|
+
- test/cpdbtest/config4cpdb_base.rb
|
266
|
+
- test/cpdbtest/config4cpdb_dbm.rb
|
267
|
+
- test/cpdbtest/config4cpdb_groonga.rb
|
268
|
+
- test/cpdbtest/config4cpdb_rh.rb
|
269
|
+
- test/cpdbtest/config4cpdb_sqlite3.rb
|
270
|
+
- test/cpdbtest/config4cpdb_tc.rb
|
271
|
+
- test/cpdbtest/config4cpdb_tcmem.rb
|
258
272
|
- test/rcirb.rb
|
259
273
|
- test/roma-test-utils.rb
|
260
274
|
- test/run-test.rb
|
261
275
|
- test/storage_error_storage.rb
|
262
276
|
- test/t_command_definition.rb
|
263
277
|
- test/t_cpdata.rb
|
278
|
+
- test/t_cpdb.rb
|
264
279
|
- test/t_eventmachine.rb
|
265
280
|
- test/t_listplugin.rb
|
281
|
+
- test/t_logshift.rb
|
266
282
|
- test/t_mapcountplugin.rb
|
267
283
|
- test/t_mapplugin.rb
|
268
284
|
- test/t_mhash.rb
|
269
285
|
- test/t_protocol.rb
|
270
286
|
- test/t_rclient.rb
|
271
287
|
- test/t_routing_data.rb
|
288
|
+
- test/t_routing_logic.rb
|
272
289
|
- test/t_storage.rb
|
273
290
|
- test/t_storage_error.rb
|
274
291
|
- test/t_writebehind.rb
|
data/bin/tc_data_restore.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'tokyocabinet'
|
3
|
-
require 'roma-client'
|
4
|
-
#require 'roma/client/rclient'
|
5
|
-
|
6
|
-
class TCRecover
|
7
|
-
include TokyoCabinet
|
8
|
-
|
9
|
-
def initialize(argv)
|
10
|
-
@timeout = 5
|
11
|
-
@data_path = nil
|
12
|
-
@division_num = 10
|
13
|
-
@wait_param = 0.001
|
14
|
-
|
15
|
-
opts = OptionParser.new
|
16
|
-
opts.banner = "usage:#{File.basename($0)} [options] address:port storage_path ..."
|
17
|
-
opts.on("-n","--division [num]","(default=10)"){|v| @division_num = v.to_i }
|
18
|
-
opts.on("-w","--wait [num]","(default=0.001)"){|v| @wait_param = v.to_i }
|
19
|
-
opts.parse!(argv)
|
20
|
-
|
21
|
-
if argv.length < 2
|
22
|
-
STDERR.puts opts.help
|
23
|
-
exit!
|
24
|
-
end
|
25
|
-
|
26
|
-
node = argv[0].sub(':','_')
|
27
|
-
|
28
|
-
@rc = Roma::Client::RomaClient.new([node])
|
29
|
-
@rttable = @rc.rttable
|
30
|
-
|
31
|
-
@data_paths = argv[1..-1]
|
32
|
-
|
33
|
-
@data_paths.each do |path|
|
34
|
-
each_storage(path) do |tc|
|
35
|
-
#p tc
|
36
|
-
hdb = open_db(tc)
|
37
|
-
start_recover(hdb)
|
38
|
-
close_db(hdb)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def open_db(fname)
|
44
|
-
hdb = HDB::new
|
45
|
-
if !hdb.open(fname, HDB::OREADER | HDB::ONOLCK)
|
46
|
-
ecode = hdb.ecode
|
47
|
-
raise RuntimeError.new("tcdb open error #{hdb.errmsg(ecode)}")
|
48
|
-
end
|
49
|
-
hdb
|
50
|
-
end
|
51
|
-
|
52
|
-
def close_db(hdb)
|
53
|
-
if !hdb.close
|
54
|
-
ecode = hdb.ecode
|
55
|
-
raise RuntimeError.new("tcdb close error #{hdb.errmsg(ecode)}")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# [ 0.. 3] vn
|
60
|
-
# [ 4.. 7] physical clock (unix time)
|
61
|
-
# [ 8..11] logical clock
|
62
|
-
# [12..15] exptime(unix time)
|
63
|
-
# [16.. ] value data
|
64
|
-
PACK_HEADER_TEMPLATE='NNNN'
|
65
|
-
PACK_TEMPLATE=PACK_HEADER_TEMPLATE+'a*'
|
66
|
-
def unpack_header(str)
|
67
|
-
str.unpack(PACK_HEADER_TEMPLATE)
|
68
|
-
end
|
69
|
-
def unpack_data(str)
|
70
|
-
str.unpack(PACK_TEMPLATE)
|
71
|
-
end
|
72
|
-
|
73
|
-
def get_raw(key)
|
74
|
-
nid, d = @rttable.search_node(key)
|
75
|
-
cmd = "eval @storages[\"roma\"].get_raw2(\"#{key}\")"
|
76
|
-
timeout(@timeout){
|
77
|
-
sender = @rc.instance_variable_get(:@sender)
|
78
|
-
return sender.send_command(nid, cmd)
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
def each_storage(path)
|
83
|
-
Dir::glob("#{path}/*").each{|file|
|
84
|
-
yield file if file =~ /\.tc/
|
85
|
-
}
|
86
|
-
end
|
87
|
-
|
88
|
-
def cmp_clk(clk1, clk2)
|
89
|
-
if (clk1-clk2).abs < 0x80000000 # 1<<31
|
90
|
-
clk1 <=> clk2
|
91
|
-
else
|
92
|
-
clk2 <=> clk1
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def start_recover(hdb)
|
97
|
-
hdb.each do |k, v|
|
98
|
-
p k
|
99
|
-
p v
|
100
|
-
#p @rc.methods
|
101
|
-
|
102
|
-
rv = @rc[k]
|
103
|
-
p "#{k} : #{rv}"
|
104
|
-
next if rv
|
105
|
-
|
106
|
-
roma_raw_data = eval(get_raw(k))
|
107
|
-
b_vn, b_t, b_clk, b_expt, b_v = unpack_data(v)
|
108
|
-
|
109
|
-
if roma_raw_data
|
110
|
-
r_vn, r_t, r_clk, r_expt, r_v = roma_raw_data
|
111
|
-
if cmp_clk(r_clk, b_clk) <= 0
|
112
|
-
@rc[k] = Marshal.load(b_v)
|
113
|
-
print "."
|
114
|
-
end
|
115
|
-
else
|
116
|
-
@rc[k] = Marshal.load(b_v)
|
117
|
-
print "."
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
tc_recover = TCRecover.new(ARGV)
|