mogilefs-client 3.10.0 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.olddoc.yml +3 -4
- data/GIT-VERSION-GEN +1 -1
- data/README +13 -15
- data/examples/stale_fid_checker.rb +3 -1
- data/lib/mogilefs/admin.rb +1 -0
- data/lib/mogilefs/http_file.rb +4 -4
- data/lib/mogilefs/mogilefs.rb +9 -2
- data/lib/mogilefs/mysql.rb +3 -3
- data/lib/mogilefs/new_file/common.rb +6 -6
- data/lib/mogilefs/new_file/stream.rb +4 -4
- data/lib/mogilefs/new_file/writer.rb +1 -1
- data/lib/mogilefs/paths_size.rb +1 -1
- data/lib/mogilefs/socket_common.rb +14 -3
- data/mogilefs-client.gemspec +10 -10
- data/test/fresh.rb +5 -3
- data/test/{test_mogstored_rack.rb → test_cmogstored.rb} +50 -64
- data/test/test_nhp_compat.rb +25 -0
- metadata +13 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df67ca0268814f324ab52a02700ead9303cb7ce1
|
4
|
+
data.tar.gz: f593fa4c418f462993efe066cdd937012f23df9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6da0266d991711aee0b33fd1e93e90cf501407f9d4d7559a00ea9fc3e83923ad345ea32f0c0982febfdd3d54a3a605d9d3b0be004704681e3fb2746740471ba
|
7
|
+
data.tar.gz: 4f6d66be2a618be1831d6b83835452397cbce8c434bd26537ac5bf42901eeaf1f78835cccf07d35523819cf8c1e6fa16b3999b7ef85fe2ef09a6f2b157c1bbba
|
data/.olddoc.yml
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
---
|
2
|
-
cgit_url:
|
2
|
+
cgit_url: https://bogomips.org/mogilefs-client.git
|
3
3
|
git_url: git://bogomips.org/mogilefs-client.git
|
4
|
-
rdoc_url:
|
4
|
+
rdoc_url: https://bogomips.org/mogilefs-client
|
5
5
|
changelog_start: v1.2.1
|
6
|
-
private_email: e@80x24.org
|
7
6
|
public_email: mogilefs-client-public@bogomips.org
|
8
7
|
nntp_url: nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.ruby
|
9
|
-
ml_url:
|
8
|
+
ml_url: https://bogomips.org/mogilefs-client-public/
|
data/GIT-VERSION-GEN
CHANGED
data/README
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
= mogilefs-client - MogileFS client library for Ruby
|
2
2
|
|
3
3
|
A MogileFS client library for Ruby. MogileFS is an open source
|
4
|
-
distributed filesystem, see: http://mogilefs.org for more details.
|
5
|
-
library allows any Ruby application to read, write and delete
|
6
|
-
MogileFS instance.
|
4
|
+
distributed filesystem, see: http://mogilefs.org for more details.
|
5
|
+
This library allows any Ruby application to read, write and delete
|
6
|
+
files in a MogileFS instance.
|
7
7
|
|
8
8
|
== Links
|
9
9
|
|
10
|
-
rdoc ::
|
10
|
+
rdoc :: https://bogomips.org/mogilefs-client
|
11
11
|
mogilefs :: http://mogilefs.org/
|
12
12
|
list :: mailto:mogilefs-client-public@bogomips.org
|
13
13
|
list-cc :: mailto:mogile@googlegroups.com
|
14
|
-
list-archive ::
|
15
|
-
email :: mailto:e@80x24.org
|
14
|
+
list-archive :: https://bogomips.org/mogilefs-client-public
|
16
15
|
repo :: git://bogomips.org/mogilefs-client.git
|
17
|
-
|
16
|
+
https://bogomips.org/mogilefs-client.git
|
18
17
|
gitweb :: http://repo.or.cz/w/ruby-mogilefs-client.git
|
19
|
-
download ::
|
18
|
+
download :: https://bogomips.org/mogilefs-client/files/
|
20
19
|
|
21
20
|
== Install
|
22
21
|
|
@@ -43,20 +42,19 @@ is required or available to post:
|
|
43
42
|
|
44
43
|
mogilefs-client-public@bogomips.org
|
45
44
|
|
46
|
-
|
45
|
+
Users of anonymous remailers and other anonymity tools are welcome.
|
46
|
+
Participants will never be asked to reveal their identity.
|
47
|
+
|
48
|
+
List archives: https://bogomips.org/mogilefs-client-public/
|
47
49
|
|
48
50
|
We may also piggy-back onto the public MogileFS mailing list at
|
49
51
|
mogile@googlegroups.com for feedback (subscription required,
|
50
52
|
unfortunately)
|
51
53
|
|
52
|
-
If you wish to keep your issue secret, feel free to email the author at:
|
53
|
-
|
54
|
-
e@80x24.org
|
55
|
-
|
56
54
|
Do not expect us to read HTML mail under any circumstances.
|
57
55
|
|
58
56
|
== WARNING!
|
59
57
|
|
60
58
|
This client is only supported in HTTP mode. NFS mode was previously
|
61
|
-
supported in 1.3.x, but since MogileFS 2.x
|
62
|
-
|
59
|
+
supported in 1.3.x, but since MogileFS 2.x dropped support for NFS
|
60
|
+
in in 2006, this client does not support it.
|
@@ -34,7 +34,9 @@
|
|
34
34
|
end
|
35
35
|
|
36
36
|
adm = MogileFS::Admin.new(:hosts => trackers)
|
37
|
-
|
37
|
+
name = File.basename($0)
|
38
|
+
Net::HTTP::Persistent::VERSION >= 3.0 and name = { :name => name }
|
39
|
+
NHP = Net::HTTP::Persistent.new(name)
|
38
40
|
client = MogileFS::MogileFS.new(:hosts => trackers, :domain => "none")
|
39
41
|
|
40
42
|
def start_perdev_thread(pfx)
|
data/lib/mogilefs/admin.rb
CHANGED
data/lib/mogilefs/http_file.rb
CHANGED
@@ -54,7 +54,7 @@ def request_put(sock, uri, file_size, input = nil)
|
|
54
54
|
"Content-Length: #{file_size}\r\n\r\n")
|
55
55
|
rv = input ? MogileFS.io.copy_stream(@active = input, sock) : yield(sock)
|
56
56
|
else
|
57
|
-
trailers = @md5 ? "Trailer: Content-MD5\r\n" : ""
|
57
|
+
trailers = @md5 ? "Trailer: Content-MD5\r\n".freeze : "".freeze
|
58
58
|
sock.write("PUT #{uri.request_uri} HTTP/1.1\r\n" \
|
59
59
|
"Host: #{host_with_port}\r\n#{trailers}" \
|
60
60
|
"Transfer-Encoding: chunked\r\n\r\n")
|
@@ -143,14 +143,14 @@ def nhp_put(devid, uri)
|
|
143
143
|
end
|
144
144
|
|
145
145
|
put = Net::HTTP::Put.new(uri.path)
|
146
|
-
put["Content-Type"] = "application/octet-stream"
|
146
|
+
put["Content-Type".freeze] = "application/octet-stream".freeze
|
147
147
|
if md5 = @opts[:content_md5]
|
148
148
|
if md5.respond_to?(:call)
|
149
149
|
md5 = md5.call.strip
|
150
150
|
elsif md5 == :trailer
|
151
|
-
md5 = [ Digest::MD5.digest(string) ].pack("m").chomp!
|
151
|
+
md5 = [ Digest::MD5.digest(string) ].pack("m".freeze).chomp!
|
152
152
|
end
|
153
|
-
put["Content-MD5"] = md5
|
153
|
+
put["Content-MD5".freeze] = md5
|
154
154
|
end
|
155
155
|
put.body = string
|
156
156
|
res = @opts[:nhp_put].request(uri, put)
|
data/lib/mogilefs/mogilefs.rb
CHANGED
@@ -73,9 +73,9 @@ def initialize(args = {})
|
|
73
73
|
|
74
74
|
@get_file_data_timeout = args[:get_file_data_timeout] || 5
|
75
75
|
@new_file_max_time = args[:new_file_max_time] || 3600.0
|
76
|
-
@nhp_get =
|
76
|
+
@nhp_get = nhp_new('get')
|
77
77
|
@nhp_get.open_timeout = @nhp_get.read_timeout = @get_file_data_timeout
|
78
|
-
@nhp_put =
|
78
|
+
@nhp_put = nhp_new('put')
|
79
79
|
@nhp_put.open_timeout = @nhp_put.read_timeout = @new_file_max_time
|
80
80
|
|
81
81
|
raise ArgumentError, "you must specify a domain" unless @domain
|
@@ -548,4 +548,11 @@ def file_debug(args)
|
|
548
548
|
end
|
549
549
|
end
|
550
550
|
end
|
551
|
+
|
552
|
+
def nhp_new(name) # :nodoc:
|
553
|
+
Net::HTTP::Persistent::VERSION.to_f >= 3.0 and name = { :name => name }
|
554
|
+
MogileFS::NHP.new(name)
|
555
|
+
rescue NameError
|
556
|
+
MogileFS::NHP.new(name)
|
557
|
+
end
|
551
558
|
end
|
data/lib/mogilefs/mysql.rb
CHANGED
@@ -28,7 +28,7 @@ def initialize(args = {})
|
|
28
28
|
##
|
29
29
|
# Lists keys starting with +prefix+ follwing +after+ up to +limit+. If
|
30
30
|
# +after+ is nil the list starts at the beginning.
|
31
|
-
def _list_keys(domain, prefix = '', after = '', limit = 1000)
|
31
|
+
def _list_keys(domain, prefix = ''.freeze, after = ''.freeze, limit = 1000)
|
32
32
|
# this code is based on server/lib/MogileFS/Worker/Query.pm
|
33
33
|
dmid = get_dmid(domain)
|
34
34
|
|
@@ -43,7 +43,7 @@ def _list_keys(domain, prefix = '', after = '', limit = 1000)
|
|
43
43
|
end
|
44
44
|
|
45
45
|
raise MogileFS::Backend::InvalidCharsError if /[%\\]/ =~ prefix
|
46
|
-
prefix.gsub!(/_/, '\_')
|
46
|
+
prefix.gsub!(/_/, '\_'.freeze)
|
47
47
|
|
48
48
|
sql = <<-EOS
|
49
49
|
SELECT dkey,length,devcount FROM file
|
@@ -150,7 +150,7 @@ def refresh_device(force = false)
|
|
150
150
|
tmp[devid.to_i] = {
|
151
151
|
:hostip => hostip.freeze,
|
152
152
|
:altip => (altip || hostip).freeze,
|
153
|
-
:readable => (host_status == "alive" &&
|
153
|
+
:readable => (host_status == "alive".freeze &&
|
154
154
|
DEV_STATUS_READABLE.include?(dev_status)),
|
155
155
|
:http_port => http_port,
|
156
156
|
:http_get_port => http_get_port ? http_get_port.to_i : http_port,
|
@@ -7,14 +7,14 @@
|
|
7
7
|
|
8
8
|
module MogileFS::NewFile::Common
|
9
9
|
# :stopdoc:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
RetryableError = Class.new(MogileFS::Error)
|
11
|
+
EmptyResponseError = Class.new(RetryableError)
|
12
|
+
BadResponseError = Class.new(RetryableError)
|
13
|
+
UnparseableResponseError = Class.new(RetryableError)
|
14
14
|
class NoStorageNodesError < MogileFS::Error
|
15
15
|
def message; 'Unable to open socket to storage node'; end
|
16
16
|
end
|
17
|
-
|
17
|
+
NonRetryableError = Class.new(MogileFS::Error)
|
18
18
|
|
19
19
|
MD5_TRAILER_NODES = {} # :nodoc: # EXPERIMENTAL
|
20
20
|
|
@@ -23,7 +23,7 @@ def read_response(sock)
|
|
23
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
|
-
when %r{^HTTP/\d\.\d\s+(2\d\d)\s} # success!
|
26
|
+
when %r{^HTTP/\d\.\d\s+(?:2\d\d)\s} # success!
|
27
27
|
when nil
|
28
28
|
raise EmptyResponseError, 'Unable to read response line from server'
|
29
29
|
when %r{^HTTP/\d\.\d\s+(\d+)}
|
@@ -66,7 +66,7 @@ def commit
|
|
66
66
|
def start_sock(sock, uri)
|
67
67
|
host_with_port = "#{uri.host}:#{uri.port}"
|
68
68
|
headers = "PUT #{uri.request_uri} HTTP/1.1\r\n" \
|
69
|
-
"Host: #{host_with_port}\r\n"
|
69
|
+
"Host: #{host_with_port}\r\n"
|
70
70
|
|
71
71
|
content_md5 = @opts[:content_md5]
|
72
72
|
if String === content_md5
|
@@ -75,16 +75,16 @@ def start_sock(sock, uri)
|
|
75
75
|
:trailer == content_md5 ||
|
76
76
|
MD5_TRAILER_NODES[host_with_port]
|
77
77
|
@md5 = Digest::MD5.new
|
78
|
-
headers << "Trailer: Content-MD5\r\n"
|
78
|
+
headers << "Trailer: Content-MD5\r\n".freeze
|
79
79
|
end
|
80
80
|
|
81
81
|
if ! @md5 && clen = @opts[:content_length]
|
82
82
|
headers << "Content-Length: #{clen}\r\n"
|
83
83
|
else
|
84
|
-
headers << "Transfer-Encoding: chunked\r\n"
|
84
|
+
headers << "Transfer-Encoding: chunked\r\n".freeze
|
85
85
|
end
|
86
86
|
|
87
|
-
sock.write(headers << "\r\n")
|
87
|
+
sock.write(headers << "\r\n".freeze)
|
88
88
|
end
|
89
89
|
|
90
90
|
alias syswrite write
|
data/lib/mogilefs/paths_size.rb
CHANGED
@@ -23,18 +23,17 @@ def request_truncated!(written, expect, timeout)
|
|
23
23
|
"request truncated (sent #{written} expected #{expect} timeout=#{timeout})"
|
24
24
|
end
|
25
25
|
|
26
|
-
SEP_RE = /\A(.*?#{Regexp.escape("\n")})/
|
27
26
|
def timed_gets(timeout = 5)
|
28
27
|
unless defined?(@rbuf) && @rbuf
|
29
28
|
@rbuf = timed_read(1024, "", timeout) or return # EOF
|
30
29
|
end
|
31
30
|
begin
|
32
|
-
@rbuf.sub!(
|
31
|
+
@rbuf.sub!(/\A(.*\n)/o, "".freeze) and return $1
|
33
32
|
tmp ||= ""
|
34
33
|
if timed_read(1024, tmp, timeout)
|
35
34
|
@rbuf << tmp
|
36
35
|
else
|
37
|
-
# EOF, return the last buffered bit even without
|
36
|
+
# EOF, return the last buffered bit even without separatar matching
|
38
37
|
# (not ideal for MogileFS, this is an error)
|
39
38
|
return @rbuf.empty? ? nil : @rbuf.slice!(0, @rbuf.size)
|
40
39
|
end
|
@@ -56,4 +55,16 @@ def read(size, buf = "", timeout = 5)
|
|
56
55
|
def readpartial(size, buf = "", timeout = 5)
|
57
56
|
timed_read(size, buf, timeout) or raise EOFError, "end of file reached"
|
58
57
|
end
|
58
|
+
|
59
|
+
# Workaround for https://bugs.ruby-lang.org/issues/13085
|
60
|
+
# (excessive garbage from IO#write)
|
61
|
+
# This looks like it will be fixed in Ruby 2.5 final.
|
62
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' &&
|
63
|
+
RUBY_VERSION.to_f >= 2.2 && RUBY_VERSION.to_f <= 2.4
|
64
|
+
def write(buf)
|
65
|
+
# Blocking TCP writes would error out long before one day,
|
66
|
+
# and MogileFS won't allow file creations which take over a day.
|
67
|
+
timed_write(buf, 86400)
|
68
|
+
end
|
69
|
+
end
|
59
70
|
end
|
data/mogilefs-client.gemspec
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
ENV["VERSION"] or abort "VERSION= must be specified"
|
2
|
-
require 'olddoc'
|
3
1
|
$LOAD_PATH << 'lib'
|
4
|
-
require 'mogilefs'
|
5
|
-
extend Olddoc::Gemspec
|
6
|
-
name, summary, title = readme_metadata
|
2
|
+
require 'mogilefs' # for MogileFS::VERSION
|
7
3
|
Gem::Specification.new do |s|
|
8
4
|
manifest = File.read('.manifest').split(/\n/)
|
9
5
|
s.name = 'mogilefs-client'
|
10
6
|
s.version = MogileFS::VERSION
|
11
7
|
s.executables = %w(mog)
|
12
8
|
s.authors = ["#{s.name} hackers"]
|
13
|
-
s.summary =
|
14
|
-
s.description =
|
15
|
-
|
9
|
+
s.summary = 'MogileFS client library for Ruby'
|
10
|
+
s.description = <<EOF
|
11
|
+
A MogileFS client library for Ruby. MogileFS is an open source
|
12
|
+
distributed filesystem, see: http://mogilefs.org for more details.
|
13
|
+
This library allows any Ruby application to read, write and delete
|
14
|
+
files in a MogileFS instance.
|
15
|
+
EOF
|
16
|
+
s.email = 'mogilefs-client-public@bogomips.org'
|
16
17
|
s.files = manifest
|
17
|
-
s.
|
18
|
-
s.homepage = Olddoc.config['rdoc_url']
|
18
|
+
s.homepage = 'https://bogomips.org/mogilefs-client/'
|
19
19
|
s.license = 'BSD-3-Clause'
|
20
20
|
end
|
data/test/fresh.rb
CHANGED
@@ -42,7 +42,7 @@ def setup_mogilefs(plugins = nil)
|
|
42
42
|
50.times do
|
43
43
|
break if File.size(@mogstored_pid.path) > 0
|
44
44
|
sleep 0.1
|
45
|
-
end
|
45
|
+
end unless Integer === @mogstored_pid
|
46
46
|
end
|
47
47
|
|
48
48
|
def start_tracker
|
@@ -108,10 +108,12 @@ def add_host_device_domain
|
|
108
108
|
|
109
109
|
def teardown_mogilefs
|
110
110
|
return if $$ != @teardown_pid
|
111
|
-
if @mogstored_pid
|
111
|
+
if Integer === @mogstored_pid
|
112
|
+
pid = @mogstored_pid
|
113
|
+
else
|
112
114
|
pid = File.read(@mogstored_pid.path).to_i
|
113
|
-
Process.kill(:TERM, pid) if pid > 0
|
114
115
|
end
|
116
|
+
Process.kill(:TERM, pid) if pid > 0
|
115
117
|
if @mogilefsd_pid
|
116
118
|
s = TCPSocket.new(@test_host, @tracker_port)
|
117
119
|
s.write "!shutdown\r\n"
|
@@ -1,18 +1,11 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
require "./test/fresh"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
ok = true
|
7
|
-
rescue LoadError
|
8
|
-
ok = false
|
9
|
-
end
|
10
|
-
|
11
|
-
class TestMogstoredRack < Test::Unit::TestCase
|
3
|
+
|
4
|
+
# cmogstored allows Content-Range on PUT, unlike the original mogstored
|
5
|
+
class Test_cmogstored < Test::Unit::TestCase
|
12
6
|
include TestFreshSetup
|
13
|
-
|
14
|
-
|
15
|
-
end
|
7
|
+
alias setup setup_mogilefs
|
8
|
+
alias teardown teardown_mogilefs
|
16
9
|
|
17
10
|
def test_range_put_new_file
|
18
11
|
add_host_device_domain
|
@@ -34,6 +27,25 @@ def test_range_put_new_file
|
|
34
27
|
assert_equal "a\nb\nc\nd\ne\n", client.get_file_data("puts")
|
35
28
|
end
|
36
29
|
|
30
|
+
def test_garbage
|
31
|
+
add_host_device_domain
|
32
|
+
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain,
|
33
|
+
:timeout => 60
|
34
|
+
nr = 1024 * 1024 * 1024
|
35
|
+
client.new_file('giant', :largefile => :stream,
|
36
|
+
:content_length => nr) do |io|
|
37
|
+
assert_instance_of MogileFS::NewFile::Stream, io
|
38
|
+
zero = Zero.new
|
39
|
+
before = GC.count
|
40
|
+
wr = IO.copy_stream(zero, io, nr)
|
41
|
+
after = GC.count
|
42
|
+
assert_equal nr, wr
|
43
|
+
assert_in_delta before, after, 1
|
44
|
+
end
|
45
|
+
end if IO.respond_to?(:copy_stream) && defined?(Zero) &&
|
46
|
+
GC.respond_to?(:count) && defined?(RUBY_ENGINE) &&
|
47
|
+
RUBY_ENGINE == 'ruby' && ENV['TEST_EXPENSIVE'].to_i != 0
|
48
|
+
|
37
49
|
def test_stream_new_file
|
38
50
|
add_host_device_domain
|
39
51
|
client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
|
@@ -136,60 +148,34 @@ def setup_mogstored
|
|
136
148
|
@mogstored_http = TCPServer.new(@test_host, 0)
|
137
149
|
@mogstored_mgmt_port = @mogstored_mgmt.addr[1]
|
138
150
|
@mogstored_http_port = @mogstored_http.addr[1]
|
139
|
-
@mogstored_conf = Tempfile.new(["mogstored", "conf"])
|
140
|
-
@mogstored_pid = Tempfile.new(["mogstored", "pid"])
|
141
|
-
@mogstored_conf.write <<EOF
|
142
|
-
pidfile = #{@mogstored_pid.path}
|
143
|
-
maxconns = 1000
|
144
|
-
mgmtlisten = #@test_host:#{@mogstored_mgmt_port}
|
145
|
-
server = none
|
146
|
-
docroot = #@docroot
|
147
|
-
EOF
|
148
|
-
@mogstored_conf.flush
|
149
|
-
@mogstored_mgmt.close
|
150
|
-
|
151
|
-
unicorn_setup
|
152
|
-
|
153
|
-
x!("mogstored", "--daemon", "--config=#{@mogstored_conf.path}")
|
154
|
-
wait_for_port @mogstored_mgmt_port
|
155
|
-
end
|
156
151
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
require "mogstored_rack"
|
171
|
-
listen "#@test_host:#{@mogstored_http_port}"
|
172
|
-
pid "#{@unicorn_pid.path}"
|
173
|
-
stderr_path "#{@unicorn_stderr.path}"
|
174
|
-
stdout_path "#{@unicorn_stdout.path}"
|
175
|
-
rewindable_input false
|
176
|
-
EOF
|
177
|
-
@unicorn_conf.flush
|
178
|
-
|
179
|
-
@mogstored_http.close
|
180
|
-
x!("unicorn", "-E", "deployment",
|
181
|
-
"--daemon", "--config", @unicorn_conf.path, @ru.path)
|
182
|
-
wait_for_port @mogstored_http_port
|
183
|
-
40.times do
|
184
|
-
break if File.size(@unicorn_pid.path) > 0
|
185
|
-
sleep 0.1
|
152
|
+
@mogstored_pid = fork do
|
153
|
+
mgmt_fd = @mogstored_mgmt.fileno
|
154
|
+
http_fd = @mogstored_http.fileno
|
155
|
+
args = []
|
156
|
+
ENV["CMOGSTORED_FD"] = "#{mgmt_fd},#{http_fd}"
|
157
|
+
if @mogstored_mgmt.respond_to?(:close_on_exec=)
|
158
|
+
@mogstored_mgmt.close_on_exec = @mogstored_http.close_on_exec = false
|
159
|
+
args << { mgmt_fd => mgmt_fd, http_fd => http_fd }
|
160
|
+
end
|
161
|
+
$stderr.reopen('/dev/null', 'a')
|
162
|
+
exec "cmogstored", "--httplisten=#@test_host:#@mogstored_http_port",
|
163
|
+
"--mgmtlisten=#@test_host:#@mogstored_mgmt_port",
|
164
|
+
"--maxconns=1000", "--docroot=#@docroot", *args
|
186
165
|
end
|
187
166
|
end
|
167
|
+
end if `which cmogstored`.chomp.size > 0
|
168
|
+
|
169
|
+
# The goal of this is to use a synthetic (non-IO) reader
|
170
|
+
# to trigger the read/write loop of IO.copy_stream,
|
171
|
+
# bypassing in-kernel mechanisms like sendfile for zero copy,
|
172
|
+
# so we wrap the /dev/zero IO object:
|
173
|
+
class Zero
|
174
|
+
def initialize
|
175
|
+
@in = File.open('/dev/zero', 'rb')
|
176
|
+
end
|
188
177
|
|
189
|
-
def
|
190
|
-
|
191
|
-
Process.kill(:QUIT, pid) if pid > 0
|
192
|
-
teardown_mogilefs
|
193
|
-
puts(@unicorn_stderr.read) if $DEBUG
|
178
|
+
def read(len, buf)
|
179
|
+
@in.read(len, buf)
|
194
180
|
end
|
195
|
-
end if
|
181
|
+
end if File.readable?('/dev/zero')
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TestNhpCompat < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_nhp_compat
|
6
|
+
ver_test_nhp('~> 2.9')
|
7
|
+
ver_test_nhp('~> 3.0')
|
8
|
+
end
|
9
|
+
|
10
|
+
def ver_test_nhp(verspec)
|
11
|
+
pid = fork do
|
12
|
+
begin
|
13
|
+
gem 'net-http-persistent', verspec
|
14
|
+
rescue LoadError => e
|
15
|
+
warn "SKIPPING net-http-persistent #{verspec}\n" \
|
16
|
+
"#{e.message} (#{e.class})\n"
|
17
|
+
end
|
18
|
+
require 'mogilefs'
|
19
|
+
mg = MogileFS::MogileFS.new :hosts => %w(127.0.0.1:7500), :domain => 'x'
|
20
|
+
exit!(Net::HTTP::Persistent === mg.nhp_new('foo'))
|
21
|
+
end
|
22
|
+
_, status = Process.waitpid2(pid)
|
23
|
+
assert status.success?, status.inspect
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,35 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogilefs-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.11.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:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
name: olddoc
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
|
-
description: |-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |
|
28
14
|
A MogileFS client library for Ruby. MogileFS is an open source
|
29
|
-
distributed filesystem, see: http://mogilefs.org for more details.
|
30
|
-
library allows any Ruby application to read, write and delete
|
31
|
-
MogileFS instance.
|
32
|
-
email:
|
15
|
+
distributed filesystem, see: http://mogilefs.org for more details.
|
16
|
+
This library allows any Ruby application to read, write and delete
|
17
|
+
files in a MogileFS instance.
|
18
|
+
email: mogilefs-client-public@bogomips.org
|
33
19
|
executables:
|
34
20
|
- mog
|
35
21
|
extensions: []
|
@@ -94,6 +80,7 @@ files:
|
|
94
80
|
- test/test_backend.rb
|
95
81
|
- test/test_bigfile.rb
|
96
82
|
- test/test_client.rb
|
83
|
+
- test/test_cmogstored.rb
|
97
84
|
- test/test_db_backend.rb
|
98
85
|
- test/test_fresh.rb
|
99
86
|
- test/test_http_reader.rb
|
@@ -103,11 +90,11 @@ files:
|
|
103
90
|
- test/test_mogilefs_integration_list_keys.rb
|
104
91
|
- test/test_mogilefs_socket_kgio.rb
|
105
92
|
- test/test_mogilefs_socket_pure.rb
|
106
|
-
- test/test_mogstored_rack.rb
|
107
93
|
- test/test_mogtool_bigfile.rb
|
108
94
|
- test/test_mysql.rb
|
95
|
+
- test/test_nhp_compat.rb
|
109
96
|
- test/test_pool.rb
|
110
|
-
homepage:
|
97
|
+
homepage: https://bogomips.org/mogilefs-client/
|
111
98
|
licenses:
|
112
99
|
- BSD-3-Clause
|
113
100
|
metadata: {}
|
@@ -127,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
114
|
version: '0'
|
128
115
|
requirements: []
|
129
116
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.6.
|
117
|
+
rubygems_version: 2.6.10
|
131
118
|
signing_key:
|
132
119
|
specification_version: 4
|
133
|
-
summary:
|
120
|
+
summary: MogileFS client library for Ruby
|
134
121
|
test_files: []
|