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
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'timeout'
|
4
|
+
|
5
|
+
module Roma
|
6
|
+
class CheckTc
|
7
|
+
def initialize(storage_path, library_path)
|
8
|
+
@storage_path = storage_path
|
9
|
+
@library_path = library_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_flag
|
13
|
+
status = {}
|
14
|
+
timeout(5){
|
15
|
+
Dir.glob("#{@storage_path}/*.tc").each{|f|
|
16
|
+
res = `#{@library_path}/bin/tchmgr inform #{f}`
|
17
|
+
res =~ /additional flags:(.*)\n/
|
18
|
+
status.store(f, $1)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
status
|
22
|
+
end
|
23
|
+
|
24
|
+
end # CheckTc
|
25
|
+
end # Roma
|
data/lib/roma/tools/cpdb.rb
CHANGED
@@ -22,8 +22,8 @@ module Roma
|
|
22
22
|
def check_storage_type
|
23
23
|
stats('st_class') do |line|
|
24
24
|
storage_type = line.match(/storages\[.+\]\.storage\.st_class\s(.+)/)[1].chomp
|
25
|
-
unless storage_type =~ /^(TCStorage
|
26
|
-
puts "ERROR:cpdb supports just TCStorage
|
25
|
+
unless storage_type =~ /^(TCStorage)$/
|
26
|
+
puts "ERROR:cpdb supports just TCStorage system, your storage type is #{storage_type}"
|
27
27
|
exit
|
28
28
|
end
|
29
29
|
end
|
@@ -127,6 +127,7 @@ begin
|
|
127
127
|
sc.check_storage_type
|
128
128
|
sc.backup_all
|
129
129
|
sc.set_gui_last_snapshot
|
130
|
+
puts "finished"
|
130
131
|
ensure
|
131
132
|
sc.close
|
132
133
|
end
|
data/lib/roma/tools/mkconfig.rb
CHANGED
@@ -50,10 +50,12 @@ module Roma
|
|
50
50
|
choice:
|
51
51
|
- Ruby Hash
|
52
52
|
- Tokyo Cabinet
|
53
|
+
- Groonga
|
53
54
|
default: 1
|
54
55
|
next:
|
55
56
|
- menu
|
56
57
|
- memory
|
58
|
+
- memory
|
57
59
|
memory:
|
58
60
|
name: memory_size_GB
|
59
61
|
path_name:
|
@@ -83,9 +85,14 @@ module Roma
|
|
83
85
|
plugin:
|
84
86
|
name: selected_plugin
|
85
87
|
path_name: plugin
|
86
|
-
message: Please select which plugin will you use.(plugin_storage.rb
|
88
|
+
message: Please select which plugin will you use.(plugin_storage.rb is essential unless you make alternative plugin.)
|
87
89
|
choice:
|
88
|
-
#{
|
90
|
+
#{
|
91
|
+
list = load_path(PLUGIN_DIR) << "Select all plugins"
|
92
|
+
list.delete("plugin_storage.rb")
|
93
|
+
list.unshift("plugin_storage.rb")
|
94
|
+
list
|
95
|
+
}
|
89
96
|
default: 1
|
90
97
|
next:
|
91
98
|
#{
|
@@ -161,7 +168,6 @@ module Roma
|
|
161
168
|
ret = Array.new
|
162
169
|
files = Dir::entries(path)
|
163
170
|
files.delete("plugin_stub.rb") if files.include?("plugin_stub.rb")
|
164
|
-
files.delete("plugin_storage.rb") if files.include?("plugin_storage.rb")
|
165
171
|
|
166
172
|
files.each do |file|
|
167
173
|
ret << file if File::ftype(File.join(path, file)) == "file"
|
@@ -353,7 +359,7 @@ module Roma
|
|
353
359
|
clear_screen
|
354
360
|
|
355
361
|
if @next_hash == "add_plugin"
|
356
|
-
@results["plugin"].value.unshift("plugin_storage.rb")
|
362
|
+
@results["plugin"].value.unshift("plugin_storage.rb") unless @results["plugin"].value.include?("plugin_storage.rb")
|
357
363
|
@next_hash = "menu"
|
358
364
|
end
|
359
365
|
|
@@ -504,17 +510,22 @@ module Roma
|
|
504
510
|
#make config.rb based on input data
|
505
511
|
def save_data(res)
|
506
512
|
if res.key?("storage")
|
507
|
-
|
513
|
+
case res["storage"].value
|
514
|
+
when "Ruby Hash"
|
508
515
|
req = "rh_storage"
|
509
516
|
storage = "RubyHashStorage"
|
510
|
-
|
511
|
-
|
512
|
-
if res["storage"].value == "Tokyo Cabinet"
|
517
|
+
when "Tokyo Cabinet"
|
513
518
|
req = "tc_storage"
|
514
519
|
storage = "TCStorage"
|
515
520
|
bnum = Calculate.get_bnum(res)
|
516
521
|
bnum = 5000000 if bnum < 5000000
|
517
522
|
xmsiz = Calculate.get_xmsize_max(res)
|
523
|
+
when "Groonga"
|
524
|
+
req = "groonga_storage"
|
525
|
+
storage = "GroongaStorage"
|
526
|
+
bnum = Calculate.get_bnum(res)
|
527
|
+
bnum = 5000000 if bnum < 5000000
|
528
|
+
xmsiz = Calculate.get_xmsize_max(res)
|
518
529
|
end
|
519
530
|
end
|
520
531
|
|
@@ -532,17 +543,15 @@ module Roma
|
|
532
543
|
body = ch_assign(body, "require", " ", "roma\/storage\/#{req}")
|
533
544
|
body = ch_assign(body, "STORAGE_CLASS", "Roma::Storage::#{storage}")
|
534
545
|
|
535
|
-
|
546
|
+
case req
|
547
|
+
when "rh_storage"
|
536
548
|
body = ch_assign(body, "STORAGE_OPTION","")
|
537
|
-
|
538
|
-
|
539
|
-
if req == "tc_storage"
|
549
|
+
when /^(tc_storage|groonga_storage)$/
|
540
550
|
body = ch_assign(body, "STORAGE_OPTION", "bnum=#{bnum}\#xmsiz=#{xmsiz}\#opts=d#dfunit=10")
|
541
551
|
end
|
542
552
|
end
|
543
553
|
|
544
554
|
if res.key?("plugin")
|
545
|
-
res["plugin"].value.unshift("plugin_storage.rb")
|
546
555
|
body = ch_assign(body, "PLUGIN_FILES", res["plugin"].value)
|
547
556
|
end
|
548
557
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'timeout'
|
5
|
+
|
6
|
+
module Roma
|
7
|
+
class Adm
|
8
|
+
def initialize(cmd, port)
|
9
|
+
@cmd = cmd.dup #to avoid frozen error
|
10
|
+
@port = port
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_type
|
14
|
+
# waiting value input command
|
15
|
+
require_value_cmd = Regexp.new(/^(set|add|replace|append|prepend|cas|alist_delete|alist_include\?|alist_insert|alist_sized_insert|alist_swap_and_insert|alist_swap_and_sized_insert|alist_join_with_time|alist_join|alist_push|alist_sized_push|alist_swap_and_push|alist_update_at)/)
|
16
|
+
|
17
|
+
case @cmd
|
18
|
+
when "balse", "shutdown" # yes/no check
|
19
|
+
make_command("halt_cmd")
|
20
|
+
@halt_cmd = true
|
21
|
+
when "start" # alias cmd
|
22
|
+
make_command("booting")
|
23
|
+
@alias = true
|
24
|
+
when require_value_cmd
|
25
|
+
make_command("value")
|
26
|
+
else
|
27
|
+
t = Thread.new do
|
28
|
+
loop{
|
29
|
+
print "."
|
30
|
+
sleep 1
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def send_command(host="localhost")
|
37
|
+
if @alias
|
38
|
+
base_path = Pathname(__FILE__).dirname.parent.parent.parent.expand_path
|
39
|
+
`#{base_path}/#{@cmd}` # bash
|
40
|
+
elsif @halt_cmd
|
41
|
+
return `echo -e "#{@cmd}" | nc -i1 #{host} #{@port}` # bash
|
42
|
+
else
|
43
|
+
timeout(5) {
|
44
|
+
res = []
|
45
|
+
TCPSocket.open(host, @port) do |sock|
|
46
|
+
sock.puts @cmd
|
47
|
+
while select [sock], nil, nil, 0.5
|
48
|
+
res << sock.gets.chomp!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
return res
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def make_command(type)
|
59
|
+
case type
|
60
|
+
when "halt_cmd"
|
61
|
+
puts("Are you sure?(yes/no)\r\n")
|
62
|
+
if STDIN.gets.chomp != "yes"
|
63
|
+
raise "confirmation was rejected"
|
64
|
+
else
|
65
|
+
@cmd.concat("\r\nyes\r\nyes\r\n")
|
66
|
+
end
|
67
|
+
when "booting"
|
68
|
+
puts("Please input hostname or ip address which is used for ROMA.\r\n Ex.) roma_serverA, 192.168.33.11\r\n")
|
69
|
+
hostname = STDIN.gets.chomp
|
70
|
+
puts("Please input PATH of config.rb.\r\n Ex.) /home/roma/config.rb\r\n")
|
71
|
+
config_path = STDIN.gets.chomp
|
72
|
+
@cmd = "bin/romad #{hostname} -p #{@port} -d --config #{config_path}"
|
73
|
+
when "value"
|
74
|
+
puts("Please input value.\r\n")
|
75
|
+
value = STDIN.gets.chomp
|
76
|
+
@cmd.concat("\r\n#{value}\r\n")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end #Adm
|
81
|
+
end # Roma
|
82
|
+
|
data/lib/roma/version.rb
CHANGED
data/test/config4mhash.rb
CHANGED
data/test/config4test.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
module CpdbBase
|
2
|
+
|
3
|
+
module Config
|
4
|
+
VERSION = "1.2.0"
|
5
|
+
|
6
|
+
DEFAULT_PORT = 12000
|
7
|
+
DEFAULT_NAME = 'ROMA'
|
8
|
+
|
9
|
+
# :no_action | :auto_assign | :shutdown
|
10
|
+
DEFAULT_LOST_ACTION = :auto_assign
|
11
|
+
|
12
|
+
# log setting
|
13
|
+
LOG_SHIFT_AGE = 10
|
14
|
+
LOG_SHIFT_SIZE = 1024 * 1024 * 10
|
15
|
+
LOG_PATH = '.'
|
16
|
+
# :debug | :info | :warn | :error
|
17
|
+
LOG_LEVEL = :debug
|
18
|
+
|
19
|
+
# routing setting
|
20
|
+
RTTABLE_PATH = '.'
|
21
|
+
|
22
|
+
# connection setting
|
23
|
+
# like a MaxStartups spec in the sshd_config
|
24
|
+
# 'start:rate:full'
|
25
|
+
CONNECTION_CONTINUOUS_LIMIT = '200:30:300'
|
26
|
+
|
27
|
+
# storage setting
|
28
|
+
#STORAGE_CLASS = Roma::Storage::GroongaStorage
|
29
|
+
STORAGE_DIVNUM = 10
|
30
|
+
STORAGE_PATH = '.'
|
31
|
+
STORAGE_DUMP_PATH = '/tmp'
|
32
|
+
STORAGE_OPTION = ''
|
33
|
+
|
34
|
+
# 5 days ago
|
35
|
+
STORAGE_DELMARK_EXPTIME = 60 * 60 * 24 * 5
|
36
|
+
|
37
|
+
# data copy setting
|
38
|
+
DATACOPY_STREAM_COPY_WAIT_PARAM = 0.0001
|
39
|
+
|
40
|
+
# plugin setting
|
41
|
+
PLUGIN_FILES = ['plugin_storage.rb','plugin_alist.rb','plugin_map.rb','plugin_mapcount.rb']
|
42
|
+
|
43
|
+
# write-behind setting
|
44
|
+
WRITEBEHIND_PATH = './wb'
|
45
|
+
WRITEBEHIND_SHIFT_SIZE = 1024 * 1024 * 10
|
46
|
+
|
47
|
+
# redundant setting
|
48
|
+
REDUNDANT_ZREDUNDANT_SIZE = 0
|
49
|
+
|
50
|
+
def self.get_stat
|
51
|
+
ret = {}
|
52
|
+
ret['config.DEFAULT_LOST_ACTION'] = DEFAULT_LOST_ACTION
|
53
|
+
ret['config.LOG_SHIFT_AGE'] = LOG_SHIFT_AGE
|
54
|
+
ret['config.LOG_SHIFT_SIZE'] = LOG_SHIFT_SIZE
|
55
|
+
ret['config.LOG_PATH'] = File.expand_path(LOG_PATH)
|
56
|
+
ret['config.RTTABLE_PATH'] = File.expand_path(RTTABLE_PATH)
|
57
|
+
ret['config.STORAGE_DELMARK_EXPTIME'] = STORAGE_DELMARK_EXPTIME
|
58
|
+
ret['config.DATACOPY_STREAM_COPY_WAIT_PARAM'] = DATACOPY_STREAM_COPY_WAIT_PARAM
|
59
|
+
ret['config.PLUGIN_FILES'] = PLUGIN_FILES.inspect
|
60
|
+
ret['config.WRITEBEHIND_PATH'] = File.expand_path(WRITEBEHIND_PATH)
|
61
|
+
ret['config.WRITEBEHIND_SHIFT_SIZE'] = WRITEBEHIND_SHIFT_SIZE
|
62
|
+
ret
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/test/roma-test-utils.rb
CHANGED
@@ -4,71 +4,171 @@ require 'fileutils'
|
|
4
4
|
require 'rbconfig'
|
5
5
|
require 'roma/config'
|
6
6
|
require 'roma/messaging/con_pool'
|
7
|
+
require 'roma/logging/rlogger'
|
8
|
+
require 'roma/client/rclient'
|
9
|
+
require 'roma/client/client_pool'
|
10
|
+
|
11
|
+
Roma::Client::RomaClient.class_eval do
|
12
|
+
def init_sync_routing_proc
|
13
|
+
end
|
14
|
+
end
|
7
15
|
|
8
16
|
module RomaTestUtils
|
17
|
+
DEFAULT_CONFIG = 'config4test.rb'
|
18
|
+
DEFAULT_HOST = 'localhost'
|
19
|
+
DEFAULT_IP = '127.0.0.1'
|
20
|
+
DEFAULT_PORTS = %w(11211 11212)
|
21
|
+
DEFAULT_NODES = DEFAULT_PORTS.map { |port| "#{DEFAULT_HOST}_#{port}" }
|
22
|
+
DEFAULT_TIMEOUT_SEC = 90
|
23
|
+
SHELL_LOG = 'roma_test_outputs.log'
|
24
|
+
|
25
|
+
Roma::Logging::RLogger.create_singleton_instance("#{Roma::Config::LOG_PATH}/roma_test.log",
|
26
|
+
Roma::Config::LOG_SHIFT_AGE,
|
27
|
+
Roma::Config::LOG_SHIFT_SIZE)
|
28
|
+
|
9
29
|
module_function
|
30
|
+
|
31
|
+
def start_roma(conf = DEFAULT_CONFIG, div_bits: 3, replication_in_host: true)
|
32
|
+
FileUtils.rm_rf(Dir.glob("#{Roma::Config::STORAGE_PATH}/#{DEFAULT_NODES[0][0..-2]}?*"))
|
33
|
+
FileUtils.rm_rf(Dir.glob("#{Roma::Config::STORAGE_PATH}/#{DEFAULT_IP}_#{DEFAULT_PORTS[0][0..-2]}?*"))
|
34
|
+
sleep 0.1
|
35
|
+
|
36
|
+
system("#{ruby_path} #{mkroute_path} #{DEFAULT_NODES.join(' ')} -d #{div_bits} --replication_in_host >> #{SHELL_LOG} 2>&1")
|
37
|
+
sleep 0.2
|
38
|
+
|
39
|
+
DEFAULT_NODES.each do |node|
|
40
|
+
do_command_romad(node, conf, replication_in_host)
|
41
|
+
end
|
42
|
+
sleep 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def join_roma(node, conf = DEFAULT_CONFIG, replication_in_host: true)
|
46
|
+
do_command_romad(node, conf, replication_in_host, true)
|
47
|
+
end
|
48
|
+
|
49
|
+
def do_command_romad(node, conf, replication_in_host = true, is_join = false)
|
50
|
+
host, port = node.split('_')
|
51
|
+
romad_command = [
|
52
|
+
ruby_path, romad_path, host,
|
53
|
+
'-p', port,
|
54
|
+
'-d', '--verbose', '--disabled_cmd_protect',
|
55
|
+
'--config', "#{test_dir}/#{conf}"
|
56
|
+
]
|
57
|
+
romad_command << '--replication_in_host' if replication_in_host
|
58
|
+
romad_command << "-j #{DEFAULT_NODES[0]}" if is_join
|
59
|
+
romad_command << ">> #{SHELL_LOG} 2>&1"
|
60
|
+
|
61
|
+
system(romad_command.join(' '))
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_client
|
65
|
+
client_pool = Roma::Client::ClientPool.instance
|
66
|
+
client_pool.servers = DEFAULT_NODES
|
67
|
+
client_pool.client
|
68
|
+
end
|
69
|
+
|
70
|
+
def wait_join(node)
|
71
|
+
client = get_client
|
72
|
+
wait_count = 0
|
73
|
+
retry_count = 0
|
74
|
+
sleep 5
|
75
|
+
|
76
|
+
until client.rttable.nodes.include?(node)
|
77
|
+
sleep 1
|
78
|
+
client.update_rttable
|
79
|
+
wait_count += 1
|
80
|
+
fail "#{__method__} timeout" if wait_count > DEFAULT_TIMEOUT_SEC
|
81
|
+
end
|
82
|
+
|
83
|
+
while client.stats(node: node)['stats.run_join'] == 'true'
|
84
|
+
sleep 1
|
85
|
+
wait_count += 1
|
86
|
+
fail "#{__method__} timeout" if wait_count > DEFAULT_TIMEOUT_SEC
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def wait_failover(down_node)
|
91
|
+
client = get_client
|
92
|
+
stats_node = down_node == DEFAULT_NODES[0] ? DEFAULT_NODES[1] : DEFAULT_NODES[0]
|
93
|
+
wait_count = 0
|
94
|
+
sleep 1
|
95
|
+
|
96
|
+
while client.stats(node: stats_node)['routing.nodes'] =~ /#{down_node}/
|
97
|
+
sleep 1
|
98
|
+
wait_count += 1
|
99
|
+
fail "#{__method__} timeout" if wait_count > DEFAULT_TIMEOUT_SEC
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def wait_release(node)
|
104
|
+
client = get_client
|
105
|
+
wait_count = 0
|
106
|
+
sleep 1
|
107
|
+
|
108
|
+
while client.stats(node: node)['stats.run_release'] == 'true'
|
109
|
+
sleep 1
|
110
|
+
wait_count += 1
|
111
|
+
fail "#{__method__} timeout" if wait_count > DEFAULT_TIMEOUT_SEC
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def stop_roma
|
116
|
+
balse_message = %w(balse yes)
|
117
|
+
send_message(messages: balse_message)
|
118
|
+
Roma::Client::ConPool.instance.close_all
|
119
|
+
Roma::Messaging::ConPool.instance.close_all
|
120
|
+
end
|
121
|
+
|
122
|
+
def stop_roma_node(node)
|
123
|
+
send_message(messages: 'rbalse', node: node)
|
124
|
+
Roma::Client::ConPool.instance.close_all
|
125
|
+
Roma::Messaging::ConPool.instance.close_all
|
126
|
+
end
|
127
|
+
|
128
|
+
def release_roma_node(node)
|
129
|
+
send_message(messages: 'release', node: node)
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
10
134
|
def base_dir
|
11
135
|
Pathname(__FILE__).dirname.parent.expand_path
|
12
136
|
end
|
13
137
|
|
14
138
|
def bin_dir
|
15
|
-
base_dir +
|
139
|
+
base_dir + 'bin'
|
16
140
|
end
|
17
141
|
|
18
142
|
def test_dir
|
19
|
-
base_dir +
|
143
|
+
base_dir + 'test'
|
20
144
|
end
|
21
145
|
|
22
146
|
def mkroute_path
|
23
|
-
(bin_dir +
|
147
|
+
(bin_dir + 'mkroute').to_s
|
24
148
|
end
|
25
149
|
|
26
150
|
def romad_path
|
27
|
-
(bin_dir +
|
151
|
+
(bin_dir + 'romad').to_s
|
28
152
|
end
|
29
153
|
|
30
154
|
def ruby_path
|
31
|
-
File.join(RbConfig::CONFIG[
|
32
|
-
RbConfig::CONFIG[
|
155
|
+
File.join(RbConfig::CONFIG['bindir'],
|
156
|
+
RbConfig::CONFIG['ruby_install_name'])
|
33
157
|
end
|
34
158
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
Dir.glob("localhost_1121?.*").each{|f| rm f }
|
39
|
-
end
|
40
|
-
FileUtils.rm_rf("#{Roma::Config::STORAGE_PATH}/localhost_11211")
|
41
|
-
FileUtils.rm_rf("#{Roma::Config::STORAGE_PATH}/localhost_11212")
|
42
|
-
sleep 0.1
|
43
|
-
|
44
|
-
sh.system(ruby_path, mkroute_path,
|
45
|
-
"localhost_11211","localhost_11212",
|
46
|
-
"-d","3",
|
47
|
-
"--replication_in_host")
|
48
|
-
sleep 0.2
|
49
|
-
do_command_romad conf
|
50
|
-
sleep 1
|
51
|
-
end
|
159
|
+
def send_message(messages: [], node: DEFAULT_NODES[0])
|
160
|
+
conn = Roma::Messaging::ConPool.instance.get_connection(node)
|
161
|
+
return false unless conn
|
52
162
|
|
53
|
-
|
54
|
-
sh = Shell.new
|
55
|
-
sh.system(ruby_path,romad_path,"localhost","-p","11211","-d","--verbose",
|
56
|
-
"--disabled_cmd_protect","--config","#{test_dir}/#{conf}")
|
57
|
-
sh.system(ruby_path,romad_path,"localhost","-p","11212","-d","--verbose",
|
58
|
-
"--disabled_cmd_protect","--config","#{test_dir}/#{conf}")
|
59
|
-
end
|
163
|
+
messages = [messages] if messages.class == String
|
60
164
|
|
61
|
-
|
62
|
-
|
63
|
-
if conn
|
64
|
-
conn.write "balse\r\n"
|
65
|
-
conn.gets
|
66
|
-
conn.write "yes\r\n"
|
165
|
+
messages.each do |message|
|
166
|
+
conn.write "#{message}\r\n"
|
67
167
|
conn.gets
|
68
|
-
conn.close
|
69
168
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
169
|
+
rescue => e
|
170
|
+
puts "#{e} #{$ERROR_POSITION}"
|
171
|
+
ensure
|
172
|
+
Roma::Messaging::ConPool.instance.return_connection(node, conn)
|
73
173
|
end
|
74
174
|
end
|