mogilefs-client 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65d3ada1142a27870a3926eeae7d15a13d28b016
4
- data.tar.gz: 7ef65f2858cb0a130cbb7c0200946a7df05bf701
3
+ metadata.gz: 6485f77cf3355bd73565e09aa5955e461c7ee184
4
+ data.tar.gz: f3c904eb2e2801526629b3684aa7bf869736f97c
5
5
  SHA512:
6
- metadata.gz: edecf8b75e5f3e218e63383c79da8ceaab6daed1890c3d51c0ca418936c30e6a613eb187ae5258137570eee8d649a612fcbaaf0cc606baa4165a817f146a681f
7
- data.tar.gz: b9448f892913e8104c611badaf368e22acaa6faf60c70abf729200a6c0725efe2657a13498aeeb64b11b4701a62caa7f1f547eefff4c0652834745380dd04e8e
6
+ metadata.gz: 630a6d7503310c7950bf343b79c7fa0709ce31ffe452390fb1d97940a09f8a019c77aa73085186043e3d140213a23b24d8b1547b928a2a8e07ce8a91960471c1
7
+ data.tar.gz: 81d66c0d390b66ad170a120bf84c0f6603971296fa8da6d708c0f6c93390271850aceb64cd726338d80770b098916e32fba5168c7fac168ed1f56a9678204555
@@ -2,7 +2,7 @@
2
2
  CONSTANT = "MogileFS::VERSION"
3
3
  RVF = "lib/mogilefs/version.rb"
4
4
  GVF = "GIT-VERSION-FILE"
5
- DEF_VER = "v3.8.0"
5
+ DEF_VER = "v3.9.0"
6
6
  vn = DEF_VER
7
7
 
8
8
  # First see if there is a version file (included in release tarballs),
data/HACKING CHANGED
@@ -7,16 +7,14 @@
7
7
  * Follow conventions set in existing code, don't add hard runtime
8
8
  dependencies outside of the standard Ruby library.
9
9
 
10
- * Do not hesitate to send plain-text(-only) email to Eric Wong at
11
- mailto:normalperson@yhbt.net about anything not covered in
12
- the documentation or mailing list archives. General MogileFS
13
- topics can go to the public mailing list at mailto:mogile@googlegroups.com
14
- You may still email Wong directly if you do not trust the corporation
15
- that hosts the public mailing list.
10
+ * Do not hesitate to send plain-text(-only) email to the public list
11
+ at mailto:mogilefs-client-public@bogomips.org about anything not covered
12
+ in the documentation or mailing list archives. General MogileFS
13
+ topics can go on the the mailing list at mailto:mogile@googlegroups.com
16
14
 
17
15
  * Use "git format-patch" and "git send-email" for sending patches.
18
16
 
19
- * Use "git request-pull" as a guideline for formatting pull-requests.
17
+ * Use "git request-pull" as a guideline for formatting pull-request emails.
20
18
 
21
19
  * Test with the latest upstream MogileFS and Ruby versions.
22
20
 
@@ -24,10 +22,6 @@
24
22
  with a single host and device using a SQLite backend if you
25
23
  have "mogdbsetup", "mogilefsd", and "mogstored" in your PATH.
26
24
 
27
- * Setting MOG_TEST_TRACKERS= to a comma-delimited list of trackers
28
- can enable additional integration tests against a live tracker
29
- (with multiple devices/hosts).
30
-
31
25
  * Tests may be run in parallel using GNU make:
32
26
 
33
27
  make -j6 test
@@ -5,19 +5,29 @@
5
5
  # Client usage information is available in MogileFS::MogileFS.
6
6
  module MogileFS
7
7
 
8
+ if defined?(Process::CLOCK_MONOTONIC)
9
+ def self.now
10
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
11
+ end
12
+ else
13
+ def self.now
14
+ Time.now.to_f
15
+ end
16
+ end
17
+
8
18
  # Standard error class for most MogileFS-specific errors
9
- class Error < StandardError; end
19
+ Error = Class.new(StandardError)
10
20
 
11
21
  # Raised when a socket remains unreadable for too long.
12
- class UnreadableSocketError < Error; end
22
+ UnreadableSocketError = Class.new(Error)
13
23
 
14
24
  # Raised when a response is truncated while reading
15
25
  # due to network/server # errors)
16
- class SizeMismatchError < Error; end
26
+ SizeMismatchError = Class.new(Error)
17
27
 
18
28
  # Raised when checksum verification fails (only while reading deprecated
19
29
  # "bigfiles" from the deprecated mogtool(1).
20
- class ChecksumMismatchError < RuntimeError; end
30
+ ChecksumMismatchError = Class.new(RuntimeError)
21
31
 
22
32
  # Raised when a backend is in read-only mode
23
33
  class ReadOnlyError < Error
@@ -27,27 +37,27 @@ module MogileFS
27
37
  end
28
38
 
29
39
  # Raised when an upload is impossible
30
- class EmptyPathError < Error; end
40
+ EmptyPathError = Class.new(Error)
31
41
 
32
42
  # Raised when we are given an unsupported protocol to upload to.
33
43
  # Currently, the \MogileFS (2.XX) server only supports HTTP and
34
44
  # this library is only capable of HTTP.
35
- class UnsupportedPathError < Error; end
45
+ UnsupportedPathError = Class.new(Error)
36
46
 
37
47
  # Raised when a request (HTTP or tracker) was truncated due to a network or
38
48
  # server error. It may be possible to retry idempotent requests from this.
39
- class RequestTruncatedError < Error; end
49
+ RequestTruncatedError = Class.new(Error)
40
50
 
41
51
  # Raised when a response from a server (HTTP or tracker) is not in a format
42
52
  # that we expected (or truncated..
43
- class InvalidResponseError < Error; end
53
+ InvalidResponseError = Class.new(Error)
44
54
 
45
55
  # Raised when all known backends have failed.
46
- class UnreachableBackendError < Error; end
56
+ UnreachableBackendError = Class.new(Error)
47
57
 
48
58
  # There was an error as a result of the use of the (experimental)
49
59
  # pipelining code to the tracker backend
50
- class PipelineError < Error; end
60
+ PipelineError = Class.new(Error)
51
61
 
52
62
  # :stopdoc:
53
63
  class << self
@@ -147,7 +147,7 @@ class MogileFS::Backend
147
147
  tries ||= Hash.new { |hash,host| hash[host] = 0 }
148
148
  nr = tries[@active_host] += 1
149
149
  if nr >= 2
150
- @dead[@active_host] = [ Time.now, err ]
150
+ @dead[@active_host] = [ MogileFS.now, err ]
151
151
  end
152
152
  shutdown_unlocked
153
153
  retry
@@ -163,7 +163,7 @@ class MogileFS::Backend
163
163
  end
164
164
 
165
165
  def timeout_update(timeout, t0) # :nodoc:
166
- timeout -= (Time.now - t0)
166
+ timeout -= (MogileFS.now - t0)
167
167
  timeout < 0 ? 0 : timeout
168
168
  end
169
169
 
@@ -174,12 +174,12 @@ class MogileFS::Backend
174
174
  def pipeline_drain_unlocked(io, timeout) # :nodoc:
175
175
  set = [ io ]
176
176
  while @pending.size > 0
177
- t0 = Time.now
177
+ t0 = MogileFS.now
178
178
  r = IO.select(set, set, nil, timeout)
179
179
  timeout = timeout_update(timeout, t0)
180
180
 
181
181
  if r && r[0][0]
182
- t0 = Time.now
182
+ t0 = MogileFS.now
183
183
  pipeline_gets_unlocked(io, timeout)
184
184
  timeout = timeout_update(timeout, t0)
185
185
  else
@@ -207,7 +207,7 @@ class MogileFS::Backend
207
207
  io.timed_write(request, timeout)
208
208
  @pending << [ request, block ]
209
209
  rescue SystemCallError, MogileFS::RequestTruncatedError => err
210
- @dead[@active_host] = [ Time.now, err ]
210
+ @dead[@active_host] = [ MogileFS.now, err ]
211
211
  shutdown_unlocked(@pending[0])
212
212
  io = socket
213
213
  retry
@@ -343,14 +343,14 @@ class MogileFS::Backend
343
343
  return @socket if @socket and not @socket.closed?
344
344
 
345
345
  @hosts.shuffle.each do |host|
346
- next if dead = @dead[host] and dead[0] > (Time.now - @fail_timeout)
346
+ next if dead = @dead[host] and dead[0] > (MogileFS.now - @fail_timeout)
347
347
 
348
348
  begin
349
349
  addr, port = host.split(/:/)
350
350
  @socket = MogileFS::Socket.tcp(addr, port, @timeout)
351
351
  @active_host = host
352
352
  rescue SystemCallError, MogileFS::Timeout => err
353
- @dead[host] = [ Time.now, err ]
353
+ @dead[host] = [ MogileFS.now, err ]
354
354
  next
355
355
  end
356
356
 
@@ -46,13 +46,13 @@ class MogileFS::HTTPReader < MogileFS::Socket
46
46
  # body of the response.
47
47
  def self.try(path, timeout, range) # :nodoc:
48
48
  uri = URI.parse(path)
49
- expire_at = Time.now + timeout
49
+ expire_at = MogileFS.now + timeout
50
50
  sock = tcp(uri.host, uri.port, timeout)
51
51
  buf = "GET #{uri.request_uri} HTTP/1.0\r\n#{range}\r\n" # no chunking
52
52
  sock.timed_write(buf, timeout)
53
53
 
54
54
  begin
55
- raise MogileFS::Timeout if Time.now > expire_at
55
+ raise MogileFS::Timeout if MogileFS.now > expire_at
56
56
  sock.timed_peek(2048, buf, timeout) or
57
57
  raise MogileFS::InvalidResponseError, "EOF while reading header", []
58
58
  end until /\r\n\r\n/ =~ buf
@@ -318,7 +318,7 @@ class MogileFS::MogileFS < MogileFS::Client
318
318
  opts[:fid] = res['fid']
319
319
  opts[:content_length] ||= bytes if bytes
320
320
  opts[:new_file_max_time] ||= @new_file_max_time
321
- opts[:start_time] = Time.now
321
+ opts[:start_time] = MogileFS.now
322
322
  info = opts[:info] and info["class"] = klass || "default"
323
323
 
324
324
  case (dests[0][1] rescue nil)
@@ -21,7 +21,7 @@ class MogileFS::Mysql
21
21
  def initialize(args = {})
22
22
  @my = args[:mysql]
23
23
  @query_method = @my.respond_to?(:c_async_query) ? :c_async_query : :query
24
- @last_update_device = @last_update_domain = Time.at(0)
24
+ @last_update_device = @last_update_domain = 0
25
25
  @cache_domain = @cache_device = nil
26
26
  end
27
27
 
@@ -139,7 +139,9 @@ class MogileFS::Mysql
139
139
  }.freeze
140
140
 
141
141
  def refresh_device(force = false)
142
- return @cache_device if ! force && ((Time.now - @last_update_device) < 60)
142
+ if ! force && ((MogileFS.now - @last_update_device) < 60)
143
+ return @cache_device
144
+ end
143
145
  tmp = {}
144
146
  res = query(GET_DEVICES)
145
147
  res.each do |devid, hostip, altip, http_port, http_get_port,
@@ -154,16 +156,18 @@ class MogileFS::Mysql
154
156
  :http_get_port => http_get_port ? http_get_port.to_i : http_port,
155
157
  }.freeze
156
158
  end
157
- @last_update_device = Time.now
159
+ @last_update_device = MogileFS.now
158
160
  @cache_device = tmp.freeze
159
161
  end
160
162
 
161
163
  def refresh_domain(force = false)
162
- return @cache_domain if ! force && ((Time.now - @last_update_domain) < 5)
164
+ if ! force && ((MogileFS.now - @last_update_domain) < 5)
165
+ return @cache_domain
166
+ end
163
167
  tmp = {}
164
168
  res = query(GET_DOMAINS)
165
169
  res.each { |dmid,namespace| tmp[namespace] = dmid.to_i }
166
- @last_update_domain = Time.now
170
+ @last_update_domain = MogileFS.now
167
171
  @cache_domain = tmp.freeze
168
172
  end
169
173
 
@@ -20,7 +20,7 @@ module MogileFS::NewFile::Common
20
20
 
21
21
  def read_response(sock)
22
22
  tout = @opts[:new_file_max_time] || 3600.0
23
- start_time = @opts[:start_time] and tout -= Time.now - start_time
23
+ start_time = @opts[:start_time] and tout -= MogileFS.now - start_time
24
24
  set_socket_options(sock)
25
25
  case line = sock.timed_read(23, "", tout > 0.0 ? tout : 0)
26
26
  when %r{^HTTP/\d\.\d\s+(2\d\d)\s} # success!
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: binary -*-
2
2
  # internal implementation details here, do not rely on them in your code
3
+ require 'io/wait'
3
4
 
4
5
  class MogileFS::Socket < Socket
5
6
  include MogileFS::SocketCommon
@@ -15,16 +16,20 @@ class MogileFS::Socket < Socket
15
16
 
16
17
  def self.tcp(host, port, timeout = 5)
17
18
  sock = start(host, port)
18
- unless IO.select(nil, [ sock ], nil, timeout)
19
+ unless sock.wait_writable(timeout)
19
20
  sock.close
20
21
  raise MogileFS::Timeout, 'socket connect timeout'
21
22
  end
22
23
  sock
23
24
  end
24
25
 
26
+ def wait_writable(timeout)
27
+ IO.select(nil, [ self ], nil, timeout)
28
+ end unless self.instance_methods.include?(:wait_writable) # Ruby <2.0.0
29
+
25
30
  def timed_read(len, dst = "", timeout = 5)
26
31
  begin
27
- IO.select([self], nil, nil, timeout) or unreadable_socket!(timeout)
32
+ wait_readable(timeout) or unreadable_socket!(timeout)
28
33
  return read_nonblock(len, dst)
29
34
  rescue Errno::EAGAIN
30
35
  rescue EOFError
@@ -34,7 +39,7 @@ class MogileFS::Socket < Socket
34
39
 
35
40
  def timed_peek(len, dst, timeout = 5)
36
41
  begin
37
- IO.select([self], nil, nil, timeout) or unreadable_socket!(timeout)
42
+ wait_readable(timeout) or unreadable_socket!(timeout)
38
43
  rc = recv_nonblock(len, Socket::MSG_PEEK)
39
44
  return rc.empty? ? nil : dst.replace(rc)
40
45
  rescue Errno::EAGAIN
@@ -61,8 +66,7 @@ class MogileFS::Socket < Socket
61
66
  buf = buf.slice(rc, buf.bytesize)
62
67
  end
63
68
  rescue Errno::EAGAIN
64
- IO.select(nil, [self], nil, timeout) or
65
- request_truncated!(written, expect, timeout)
69
+ wait_writable(timeout) or request_truncated!(written, expect, timeout)
66
70
  end while true
67
71
  end
68
72
  end
@@ -24,4 +24,4 @@ require 'timeout'
24
24
  # Timeout error class. Subclassing it from Timeout::Error is the only
25
25
  # reason we require the 'timeout' module, otherwise that module is
26
26
  # broken and worthless to us.
27
- class MogileFS::Timeout < Timeout::Error; end
27
+ MogileFS::Timeout = Class.new(Timeout::Error)
@@ -138,7 +138,7 @@ class TestMogFresh < Test::Unit::TestCase
138
138
  if IO.respond_to?(:copy_stream)
139
139
  # ensure we match IO.copy_stream semantics
140
140
  dst = StringIO.new
141
- IO.copy_stream(src, dst, *range)
141
+ IO.copy_stream(src.to_io, dst, *range)
142
142
  assert_equal dst.string, dst2.string
143
143
  assert_equal dst.string, client.get_file_data("key", nil, *range)
144
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mogilefs-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mogilefs-client hackers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: olddoc
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.4.5
129
+ rubygems_version: 2.4.8
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: client - MogileFS client library for Ruby