Top Level Namespace
Defined Under Namespace
Modules: Roma Classes: ReadLog, Tribunus, WriteLog
Constant Summary collapse
- UDP_PORT =
14329
- MULTICAST_ADDR =
"225.0.0.123"
- ROMA_LOAD_PATH =
File.(File.join(File.dirname(__FILE__),"../.."))
- RUBY_COMMAND_OPTIONS =
["-I",ROMA_LOAD_PATH]
- ROMAD_OPTIONS =
["--replication_in_host"]
- ROMAD_PATH =
File.(File.join(bin_dir,"romad"))
- MKROUTE_PATH =
File.(File.join(bin_dir,"mkroute"))
- ROMAD_WORK_DIR =
'.'
Instance Method Summary collapse
- #check_count(ini_nodes, range, key_prefix, value) ⇒ Object
- #get_routing_data(nid) ⇒ Object
- #get_sequence(ini_nodes, n) ⇒ Object
- #random_request_sender(ini_nodes) ⇒ Object
- #random_rquest_sender(ini_nodes, n) ⇒ Object
- #safecopy_stats(nid) ⇒ Object
- #send_cmd(nid, cmd) ⇒ Object
- #set_counts(ini_nodes, range, key_prefix, value) ⇒ Object
- #set_sequence(ini_nodes, n) ⇒ Object
- #set_storage_status(nid, fno, stat) ⇒ Object
- #stats(nid, regexp = nil) ⇒ Object
- #test_change_status ⇒ Object
- #test_round ⇒ Object
-
#usage ⇒ Object
Roma.
- #wait_status(nid, fno, stat) ⇒ Object
Instance Method Details
#check_count(ini_nodes, range, key_prefix, value) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/roma/tools/safecopy_test.rb', line 61 def check_count(ini_nodes, range, c) puts "#{__method__} #{range} #{c}" rc=Roma::Client::RomaClient.new(ini_nodes) range.each do |i| ts = DateTime.now res = rc.get("key_#{i}") if res != c.to_s puts "error k=key_#{i} #{res}" end t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#get_routing_data(nid) ⇒ Object
10 11 12 13 |
# File 'lib/roma/tools/chg_redundancy.rb', line 10 def get_routing_data(nid) sender = Roma::Client::Sender.new sender.send_routedump_command(nid) end |
#get_sequence(ini_nodes, n) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/roma/tools/simple_bench.rb', line 61 def get_sequence(ini_nodes, n) puts __method__ rc=Roma::Client::RomaClient.new(ini_nodes) n.times do |i| ts = DateTime.now res=rc.get("key_#{i}") puts "get #{i} #{res}" if res != "value_#{i}" t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#random_request_sender(ini_nodes) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/roma/tools/simple_bench.rb', line 21 def random_request_sender(ini_nodes, n) puts __method__ rc=Roma::Client::RomaClient.new(ini_nodes) loop do i=rand(n) ts = DateTime.now case rand(3) when 0 res=rc.set(i.to_s,'hoge'+i.to_s) puts "set k=#{i} #{res}" if res==nil || res.chomp != 'STORED' when 1 res=rc.get(i.to_s) puts "get k=#{i} #{res}" if res == :error when 2 res=rc.delete(i.to_s) puts "del k=#{i} #{res}" if res != 'DELETED' && res != 'NOT_FOUND' end t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#random_rquest_sender(ini_nodes, n) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/roma/tools/safecopy_test.rb', line 21 def random_rquest_sender(ini_nodes, n) puts __method__ rc=Roma::Client::RomaClient.new(ini_nodes) loop do i=rand(n) ts = DateTime.now case rand(3) when 0 res=rc.set(i.to_s,'hoge'+i.to_s) puts "set k=#{i} #{res}" if res==nil || res.chomp != 'STORED' when 1 res=rc.get(i.to_s) puts "get k=#{i} #{res}" if res == :error when 2 res=rc.delete(i.to_s) puts "del k=#{i} #{res}" if res != 'DELETED' && res != 'NOT_FOUND' end t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#safecopy_stats(nid) ⇒ Object
107 108 109 110 111 |
# File 'lib/roma/tools/safecopy_test.rb', line 107 def safecopy_stats(nid) ret = stats(nid, 'storage.safecopy_stats') return eval $1 if ret =~ /^.+\s(\[.+\])/ nil end |
#send_cmd(nid, cmd) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/roma/tools/safecopy_test.rb', line 78 def send_cmd(nid, cmd) conn = Roma::Client::ConPool.instance.get_connection(nid) conn.write "#{cmd}\r\n" ret = conn.gets Roma::Client::ConPool.instance.return_connection(nid, conn) ret rescue =>e STDERR.puts "#{nid} #{cmd} #{e.inspect}" nil end |
#set_counts(ini_nodes, range, key_prefix, value) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/roma/tools/safecopy_test.rb', line 46 def set_counts(ini_nodes, range, c) puts "#{__method__} #{range} #{c}" rc=Roma::Client::RomaClient.new(ini_nodes) range.each do |i| ts = DateTime.now res=rc.set("key_#{i}","#{c}") puts "set k=#{i} #{res}" if res==nil || res.chomp != 'STORED' t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#set_sequence(ini_nodes, n) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/roma/tools/simple_bench.rb', line 46 def set_sequence(ini_nodes, n) puts __method__ rc=Roma::Client::RomaClient.new(ini_nodes) n.times do |i| ts = DateTime.now res=rc.set("key_#{i}","value_#{i}") puts "set k=#{i} #{res}" if res==nil || res.chomp != 'STORED' t=(DateTime.now - ts).to_f * 86400.0 @tmax=t if t > @tmax @tmin=t if t < @tmin @cnt+=1 end end |
#set_storage_status(nid, fno, stat) ⇒ Object
113 114 115 |
# File 'lib/roma/tools/safecopy_test.rb', line 113 def set_storage_status(nid, fno, stat) send_cmd(ARGV[0], "set_storage_status #{fno} #{stat}") end |
#stats(nid, regexp = nil) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/roma/tools/safecopy_test.rb', line 89 def stats(nid, regexp=nil) conn = Roma::Client::ConPool.instance.get_connection(nid) if regexp conn.write "stats #{regexp}\r\n" else conn.write "stats\r\n" end ret = "" while(conn.gets != "END\r\n") ret << $_ end Roma::Client::ConPool.instance.return_connection(nid, conn) ret rescue =>e STDERR.puts "#{nid} #{e.inspect}" nil end |
#test_change_status ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/roma/tools/safecopy_test.rb', line 125 def test_change_status puts "write (0...10000) = 0" set_counts(ARGV, 0...10000, 0) Thread.new { random_rquest_sender(ARGV, 10000) } nid = ARGV[0] sleep(5) 10.times do |n| t = Thread.new { set_counts(ARGV, (n * 1000)...(n * 1000 + 2000), n * 10 + 1) } p set_storage_status(nid, n, 'safecopy') p wait_status(nid, n, :safecopy_flushed) t.join p safecopy_stats(nid) #sleep(30) t = Thread.new { set_counts(ARGV, (n * 1000 + 500)...(n * 1000 + 2000), n * 10 + 2) } p set_storage_status(nid, n, 'normal') p wait_status(nid, n, :normal) t.join p safecopy_stats(nid) check_count(ARGV, (n * 1000)...(n * 1000 + 500), n * 10 + 1) check_count(ARGV, (n * 1000 + 500)...(n * 1000 + 2000), n * 10 + 2) if (n * 1000 + 2000) < 10000 check_count(ARGV, (n * 1000 + 2000)...10000, 0) end end end |
#test_round ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/roma/tools/safecopy_test.rb', line 156 def test_round n = 0 1000.times do |i| set_counts(ARGV, 0...10000, i) check_count(ARGV, 0...10000, i) end end |
#usage ⇒ Object
Roma
140 141 142 |
# File 'lib/roma/tools/roma_watcher.rb', line 140 def usage puts File.basename(__FILE__) + " config.yml" end |
#wait_status(nid, fno, stat) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/roma/tools/safecopy_test.rb', line 117 def wait_status(nid, fno, stat) while safecopy_stats(nid)[fno] != stat sleep 5 end stat end |