mogilefs-client 3.1.1 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3752 -0
- data/GIT-VERSION-GEN +1 -1
- data/Manifest.txt +67 -0
- data/NEWS +308 -0
- data/README +1 -0
- data/Rakefile +13 -6
- data/lib/mogilefs/backend.rb +8 -2
- data/lib/mogilefs/mogilefs.rb +31 -1
- data/lib/mogilefs/version.rb +1 -1
- data/test/test_fresh.rb +21 -0
- data/test/test_mogilefs_integration.rb +21 -0
- metadata +153 -74
data/GIT-VERSION-GEN
CHANGED
data/Manifest.txt
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
.document
|
2
|
+
.gitignore
|
3
|
+
.wrongdoc.yml
|
4
|
+
GIT-VERSION-GEN
|
5
|
+
GNUmakefile
|
6
|
+
HACKING
|
7
|
+
History
|
8
|
+
LICENSE
|
9
|
+
README
|
10
|
+
Rakefile
|
11
|
+
TODO
|
12
|
+
bin/mog
|
13
|
+
examples/stale_fid_checker.rb
|
14
|
+
lib/mogilefs.rb
|
15
|
+
lib/mogilefs/admin.rb
|
16
|
+
lib/mogilefs/backend.rb
|
17
|
+
lib/mogilefs/bigfile.rb
|
18
|
+
lib/mogilefs/bigfile/filter.rb
|
19
|
+
lib/mogilefs/chunker.rb
|
20
|
+
lib/mogilefs/client.rb
|
21
|
+
lib/mogilefs/copy_stream.rb
|
22
|
+
lib/mogilefs/http_file.rb
|
23
|
+
lib/mogilefs/http_reader.rb
|
24
|
+
lib/mogilefs/mogilefs.rb
|
25
|
+
lib/mogilefs/mysql.rb
|
26
|
+
lib/mogilefs/new_file.rb
|
27
|
+
lib/mogilefs/new_file/common.rb
|
28
|
+
lib/mogilefs/new_file/content_range.rb
|
29
|
+
lib/mogilefs/new_file/stream.rb
|
30
|
+
lib/mogilefs/new_file/tempfile.rb
|
31
|
+
lib/mogilefs/new_file/writer.rb
|
32
|
+
lib/mogilefs/paths_size.rb
|
33
|
+
lib/mogilefs/pool.rb
|
34
|
+
lib/mogilefs/socket.rb
|
35
|
+
lib/mogilefs/socket/kgio.rb
|
36
|
+
lib/mogilefs/socket/pure_ruby.rb
|
37
|
+
lib/mogilefs/socket_common.rb
|
38
|
+
lib/mogilefs/util.rb
|
39
|
+
setup.rb
|
40
|
+
test/.gitignore
|
41
|
+
test/aggregate.rb
|
42
|
+
test/exec.rb
|
43
|
+
test/fresh.rb
|
44
|
+
test/integration.rb
|
45
|
+
test/setup.rb
|
46
|
+
test/socket_test.rb
|
47
|
+
test/test_admin.rb
|
48
|
+
test/test_backend.rb
|
49
|
+
test/test_bigfile.rb
|
50
|
+
test/test_client.rb
|
51
|
+
test/test_db_backend.rb
|
52
|
+
test/test_fresh.rb
|
53
|
+
test/test_http_reader.rb
|
54
|
+
test/test_mogilefs.rb
|
55
|
+
test/test_mogilefs_integration.rb
|
56
|
+
test/test_mogilefs_integration_large_pipe.rb
|
57
|
+
test/test_mogilefs_integration_list_keys.rb
|
58
|
+
test/test_mogilefs_socket_kgio.rb
|
59
|
+
test/test_mogilefs_socket_pure.rb
|
60
|
+
test/test_mogstored_rack.rb
|
61
|
+
test/test_mogtool_bigfile.rb
|
62
|
+
test/test_mysql.rb
|
63
|
+
test/test_pool.rb
|
64
|
+
Manifest.txt
|
65
|
+
ChangeLog
|
66
|
+
NEWS
|
67
|
+
lib/mogilefs/version.rb
|
data/NEWS
ADDED
@@ -0,0 +1,308 @@
|
|
1
|
+
=== Ruby mogilefs-client 3.2.0-rc1 / 2012-06-15 01:05 UTC
|
2
|
+
|
3
|
+
* "list_keys" and "exist?" client commands raise errors properly
|
4
|
+
on failure.
|
5
|
+
|
6
|
+
* backend connections no longer terminate on ERR responses, only
|
7
|
+
on socket/connection errors.
|
8
|
+
|
9
|
+
* support the "updateclass" client command. This is for updating
|
10
|
+
the class of a given key and not to be confused with the
|
11
|
+
"update_class" admin command.
|
12
|
+
|
13
|
+
* "new_file" checksum usage is now documented since MogileFS 2.60
|
14
|
+
includes official support for checksums
|
15
|
+
|
16
|
+
=== Ruby mogilefs-client 3.1.1 / 2012-02-28 22:12 UTC
|
17
|
+
|
18
|
+
This releases fixes problems short reads when slurping files
|
19
|
+
into memory. Thanks to Matthew Draper for this fix.
|
20
|
+
There are also minor documentation updates.
|
21
|
+
|
22
|
+
=== Ruby mogilefs-client 3.1.0 / 2011-12-15 04:10 UTC
|
23
|
+
|
24
|
+
* improved API support for uploading large files
|
25
|
+
While we've always supported uploading large files, the
|
26
|
+
(still-supported) existing APIs were somewhat awkward or
|
27
|
+
required the file to exist on the file system. See
|
28
|
+
MogileFS::NewFile for details and examples.
|
29
|
+
|
30
|
+
* more informative exception messages for timed-out requests
|
31
|
+
|
32
|
+
* :fail_timeout parameter, the timeout for retrying a failed
|
33
|
+
tracker connection. This defaults to 5 seconds (same as
|
34
|
+
previous versions where this was hard-coded.
|
35
|
+
|
36
|
+
* :new_file_max_time parameter
|
37
|
+
Controls the maximum of time spent creating and uploading
|
38
|
+
a new file in MogileFS. This defaults to 1 hour (which
|
39
|
+
matching the expiry time of a row in the MogileFS internal
|
40
|
+
tempfile table).
|
41
|
+
|
42
|
+
* store_file works on unlinked File/Tempfile objects
|
43
|
+
|
44
|
+
* each_fid method in MogileFS::Admin fixed
|
45
|
+
|
46
|
+
* stale_fid_checker example script added
|
47
|
+
|
48
|
+
* mogstored_rack example split into a standalone RubyGem:
|
49
|
+
http://bogomips.org/mogstored_rack/
|
50
|
+
|
51
|
+
* backend error constants are generated on const_missing,
|
52
|
+
instead of when raised, making it easier to rescue exceptions
|
53
|
+
we didn't explicitly enable
|
54
|
+
|
55
|
+
* some internal cleanups and documentation improvements
|
56
|
+
|
57
|
+
=== Ruby mogilefs-client 3.0.0 / 2011-11-28 20:53 UTC
|
58
|
+
|
59
|
+
Changes since 3.0.0-rc1:
|
60
|
+
|
61
|
+
* 1.8 copy_stream emulator respects creation umask
|
62
|
+
This matches the latest IO.copy_stream behavior.
|
63
|
+
[ruby-core:41308], r33851 in ruby/trunk
|
64
|
+
|
65
|
+
* higher timeouts for uploads to compensate for slow
|
66
|
+
(but not dead) servers.
|
67
|
+
|
68
|
+
Changes since v2.2.0:
|
69
|
+
|
70
|
+
=== client changes
|
71
|
+
|
72
|
+
* "store_file" now accepts any IO object capable of streaming
|
73
|
+
data (e.g. pipes and sockets). This uses chunked
|
74
|
+
Transfer-Encoding for PUTs, so backend storage nodes
|
75
|
+
will need to support this (latest mogstored does).
|
76
|
+
|
77
|
+
* "store_file" no longer uses an infinite timeout when
|
78
|
+
awaiting a response after a PUT, the new timeout for the
|
79
|
+
response is now calculated based on the time and size of
|
80
|
+
the PUT request.
|
81
|
+
|
82
|
+
* new commands: "file_debug" and "file_info" (new commands
|
83
|
+
in mogilefsd, be sure you have the latest version)
|
84
|
+
|
85
|
+
* "get_paths" takes optional ":pathcount" parameter
|
86
|
+
to control the number of returned paths.
|
87
|
+
|
88
|
+
* "get_file_data" supports offset and count for partial
|
89
|
+
transfer (requires support from storage node for
|
90
|
+
Range: requests, most HTTP servers are capable of this)
|
91
|
+
|
92
|
+
* IO.copy_stream is enabled by default under Ruby 1.9.3.
|
93
|
+
Expect performance improvements.
|
94
|
+
|
95
|
+
* "list_keys" with a passed block (for additional info) is
|
96
|
+
faster due to internal pipelining implementation and the
|
97
|
+
addition of "file_info" support.
|
98
|
+
|
99
|
+
* fixed handling of "+" in key/domain names (old bug)
|
100
|
+
|
101
|
+
* rare, truncated partial responses due to network/server
|
102
|
+
failure now raise MogileFS::InvalidResponseError
|
103
|
+
|
104
|
+
=== admin changes
|
105
|
+
|
106
|
+
Admin support is still a work-in-progress,
|
107
|
+
I usually just find myself using "mogadm" anyways.
|
108
|
+
|
109
|
+
* new admin commands: "replicate_now"
|
110
|
+
|
111
|
+
* "get_stats" no longer works on new mogilefsd versions
|
112
|
+
|
113
|
+
* get_domains handles "repl_policy" field correctly for classes
|
114
|
+
in MogileFS 2.x
|
115
|
+
|
116
|
+
* admin commands should convert all numeric fields to either
|
117
|
+
Integer or Float objects and not String representations
|
118
|
+
of numerics. Affected methods include:
|
119
|
+
get_hosts, get_devices, list_fids, each_fids, get_domains
|
120
|
+
|
121
|
+
=== miscellany
|
122
|
+
|
123
|
+
* we no longer add methods to standard Ruby classes
|
124
|
+
(at least we never /changed/ existing methods :P)
|
125
|
+
|
126
|
+
* {kgio}[http://bogomips.org/kgio] automatically used
|
127
|
+
if available, but not required to avoid exceptions
|
128
|
+
with non-blocking I/O
|
129
|
+
|
130
|
+
* dropped Ruby 1.8.6 support, 1.8.7 or later is required.
|
131
|
+
|
132
|
+
* Tested with MRI 1.8.7, 1.9.3 and Rubinius 1.2.4
|
133
|
+
|
134
|
+
* MogileFS::Mysql - deprecated, to be removed in 2012
|
135
|
+
|
136
|
+
* improved test suite
|
137
|
+
|
138
|
+
* some optional experimental features/changes,
|
139
|
+
see "git log" for details
|
140
|
+
|
141
|
+
* Added internal pipelining implementation, this is
|
142
|
+
not easy-to-use since the server can respond-out-of-order,
|
143
|
+
but still useful for things like a list_keys+file_info
|
144
|
+
loop.
|
145
|
+
|
146
|
+
=== mogilefs-client 3.0.0-rc1 / 2011-11-21 02:48 UTC
|
147
|
+
|
148
|
+
=== client changes
|
149
|
+
|
150
|
+
* "store_file" now accepts any IO object capable of streaming
|
151
|
+
data (e.g. pipes and sockets). This uses chunked
|
152
|
+
Transfer-Encoding for PUTs, so backend storage nodes
|
153
|
+
will need to support this (latest mogstored does).
|
154
|
+
|
155
|
+
* "store_file" no longer uses an infinite timeout when
|
156
|
+
awaiting a response after a PUT, the new timeout for the
|
157
|
+
response is now calculated based on the time and size of
|
158
|
+
the PUT request.
|
159
|
+
|
160
|
+
* new commands: "file_debug" and "file_info" (new commands
|
161
|
+
in mogilefsd, be sure you have the latest version)
|
162
|
+
|
163
|
+
* "get_paths" takes optional ":pathcount" parameter
|
164
|
+
to control the number of returned paths.
|
165
|
+
|
166
|
+
* "get_file_data" supports offset and count for partial
|
167
|
+
transfer (requires support from storage node for
|
168
|
+
Range: requests, most HTTP servers are capable of this)
|
169
|
+
|
170
|
+
* IO.copy_stream is enabled by default under Ruby 1.9.3.
|
171
|
+
Expect performance improvements.
|
172
|
+
|
173
|
+
* "list_keys" with a passed block (for additional info) is
|
174
|
+
faster due to internal pipelining implementation and the
|
175
|
+
addition of "file_info" support.
|
176
|
+
|
177
|
+
* fixed handling of "+" in key/domain names (old bug)
|
178
|
+
|
179
|
+
* rare, truncated partial responses due to network/server
|
180
|
+
failure now raise MogileFS::InvalidResponseError
|
181
|
+
|
182
|
+
=== admin changes
|
183
|
+
|
184
|
+
Admin support is still a work-in-progress,
|
185
|
+
I usually just find myself using "mogadm" anyways.
|
186
|
+
|
187
|
+
* new admin commands: "replicate_now"
|
188
|
+
|
189
|
+
* "get_stats" no longer works on new mogilefsd versions
|
190
|
+
|
191
|
+
* get_domains handles "repl_policy" field correctly for classes
|
192
|
+
in MogileFS 2.x
|
193
|
+
|
194
|
+
* admin commands should convert all numeric fields to either
|
195
|
+
Integer or Float objects and not String representations
|
196
|
+
of numerics. Affected methods include:
|
197
|
+
get_hosts, get_devices, list_fids, each_fids, get_domains
|
198
|
+
|
199
|
+
=== miscellany
|
200
|
+
|
201
|
+
* we no longer add methods to standard Ruby classes
|
202
|
+
(at least we never /changed/ existing methods :P)
|
203
|
+
|
204
|
+
* {kgio}[http://bogomips.org/kgio] automatically used
|
205
|
+
if available, but not required to avoid exceptions
|
206
|
+
with non-blocking I/O
|
207
|
+
|
208
|
+
* dropped Ruby 1.8.6 support, 1.8.7 or later is required.
|
209
|
+
|
210
|
+
* Tested with MRI 1.8.7, 1.9.3 and Rubinius 1.2.4
|
211
|
+
|
212
|
+
* MogileFS::Mysql - deprecated, to be removed in 2012
|
213
|
+
|
214
|
+
* improved test suite
|
215
|
+
|
216
|
+
* some optional experimental features/changes,
|
217
|
+
see "git log" for details
|
218
|
+
|
219
|
+
* Added internal pipelining implementation, this is
|
220
|
+
not easy-to-use since the server can respond-out-of-order,
|
221
|
+
but still useful for things like a list_keys+file_info
|
222
|
+
loop.
|
223
|
+
|
224
|
+
=== mogilefs-client 2.2.0 / 2011-01-13 02:10 UTC
|
225
|
+
|
226
|
+
= 2.2.0
|
227
|
+
* internal cleanups (no public API breakage)
|
228
|
+
* refactor backend socket/connection handling for reliability
|
229
|
+
|
230
|
+
There'll probably be more aggressive cleanups/refactoring in
|
231
|
+
future releases if I have time.
|
232
|
+
|
233
|
+
=== mogilefs-client 2.1.0 / 2009-04-12 03:04 UTC
|
234
|
+
|
235
|
+
= 2.1.0
|
236
|
+
* MySQL interface returns integer length and devcount (API change)
|
237
|
+
* Ensure store_{content,file} always returns size (API fix)
|
238
|
+
* Add get_uris API method
|
239
|
+
* Respect timeout when doing get_file_data
|
240
|
+
* MySQL interface filters out URLs for down/dead hosts/devices
|
241
|
+
* Really remove all NFS support
|
242
|
+
* get_file in slurp mode slurps all output correctly
|
243
|
+
|
244
|
+
Eric Wong (18):
|
245
|
+
tests: retry random ports correctly
|
246
|
+
test_mogilefs: fix race conditions
|
247
|
+
MySQL interface returns integer length and devcount
|
248
|
+
Respect timeout when doing get_file_data
|
249
|
+
Unify internal HTTP GET/HEAD methods
|
250
|
+
Close socket we create before raising exceptions
|
251
|
+
Compact get_paths output so we don't have nils
|
252
|
+
Really remove all NFS support
|
253
|
+
README: add a note about emailing me
|
254
|
+
Extra checking for full_timeout in sysread_full
|
255
|
+
Add get_uris API method
|
256
|
+
verify_uris: use write_nonblock instead of syswrite
|
257
|
+
README: add links to the repo.or.cz mirror
|
258
|
+
mysql: filter out URLs for down/dead hosts/devices
|
259
|
+
mog: small cleanup
|
260
|
+
Ensure store_{content,file} always returns size
|
261
|
+
GNUmakefile: better logging/output control
|
262
|
+
mogilefs-client 2.1.0
|
263
|
+
|
264
|
+
godfat (1):
|
265
|
+
call IO.select([sock]) if sock is not ready.
|
266
|
+
|
267
|
+
=== mogilefs-client 1.2.1 / 2009-03-25 07:29 UTC
|
268
|
+
|
269
|
+
Retroactively tagging this old release since
|
270
|
+
it was in SVN or Perforce...
|
271
|
+
|
272
|
+
=== mogilefs-client 2.0.2 / 2009-03-02 21:56 UTC
|
273
|
+
|
274
|
+
initial
|
275
|
+
|
276
|
+
=== mogilefs-client v2.0.1 / 2009-02-25 08:13 UTC
|
277
|
+
|
278
|
+
* verify_uris method made more robust
|
279
|
+
* preliminary Ruby 1.9 compatibility, tests still need some work
|
280
|
+
* allow store_content to be used with a streamable object of known length
|
281
|
+
* add setup.rb for non-RubyGems users
|
282
|
+
|
283
|
+
=== mogilefs-client 2.0.0 / 2009-02-03 04:27 UTC
|
284
|
+
|
285
|
+
initial
|
286
|
+
|
287
|
+
=== v1.3.1 / 2008-10-03 03:01 UTC
|
288
|
+
|
289
|
+
* Fix missing MogileFS::Util include for sysrwloop in MogileFS::MogileFS
|
290
|
+
|
291
|
+
=== v1.3.0 / 2008-09-18 23:46 UTC
|
292
|
+
|
293
|
+
* Fixed MogileFS#rename. Bug #14465 submitted by Justin Dossey.
|
294
|
+
* Removed infinite loop in MogileFS::HTTPFile#store_file. Patch #13789
|
295
|
+
submitted by Andy Lo-A-Foe.
|
296
|
+
* Made MogileFS#get_file_data timeout configurable. Bug #13490 submitted by
|
297
|
+
Andy Lo-A-Foe.
|
298
|
+
* Add MogileFS#size. Feature Request #14484 submitted by Justin Dossey.
|
299
|
+
* Fix MogileFS#get_file_data to return the data for HTTP mode. Bug #7133
|
300
|
+
submitted by John Wanko.
|
301
|
+
* New maintainer: Eric Wong
|
302
|
+
* Add `mog' command-line tool as a demo/example
|
303
|
+
* Lower memory consumption with large files
|
304
|
+
* Allow get_file_data to accept a block for large files
|
305
|
+
* Fix each_keys loop termination condition
|
306
|
+
* Apply error handling patch from Matthew Willson. Bug #15987
|
307
|
+
* Merge large file patch from Andy Lo-A-Foe. Bug #13764
|
308
|
+
|
data/README
CHANGED
@@ -14,6 +14,7 @@ email :: mailto:normalperson@yhbt.net
|
|
14
14
|
repo :: git://bogomips.org/mogilefs-client.git
|
15
15
|
cgit :: http://bogomips.org/mogilefs-client.git
|
16
16
|
gitweb :: http://repo.or.cz/w/ruby-mogilefs-client.git
|
17
|
+
download :: http://bogomips.org/mogilefs-client/files/
|
17
18
|
|
18
19
|
== Install
|
19
20
|
|
data/Rakefile
CHANGED
@@ -7,11 +7,21 @@ $:.unshift 'lib'
|
|
7
7
|
require 'mogilefs'
|
8
8
|
Hoe.plugin :seattlerb
|
9
9
|
|
10
|
+
if ! File.exist?("ChangeLog") || ! File.exist?("NEWS")
|
11
|
+
system("wrongdoc all")
|
12
|
+
end
|
13
|
+
|
10
14
|
manifest = "Manifest.txt"
|
11
15
|
if ! File.exist?(manifest) ||
|
12
|
-
File.stat(manifest).mtime < File.stat(RVF).mtime
|
16
|
+
File.stat(manifest).mtime < File.stat(RVF).mtime ||
|
17
|
+
File.stat(manifest).mtime < File.stat(__FILE__).mtime
|
13
18
|
system("git ls-files > #{manifest}")
|
14
|
-
File.open(manifest, "a")
|
19
|
+
File.open(manifest, "a") do |fp|
|
20
|
+
fp.puts "Manifest.txt"
|
21
|
+
fp.puts "ChangeLog"
|
22
|
+
fp.puts "NEWS"
|
23
|
+
fp.puts "lib/mogilefs/version.rb"
|
24
|
+
end
|
15
25
|
end
|
16
26
|
|
17
27
|
Hoe.spec 'mogilefs-client' do
|
@@ -19,7 +29,7 @@ Hoe.spec 'mogilefs-client' do
|
|
19
29
|
developer 'Eric Wong', 'normalperson@yhbt.net'
|
20
30
|
# developer 'drbrain@segment7.net', 'Eric Hodel'
|
21
31
|
self.readme_file = "README"
|
22
|
-
self.history_file = "
|
32
|
+
self.history_file = "NEWS"
|
23
33
|
self.url = "http://bogomips.org/mogilefs-client"
|
24
34
|
self.description = self.paragraphs_of("README", 1)
|
25
35
|
self.summary = "MogileFS client library for Ruby"
|
@@ -36,6 +46,3 @@ task :fix_perms do
|
|
36
46
|
end
|
37
47
|
end
|
38
48
|
end
|
39
|
-
|
40
|
-
# vim: syntax=Ruby
|
41
|
-
|
data/lib/mogilefs/backend.rb
CHANGED
@@ -118,6 +118,7 @@ class MogileFS::Backend
|
|
118
118
|
add_command :delete_domain
|
119
119
|
add_command :create_class
|
120
120
|
add_command :update_class
|
121
|
+
add_command :updateclass
|
121
122
|
add_command :delete_class
|
122
123
|
add_command :create_host
|
123
124
|
add_command :update_host
|
@@ -228,11 +229,15 @@ class MogileFS::Backend
|
|
228
229
|
def do_request(cmd, args, idempotent = false)
|
229
230
|
no_raise = args.delete(:ruby_no_raise)
|
230
231
|
request = make_request(cmd, args)
|
232
|
+
line = nil
|
231
233
|
@mutex.synchronize do
|
232
234
|
begin
|
233
235
|
io = dispatch_unlocked(request)
|
234
|
-
line = io.timed_gets(@timeout)
|
235
|
-
|
236
|
+
line = io.timed_gets(@timeout)
|
237
|
+
break if /\r?\n\z/ =~ line
|
238
|
+
|
239
|
+
line and raise MogileFS::InvalidResponseError,
|
240
|
+
"Invalid response from server: #{line.inspect}"
|
236
241
|
|
237
242
|
idempotent or
|
238
243
|
raise EOFError, "end of file reached after: #{request.inspect}"
|
@@ -251,6 +256,7 @@ class MogileFS::Backend
|
|
251
256
|
shutdown_unlocked(true)
|
252
257
|
end while idempotent
|
253
258
|
end # @mutex.synchronize
|
259
|
+
parse_response(line, no_raise ? request : nil)
|
254
260
|
end
|
255
261
|
|
256
262
|
# Makes a new request string for +cmd+ and +args+.
|
data/lib/mogilefs/mogilefs.rb
CHANGED
@@ -140,7 +140,14 @@ class MogileFS::MogileFS < MogileFS::Client
|
|
140
140
|
# Returns +true+ if +key+ exists, +false+ if not
|
141
141
|
def exist?(key)
|
142
142
|
args = { :key => key, :domain => @domain , :ruby_no_raise => true}
|
143
|
-
|
143
|
+
case rv = @backend.get_paths(args)
|
144
|
+
when Hash
|
145
|
+
true
|
146
|
+
when MogileFS::Backend::UnknownKeyError
|
147
|
+
false
|
148
|
+
else
|
149
|
+
raise rv
|
150
|
+
end
|
144
151
|
end
|
145
152
|
|
146
153
|
# Get the URIs for +key+ (paths) as URI::HTTP objects
|
@@ -172,6 +179,20 @@ class MogileFS::MogileFS < MogileFS::Client
|
|
172
179
|
# [ :class => String]
|
173
180
|
#
|
174
181
|
# The MogileFS storage class of the object.
|
182
|
+
#
|
183
|
+
# [:content_md5 => String, Proc, or :trailer]
|
184
|
+
#
|
185
|
+
# This can either be a Base64-encoded String, a Proc object, or
|
186
|
+
# the :trailer symbol. If given a String, it will be used as the
|
187
|
+
# Content-MD5 HTTP header. If given the :trailer symbol, this library
|
188
|
+
# will automatically generate an Content-MD5 HTTP trailer. If given
|
189
|
+
# a Proc object, this Proc object should give a Base64-encoded string
|
190
|
+
# which can be used as the Content-MD5 HTTP trailer when called at the
|
191
|
+
# end of the request.
|
192
|
+
#
|
193
|
+
# Keep in mind most HTTP servers do not support HTTP trailers, so
|
194
|
+
# passing a String is usually the safest way to use this.
|
195
|
+
#
|
175
196
|
def new_file(key, args = nil, bytes = nil) # :yields: file
|
176
197
|
raise MogileFS::ReadOnlyError if readonly?
|
177
198
|
opts = { :key => key, :multi_dest => 1 }
|
@@ -256,6 +277,14 @@ class MogileFS::MogileFS < MogileFS::Client
|
|
256
277
|
true
|
257
278
|
end
|
258
279
|
|
280
|
+
# Updates +key+ to +newclass+
|
281
|
+
def updateclass(key, newclass)
|
282
|
+
raise MogileFS::ReadOnlyError if readonly?
|
283
|
+
|
284
|
+
@backend.updateclass(:domain => @domain, :key => key, :class => newclass)
|
285
|
+
true
|
286
|
+
end
|
287
|
+
|
259
288
|
# Sleeps +duration+, only used for testing
|
260
289
|
def sleep(duration) # :nodoc:
|
261
290
|
@backend.sleep :duration => duration
|
@@ -294,6 +323,7 @@ class MogileFS::MogileFS < MogileFS::Client
|
|
294
323
|
:after => after, :limit => limit,
|
295
324
|
:ruby_no_raise => true)
|
296
325
|
MogileFS::Backend::NoneMatchError === res and return
|
326
|
+
raise res if MogileFS::Error === res
|
297
327
|
|
298
328
|
keys = (1..res['key_count'].to_i).map { |i| res["key_#{i}"] }
|
299
329
|
if block
|
data/lib/mogilefs/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
MogileFS::VERSION = '3.
|
1
|
+
MogileFS::VERSION = '3.2.0.rc1'
|
data/test/test_fresh.rb
CHANGED
@@ -5,4 +5,25 @@ class TestMogFresh < Test::Unit::TestCase
|
|
5
5
|
include TestFreshSetup
|
6
6
|
alias setup setup_mogilefs
|
7
7
|
alias teardown teardown_mogilefs
|
8
|
+
|
9
|
+
def test_list_keys_invalid_domain
|
10
|
+
add_host_device_domain
|
11
|
+
domain = @domain + ".non-existent"
|
12
|
+
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => domain
|
13
|
+
assert_raises(MogileFS::Backend::UnregDomainError) do
|
14
|
+
client.list_keys
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_invalid_key_exists
|
19
|
+
add_host_device_domain
|
20
|
+
domain = @domain + ".non-existent"
|
21
|
+
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => domain
|
22
|
+
assert_raises(MogileFS::Backend::UnregDomainError) do
|
23
|
+
client.exist?("FOO")
|
24
|
+
end
|
25
|
+
|
26
|
+
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
|
27
|
+
assert_equal false, client.exist?("non-existent")
|
28
|
+
end
|
8
29
|
end
|
@@ -290,4 +290,25 @@ class TestMogileFSIntegration < TestMogIntegration
|
|
290
290
|
|
291
291
|
assert_equal "HIHI", @client.get_file_data("unlinked")
|
292
292
|
end
|
293
|
+
|
294
|
+
def test_updateclass
|
295
|
+
admin = MogileFS::Admin.new(:hosts => @trackers)
|
296
|
+
admin.create_class(@domain, "one", 1)
|
297
|
+
admin.create_class(@domain, "two", 2)
|
298
|
+
4.times { admin.clear_cache }
|
299
|
+
|
300
|
+
assert_equal 4, @client.store_content("uc", "default", "DATA")
|
301
|
+
assert_equal true, @client.updateclass("uc", "one")
|
302
|
+
assert_equal true, @client.updateclass("uc", "two")
|
303
|
+
assert_raises(MogileFS::Backend::ClassNotFoundError) do
|
304
|
+
@client.updateclass("uc", "wtf")
|
305
|
+
end
|
306
|
+
assert_raises(MogileFS::Backend::InvalidKeyError) do
|
307
|
+
@client.updateclass("nonexistent", "one")
|
308
|
+
end
|
309
|
+
|
310
|
+
@client.delete "uc"
|
311
|
+
admin.delete_class @domain, "one"
|
312
|
+
admin.delete_class @domain, "two"
|
313
|
+
end
|
293
314
|
end
|