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
data/test/t_writebehind.rb
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
require 'logger'
|
5
|
-
require 'roma/write_behind'
|
6
|
-
|
7
|
-
class FileWriterTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def initialize(arg)
|
10
|
-
super(arg)
|
11
|
-
end
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@stats = Roma::Stats.instance
|
15
|
-
@stats.address = 'roma0'
|
16
|
-
@stats.port = 11211
|
17
|
-
|
18
|
-
@log = Logger.new(StringIO.new)
|
19
|
-
@log.level = Logger::INFO
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
system('rm -rf wb_test')
|
24
|
-
end
|
25
|
-
|
26
|
-
# 作成と write のテスト
|
27
|
-
def test_write
|
28
|
-
system('rm -rf wb_test')
|
29
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 1024 * 1024, @log)
|
30
|
-
path = "wb_test/roma0_11211/roma/#{Time.now.strftime('%Y%m%d')}/"
|
31
|
-
|
32
|
-
assert(!File.exist?("#{path}/0.wb"))
|
33
|
-
100.times{|i|
|
34
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
35
|
-
}
|
36
|
-
assert(File.exist?("#{path}/0.wb"))
|
37
|
-
assert(!File.exist?("#{path}/1.wb"))
|
38
|
-
|
39
|
-
fw.rotate('roma')
|
40
|
-
|
41
|
-
i = 100
|
42
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
43
|
-
assert(File.exist?("#{path}/1.wb"))
|
44
|
-
|
45
|
-
fw.close_all
|
46
|
-
|
47
|
-
wb0 = read_wb("#{path}/0.wb")
|
48
|
-
assert(100,wb0.length )
|
49
|
-
wb0.each{|last, cmd, key, val|
|
50
|
-
assert_equal( "key-#{cmd}",key)
|
51
|
-
assert_equal( "val-#{cmd}",val)
|
52
|
-
}
|
53
|
-
wb1 = read_wb("#{path}/1.wb")
|
54
|
-
assert_equal(1,wb1.length )
|
55
|
-
end
|
56
|
-
|
57
|
-
# サイズによるローテーションのテスト
|
58
|
-
def test_rotation
|
59
|
-
system('rm -rf wb_test')
|
60
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 900, @log)
|
61
|
-
path = "wb_test/roma0_11211/roma/#{Time.now.strftime('%Y%m%d')}/"
|
62
|
-
|
63
|
-
100.times{|i|
|
64
|
-
fw.write('roma',0,
|
65
|
-
sprintf("key-%04d",i),
|
66
|
-
sprintf("val-%04d",i))
|
67
|
-
}
|
68
|
-
|
69
|
-
assert(File.exist?("#{path}/0.wb"))
|
70
|
-
assert(File.exist?("#{path}/1.wb"))
|
71
|
-
assert(File.exist?("#{path}/2.wb"))
|
72
|
-
assert(File.exist?("#{path}/3.wb"))
|
73
|
-
assert(!File.exist?("#{path}/4.wb"))
|
74
|
-
end
|
75
|
-
|
76
|
-
# 時間によるローテーションのテスト
|
77
|
-
def test_rotation2
|
78
|
-
system('rm -rf wb_test')
|
79
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 1024 * 1024, @log)
|
80
|
-
path = "wb_test/roma0_11211/roma/#{Time.now.strftime('%Y%m%d')}/"
|
81
|
-
|
82
|
-
# インスタンス生成直後の rottime の時分秒usecは何かの値を持っている
|
83
|
-
rt = fw.instance_eval{ @rottime }
|
84
|
-
assert_not_equal(0, rt.hour + rt.min + rt.sec+ rt.usec)
|
85
|
-
# 初期化は今日の日付で行われる
|
86
|
-
assert_equal(Time.now.day, rt.day)
|
87
|
-
# ファイルは存在しない
|
88
|
-
assert(!File.exist?("#{path}/0.wb"))
|
89
|
-
fw.write('roma',1,"key","val")
|
90
|
-
# 何かを書き込むとオープンされ、そのタイミングで rottime が更新される
|
91
|
-
rt = fw.instance_eval{ @rottime }
|
92
|
-
# この時、日付以下は 0 となる
|
93
|
-
assert_equal(0, rt.hour + rt.min + rt.sec+ rt.usec)
|
94
|
-
# 日付は明日になる
|
95
|
-
assert_not_equal(Time.now.day, rt.day)
|
96
|
-
10.times{|i|
|
97
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
98
|
-
}
|
99
|
-
# ファイルは1つ
|
100
|
-
assert(File.exist?("#{path}/0.wb"))
|
101
|
-
assert(!File.exist?("#{path}/1.wb"))
|
102
|
-
|
103
|
-
# ローテーションの時刻を強制的に今にする
|
104
|
-
fw.instance_eval{ @rottime=Time.now }
|
105
|
-
# rottime の変更を確認
|
106
|
-
assert_not_equal(rt, fw.instance_eval{ @rottime })
|
107
|
-
# 何かを書き込むとローテーションが発生する
|
108
|
-
fw.write('roma',1,"key","val")
|
109
|
-
assert(File.exist?("#{path}/1.wb"))
|
110
|
-
# テストは日をまたがないので rottime は元に戻る
|
111
|
-
assert_equal(rt, fw.instance_eval{ @rottime })
|
112
|
-
end
|
113
|
-
|
114
|
-
# 外部からローテーションするテスト
|
115
|
-
def test_rotation3
|
116
|
-
system('rm -rf wb_test')
|
117
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 1024 * 1024, @log)
|
118
|
-
path = "wb_test/roma0_11211/roma/#{Time.now.strftime('%Y%m%d')}/"
|
119
|
-
|
120
|
-
# ファイルはない
|
121
|
-
assert(!File.exist?("#{path}/0.wb"))
|
122
|
-
10.times{|i|
|
123
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
124
|
-
}
|
125
|
-
# ファイルは1つ
|
126
|
-
assert(File.exist?("#{path}/0.wb"))
|
127
|
-
assert(!File.exist?("#{path}/1.wb"))
|
128
|
-
|
129
|
-
fw.rotate('roma')
|
130
|
-
10.times{|i|
|
131
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
132
|
-
}
|
133
|
-
# ファイルは2つ
|
134
|
-
assert(File.exist?("#{path}/0.wb"))
|
135
|
-
assert(File.exist?("#{path}/1.wb"))
|
136
|
-
assert(!File.exist?("#{path}/2.wb"))
|
137
|
-
|
138
|
-
# ローテーションの重複呼び出し
|
139
|
-
fw.rotate('roma')
|
140
|
-
fw.rotate('roma')
|
141
|
-
fw.rotate('roma')
|
142
|
-
# ファイルは2つで変化なし
|
143
|
-
assert(File.exist?("#{path}/0.wb"))
|
144
|
-
assert(File.exist?("#{path}/1.wb"))
|
145
|
-
assert(!File.exist?("#{path}/2.wb"))
|
146
|
-
10.times{|i|
|
147
|
-
fw.write('roma',i,"key-#{i}","val-#{i}")
|
148
|
-
}
|
149
|
-
# ファイルは3つ
|
150
|
-
assert(File.exist?("#{path}/0.wb"))
|
151
|
-
assert(File.exist?("#{path}/1.wb"))
|
152
|
-
assert(File.exist?("#{path}/2.wb"))
|
153
|
-
assert(!File.exist?("#{path}/3.wb"))
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
def test_get_current_file_path
|
158
|
-
system('rm -rf wb_test')
|
159
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 900, @log)
|
160
|
-
|
161
|
-
assert_nil( fw.get_current_file_path('roma') )
|
162
|
-
|
163
|
-
fw.write('roma',0,"key","val")
|
164
|
-
|
165
|
-
path = File.expand_path("./wb_test/roma0_11211/roma/#{Time.now.strftime('%Y%m%d')}/")
|
166
|
-
assert_equal( File.join(path,"0.wb"), fw.get_current_file_path('roma'))
|
167
|
-
|
168
|
-
fw.rotate('roma')
|
169
|
-
assert_nil( fw.get_current_file_path('roma'))
|
170
|
-
|
171
|
-
fw.write('roma',0,"key","val")
|
172
|
-
assert_equal( File.join(path,"1.wb"), fw.get_current_file_path('roma') )
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_get_path
|
176
|
-
system('rm -rf wb_test')
|
177
|
-
fw = Roma::WriteBehind::FileWriter.new("wb_test", 900, @log)
|
178
|
-
path = File.expand_path("./wb_test/roma0_11211/roma")
|
179
|
-
assert_equal( path, fw.wb_get_path('roma'))
|
180
|
-
end
|
181
|
-
|
182
|
-
private
|
183
|
-
|
184
|
-
def read_wb(fname)
|
185
|
-
ret = []
|
186
|
-
open(fname,'rb'){|f|
|
187
|
-
until(f.eof?)
|
188
|
-
b1 = f.read(10)
|
189
|
-
last, cmd, klen = b1.unpack('NnN')
|
190
|
-
key = f.read(klen)
|
191
|
-
b2 = f.read(4)
|
192
|
-
vlen = b2.unpack('N')[0]
|
193
|
-
val = f.read(vlen)
|
194
|
-
ret << [last,cmd,key,val]
|
195
|
-
end
|
196
|
-
}
|
197
|
-
ret
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|