roma 0.8.10 → 0.8.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/ruby/server/bin/log_merger +6 -0
- data/ruby/server/lib/roma/async_process.rb +18 -11
- data/ruby/server/lib/roma/plugin/plugin_cmd_aliases.rb +43 -0
- data/ruby/server/lib/roma/plugin/plugin_mapcount.rb +2 -2
- data/ruby/server/lib/roma/storage/rh_storage.rb +80 -0
- data/ruby/server/lib/roma/storage/tc_storage.rb +36 -2
- data/ruby/server/lib/roma/tools/log_merger.rb +150 -0
- data/ruby/server/lib/roma/tools/mkconfig.rb +3 -3
- data/ruby/server/lib/roma/version.rb +1 -1
- data/ruby/server/test/t_mapcountplugin.rb +194 -141
- metadata +97 -99
- data/CHANG +0 -326
- data/FETCH_HEAD +0 -0
- data/ruby/server/lib/roma/live_patch-20120302-001.rb +0 -107
- data/ruby/server/lib/roma/plugin/plugin_stub.rb +0 -283
@@ -15,6 +15,10 @@ class MapCountPluginTest < Test::Unit::TestCase
|
|
15
15
|
def setup
|
16
16
|
start_roma
|
17
17
|
@rc=Roma::Client::RomaClient.new(["localhost_11211","localhost_11212"], [Roma::Client::Plugin::MapCount])
|
18
|
+
@k = "key1"
|
19
|
+
@sk = "subkey1"
|
20
|
+
@lt = Time.parse(Time.now.strftime(DATE_FORMAT))
|
21
|
+
@ret = {"last_updated_date"=>@lt, @sk=>1}
|
18
22
|
end
|
19
23
|
|
20
24
|
def teardown
|
@@ -23,209 +27,258 @@ class MapCountPluginTest < Test::Unit::TestCase
|
|
23
27
|
|
24
28
|
def test_mapcount_get(n = 5)
|
25
29
|
n.times do |i|
|
26
|
-
|
30
|
+
@sk = "subkey#{i}"
|
27
31
|
expt = i
|
28
|
-
|
29
|
-
|
30
|
-
retc = {"last_updated_date"=>lt}
|
32
|
+
|
33
|
+
retc = {"last_updated_date"=>@lt}
|
31
34
|
(i+1).times do |j|
|
32
35
|
retc["subkey#{j}"] = 1
|
33
36
|
end
|
34
|
-
assert_equal retc, @rc.mapcount_countup(
|
35
|
-
|
36
|
-
retg = {"last_updated_date"
|
37
|
+
assert_equal retc, @rc.mapcount_countup(@k, @sk, 0)
|
38
|
+
|
39
|
+
retg = {"last_updated_date"=>@lt}
|
37
40
|
retg["subkey#{i}"] = 1
|
38
|
-
assert_equal retg, @rc.mapcount_get(
|
39
|
-
assert_equal retc, @rc.mapcount_get(
|
40
|
-
end
|
41
|
+
assert_equal retg, @rc.mapcount_get(@k, @sk)
|
42
|
+
assert_equal retc, @rc.mapcount_get(@k)
|
43
|
+
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal ret, @rc.mapcount_get('key1', 'subkey0,subkey1')
|
45
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
46
|
+
assert_equal ret2, @rc.mapcount_get(@k, 'subkey0,subkey1')
|
45
47
|
end
|
46
48
|
|
47
|
-
def
|
48
|
-
k
|
49
|
-
|
50
|
-
|
49
|
+
def test_mapcount_countup_array
|
50
|
+
assert_equal @ret, @rc.mapcount_countup(@k, [@sk])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_mapcount_countup_array_multi
|
54
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
55
|
+
assert_equal ret2, @rc.mapcount_countup(@k, ["subkey0", "subkey1"])
|
56
|
+
|
57
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>2}
|
58
|
+
@rc.mapcount_countup(@k, ["subkey1"])
|
59
|
+
assert_equal ret2, @rc.mapcount_get(@k)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_mapcount_countup_hash
|
63
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
64
|
+
assert_equal ret2, @rc.mapcount_countup(@k, ["subkey0", "subkey1"])
|
51
65
|
|
52
|
-
|
53
|
-
|
54
|
-
assert_equal
|
66
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>4, "subkey1"=>1}
|
67
|
+
@rc.mapcount_countup(@k, {"subkey0" => 3})
|
68
|
+
assert_equal ret2, @rc.mapcount_get(@k)
|
69
|
+
|
70
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>4, "subkey1"=>11}
|
71
|
+
@rc.mapcount_countup(@k, {"subkey1" => 10})
|
72
|
+
assert_equal ret2, @rc.mapcount_get(@k)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_mapcount_countup_degits
|
76
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>125, "subkey1"=>30}
|
77
|
+
@rc.mapcount_countup(@k, {"subkey0" => 125, "subkey1" => 30})
|
78
|
+
assert_equal ret2, @rc.mapcount_get(@k)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_mapcount_countup_expt
|
82
|
+
assert_nil @rc.mapcount_get(@k, @sk)
|
83
|
+
assert_equal @ret, @rc.mapcount_countup(@k, @sk, 1)
|
84
|
+
assert_equal @ret, @rc.mapcount_get(@k, @sk)
|
55
85
|
sleep 2
|
56
|
-
assert_nil @rc.mapcount_get(
|
86
|
+
assert_nil @rc.mapcount_get(@k, @sk)
|
57
87
|
end
|
58
88
|
|
59
89
|
def test_mapcount_update
|
60
|
-
|
61
|
-
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
62
|
-
ret_time = {"last_updated_date"=>lt}
|
63
|
-
ret_all = {"last_updated_date"=>lt, k=>1}
|
64
|
-
|
65
|
-
assert_nil @rc.mapcount_update('key1')
|
66
|
-
assert_equal ret_all, @rc.mapcount_countup('key1', k, 0)
|
67
|
-
assert_equal ret_all, @rc.mapcount_update('key1')
|
68
|
-
assert_equal ret_time, @rc.mapcount_update('key1', 'subkey2')
|
90
|
+
ret_time = {"last_updated_date"=>@lt}
|
69
91
|
|
70
|
-
|
92
|
+
assert_nil @rc.mapcount_update(@k)
|
93
|
+
assert_equal @ret, @rc.mapcount_countup(@k, @sk, 0)
|
94
|
+
assert_equal @ret, @rc.mapcount_update(@k)
|
95
|
+
assert_equal ret_time, @rc.mapcount_update(@k, 'subkey2')
|
96
|
+
assert_equal @ret, @rc.mapcount_update(@k, nil, 1)
|
71
97
|
sleep 2
|
72
|
-
assert_nil @rc.mapcount_get(
|
98
|
+
assert_nil @rc.mapcount_get(@k)
|
99
|
+
end
|
73
100
|
|
74
|
-
|
75
|
-
|
76
|
-
assert_equal
|
77
|
-
assert_equal
|
101
|
+
def test_mapcount_update_subkeys
|
102
|
+
ret = {"last_updated_date"=>@lt, @sk=>1}
|
103
|
+
assert_equal @ret, @rc.mapcount_countup(@k, @sk, 0)
|
104
|
+
assert_equal @ret, @rc.mapcount_update(@k, @sk, 1)
|
78
105
|
sleep 2
|
79
|
-
assert_nil @rc.mapcount_get(
|
106
|
+
assert_nil @rc.mapcount_get(@k)
|
107
|
+
end
|
80
108
|
|
81
|
-
|
82
|
-
|
83
|
-
assert_equal
|
109
|
+
def test_mapcount_update_time
|
110
|
+
ret = {"last_updated_date"=>@lt, @sk=>1}
|
111
|
+
assert_equal @ret, @rc.mapcount_countup(@k, @sk, 0)
|
84
112
|
sleep 2
|
85
|
-
|
86
|
-
|
87
|
-
assert_equal
|
113
|
+
lt2 = Time.parse(Time.now.strftime(DATE_FORMAT))
|
114
|
+
ret2 = {"last_updated_date"=>lt2, @sk=>1}
|
115
|
+
assert_equal ret2, @rc.mapcount_update(@k)
|
88
116
|
end
|
89
117
|
|
90
118
|
def test_counts
|
91
|
-
|
92
|
-
|
93
|
-
conn.write "stat read_count\n"
|
94
|
-
r = conn.gets.split(" ")
|
95
|
-
assert_equal 0, r[1].to_i
|
96
|
-
conn.gets
|
119
|
+
conn1 = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
|
120
|
+
conn2 = Roma::Messaging::ConPool.instance.get_connection("localhost_11212")
|
97
121
|
|
98
|
-
|
99
|
-
|
100
|
-
conn.write "stat read_count\n"
|
101
|
-
r = conn.gets.split(" ")
|
102
|
-
assert_equal 1, r[1].to_i
|
103
|
-
conn.gets
|
122
|
+
if conn1 && conn2
|
123
|
+
conns = [conn1, conn2]
|
104
124
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
ret = get_stat_sum(conns, "stat read_count\n")
|
126
|
+
assert_equal 0, ret
|
127
|
+
|
128
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
129
|
+
assert_equal 0, ret
|
130
|
+
|
131
|
+
@rc.mapcount_get('key')
|
132
|
+
ret = get_stat_sum(conns, "stat read_count\n")
|
133
|
+
assert_equal 1, ret
|
109
134
|
|
110
135
|
@rc.mapcount_countup('key', 'subkey', 0)
|
111
|
-
|
112
|
-
|
113
|
-
r = conn.gets.split(" ")
|
114
|
-
assert_equal 1, r[1].to_i
|
115
|
-
conn.gets
|
136
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
137
|
+
assert_equal 1, ret
|
116
138
|
|
117
139
|
@rc.mapcount_update('key')
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
conn.gets
|
123
|
-
|
124
|
-
conn.close
|
140
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
141
|
+
assert_equal 2, ret
|
142
|
+
else
|
143
|
+
flunk(message="Fail to get connection")
|
125
144
|
end
|
145
|
+
|
146
|
+
conn1.close
|
147
|
+
conn2.close
|
126
148
|
end
|
127
149
|
|
128
150
|
def test_mapcount_get_ms(n = 5)
|
129
151
|
n.times do |i|
|
130
|
-
|
152
|
+
@sk = "subkey#{i}"
|
131
153
|
expt = i
|
132
|
-
|
133
|
-
|
134
|
-
retc = {"last_updated_date"=>lt}
|
154
|
+
|
155
|
+
retc = {"last_updated_date"=>@lt}
|
135
156
|
(i+1).times do |j|
|
136
157
|
retc["subkey#{j}"] = 1
|
137
158
|
end
|
138
|
-
assert_equal retc, @rc.mapcount_countup_ms(
|
139
|
-
|
140
|
-
retg = {"last_updated_date"
|
159
|
+
assert_equal retc, @rc.mapcount_countup_ms(@k, @sk, 0)
|
160
|
+
|
161
|
+
retg = {"last_updated_date"=>@lt}
|
141
162
|
retg["subkey#{i}"] = 1
|
142
|
-
assert_equal retg, @rc.mapcount_get_ms(
|
143
|
-
assert_equal retc, @rc.mapcount_get_ms(
|
144
|
-
end
|
163
|
+
assert_equal retg, @rc.mapcount_get_ms(@k, @sk)
|
164
|
+
assert_equal retc, @rc.mapcount_get_ms(@k)
|
165
|
+
end
|
145
166
|
|
146
|
-
|
147
|
-
|
148
|
-
assert_equal ret, @rc.mapcount_get_ms('key1', 'subkey0,subkey1')
|
167
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
168
|
+
assert_equal ret2, @rc.mapcount_get_ms(@k, 'subkey0,subkey1')
|
149
169
|
end
|
150
170
|
|
151
|
-
def
|
152
|
-
k
|
153
|
-
|
154
|
-
|
171
|
+
def test_mapcount_countup_ms_array
|
172
|
+
assert_equal @ret, @rc.mapcount_countup_ms(@k, [@sk])
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_mapcount_countup_ms_array_multi
|
176
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
177
|
+
assert_equal ret2, @rc.mapcount_countup_ms(@k, ["subkey0", "subkey1"])
|
178
|
+
|
179
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>2}
|
180
|
+
@rc.mapcount_countup_ms(@k, ["subkey1"])
|
181
|
+
assert_equal ret2, @rc.mapcount_get_ms(@k)
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_mapcount_countup_ms_hash
|
185
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>1, "subkey1"=>1}
|
186
|
+
assert_equal ret2, @rc.mapcount_countup_ms(@k, ["subkey0", "subkey1"])
|
187
|
+
|
188
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>4, "subkey1"=>1}
|
189
|
+
@rc.mapcount_countup_ms(@k, {"subkey0" => 3})
|
190
|
+
assert_equal ret2, @rc.mapcount_get_ms(@k)
|
155
191
|
|
156
|
-
|
157
|
-
|
158
|
-
assert_equal
|
192
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>4, "subkey1"=>11}
|
193
|
+
@rc.mapcount_countup_ms(@k, {"subkey1" => 10})
|
194
|
+
assert_equal ret2, @rc.mapcount_get_ms(@k)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_mapcount_countup_ms_degits
|
198
|
+
ret2 = {"last_updated_date"=>@lt, "subkey0"=>125, "subkey1"=>30}
|
199
|
+
@rc.mapcount_countup_ms(@k, {"subkey0" => 125, "subkey1" => 30})
|
200
|
+
assert_equal ret2, @rc.mapcount_get_ms(@k)
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_mapcount_countup_ms_expt
|
204
|
+
assert_nil @rc.mapcount_get_ms(@k, @sk)
|
205
|
+
assert_equal @ret, @rc.mapcount_countup_ms(@k, @sk, 1)
|
206
|
+
assert_equal @ret, @rc.mapcount_get_ms(@k, @sk)
|
159
207
|
sleep 2
|
160
|
-
assert_nil @rc.mapcount_get_ms(
|
208
|
+
assert_nil @rc.mapcount_get_ms(@k, @sk)
|
161
209
|
end
|
162
210
|
|
163
211
|
def test_mapcount_update_ms
|
164
|
-
|
165
|
-
lt = Time.parse(Time.now.gmtime.strftime(DATE_FORMAT))
|
166
|
-
ret_time = {"last_updated_date"=>lt}
|
167
|
-
ret_all = {"last_updated_date"=>lt, k=>1}
|
212
|
+
ret_time = {"last_updated_date"=>@lt}
|
168
213
|
|
169
|
-
assert_nil @rc.mapcount_update_ms(
|
170
|
-
assert_equal
|
171
|
-
assert_equal
|
172
|
-
assert_equal ret_time, @rc.mapcount_update_ms(
|
173
|
-
|
174
|
-
assert_equal ret_all, @rc.mapcount_update_ms('key1', nil, 1)
|
214
|
+
assert_nil @rc.mapcount_update_ms(@k)
|
215
|
+
assert_equal @ret, @rc.mapcount_countup_ms(@k, @sk, 0)
|
216
|
+
assert_equal @ret, @rc.mapcount_update_ms(@k)
|
217
|
+
assert_equal ret_time, @rc.mapcount_update_ms(@k, 'subkey2')
|
218
|
+
assert_equal @ret, @rc.mapcount_update_ms(@k, nil, 1)
|
175
219
|
sleep 2
|
176
|
-
assert_nil @rc.mapcount_get_ms(
|
220
|
+
assert_nil @rc.mapcount_get_ms(@k)
|
221
|
+
end
|
177
222
|
|
178
|
-
|
179
|
-
|
180
|
-
assert_equal
|
181
|
-
assert_equal
|
223
|
+
def test_mapcount_update_ms_subkeys
|
224
|
+
ret = {"last_updated_date"=>@lt, @sk=>1}
|
225
|
+
assert_equal @ret, @rc.mapcount_countup_ms(@k, @sk, 0)
|
226
|
+
assert_equal @ret, @rc.mapcount_update_ms(@k, @sk, 1)
|
182
227
|
sleep 2
|
183
|
-
assert_nil @rc.mapcount_get_ms(
|
228
|
+
assert_nil @rc.mapcount_get_ms(@k)
|
229
|
+
end
|
184
230
|
|
185
|
-
|
186
|
-
|
187
|
-
assert_equal
|
231
|
+
def test_mapcount_update_ms_time
|
232
|
+
ret = {"last_updated_date"=>@lt, @sk=>1}
|
233
|
+
assert_equal @ret, @rc.mapcount_countup_ms(@k, @sk, 0)
|
188
234
|
sleep 2
|
189
|
-
|
190
|
-
|
191
|
-
assert_equal
|
235
|
+
lt2 = Time.parse(Time.now.strftime(DATE_FORMAT))
|
236
|
+
ret2 = {"last_updated_date"=>lt2, @sk=>1}
|
237
|
+
assert_equal ret2, @rc.mapcount_update_ms(@k)
|
192
238
|
end
|
193
239
|
|
194
240
|
def test_counts_ms
|
195
|
-
|
196
|
-
|
197
|
-
conn.write "stat read_count\n"
|
198
|
-
r = conn.gets.split(" ")
|
199
|
-
assert_equal 0, r[1].to_i
|
200
|
-
conn.gets
|
241
|
+
conn1 = Roma::Messaging::ConPool.instance.get_connection("localhost_11211")
|
242
|
+
conn2 = Roma::Messaging::ConPool.instance.get_connection("localhost_11212")
|
201
243
|
|
202
|
-
|
203
|
-
|
204
|
-
conn.write "stat read_count\n"
|
205
|
-
r = conn.gets.split(" ")
|
206
|
-
assert_equal 1, r[1].to_i
|
207
|
-
conn.gets
|
244
|
+
if conn1 && conn2
|
245
|
+
conns = [conn1, conn2]
|
208
246
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
247
|
+
ret = get_stat_sum(conns, "stat read_count\n")
|
248
|
+
assert_equal 0, ret
|
249
|
+
|
250
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
251
|
+
assert_equal 0, ret
|
252
|
+
|
253
|
+
@rc.mapcount_get_ms('key')
|
254
|
+
ret = get_stat_sum(conns, "stat read_count\n")
|
255
|
+
assert_equal 1, ret
|
213
256
|
|
214
257
|
@rc.mapcount_countup_ms('key', 'subkey', 0)
|
215
|
-
|
216
|
-
|
217
|
-
r = conn.gets.split(" ")
|
218
|
-
assert_equal 1, r[1].to_i
|
219
|
-
conn.gets
|
258
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
259
|
+
assert_equal 1, ret
|
220
260
|
|
221
261
|
@rc.mapcount_update_ms('key')
|
222
|
-
|
223
|
-
|
262
|
+
ret = get_stat_sum(conns, "stat write_count\n")
|
263
|
+
assert_equal 2, ret
|
264
|
+
else
|
265
|
+
flunk(message="Fail to get connection")
|
266
|
+
end
|
267
|
+
|
268
|
+
conn1.close
|
269
|
+
conn2.close
|
270
|
+
end
|
271
|
+
|
272
|
+
private
|
273
|
+
def get_stat_sum(conns, msg)
|
274
|
+
sum = 0
|
275
|
+
conns.each do |conn|
|
276
|
+
conn.write(msg)
|
224
277
|
r = conn.gets.split(" ")
|
225
|
-
|
278
|
+
sum += r[1].to_i
|
226
279
|
conn.gets
|
227
|
-
|
228
|
-
conn.close
|
229
280
|
end
|
281
|
+
sum
|
230
282
|
end
|
231
|
-
|
283
|
+
|
284
|
+
end #MapCountPluginTest
|