roma 0.8.12 → 0.8.13p1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -1
- data/Gemfile +17 -0
- data/Rakefile +2 -3
- data/ruby/server/lib/roma/async_process.rb +158 -20
- data/ruby/server/lib/roma/command/bg_command_receiver.rb +3 -4
- data/ruby/server/lib/roma/command/rt_command_receiver.rb +133 -5
- data/ruby/server/lib/roma/command/sys_command_receiver.rb +353 -0
- data/ruby/server/lib/roma/command/vn_command_receiver.rb +9 -3
- data/ruby/server/lib/roma/config.rb +6 -0
- data/ruby/server/lib/roma/dns_cache.rb +40 -0
- data/ruby/server/lib/roma/event/con_pool.rb +3 -1
- data/ruby/server/lib/roma/event/handler.rb +18 -3
- data/ruby/server/lib/roma/messaging/con_pool.rb +3 -1
- data/ruby/server/lib/roma/romad.rb +19 -3
- data/ruby/server/lib/roma/routing/cb_rttable.rb +22 -1
- data/ruby/server/lib/roma/routing/random_balancer.rb +76 -0
- data/ruby/server/lib/roma/routing/routing_data.rb +16 -2
- data/ruby/server/lib/roma/routing/rttable.rb +55 -8
- data/ruby/server/lib/roma/stats.rb +32 -0
- data/ruby/server/lib/roma/storage/sqlite3_storage.rb +9 -3
- data/ruby/server/lib/roma/tools/mkconfig.rb +135 -73
- data/ruby/server/lib/roma/tools/mkrecent.rb +3 -4
- data/ruby/server/lib/roma/tools/mkroute.rb +6 -7
- data/ruby/server/lib/roma/tools/multi_commander.rb +3 -4
- data/ruby/server/lib/roma/tools/recoverlost.rb +0 -1
- data/ruby/server/lib/roma/tools/recoverlost_alist.rb +0 -1
- data/ruby/server/lib/roma/tools/recoverlost_lib.rb +10 -11
- data/ruby/server/lib/roma/tools/roma_watcher.rb +0 -1
- data/ruby/server/lib/roma/tools/sample_watcher.rb +3 -4
- data/ruby/server/lib/roma/tools/sample_watcher2.rb +3 -4
- data/ruby/server/lib/roma/tools/sample_watcher3.rb +0 -1
- data/ruby/server/lib/roma/tools/simple_bench.rb +3 -3
- data/ruby/server/lib/roma/tools/simple_bench2.rb +1 -2
- data/ruby/server/lib/roma/tools/ssroute.rb +0 -1
- data/ruby/server/lib/roma/tools/tribunus.rb +5 -6
- data/ruby/server/lib/roma/version.rb +1 -1
- data/ruby/server/lib/roma/write_behind.rb +4 -1
- data/ruby/server/test/rcirb.rb +0 -1
- data/ruby/server/test/t_cpdata.rb +8 -9
- data/ruby/server/test/t_rclient.rb +1 -2
- data/ruby/server/test/t_routing_data.rb +13 -14
- data/ruby/server/test/t_storage.rb +1 -1
- data/ruby/server/test/t_writebehind.rb +29 -30
- metadata +25 -24
@@ -7,8 +7,7 @@ module Roma
|
|
7
7
|
class Mkconfig
|
8
8
|
TREE_TOP = "menu"
|
9
9
|
LIB_PATH = Pathname(__FILE__).dirname.parent.parent
|
10
|
-
|
11
|
-
CONFIG_FULL_PATH = File.expand_path(File.join(LIB_PATH, CONFIG_PATH))
|
10
|
+
CONFIG_TEMPLATE_PATH = File.expand_path(File.join(LIB_PATH, "roma/config.rb"))
|
12
11
|
CONFIG_OUT_PATH = File.expand_path(File.join(Pathname.pwd, "config.rb"))
|
13
12
|
PLUGIN_DIR = File.expand_path(File.join(LIB_PATH, File.join("roma", "plugin")))
|
14
13
|
BNUM_COEFFICIENT = 2 #reccomend1-4.
|
@@ -20,7 +19,7 @@ module Roma
|
|
20
19
|
PHP_CONNECTION = 256
|
21
20
|
KB = 1024
|
22
21
|
GB = 1024 * 1024 * 1024
|
23
|
-
OS_MEMORY_SIZE =
|
22
|
+
OS_MEMORY_SIZE = 1 * GB
|
24
23
|
END_MSG = ["exit", "quit", "balse"]
|
25
24
|
|
26
25
|
class Base
|
@@ -34,61 +33,60 @@ module Roma
|
|
34
33
|
path_name: menu
|
35
34
|
message: Please select by number.
|
36
35
|
choice:
|
37
|
-
- Select storage
|
36
|
+
- Select storage
|
38
37
|
- Select plugin
|
39
38
|
- Calculate File Descriptor
|
40
39
|
- Save
|
41
40
|
next:
|
42
41
|
- storage
|
43
42
|
- plugin
|
44
|
-
-
|
43
|
+
- language
|
45
44
|
- save
|
45
|
+
|
46
46
|
storage:
|
47
47
|
name: selected_storage
|
48
48
|
path_name: storage
|
49
|
-
message:
|
49
|
+
message: Which storage will you use?
|
50
50
|
choice:
|
51
51
|
- Ruby Hash
|
52
52
|
- Tokyo Cabinet
|
53
|
+
default: 1
|
53
54
|
next:
|
54
55
|
- menu
|
55
56
|
- memory
|
56
57
|
memory:
|
57
58
|
name: memory_size_GB
|
58
59
|
path_name:
|
59
|
-
|
60
|
+
float_flg: on
|
61
|
+
message: How big memory size in 1 server? Please measure in GB.
|
62
|
+
default: 0.6
|
60
63
|
next: process
|
61
64
|
process:
|
62
65
|
name: process_num
|
63
66
|
path_name:
|
64
67
|
message: How many run ROMA process per machine?
|
68
|
+
default: 2
|
65
69
|
next: server
|
66
70
|
server:
|
67
71
|
name: server_num
|
68
72
|
path_name:
|
69
73
|
message: How many machine run as ROMA server?
|
74
|
+
default: 1
|
70
75
|
next: data
|
71
76
|
data:
|
72
77
|
name: data_num
|
73
78
|
path_name:
|
74
79
|
message: How many data will you store?
|
75
|
-
|
76
|
-
key:
|
77
|
-
name: key_size_KB
|
78
|
-
path_name:
|
79
|
-
message: How big is key size per data? Please measure in KB.
|
80
|
-
next: value
|
81
|
-
value:
|
82
|
-
name: value_size_KB
|
83
|
-
path_name:
|
84
|
-
message: How big is value size per data? Please measure in KB.
|
80
|
+
default: 10000
|
85
81
|
next: menu
|
82
|
+
|
86
83
|
plugin:
|
87
84
|
name: selected_plugin
|
88
85
|
path_name: plugin
|
89
|
-
message: Please select
|
86
|
+
message: Please select which plugin will you use.(plugin_storage.rb was already set)
|
90
87
|
choice:
|
91
88
|
#{load_path(PLUGIN_DIR) << "Select all plugins"}
|
89
|
+
default: 1
|
92
90
|
next:
|
93
91
|
#{
|
94
92
|
r = Array.new
|
@@ -100,23 +98,26 @@ module Roma
|
|
100
98
|
continue:
|
101
99
|
name:
|
102
100
|
path_name:
|
103
|
-
message:
|
101
|
+
message: Will you use other plugin?
|
104
102
|
choice:
|
105
103
|
- Select more
|
106
104
|
- No more
|
105
|
+
default: 2
|
107
106
|
next:
|
108
107
|
- plugin
|
108
|
+
- check_plugin
|
109
|
+
check_plugin:
|
110
|
+
name:
|
111
|
+
path_name:
|
112
|
+
message: ROMA requires plugin_storage.rb or substitute plugin.Will you continue without plugin_storage.rb?
|
113
|
+
choice:
|
114
|
+
- Add plugin_storage.rb
|
115
|
+
- Not necessary
|
116
|
+
default: 2
|
117
|
+
next:
|
118
|
+
- add_plugin
|
109
119
|
- menu
|
110
|
-
|
111
|
-
name: server_num
|
112
|
-
path_name: FileDescriptor
|
113
|
-
message: How many machine run as ROMA server?
|
114
|
-
next: fd_client
|
115
|
-
fd_client:
|
116
|
-
name: client_num
|
117
|
-
path_name:
|
118
|
-
message: How many machine run as ROMA client?
|
119
|
-
next: language
|
120
|
+
|
120
121
|
language:
|
121
122
|
name: client_language
|
122
123
|
path_name:
|
@@ -125,11 +126,26 @@ module Roma
|
|
125
126
|
- Ruby
|
126
127
|
- Java
|
127
128
|
- PHP
|
129
|
+
default: 3
|
128
130
|
next:
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
131
|
+
- fd_server
|
132
|
+
- fd_server
|
133
|
+
- fd_server
|
134
|
+
fd_server:
|
135
|
+
name: server_num
|
136
|
+
path_name: FileDescriptor
|
137
|
+
message: How many machine run as ROMA server?
|
138
|
+
default: 1
|
139
|
+
next: fd_client
|
140
|
+
fd_client:
|
141
|
+
name: client_num
|
142
|
+
path_name:
|
143
|
+
message: How many machine run as ROMA client?
|
144
|
+
default: 1
|
145
|
+
next: menu
|
146
|
+
|
132
147
|
save: END
|
148
|
+
|
133
149
|
YAML
|
134
150
|
end
|
135
151
|
|
@@ -144,17 +160,20 @@ module Roma
|
|
144
160
|
def load_path(path)
|
145
161
|
ret = Array.new
|
146
162
|
files = Dir::entries(path)
|
163
|
+
files.delete("plugin_stub.rb") if files.include?("plugin_stub.rb")
|
164
|
+
files.delete("plugin_storage.rb") if files.include?("plugin_storage.rb")
|
165
|
+
|
147
166
|
files.each do |file|
|
148
167
|
ret << file if File::ftype(File.join(path, file)) == "file"
|
149
168
|
end
|
169
|
+
|
150
170
|
ret
|
151
171
|
end
|
152
172
|
|
153
173
|
def print_question(key)
|
154
174
|
target = all[key]
|
155
|
-
|
175
|
+
#print question
|
156
176
|
print "#{target["message"]}\n"
|
157
|
-
|
158
177
|
if target.key?("choice")
|
159
178
|
target["choice"].each_with_index do |k, i|
|
160
179
|
print "[#{i + 1}] #{k}\n"
|
@@ -256,24 +275,22 @@ module Roma
|
|
256
275
|
|
257
276
|
class Calculate
|
258
277
|
def self.get_bnum(res)
|
278
|
+
res["server"] = res["fd_server"] if !res["server"]
|
259
279
|
ans = res["data"].value.to_i * BNUM_COEFFICIENT * REDUNDANCY / res["server"].value.to_i / TC_FILE
|
260
280
|
return ans
|
261
281
|
end
|
262
282
|
|
263
283
|
def self.get_xmsize_max(res)
|
264
|
-
ans = (res["memory"].value.
|
284
|
+
ans = (res["memory"].value.to_f * GB - OS_MEMORY_SIZE) / res["process"].value.to_i / TC_FILE
|
265
285
|
if ans <= 0
|
266
|
-
ans = res["memory"].value.
|
286
|
+
ans = res["memory"].value.to_f * GB / 2 / res["process"].value.to_i / TC_FILE
|
267
287
|
end
|
288
|
+
ans = ans.to_i
|
268
289
|
return ans
|
269
290
|
end
|
270
291
|
|
271
|
-
def self.get_xmsize_min(res)
|
272
|
-
ans = (res["key"].value.to_i * KB + res["value"].value.to_i * KB) * res["data"].value.to_i * REDUNDANCY / res["server"].value.to_i / res["process"].value.to_i / TC_FILE
|
273
|
-
ans = ans
|
274
|
-
end
|
275
|
-
|
276
292
|
def self.get_fd(res)
|
293
|
+
res["fd_server"] = res["server"] if !res["fd_server"]
|
277
294
|
res["fd_server"].value.to_i * connection_num(res) + (res["fd_client"].value.to_i- 1) * DEFAULT_ROMA_CONNECTION * 2
|
278
295
|
end
|
279
296
|
|
@@ -292,9 +309,19 @@ module Roma
|
|
292
309
|
end
|
293
310
|
|
294
311
|
def initialize(mode = :no_menu)
|
312
|
+
# confirming overwrite
|
313
|
+
if File.exist?(CONFIG_OUT_PATH)
|
314
|
+
print("Config.rb already exist in current directory. \nWill you overwrite?[y/n]")
|
315
|
+
if gets.chomp! != "y"
|
316
|
+
p "config.rb were not created!"
|
317
|
+
exit
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
295
321
|
@base = Base.new
|
296
322
|
@results = Hash::new
|
297
323
|
@next_hash = TREE_TOP
|
324
|
+
|
298
325
|
begin
|
299
326
|
@defaults = load_config([:STORAGE_CLASS, :STORAGE_OPTION, :PLUGIN_FILES])
|
300
327
|
rescue LoadError
|
@@ -309,7 +336,7 @@ module Roma
|
|
309
336
|
end
|
310
337
|
|
311
338
|
def load_config(targets)
|
312
|
-
require
|
339
|
+
require CONFIG_TEMPLATE_PATH
|
313
340
|
d_value = Hash.new
|
314
341
|
Config.constants.each do |cnst|
|
315
342
|
if targets.include?(cnst)
|
@@ -321,16 +348,28 @@ module Roma
|
|
321
348
|
|
322
349
|
def mkconfig(mode)
|
323
350
|
skip = skip_menu!(mode)
|
351
|
+
|
324
352
|
while true
|
325
353
|
clear_screen
|
326
|
-
|
354
|
+
|
355
|
+
if @next_hash == "add_plugin"
|
356
|
+
@results["plugin"].value.unshift("plugin_storage.rb")
|
357
|
+
@next_hash = "menu"
|
358
|
+
end
|
359
|
+
|
360
|
+
skip.call if @next_hash == "menu" || @next_hash == "server" || @next_hash == "fd_server" || @next_hash == "check_plugin"
|
327
361
|
break if end?(@base[@next_hash])
|
362
|
+
puts "if you dosen't input anything, default value is set."
|
328
363
|
Box.print_with_box(@defaults)
|
329
364
|
print_status(@results)
|
330
365
|
@base.print_question(@next_hash)
|
331
366
|
input = get_input(@base[@next_hash])
|
367
|
+
|
368
|
+
# if specific words(balse, exit, quit) was inputed, mkconfig.rb was finished.
|
332
369
|
if END_MSG.include?(input)
|
333
|
-
|
370
|
+
p "config.rb were not created!"
|
371
|
+
break
|
372
|
+
|
334
373
|
else
|
335
374
|
@results = store_result(@results, @base, @next_hash, input)
|
336
375
|
@next_hash = @base.next(@next_hash, input)
|
@@ -343,15 +382,37 @@ module Roma
|
|
343
382
|
end
|
344
383
|
|
345
384
|
def skip_menu!(menu)
|
346
|
-
|
385
|
+
# in case of "-m" or "--with_menu" option was used
|
386
|
+
if menu == :with_menu
|
387
|
+
return Proc.new do
|
388
|
+
if @next_hash == "server" && @results["fd_server"]
|
389
|
+
@next_hash = @base["server"]["next"]
|
390
|
+
elsif @next_hash == "fd_server" && @results["server"]
|
391
|
+
@next_hash = "fd_client"
|
392
|
+
elsif @next_hash == "check_plugin" && @results["plugin"].value.include?("plugin_storage.rb")
|
393
|
+
@next_hash = "menu"
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
347
397
|
|
398
|
+
# in case of "-m" or "--with_menu" option was NOT used
|
348
399
|
i = 0
|
349
400
|
return Proc.new do
|
350
|
-
@next_hash
|
351
|
-
|
401
|
+
if @next_hash == "menu"
|
402
|
+
@next_hash = @base["menu"]["next"][i]
|
403
|
+
i += 1
|
404
|
+
elsif @next_hash == "server" && @results["fd_server"]
|
405
|
+
@next_hash = @base["server"]["next"]
|
406
|
+
elsif @next_hash == "fd_server" && @results["server"]
|
407
|
+
@next_hash = "fd_client"
|
408
|
+
elsif @next_hash == "check_plugin" && @results["plugin"].value.include?("plugin_storage.rb")
|
409
|
+
@next_hash = "language"
|
410
|
+
i += 1
|
411
|
+
end
|
352
412
|
end
|
353
413
|
end
|
354
414
|
|
415
|
+
#judge whether data inputting finish or not
|
355
416
|
def end?(s)
|
356
417
|
if s == "END"
|
357
418
|
save_data(@results)
|
@@ -373,6 +434,10 @@ module Roma
|
|
373
434
|
|
374
435
|
while !correct_in?(hash,input)
|
375
436
|
input = receiver.get_line
|
437
|
+
if input == ""
|
438
|
+
#set defaults value
|
439
|
+
input = hash["default"]
|
440
|
+
end
|
376
441
|
end
|
377
442
|
|
378
443
|
input
|
@@ -383,7 +448,7 @@ module Roma
|
|
383
448
|
return true
|
384
449
|
end
|
385
450
|
|
386
|
-
if hash == "continue"
|
451
|
+
if hash["next"] == "continue"
|
387
452
|
if (input == "y" || input == "n")
|
388
453
|
return true
|
389
454
|
end
|
@@ -393,8 +458,14 @@ module Roma
|
|
393
458
|
return true
|
394
459
|
end
|
395
460
|
else
|
396
|
-
if
|
397
|
-
|
461
|
+
if hash["float_flg"]
|
462
|
+
if 0 < input.to_f
|
463
|
+
return true
|
464
|
+
end
|
465
|
+
else
|
466
|
+
if 0 < input.to_i
|
467
|
+
return true
|
468
|
+
end
|
398
469
|
end
|
399
470
|
end
|
400
471
|
end
|
@@ -402,23 +473,6 @@ module Roma
|
|
402
473
|
return false
|
403
474
|
end
|
404
475
|
|
405
|
-
def exit?
|
406
|
-
question = "Settings are not saved. Really exit? [y/n]\n"
|
407
|
-
receiver = Input.new
|
408
|
-
input = ""
|
409
|
-
|
410
|
-
print question
|
411
|
-
input = receiver.get_line
|
412
|
-
if input == "y"
|
413
|
-
print "bye.\n"
|
414
|
-
true
|
415
|
-
else
|
416
|
-
print "Continue.\n"
|
417
|
-
sleep 1
|
418
|
-
false
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
476
|
def store_result(results, base, hash, input)
|
423
477
|
target = base[hash]
|
424
478
|
|
@@ -447,6 +501,7 @@ module Roma
|
|
447
501
|
return results
|
448
502
|
end
|
449
503
|
|
504
|
+
#make config.rb based on input data
|
450
505
|
def save_data(res)
|
451
506
|
if res.key?("storage")
|
452
507
|
if res["storage"].value == "Ruby Hash"
|
@@ -463,13 +518,13 @@ module Roma
|
|
463
518
|
end
|
464
519
|
end
|
465
520
|
|
466
|
-
if res.key?("
|
521
|
+
if res.key?("language")
|
467
522
|
fd = Calculate.get_fd(res)
|
468
|
-
print "\r\nPlease set
|
523
|
+
print "\r\nPlease set FileDescriptor bigger than #{fd}.\r\n\r\n"
|
469
524
|
end
|
470
525
|
|
471
526
|
body = ""
|
472
|
-
open(
|
527
|
+
open(CONFIG_TEMPLATE_PATH, "r") do |f|
|
473
528
|
body = f.read
|
474
529
|
end
|
475
530
|
|
@@ -487,6 +542,7 @@ module Roma
|
|
487
542
|
end
|
488
543
|
|
489
544
|
if res.key?("plugin")
|
545
|
+
res["plugin"].value.unshift("plugin_storage.rb")
|
490
546
|
body = ch_assign(body, "PLUGIN_FILES", res["plugin"].value)
|
491
547
|
end
|
492
548
|
|
@@ -504,20 +560,26 @@ module Roma
|
|
504
560
|
results = load_config([:STORAGE_CLASS, :STORAGE_OPTION, :PLUGIN_FILES])
|
505
561
|
print "\r\nAfter\r\n"
|
506
562
|
Box.print_with_box(results)
|
507
|
-
print "\r\nMkconfig is finish.\r\n
|
563
|
+
print "\r\nMkconfig is finish.\r\n"
|
564
|
+
print "\r\nIf you need, change directory path about LOG, RTTABLE, STORAGE, WB and other setting.\r\n\r\n"
|
508
565
|
end
|
509
566
|
|
567
|
+
# sep means separating right and left part(config.rb style)
|
510
568
|
def ch_assign(text, exp, sep = " = ", str)
|
511
569
|
sep = " = " if sep == "="
|
512
570
|
text = text.gsub(/(\s*#{exp}).*/) do |s|
|
513
571
|
name = $1
|
514
572
|
if str.class == String
|
515
573
|
if str =~ /::/ || str =~ /^\d+$/
|
516
|
-
|
574
|
+
# storage type
|
575
|
+
name + sep + str
|
517
576
|
else
|
518
|
-
|
577
|
+
# require & storage option
|
578
|
+
name + sep + str.inspect
|
519
579
|
end
|
520
580
|
else
|
581
|
+
# plugin
|
582
|
+
# "to_s" equal "inspect" in Ruby 1.9
|
521
583
|
name + sep + str.to_s.sub("\\", "")
|
522
584
|
end
|
523
585
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
#
|
4
3
|
# usage:mkrecent dgst-bits div-bits divnum storage-path1 storage-path2 recent-storage-path
|
5
4
|
#
|
@@ -13,7 +12,7 @@ module Roma
|
|
13
12
|
Storage::autoload(:SQLite3Storage,'roma/storage/sqlite3_storage')
|
14
13
|
|
15
14
|
class MakeRecentData
|
16
|
-
|
15
|
+
|
17
16
|
def initialize(argv = nil)
|
18
17
|
if argv.length != 6
|
19
18
|
STDERR.puts "usage:mkrecent dgst-bits div-bits divnum storage-path1 storage-path2 recent-storage-path"
|
@@ -38,7 +37,7 @@ module Roma
|
|
38
37
|
STDERR.puts "#{@recentpath} exists."
|
39
38
|
exit
|
40
39
|
end
|
41
|
-
|
40
|
+
|
42
41
|
Dir::mkdir(@recentpath)
|
43
42
|
|
44
43
|
Dir::glob("#{@strgpath1}/*").each{|dir|
|
@@ -66,7 +65,7 @@ module Roma
|
|
66
65
|
@st1.closedb
|
67
66
|
exit
|
68
67
|
end
|
69
|
-
|
68
|
+
|
70
69
|
if @st1.class != @st2.class
|
71
70
|
STDERR.puts "#{p1} and #{p2} that file type is different."
|
72
71
|
@st1.closedb
|
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
require 'optparse'
|
4
3
|
require 'roma/routing/routing_data'
|
5
4
|
|
6
|
-
#
|
5
|
+
# digest bit count
|
7
6
|
dgst_bits=32
|
8
|
-
#
|
7
|
+
# dividing bit count (dgst_bits >= div_bits)
|
9
8
|
div_bits=9
|
10
|
-
#
|
9
|
+
# redundancy (nodes.length >= rn)
|
11
10
|
rn=2
|
12
|
-
#
|
11
|
+
# permit redundant on single host
|
13
12
|
repeathost=false
|
14
13
|
|
15
14
|
opts = OptionParser.new
|
@@ -30,12 +29,12 @@ end
|
|
30
29
|
|
31
30
|
if dgst_bits < div_bits
|
32
31
|
STDERR.puts "The hash bits should be divide bits or more."
|
33
|
-
exit!
|
32
|
+
exit!
|
34
33
|
end
|
35
34
|
|
36
35
|
if div_bits > 32
|
37
36
|
STDERR.puts "The upper bound of divide bits is 32."
|
38
|
-
exit!
|
37
|
+
exit!
|
39
38
|
end
|
40
39
|
|
41
40
|
if nodes.length < rn
|
@@ -1,16 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
require 'roma/logging/rlogger'
|
4
3
|
require 'roma/messaging/con_pool'
|
5
4
|
require 'roma/routing/routing_data'
|
6
5
|
require 'roma/client/sender'
|
7
6
|
|
8
7
|
module Roma
|
9
|
-
|
8
|
+
|
10
9
|
class MultiCommander
|
11
10
|
|
12
11
|
Roma::Client::Sender.class_eval{
|
13
|
-
def multiplelines_receiver2(con)
|
12
|
+
def multiplelines_receiver2(con)
|
14
13
|
ret = []
|
15
14
|
while select [con], nil, nil, 0.05
|
16
15
|
ret << con.gets.chomp
|
@@ -41,5 +40,5 @@ module Roma
|
|
41
40
|
end
|
42
41
|
|
43
42
|
end # class MultiCommander
|
44
|
-
|
43
|
+
|
45
44
|
end # module Roma
|
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
#
|
4
3
|
# usage:recoverlost address port storage-path [yyyymmddhhmmss]
|
5
4
|
#
|
@@ -15,7 +14,7 @@ module Roma
|
|
15
14
|
Storage::autoload(:SQLite3Storage,'roma/storage/sqlite3_storage')
|
16
15
|
|
17
16
|
class RecoverLost
|
18
|
-
|
17
|
+
|
19
18
|
def initialize(pname, pushv_cmd, argv, alldata = false)
|
20
19
|
if alldata == false && argv.length < 4
|
21
20
|
puts "usage:#{pname} address port storage-path [yyyymmddhhmmss]"
|
@@ -36,7 +35,7 @@ module Roma
|
|
36
35
|
STDERR.puts "port was not numeric."
|
37
36
|
exit
|
38
37
|
end
|
39
|
-
|
38
|
+
|
40
39
|
if @ymdhms && (@ymdhms.length != 14 || @ymdhms =~ /\D/)
|
41
40
|
STDERR.puts "yyyymmddhhmmss format mismatch."
|
42
41
|
exit
|
@@ -84,7 +83,7 @@ module Roma
|
|
84
83
|
next unless File::directory?(dir)
|
85
84
|
hname = dir[dir.rindex('/')+1..-1]
|
86
85
|
yield hname,dir
|
87
|
-
}
|
86
|
+
}
|
88
87
|
end
|
89
88
|
|
90
89
|
def get_routing_data(nid)
|
@@ -121,7 +120,7 @@ module Roma
|
|
121
120
|
ext = File::extname(Dir::glob("#{path}/0.*")[0])[1..-1]
|
122
121
|
# count a number of divided files
|
123
122
|
divnum = Dir::glob("#{path}/*.#{ext}").length
|
124
|
-
|
123
|
+
|
125
124
|
st = new_storage(ext)
|
126
125
|
st.divnum = divnum
|
127
126
|
st.vn_list = vn_list
|
@@ -163,9 +162,9 @@ module Roma
|
|
163
162
|
}
|
164
163
|
|
165
164
|
if nodes == nil || nodes.length == 0
|
166
|
-
cmd = "setroute #{vn} #{@rd.v_clk[vn]} #{
|
167
|
-
exit unless send_cmd(
|
168
|
-
broadcast_cmd(cmd,
|
165
|
+
cmd = "setroute #{vn} #{@rd.v_clk[vn]} #{nids[0]}\r\n"
|
166
|
+
exit unless send_cmd(nids[0] ,cmd)
|
167
|
+
broadcast_cmd(cmd, nids[0])
|
169
168
|
end
|
170
169
|
}
|
171
170
|
end
|
@@ -242,7 +241,7 @@ module Roma
|
|
242
241
|
else
|
243
242
|
wd = [vn, last, 0, expt, k.length, k, 0].pack("NNNNNa#{k.length}N")
|
244
243
|
end
|
245
|
-
|
244
|
+
|
246
245
|
con.write(wd)
|
247
246
|
sleep @stream_copy_wait_param
|
248
247
|
}
|
@@ -293,10 +292,10 @@ module Roma
|
|
293
292
|
else
|
294
293
|
wd = [vn, last, 0, expt, k.length, k, 0].pack("NNNNNa#{k.length}N")
|
295
294
|
end
|
296
|
-
|
295
|
+
|
297
296
|
con.write(wd)
|
298
297
|
sleep @stream_copy_wait_param
|
299
|
-
|
298
|
+
|
300
299
|
con.write("\0"*20) # end of steram
|
301
300
|
|
302
301
|
res = con.gets # STORED\r\n or error string
|
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
require 'roma/logging/rlogger'
|
4
3
|
require 'roma/messaging/con_pool'
|
5
4
|
require 'roma/routing/routing_data'
|
6
5
|
require 'roma/client/sender'
|
7
6
|
|
8
7
|
module Roma
|
9
|
-
|
8
|
+
|
10
9
|
class Watcher
|
11
10
|
|
12
11
|
def initialize
|
@@ -18,13 +17,13 @@ module Roma
|
|
18
17
|
end
|
19
18
|
|
20
19
|
end # class Watcher
|
21
|
-
|
20
|
+
|
22
21
|
end # module Roma
|
23
22
|
|
24
23
|
|
25
24
|
w = Roma::Watcher.new
|
26
25
|
|
27
|
-
#
|
26
|
+
# define the watch list of node
|
28
27
|
nodes = ['roma0:11211','roma0:11212','roma0:11213','roma0:11214']
|
29
28
|
|
30
29
|
nodes.each{|nid|
|
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
2
|
require 'roma/logging/rlogger'
|
4
3
|
require 'roma/messaging/con_pool'
|
5
4
|
require 'roma/routing/routing_data'
|
6
5
|
require 'roma/client/sender'
|
7
6
|
|
8
7
|
module Roma
|
9
|
-
|
8
|
+
|
10
9
|
class Watcher
|
11
10
|
|
12
11
|
def initialize
|
@@ -17,12 +16,12 @@ module Roma
|
|
17
16
|
ret = @sender.send_command(nid, command, value = nil, :multiplelines_receiver)
|
18
17
|
end
|
19
18
|
end # class Watcher
|
20
|
-
|
19
|
+
|
21
20
|
end # module Roma
|
22
21
|
|
23
22
|
w = Roma::Watcher.new
|
24
23
|
|
25
|
-
# the definition of all nodes
|
24
|
+
# the definition of all nodes
|
26
25
|
nodes = ['roma0:11211','roma0:11212']
|
27
26
|
|
28
27
|
nodes.each{|nid|
|