roma 0.8.2 → 0.8.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANG +326 -0
- data/CHANGELOG +132 -0
- data/{README.rdoc → FETCH_HEAD} +0 -0
- data/{LICENSE.rdoc → LICENSE} +0 -1
- data/README +17 -0
- data/Rakefile +33 -18
- data/ruby/server/bin/chg_redundancy +10 -0
- data/ruby/server/bin/key_access +7 -0
- data/ruby/server/bin/key_list +7 -0
- data/ruby/server/bin/mkconfig +19 -0
- data/{bin → ruby/server/bin}/mkrecent +0 -1
- data/{bin → ruby/server/bin}/mkroute +0 -1
- data/ruby/server/bin/multi_commander +19 -0
- data/ruby/server/bin/recoverlost +10 -0
- data/ruby/server/bin/recoverlost_alist +10 -0
- data/ruby/server/bin/recoverlost_alist_all +10 -0
- data/ruby/server/bin/recoverlost_alist_keys +10 -0
- data/{bin/recoverlost → ruby/server/bin/roma_watcher} +1 -2
- data/ruby/server/bin/romad +36 -0
- data/{bin → ruby/server/bin}/sample_watcher +0 -1
- data/{bin → ruby/server/bin}/sample_watcher2 +0 -1
- data/{bin/simple_bench → ruby/server/bin/sample_watcher3} +1 -2
- data/ruby/server/bin/simple_bench +26 -0
- data/{bin → ruby/server/bin}/ssroute +0 -1
- data/ruby/server/bin/test-scenario +11 -0
- data/{bin → ruby/server/bin}/tribunus +0 -1
- data/{lib → ruby/server/lib}/roma/async_process.rb +67 -15
- data/{lib → ruby/server/lib}/roma/command/bg_command_receiver.rb +1 -1
- data/ruby/server/lib/roma/command/command_definition.rb +422 -0
- data/ruby/server/lib/roma/command/mh_command_receiver.rb +127 -0
- data/ruby/server/lib/roma/command/receiver.rb +64 -0
- data/{lib → ruby/server/lib}/roma/command/rt_command_receiver.rb +6 -1
- data/ruby/server/lib/roma/command/sys_command_receiver.rb +609 -0
- data/{lib → ruby/server/lib}/roma/command/util_command_receiver.rb +15 -5
- data/{lib → ruby/server/lib}/roma/command/vn_command_receiver.rb +12 -4
- data/{lib → ruby/server/lib}/roma/command_plugin.rb +0 -0
- data/ruby/server/lib/roma/config.rb +84 -0
- data/{lib → ruby/server/lib}/roma/event/con_pool.rb +12 -1
- data/ruby/server/lib/roma/event/handler.rb +256 -0
- data/ruby/server/lib/roma/live_patch-20120302-001.rb +107 -0
- data/ruby/server/lib/roma/logging/rlogger.rb +163 -0
- data/ruby/server/lib/roma/messaging/con_pool.rb +92 -0
- data/{lib → ruby/server/lib}/roma/plugin/plugin_alist.rb +118 -240
- data/ruby/server/lib/roma/plugin/plugin_debug.rb +31 -0
- data/ruby/server/lib/roma/plugin/plugin_map.rb +177 -0
- data/ruby/server/lib/roma/plugin/plugin_mapcount.rb +185 -0
- data/{lib/roma/command/st_command_receiver.rb → ruby/server/lib/roma/plugin/plugin_storage.rb} +170 -146
- data/ruby/server/lib/roma/plugin/plugin_stub.rb +283 -0
- data/{lib → ruby/server/lib}/roma/plugin/plugin_test.rb +0 -0
- data/{lib → ruby/server/lib}/roma/romad.rb +221 -94
- data/{lib → ruby/server/lib}/roma/routing/cb_rttable.rb +4 -6
- data/{lib → ruby/server/lib}/roma/routing/merkle_tree.rb +0 -0
- data/ruby/server/lib/roma/routing/routing_data.rb +307 -0
- data/{lib → ruby/server/lib}/roma/routing/rttable.rb +4 -0
- data/{lib → ruby/server/lib}/roma/stats.rb +19 -3
- data/{lib → ruby/server/lib}/roma/storage/basic_storage.rb +25 -26
- data/{lib → ruby/server/lib}/roma/storage/dbm_storage.rb +1 -23
- data/{lib → ruby/server/lib}/roma/storage/dummy_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/rh_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/sqlite3_storage.rb +0 -0
- data/{lib → ruby/server/lib}/roma/storage/tc_storage.rb +62 -2
- data/ruby/server/lib/roma/tools/chg_redundancy.rb +36 -0
- data/ruby/server/lib/roma/tools/key_access.rb +105 -0
- data/ruby/server/lib/roma/tools/key_list.rb +94 -0
- data/ruby/server/lib/roma/tools/mkconfig.rb +535 -0
- data/{lib → ruby/server/lib}/roma/tools/mkrecent.rb +0 -0
- data/{lib → ruby/server/lib}/roma/tools/mkroute.rb +0 -0
- data/ruby/server/lib/roma/tools/multi_commander.rb +45 -0
- data/{lib → ruby/server/lib}/roma/tools/recoverlost.rb +0 -0
- data/{lib → ruby/server/lib}/roma/tools/recoverlost_alist.rb +0 -0
- data/ruby/server/lib/roma/tools/recoverlost_alist_all.rb +8 -0
- data/ruby/server/lib/roma/tools/recoverlost_alist_keys.rb +16 -0
- data/ruby/server/lib/roma/tools/recoverlost_lib.rb +349 -0
- data/ruby/server/lib/roma/tools/roma_watcher.rb +150 -0
- data/ruby/server/lib/roma/tools/roma_watcher_config.yml.example +20 -0
- data/{lib → ruby/server/lib}/roma/tools/sample_watcher.rb +3 -1
- data/{lib → ruby/server/lib}/roma/tools/sample_watcher2.rb +3 -1
- data/ruby/server/lib/roma/tools/sample_watcher3.rb +49 -0
- data/{lib → ruby/server/lib}/roma/tools/simple_bench.rb +2 -0
- data/ruby/server/lib/roma/tools/simple_bench2.rb +78 -0
- data/{lib → ruby/server/lib}/roma/tools/ssroute.rb +0 -0
- data/ruby/server/lib/roma/tools/test-scenario.rb +327 -0
- data/{lib → ruby/server/lib}/roma/tools/tribunus.rb +0 -0
- data/ruby/server/lib/roma/version.rb +4 -0
- data/{lib → ruby/server/lib}/roma/write_behind.rb +1 -0
- data/ruby/server/test/config4mhash.rb +68 -0
- data/ruby/server/test/config4storage_error.rb +69 -0
- data/{lib/roma/config.rb → ruby/server/test/config4test.rb} +6 -3
- data/{test → ruby/server/test}/rcirb.rb +0 -1
- data/{test → ruby/server/test}/roma-test-utils.rb +21 -8
- data/{test → ruby/server/test}/run-test.rb +3 -2
- data/ruby/server/test/storage_error_storage.rb +37 -0
- data/ruby/server/test/t_command_definition.rb +326 -0
- data/{test → ruby/server/test}/t_cpdata.rb +9 -3
- data/{test → ruby/server/test}/t_listplugin.rb +48 -12
- data/ruby/server/test/t_mapcountplugin.rb +231 -0
- data/ruby/server/test/t_mapplugin.rb +131 -0
- data/ruby/server/test/t_mhash.rb +222 -0
- data/ruby/server/test/t_rclient.rb +199 -0
- data/{test → ruby/server/test}/t_routing_data.rb +56 -0
- data/{test → ruby/server/test}/t_storage.rb +107 -111
- data/ruby/server/test/t_storage_error.rb +61 -0
- data/ruby/server/test/t_writebehind.rb +374 -0
- metadata +150 -82
- data/bin/recoverlost_alist +0 -8
- data/bin/romad +0 -7
- data/lib/roma/command/mh_command_receiver.rb +0 -117
- data/lib/roma/command/receiver.rb +0 -287
- data/lib/roma/event/handler.rb +0 -159
- data/lib/roma/plugin/plugin_debug.rb +0 -19
- data/lib/roma/tools/recoverlost_lib.rb +0 -217
- data/lib/roma/version.rb +0 -4
- data/test/t_rclient.rb +0 -318
- data/test/t_writebehind.rb +0 -200
@@ -40,9 +40,7 @@ module Roma
|
|
40
40
|
|
41
41
|
def set_version(nid,ver)
|
42
42
|
@version_of_nodes[nid] = ver
|
43
|
-
|
44
|
-
@min_version = ver
|
45
|
-
end
|
43
|
+
@min_version = find_min_version
|
46
44
|
end
|
47
45
|
|
48
46
|
def find_min_version
|
@@ -176,8 +174,8 @@ module Roma
|
|
176
174
|
end
|
177
175
|
|
178
176
|
def enabled_failover=(b)
|
179
|
-
@enabled_failover=b
|
180
177
|
@fail_cnt.clear
|
178
|
+
@enabled_failover=b
|
181
179
|
end
|
182
180
|
|
183
181
|
def enabled_failover
|
@@ -312,9 +310,9 @@ module Roma
|
|
312
310
|
|
313
311
|
@log.debug("#{__FILE__}:#{__LINE__}:n=#{n} pcount=#{pcount} scount=#{scount}")
|
314
312
|
|
315
|
-
if pcount > n
|
313
|
+
if pcount > n
|
316
314
|
return :over
|
317
|
-
elsif pcount < n
|
315
|
+
elsif pcount < n
|
318
316
|
return :less
|
319
317
|
end
|
320
318
|
:even
|
File without changes
|
@@ -0,0 +1,307 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Roma
|
4
|
+
module Routing
|
5
|
+
|
6
|
+
class RoutingData
|
7
|
+
attr_accessor :dgst_bits
|
8
|
+
attr_accessor :div_bits
|
9
|
+
attr_accessor :rn
|
10
|
+
attr_accessor :nodes
|
11
|
+
attr_accessor :v_idx
|
12
|
+
attr_accessor :v_clk
|
13
|
+
|
14
|
+
def initialize(dgst_bits,div_bits,rn)
|
15
|
+
@dgst_bits=dgst_bits
|
16
|
+
@div_bits=div_bits
|
17
|
+
@rn=rn
|
18
|
+
@nodes=[]
|
19
|
+
@v_idx={}
|
20
|
+
@v_clk={}
|
21
|
+
end
|
22
|
+
|
23
|
+
def save(fname)
|
24
|
+
@nodes.sort!
|
25
|
+
open(fname,'wb'){|io|
|
26
|
+
io.write(YAML.dump(self))
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.load(fname)
|
31
|
+
rd=load_snapshot(fname)
|
32
|
+
rd.load_log_all(fname)
|
33
|
+
rd
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.load_snapshot(fname)
|
37
|
+
rd=nil
|
38
|
+
open(fname,'rb'){|io|
|
39
|
+
rd = YAML.load(io.read)
|
40
|
+
}
|
41
|
+
rd
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.snapshot(fname)
|
45
|
+
rd=load_snapshot(fname)
|
46
|
+
loglist=rd.get_file_list(fname)
|
47
|
+
if loglist.length<2
|
48
|
+
return false
|
49
|
+
end
|
50
|
+
loglist.delete(loglist.last)
|
51
|
+
loglist.each{|i,f|
|
52
|
+
rd.load_log_one(f)
|
53
|
+
File.rename(f,"#{f}~")
|
54
|
+
}
|
55
|
+
File.rename(fname,"#{fname}~")
|
56
|
+
rd.save(fname)
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.decode_binary(bin)
|
61
|
+
magic, ver, dgst_bits, div_bits, rn, nodeslen = bin.unpack('a2nCCCn')
|
62
|
+
raise 'Illegal format error' if magic != 'RT'
|
63
|
+
raise 'Unsupported version error' if ver != 1
|
64
|
+
|
65
|
+
rd = RoutingData.new(dgst_bits, div_bits, rn)
|
66
|
+
|
67
|
+
bin = bin[9..-1]
|
68
|
+
nodeslen.times{|i|
|
69
|
+
len, = bin.unpack('n')
|
70
|
+
bin = bin[2..-1]
|
71
|
+
nid, = bin.unpack("a#{len}")
|
72
|
+
bin = bin[len..-1]
|
73
|
+
rd.nodes << nid
|
74
|
+
}
|
75
|
+
(2**div_bits).times{|i|
|
76
|
+
vn=i<<(dgst_bits-div_bits)
|
77
|
+
v_clk,len = bin.unpack('Nc')
|
78
|
+
rd.v_clk[vn] = v_clk
|
79
|
+
bin = bin[5..-1]
|
80
|
+
len.times{|i|
|
81
|
+
idx, = bin.unpack('n')
|
82
|
+
rd.v_idx[vn] = [] unless rd.v_idx[vn]
|
83
|
+
rd.v_idx[vn] << rd.nodes[idx]
|
84
|
+
bin = bin[2..-1]
|
85
|
+
}
|
86
|
+
}
|
87
|
+
rd
|
88
|
+
end
|
89
|
+
|
90
|
+
# 2 bytes('RT'):magic code
|
91
|
+
# unsigned short:format version
|
92
|
+
# unsigned char:dgst_bits
|
93
|
+
# unsigned char:div_bits
|
94
|
+
# unsigned char:rn
|
95
|
+
# unsigned short:number of nodes
|
96
|
+
# while number of nodes
|
97
|
+
# unsigned short:length of node-id string
|
98
|
+
# node-id string
|
99
|
+
# while umber of vnodes
|
100
|
+
# unsigned int32:v_clk
|
101
|
+
# unsigned char:number of nodes
|
102
|
+
# while umber of nodes
|
103
|
+
# unsigned short:index of nodes
|
104
|
+
def dump_binary
|
105
|
+
format_version = 1
|
106
|
+
# 9 bytes
|
107
|
+
ret = ['RT',format_version,dgst_bits,div_bits,rn,nodes.length].pack('a2nCCCn')
|
108
|
+
rev_hash = {}
|
109
|
+
nodes.each_with_index{|nid,idx|
|
110
|
+
rev_hash[nid] = idx
|
111
|
+
# 2 + nid.length bytes
|
112
|
+
ret += [nid.length,nid].pack('na*')
|
113
|
+
}
|
114
|
+
(2**div_bits).times{|i|
|
115
|
+
vn=i<<(dgst_bits-div_bits)
|
116
|
+
# 5 bytes
|
117
|
+
ret += [v_clk[vn],v_idx[vn].length].pack('Nc')
|
118
|
+
v_idx[vn].each{|nid|
|
119
|
+
# 2 bytes
|
120
|
+
ret += [rev_hash[nid]].pack('n')
|
121
|
+
}
|
122
|
+
}
|
123
|
+
ret
|
124
|
+
end
|
125
|
+
|
126
|
+
def each_log_all(fname)
|
127
|
+
loglist=get_file_list(fname)
|
128
|
+
loglist.each{|i,f|
|
129
|
+
each_log_one(f){|t,l| yield t,l}
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def each_log_one(fname)
|
134
|
+
File.open(fname,"r"){|f|
|
135
|
+
while((line=f.gets)!=nil)
|
136
|
+
line.chomp!
|
137
|
+
next if line[0]=="#" || line.length==0
|
138
|
+
if line =~ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d+\s(.+)/
|
139
|
+
yield Time.mktime($1, $2, $3, $4, $5, $6), $7
|
140
|
+
end
|
141
|
+
end
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
def load_log_all(fname)
|
146
|
+
each_log_all(fname){|t,line|
|
147
|
+
parse_log(t,line)
|
148
|
+
}
|
149
|
+
@nodes.sort!
|
150
|
+
end
|
151
|
+
|
152
|
+
def load_log_one(fname)
|
153
|
+
each_log_one(fname){|t,line|
|
154
|
+
parse_log(t,line)
|
155
|
+
}
|
156
|
+
@nodes.sort!
|
157
|
+
end
|
158
|
+
|
159
|
+
def parse_log(t,line)
|
160
|
+
s=line.split(' ')
|
161
|
+
case s[0]
|
162
|
+
when 'setroute'
|
163
|
+
# setroute <vnode-id> <clock> <node-id> ...
|
164
|
+
nids=[]
|
165
|
+
s[3..-1].each{ |nid| nids << nid }
|
166
|
+
@v_idx[s[1].to_i]=nids
|
167
|
+
@v_clk[s[1].to_i]=s[2].to_i
|
168
|
+
when 'join'
|
169
|
+
# join <node-id>
|
170
|
+
@nodes << s[1] unless @nodes.include?(s[1])
|
171
|
+
when 'leave'
|
172
|
+
# leave <node-id>
|
173
|
+
@nodes.delete(s[1])
|
174
|
+
else
|
175
|
+
raise "RoutingData.parse_log:parse error #{line}"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def search_mask
|
180
|
+
2**@div_bits-1<<(@dgst_bits-@div_bits)
|
181
|
+
end
|
182
|
+
|
183
|
+
def next_vnode(vn)
|
184
|
+
n = (vn >> (@dgst_bits-@div_bits)) + 1
|
185
|
+
n = 0 if n == (2**@div_bits)
|
186
|
+
n << (@dgst_bits-@div_bits)
|
187
|
+
end
|
188
|
+
|
189
|
+
def create_nodes_from_v_idx
|
190
|
+
buf_nodes={}
|
191
|
+
v_idx.each_value{|nids|
|
192
|
+
nids.each{|nid| buf_nodes[nid]=nid }
|
193
|
+
}
|
194
|
+
@nodes=buf_nodes.values.sort
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the losted vnode-id list.
|
198
|
+
def get_lost_vnodes
|
199
|
+
ret=[]
|
200
|
+
v_idx.each_pair{|vn,nids|
|
201
|
+
ret << vn if nids.length == 0
|
202
|
+
}
|
203
|
+
ret
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.create(dgst_bits,div_bits,rn,nodes,repethost=false)
|
207
|
+
ret=RoutingData.new(dgst_bits,div_bits,rn)
|
208
|
+
ret.nodes=nodes.clone
|
209
|
+
|
210
|
+
rnlm=RandomNodeListMaker.new(nodes,repethost)
|
211
|
+
|
212
|
+
(2**div_bits).times{|i|
|
213
|
+
vn=i<<(dgst_bits-div_bits)
|
214
|
+
ret.v_clk[vn]=0
|
215
|
+
ret.v_idx[vn]=rnlm.list(rn)
|
216
|
+
}
|
217
|
+
ret
|
218
|
+
end
|
219
|
+
|
220
|
+
# Returns the log file list by old ordered.
|
221
|
+
# +fname+:: Prefix of a log file.(ex.roma0_3300.route)
|
222
|
+
# One of the following example:
|
223
|
+
# [[1, "roma0_3300.route.1"], [2, "roma0_3300.route.2"]]
|
224
|
+
def get_file_list(fname)
|
225
|
+
l={}
|
226
|
+
files=Dir.glob("#{fname}*")
|
227
|
+
files.each{ |file|
|
228
|
+
if /#{fname}\.(\d+)$/=~file
|
229
|
+
l[$1.to_i]=$&
|
230
|
+
end
|
231
|
+
}
|
232
|
+
# sorted by old order
|
233
|
+
l.to_a.sort{|a,b| a[0]<=>b[0]}
|
234
|
+
end
|
235
|
+
|
236
|
+
def get_histgram
|
237
|
+
ret = {}
|
238
|
+
nodes.each{|nid|
|
239
|
+
ret[nid] = Array.new(rn,0)
|
240
|
+
}
|
241
|
+
v_idx.each_pair{|vn,nids|
|
242
|
+
nids.each_with_index{|nid,i|
|
243
|
+
ret[nid][i] += 1
|
244
|
+
}
|
245
|
+
}
|
246
|
+
ret
|
247
|
+
end
|
248
|
+
|
249
|
+
private
|
250
|
+
|
251
|
+
class RandomNodeListMaker
|
252
|
+
def initialize(nodes,repethost)
|
253
|
+
@repethost=repethost
|
254
|
+
@nodes=nodes
|
255
|
+
@host_idx={}
|
256
|
+
nodes.each{|nid|
|
257
|
+
h,p=nid.split('_')
|
258
|
+
if @host_idx.key?(h)
|
259
|
+
@host_idx[h] << nid
|
260
|
+
else
|
261
|
+
@host_idx[h]=[nid]
|
262
|
+
end
|
263
|
+
}
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the random node-list without repetition.
|
267
|
+
# +n+:: list length
|
268
|
+
def list(n)
|
269
|
+
ret=[]
|
270
|
+
hosts=[]
|
271
|
+
proc_other_one = :get_other_one
|
272
|
+
proc_other_one = :get_other_one_repethost if @repethost
|
273
|
+
n.times{
|
274
|
+
nid=nil
|
275
|
+
nid=send(proc_other_one,hosts,ret)
|
276
|
+
break unless nid
|
277
|
+
hosts << nid.split('_')[0]
|
278
|
+
ret << nid
|
279
|
+
}
|
280
|
+
ret
|
281
|
+
end
|
282
|
+
|
283
|
+
# +exp_hosts+:: ignore
|
284
|
+
# +exp_nodes+:: exceptional nodes(ex.['roma0_11211'])
|
285
|
+
def get_other_one_repethost(exp_hosts,exp_nodes)
|
286
|
+
buf=@nodes.clone
|
287
|
+
buf.delete_if{|nid| exp_nodes.include?(nid)}
|
288
|
+
buf[rand(buf.length)]
|
289
|
+
end
|
290
|
+
|
291
|
+
# +exp_hosts+:: exceptional hosts(ex.['roma0','roma1'])
|
292
|
+
# +exp_nodes+:: ignore
|
293
|
+
def get_other_one(exp_hosts,exp_nodes)
|
294
|
+
hidx=@host_idx.clone
|
295
|
+
exp_hosts.each{|h| hidx.delete(h) }
|
296
|
+
return nil if hidx.length == 0
|
297
|
+
|
298
|
+
rh=hidx.keys[rand(hidx.keys.length)]
|
299
|
+
nodes=hidx[rh]
|
300
|
+
nodes[rand(nodes.length)]
|
301
|
+
end
|
302
|
+
end # class RandomNodeListMaker
|
303
|
+
|
304
|
+
end # class RoutingData
|
305
|
+
|
306
|
+
end # module Routing
|
307
|
+
end # module Roma
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'singleton'
|
2
|
-
require 'roma/config'
|
3
2
|
|
4
3
|
module Roma
|
5
4
|
|
6
5
|
class Stats
|
7
6
|
include Singleton
|
8
7
|
|
8
|
+
# environment options
|
9
|
+
attr_accessor :config_path
|
10
|
+
|
9
11
|
# command options
|
10
12
|
attr_accessor :address, :port
|
11
13
|
attr_accessor :daemon
|
@@ -14,6 +16,7 @@ module Roma
|
|
14
16
|
attr_accessor :name
|
15
17
|
attr_accessor :verbose
|
16
18
|
attr_accessor :enabled_repetition_host_in_routing
|
19
|
+
attr_accessor :disabled_cmd_protect
|
17
20
|
|
18
21
|
# proc mode
|
19
22
|
attr_accessor :enabled_vnodes_balance
|
@@ -29,6 +32,7 @@ module Roma
|
|
29
32
|
|
30
33
|
# proc param
|
31
34
|
attr_accessor :stream_copy_wait_param
|
35
|
+
attr_accessor :dcnice
|
32
36
|
|
33
37
|
# compressed redundant param
|
34
38
|
attr_accessor :size_of_zredundant
|
@@ -41,7 +45,13 @@ module Roma
|
|
41
45
|
attr_accessor :out_message_count
|
42
46
|
attr_accessor :redundant_count
|
43
47
|
|
48
|
+
attr_accessor :hilatency_warn_time
|
49
|
+
|
50
|
+
# for write behind
|
51
|
+
attr_accessor :wb_command_map
|
52
|
+
|
44
53
|
def initialize
|
54
|
+
@config_path = nil
|
45
55
|
@run_acquire_vnodes = false
|
46
56
|
@run_recover = false
|
47
57
|
@run_sync_routing = false
|
@@ -49,8 +59,8 @@ module Roma
|
|
49
59
|
@run_storage_clean_up = false
|
50
60
|
@run_receive_a_vnode = false
|
51
61
|
@run_release = false
|
52
|
-
@stream_copy_wait_param =
|
53
|
-
|
62
|
+
@stream_copy_wait_param = 0.0001
|
63
|
+
@dcnice = 3
|
54
64
|
@enabled_vnodes_balance = nil
|
55
65
|
@write_count = 0
|
56
66
|
@read_count = 0
|
@@ -59,6 +69,8 @@ module Roma
|
|
59
69
|
@out_message_count = 0
|
60
70
|
@redundant_count = 0
|
61
71
|
@size_of_zredundant = 0
|
72
|
+
@hilatency_warn_time = 5
|
73
|
+
@wb_command_map = {}
|
62
74
|
end
|
63
75
|
|
64
76
|
def ap_str
|
@@ -67,6 +79,7 @@ module Roma
|
|
67
79
|
|
68
80
|
def get_stat
|
69
81
|
ret = {}
|
82
|
+
ret['stats.config_path'] = @config_path
|
70
83
|
ret['stats.address'] = @address
|
71
84
|
ret['stats.port'] = @port
|
72
85
|
ret['stats.daemon'] = @daemon
|
@@ -80,6 +93,7 @@ module Roma
|
|
80
93
|
ret['stats.run_storage_clean_up'] = @run_storage_clean_up
|
81
94
|
ret['stats.run_release'] = @run_release
|
82
95
|
ret['stats.stream_copy_wait_param'] = @stream_copy_wait_param
|
96
|
+
ret['stats.dcnice'] = @dcnice
|
83
97
|
ret['stats.size_of_zredundant'] = @size_of_zredundant
|
84
98
|
ret['stats.write_count'] = @write_count
|
85
99
|
ret['stats.read_count'] = @read_count
|
@@ -87,6 +101,8 @@ module Roma
|
|
87
101
|
ret['stats.out_count'] = @out_count
|
88
102
|
ret['stats.out_message_count'] = @out_message_count
|
89
103
|
ret['stats.redundant_count'] = @redundant_count
|
104
|
+
ret['stats.hilatency_warn_time'] = @hilatency_warn_time
|
105
|
+
ret['stats.wb_command_map'] = @wb_command_map.inspect
|
90
106
|
ret
|
91
107
|
end
|
92
108
|
|
@@ -3,6 +3,8 @@ require 'digest/sha1'
|
|
3
3
|
module Roma
|
4
4
|
module Storage
|
5
5
|
|
6
|
+
class StorageException < Exception; end
|
7
|
+
|
6
8
|
class BasicStorage
|
7
9
|
|
8
10
|
attr :hdb
|
@@ -13,9 +15,9 @@ module Roma
|
|
13
15
|
|
14
16
|
attr_writer :vn_list
|
15
17
|
attr_writer :storage_path
|
16
|
-
attr_writer :divnum
|
17
18
|
attr_writer :option
|
18
19
|
|
20
|
+
attr_accessor :divnum
|
19
21
|
attr_accessor :each_vn_dump_sleep
|
20
22
|
attr_accessor :each_vn_dump_sleep_count
|
21
23
|
attr_accessor :each_clean_up_sleep
|
@@ -87,6 +89,7 @@ module Roma
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def closedb
|
92
|
+
stop_clean_up
|
90
93
|
buf = @hdb; @hdb = []
|
91
94
|
buf.each{ |hdb| close_db(hdb) }
|
92
95
|
end
|
@@ -237,6 +240,14 @@ module Roma
|
|
237
240
|
unpack_data(buf)
|
238
241
|
end
|
239
242
|
|
243
|
+
def get_raw2(k)
|
244
|
+
@hdb.each{|hdb|
|
245
|
+
buf = hdb.get(k)
|
246
|
+
return unpack_data(buf) if buf
|
247
|
+
}
|
248
|
+
nil
|
249
|
+
end
|
250
|
+
|
240
251
|
def rdelete(vn, k, d, clk)
|
241
252
|
buf = @hdb[@hdiv[vn]].get(k)
|
242
253
|
t = Time.now.to_i
|
@@ -323,6 +334,19 @@ module Roma
|
|
323
334
|
nil
|
324
335
|
end
|
325
336
|
|
337
|
+
# set expire time
|
338
|
+
def set_expt(vn, k, d, expt)
|
339
|
+
buf = @hdb[@hdiv[vn]].get(k)
|
340
|
+
if buf
|
341
|
+
vn, t, clk, expt2, v = unpack_data(buf)
|
342
|
+
return nil if Time.now.to_i > expt2
|
343
|
+
clk = (clk + 1) & 0xffffffff
|
344
|
+
ret = [vn, Time.now.to_i, clk, expt, v]
|
345
|
+
return ret if @hdb[@hdiv[vn]].put(k, pack_data(*ret))
|
346
|
+
end
|
347
|
+
nil
|
348
|
+
end
|
349
|
+
|
326
350
|
def true_length
|
327
351
|
res = 0
|
328
352
|
@hdb.each{ |hdb| res += hdb.rnum }
|
@@ -337,30 +361,6 @@ module Roma
|
|
337
361
|
buf.each_key{ |k| @hdb[@hdiv[vn]].out(k) }
|
338
362
|
end
|
339
363
|
|
340
|
-
def clean_up(t,unit_test_flg=nil)
|
341
|
-
n = 0
|
342
|
-
nt = Time.now.to_i
|
343
|
-
@hdb.each_index{ |i|
|
344
|
-
delkey = []
|
345
|
-
@hdb[i].each{ |k, v|
|
346
|
-
vn, last, clk, expt = unpack_header(v)
|
347
|
-
if nt > expt && t > last
|
348
|
-
n += 1
|
349
|
-
#delkey << k
|
350
|
-
@hdb[i].out(k)
|
351
|
-
end
|
352
|
-
if unit_test_flg
|
353
|
-
closedb
|
354
|
-
end
|
355
|
-
sleep @each_clean_up_sleep
|
356
|
-
}
|
357
|
-
#delkey.each{ |k| @hdb[i].out(k) }
|
358
|
-
}
|
359
|
-
n
|
360
|
-
rescue => e
|
361
|
-
raise NoMethodError(e.message)
|
362
|
-
end
|
363
|
-
|
364
364
|
def each_clean_up(t, vnhash)
|
365
365
|
@do_clean_up = true
|
366
366
|
nt = Time.now.to_i
|
@@ -488,7 +488,6 @@ module Roma
|
|
488
488
|
end
|
489
489
|
}
|
490
490
|
end
|
491
|
-
private :each_hdb_dump
|
492
491
|
|
493
492
|
# Create vnode dump.
|
494
493
|
def get_vnode_hash(vn)
|