roma 0.8.2 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANG +326 -0
  2. data/CHANGELOG +132 -0
  3. data/{README.rdoc → FETCH_HEAD} +0 -0
  4. data/{LICENSE.rdoc → LICENSE} +0 -1
  5. data/README +17 -0
  6. data/Rakefile +33 -18
  7. data/ruby/server/bin/chg_redundancy +10 -0
  8. data/ruby/server/bin/key_access +7 -0
  9. data/ruby/server/bin/key_list +7 -0
  10. data/ruby/server/bin/mkconfig +19 -0
  11. data/{bin → ruby/server/bin}/mkrecent +0 -1
  12. data/{bin → ruby/server/bin}/mkroute +0 -1
  13. data/ruby/server/bin/multi_commander +19 -0
  14. data/ruby/server/bin/recoverlost +10 -0
  15. data/ruby/server/bin/recoverlost_alist +10 -0
  16. data/ruby/server/bin/recoverlost_alist_all +10 -0
  17. data/ruby/server/bin/recoverlost_alist_keys +10 -0
  18. data/{bin/recoverlost → ruby/server/bin/roma_watcher} +1 -2
  19. data/ruby/server/bin/romad +36 -0
  20. data/{bin → ruby/server/bin}/sample_watcher +0 -1
  21. data/{bin → ruby/server/bin}/sample_watcher2 +0 -1
  22. data/{bin/simple_bench → ruby/server/bin/sample_watcher3} +1 -2
  23. data/ruby/server/bin/simple_bench +26 -0
  24. data/{bin → ruby/server/bin}/ssroute +0 -1
  25. data/ruby/server/bin/test-scenario +11 -0
  26. data/{bin → ruby/server/bin}/tribunus +0 -1
  27. data/{lib → ruby/server/lib}/roma/async_process.rb +67 -15
  28. data/{lib → ruby/server/lib}/roma/command/bg_command_receiver.rb +1 -1
  29. data/ruby/server/lib/roma/command/command_definition.rb +422 -0
  30. data/ruby/server/lib/roma/command/mh_command_receiver.rb +127 -0
  31. data/ruby/server/lib/roma/command/receiver.rb +64 -0
  32. data/{lib → ruby/server/lib}/roma/command/rt_command_receiver.rb +6 -1
  33. data/ruby/server/lib/roma/command/sys_command_receiver.rb +609 -0
  34. data/{lib → ruby/server/lib}/roma/command/util_command_receiver.rb +15 -5
  35. data/{lib → ruby/server/lib}/roma/command/vn_command_receiver.rb +12 -4
  36. data/{lib → ruby/server/lib}/roma/command_plugin.rb +0 -0
  37. data/ruby/server/lib/roma/config.rb +84 -0
  38. data/{lib → ruby/server/lib}/roma/event/con_pool.rb +12 -1
  39. data/ruby/server/lib/roma/event/handler.rb +256 -0
  40. data/ruby/server/lib/roma/live_patch-20120302-001.rb +107 -0
  41. data/ruby/server/lib/roma/logging/rlogger.rb +163 -0
  42. data/ruby/server/lib/roma/messaging/con_pool.rb +92 -0
  43. data/{lib → ruby/server/lib}/roma/plugin/plugin_alist.rb +118 -240
  44. data/ruby/server/lib/roma/plugin/plugin_debug.rb +31 -0
  45. data/ruby/server/lib/roma/plugin/plugin_map.rb +177 -0
  46. data/ruby/server/lib/roma/plugin/plugin_mapcount.rb +185 -0
  47. data/{lib/roma/command/st_command_receiver.rb → ruby/server/lib/roma/plugin/plugin_storage.rb} +170 -146
  48. data/ruby/server/lib/roma/plugin/plugin_stub.rb +283 -0
  49. data/{lib → ruby/server/lib}/roma/plugin/plugin_test.rb +0 -0
  50. data/{lib → ruby/server/lib}/roma/romad.rb +221 -94
  51. data/{lib → ruby/server/lib}/roma/routing/cb_rttable.rb +4 -6
  52. data/{lib → ruby/server/lib}/roma/routing/merkle_tree.rb +0 -0
  53. data/ruby/server/lib/roma/routing/routing_data.rb +307 -0
  54. data/{lib → ruby/server/lib}/roma/routing/rttable.rb +4 -0
  55. data/{lib → ruby/server/lib}/roma/stats.rb +19 -3
  56. data/{lib → ruby/server/lib}/roma/storage/basic_storage.rb +25 -26
  57. data/{lib → ruby/server/lib}/roma/storage/dbm_storage.rb +1 -23
  58. data/{lib → ruby/server/lib}/roma/storage/dummy_storage.rb +0 -0
  59. data/{lib → ruby/server/lib}/roma/storage/rh_storage.rb +0 -0
  60. data/{lib → ruby/server/lib}/roma/storage/sqlite3_storage.rb +0 -0
  61. data/{lib → ruby/server/lib}/roma/storage/tc_storage.rb +62 -2
  62. data/ruby/server/lib/roma/tools/chg_redundancy.rb +36 -0
  63. data/ruby/server/lib/roma/tools/key_access.rb +105 -0
  64. data/ruby/server/lib/roma/tools/key_list.rb +94 -0
  65. data/ruby/server/lib/roma/tools/mkconfig.rb +535 -0
  66. data/{lib → ruby/server/lib}/roma/tools/mkrecent.rb +0 -0
  67. data/{lib → ruby/server/lib}/roma/tools/mkroute.rb +0 -0
  68. data/ruby/server/lib/roma/tools/multi_commander.rb +45 -0
  69. data/{lib → ruby/server/lib}/roma/tools/recoverlost.rb +0 -0
  70. data/{lib → ruby/server/lib}/roma/tools/recoverlost_alist.rb +0 -0
  71. data/ruby/server/lib/roma/tools/recoverlost_alist_all.rb +8 -0
  72. data/ruby/server/lib/roma/tools/recoverlost_alist_keys.rb +16 -0
  73. data/ruby/server/lib/roma/tools/recoverlost_lib.rb +349 -0
  74. data/ruby/server/lib/roma/tools/roma_watcher.rb +150 -0
  75. data/ruby/server/lib/roma/tools/roma_watcher_config.yml.example +20 -0
  76. data/{lib → ruby/server/lib}/roma/tools/sample_watcher.rb +3 -1
  77. data/{lib → ruby/server/lib}/roma/tools/sample_watcher2.rb +3 -1
  78. data/ruby/server/lib/roma/tools/sample_watcher3.rb +49 -0
  79. data/{lib → ruby/server/lib}/roma/tools/simple_bench.rb +2 -0
  80. data/ruby/server/lib/roma/tools/simple_bench2.rb +78 -0
  81. data/{lib → ruby/server/lib}/roma/tools/ssroute.rb +0 -0
  82. data/ruby/server/lib/roma/tools/test-scenario.rb +327 -0
  83. data/{lib → ruby/server/lib}/roma/tools/tribunus.rb +0 -0
  84. data/ruby/server/lib/roma/version.rb +4 -0
  85. data/{lib → ruby/server/lib}/roma/write_behind.rb +1 -0
  86. data/ruby/server/test/config4mhash.rb +68 -0
  87. data/ruby/server/test/config4storage_error.rb +69 -0
  88. data/{lib/roma/config.rb → ruby/server/test/config4test.rb} +6 -3
  89. data/{test → ruby/server/test}/rcirb.rb +0 -1
  90. data/{test → ruby/server/test}/roma-test-utils.rb +21 -8
  91. data/{test → ruby/server/test}/run-test.rb +3 -2
  92. data/ruby/server/test/storage_error_storage.rb +37 -0
  93. data/ruby/server/test/t_command_definition.rb +326 -0
  94. data/{test → ruby/server/test}/t_cpdata.rb +9 -3
  95. data/{test → ruby/server/test}/t_listplugin.rb +48 -12
  96. data/ruby/server/test/t_mapcountplugin.rb +231 -0
  97. data/ruby/server/test/t_mapplugin.rb +131 -0
  98. data/ruby/server/test/t_mhash.rb +222 -0
  99. data/ruby/server/test/t_rclient.rb +199 -0
  100. data/{test → ruby/server/test}/t_routing_data.rb +56 -0
  101. data/{test → ruby/server/test}/t_storage.rb +107 -111
  102. data/ruby/server/test/t_storage_error.rb +61 -0
  103. data/ruby/server/test/t_writebehind.rb +374 -0
  104. metadata +150 -82
  105. data/bin/recoverlost_alist +0 -8
  106. data/bin/romad +0 -7
  107. data/lib/roma/command/mh_command_receiver.rb +0 -117
  108. data/lib/roma/command/receiver.rb +0 -287
  109. data/lib/roma/event/handler.rb +0 -159
  110. data/lib/roma/plugin/plugin_debug.rb +0 -19
  111. data/lib/roma/tools/recoverlost_lib.rb +0 -217
  112. data/lib/roma/version.rb +0 -4
  113. data/test/t_rclient.rb +0 -318
  114. data/test/t_writebehind.rb +0 -200
@@ -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