mogilefs-client 3.2.0 → 3.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  CONSTANT = "MogileFS::VERSION"
3
3
  RVF = "lib/mogilefs/version.rb"
4
- DEF_VER = "v3.2.0"
4
+ DEF_VER = "v3.3.0-rc1"
5
5
  vn = DEF_VER
6
6
 
7
7
  # First see if there is a version file (included in release tarballs),
data/HACKING CHANGED
@@ -31,3 +31,7 @@
31
31
  * Tests may be run in parallel using GNU make:
32
32
 
33
33
  make -j6 test
34
+
35
+ * Generate a pre-release gem for distribution/testing:
36
+
37
+ rake gem
data/Rakefile CHANGED
@@ -7,10 +7,18 @@ $:.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")
10
+ wd = %w(ChangeLog NEWS)
11
+ wd_ok = true
12
+ wd.each do |f|
13
+ next if File.exist?(f) || system("wrongdoc all")
14
+ wd_ok = false
15
+ File.open(f, "a") do |fp|
16
+ fp.puts "`wrongdoc all' failed, #{f} not generated properly"
17
+ end
12
18
  end
13
19
 
20
+ warn "install `wrongdoc' gem to generate: #{wd.inspect}" unless wd_ok
21
+
14
22
  manifest = "Manifest.txt"
15
23
  if ! File.exist?(manifest) ||
16
24
  File.stat(manifest).mtime < File.stat(RVF).mtime ||
@@ -30,7 +38,7 @@ Hoe.spec 'mogilefs-client' do
30
38
  # developer 'drbrain@segment7.net', 'Eric Hodel'
31
39
  self.readme_file = "README"
32
40
  self.history_file = "NEWS"
33
- self.url = "http://bogomips.org/mogilefs-client"
41
+ self.urls = %w(http://bogomips.org/mogilefs-client/)
34
42
  self.description = self.paragraphs_of("README", 1)
35
43
  self.summary = "MogileFS client library for Ruby"
36
44
  end
@@ -232,6 +232,7 @@ class MogileFS::Backend
232
232
  no_raise = args.delete(:ruby_no_raise)
233
233
  request = make_request(cmd, args)
234
234
  line = nil
235
+ failed = false
235
236
  @mutex.synchronize do
236
237
  begin
237
238
  io = dispatch_unlocked(request)
@@ -245,11 +246,15 @@ class MogileFS::Backend
245
246
  raise EOFError, "end of file reached after: #{request.inspect}"
246
247
  # fall through to retry in loop
247
248
  rescue SystemCallError,
248
- MogileFS::UnreadableSocketError,
249
- MogileFS::InvalidResponseError, # truncated response
250
- MogileFS::Timeout
249
+ MogileFS::InvalidResponseError # truncated response
251
250
  # we got a successful timed_write, but not a timed_gets
252
- retry if idempotent
251
+ if idempotent
252
+ failed = true
253
+ shutdown_unlocked(false)
254
+ retry
255
+ end
256
+ shutdown_unlocked(true)
257
+ rescue MogileFS::UnreadableSocketError, MogileFS::Timeout
253
258
  shutdown_unlocked(true)
254
259
  rescue
255
260
  # we DO NOT want the response we timed out waiting for, to crop up later
@@ -257,6 +262,7 @@ class MogileFS::Backend
257
262
  # close the socket if there's any error.
258
263
  shutdown_unlocked(true)
259
264
  end while idempotent
265
+ shutdown_unlocked if failed
260
266
  end # @mutex.synchronize
261
267
  parse_response(line, no_raise ? request : nil)
262
268
  end
@@ -105,7 +105,13 @@ class MogileFS::HTTPFile < StringIO
105
105
  if @big_io.respond_to?(:stat)
106
106
  stat = @big_io.stat
107
107
  elsif String === @big_io || @big_io.respond_to?(:to_path)
108
- file = File.open(@big_io)
108
+ begin
109
+ file = File.open(@big_io)
110
+ rescue => e
111
+ msg = "Failed to open input (#{@big_io.inspect}): " \
112
+ "#{e.message} (#{e.class})"
113
+ raise NonRetryableError, msg, e.backtrace
114
+ end
109
115
  stat = file.stat
110
116
  elsif @big_io.respond_to?(:size)
111
117
  size = @big_io.size
@@ -605,6 +605,64 @@ class TestMogileFS__MogileFS < TestMogileFS
605
605
  assert_equal received[0], received[1]
606
606
  end
607
607
 
608
+ def test_idempotent_command_slow
609
+ ip = "127.0.0.1"
610
+ a = TCPServer.new(ip, 0)
611
+ hosts = [ "#{ip}:#{a.addr[1]}" ]
612
+ q = Queue.new
613
+ timeout = 1
614
+ args = { :hosts => hosts, :domain => "foo", :timeout => timeout }
615
+ c = MogileFS::MogileFS.new(args)
616
+ received = []
617
+ secs = timeout + 1
618
+ th = Thread.new do
619
+ close_later = []
620
+ x = a.accept
621
+ close_later << x
622
+ line = x.gets
623
+ %r{key=(\w+)} =~ line
624
+
625
+ sleep(secs) # cause the client to timeout:
626
+
627
+ begin
628
+ x.write("OK paths=1&path1=http://0/#{$1}\r\n")
629
+ rescue Errno::EPIPE
630
+ # EPIPE may or may not get raised due to timing issue,
631
+ # we don't care either way
632
+ rescue => e
633
+ flunk("#{e.message} (#{e.class})")
634
+ end
635
+ q << :continue_test
636
+
637
+ # client should start a new connection here
638
+ y = a.accept
639
+ close_later << y
640
+ line = y.gets
641
+ %r{key=(\w+)} =~ line
642
+ begin
643
+ y.write("OK paths=1&path1=http://0/#{$1}\r\n")
644
+ rescue => e
645
+ flunk("#{e.message} (#{e.class})")
646
+ end
647
+
648
+ # the client should've killed the old connection:
649
+ assert_raises(Errno::EPIPE) do
650
+ loop { x.write("OK paths=1&path1=http://0/#{$1}\r\n") }
651
+ end
652
+
653
+ close_later # main thread closes
654
+ end
655
+ assert_raises(MogileFS::UnreadableSocketError) do
656
+ c.get_paths("a")
657
+ end
658
+ assert_equal :continue_test, q.pop, "avoid race during test"
659
+ expect2 = %w(http://0/b)
660
+ assert_equal expect2, c.get_paths("b")
661
+ a.close
662
+ close_later = th.value
663
+ close_later.each { |io| assert_nil io.close }
664
+ end
665
+
608
666
  def test_idempotent_command_response_truncated
609
667
  ip = "127.0.0.1"
610
668
  a, b = TCPServer.new(ip, 0), TCPServer.new(ip, 0)
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mogilefs-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
4
+ hash: 15424071
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 3.2.0
10
+ - rc
11
+ - 1
12
+ version: 3.3.0.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Eric Wong
@@ -15,23 +17,38 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-06-29 00:00:00 Z
20
+ date: 2012-08-03 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
- name: hoe
23
+ name: rdoc
22
24
  prerelease: false
23
25
  requirement: &id001 !ruby/object:Gem::Requirement
24
26
  none: false
25
27
  requirements:
26
28
  - - ~>
27
29
  - !ruby/object:Gem::Version
28
- hash: 27
30
+ hash: 19
29
31
  segments:
30
- - 2
31
- - 12
32
- version: "2.12"
32
+ - 3
33
+ - 10
34
+ version: "3.10"
33
35
  type: :development
34
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hoe
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 3
48
+ - 0
49
+ version: "3.0"
50
+ type: :development
51
+ version_requirements: *id002
35
52
  description: |-
36
53
  A MogileFS client library for Ruby. MogileFS is an open source
37
54
  distributed filesystem, see: http://mogilefs.org for more details. This
@@ -114,7 +131,7 @@ files:
114
131
  - NEWS
115
132
  - lib/mogilefs/version.rb
116
133
  - .gemtest
117
- homepage: http://bogomips.org/mogilefs-client
134
+ homepage: http://bogomips.org/mogilefs-client/
118
135
  licenses: []
119
136
 
120
137
  post_install_message:
@@ -135,12 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
152
  required_rubygems_version: !ruby/object:Gem::Requirement
136
153
  none: false
137
154
  requirements:
138
- - - ">="
155
+ - - ">"
139
156
  - !ruby/object:Gem::Version
140
- hash: 3
157
+ hash: 25
141
158
  segments:
142
- - 0
143
- version: "0"
159
+ - 1
160
+ - 3
161
+ - 1
162
+ version: 1.3.1
144
163
  requirements: []
145
164
 
146
165
  rubyforge_project: seattlerb