mogilefs-client 3.2.0.rc1 → 3.2.0

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-rc1"
4
+ DEF_VER = "v3.2.0"
5
5
  vn = DEF_VER
6
6
 
7
7
  # First see if there is a version file (included in release tarballs),
@@ -37,7 +37,7 @@ class MogileFS::Admin < MogileFS::Client
37
37
  # "altmask"=>""}]
38
38
 
39
39
  def get_hosts(hostid = nil)
40
- to_i = { "hostid" => true, "http_port" => true, "http_get_port" => true }
40
+ to_i = %w(hostid http_port http_get_port)
41
41
  clean('hosts', 'host',
42
42
  @backend.get_hosts(hostid ? { :hostid => hostid } : {}), true, to_i)
43
43
  end
@@ -59,16 +59,18 @@ class MogileFS::Admin < MogileFS::Client
59
59
  # "mb_total"=>666666}]
60
60
 
61
61
  def get_devices(devid = nil)
62
- to_i = {
63
- "mb_asof" => true, "mb_free" => true,
64
- "mb_used" => true, "mb_total" => true ,
65
- "devid" => true, "weight" => true, "hostid" => true
66
- }
62
+ to_i = %w(mb_asof mb_free mb_used mb_total devid weight hostid)
67
63
  rv = @backend.get_devices(devid ? { :devid => devid } : {})
68
64
  rv = clean('devices', 'dev', rv, true, to_i)
69
65
  rv.each do |row|
70
66
  u = row["utilization"] and
71
67
  row["utilization"] = nil == u ? nil : u.to_f
68
+ case row["reject_bad_md5"]
69
+ when "1"
70
+ row["reject_bad_md5"] = true
71
+ when "0"
72
+ row["reject_bad_md5"] = false
73
+ end
72
74
  end
73
75
  end
74
76
 
@@ -93,7 +95,7 @@ class MogileFS::Admin < MogileFS::Client
93
95
  # "key"=>"new_new_key"}]
94
96
 
95
97
  def list_fids(from_fid, count = 100)
96
- to_i = { "fid" => true, "devcount" => true, "length" => true }
98
+ to_i = %w(fid devcount length)
97
99
  # :to is now :count internally in mogilefsd
98
100
  clean('fid_count', 'fid_',
99
101
  @backend.list_fids(:from => from_fid, :to => count), true, to_i)
@@ -163,7 +165,7 @@ class MogileFS::Admin < MogileFS::Client
163
165
  have_replpolicy = false
164
166
 
165
167
  domains = {}
166
- to_i = { "mindevcount" => true }
168
+ to_i = %w(mindevcount)
167
169
  (1..res['domains'].to_i).each do |i|
168
170
  domain = clean "domain#{i}classes", "domain#{i}class", res, false, to_i
169
171
 
@@ -254,6 +256,26 @@ class MogileFS::Admin < MogileFS::Client
254
256
  ! @backend.delete_host(:host => host).nil?
255
257
  end
256
258
 
259
+ ##
260
+ # Creates device with Integer +devid+ on +host+
261
+ # +host+ may be an integer for hostid or String for hostname
262
+ def create_device(host, devid, opts = {})
263
+ raise MogileFS::ReadOnlyError if readonly?
264
+ opts = opts.dup
265
+
266
+ case host
267
+ when Integer
268
+ opts[:hostid] = host
269
+ when String
270
+ opts[:hostname] = host
271
+ else
272
+ raise ArgumentError, "host=#{host.inspect} is not a String or Integer"
273
+ end
274
+
275
+ opts[:devid] = devid
276
+ ! @backend.create_device(opts).nil?
277
+ end
278
+
257
279
  ##
258
280
  # Changes the device status of +device+ on +host+ to +state+ which can be
259
281
  # 'alive', 'down', or 'dead'.
@@ -263,6 +285,16 @@ class MogileFS::Admin < MogileFS::Client
263
285
  ! @backend.set_state(:host => host, :device => device, :state => state).nil?
264
286
  end
265
287
 
288
+ ##
289
+ # Changes the device weight of +device+ on +host+ to +weight+.
290
+ # +weight+ should be a non-negative Integer. Devices with higher
291
+ # +weight+ values are more likely to be chosen for reads and writes.
292
+ def change_device_weight(host, device, weight)
293
+ raise MogileFS::ReadOnlyError if readonly?
294
+ opts = { :host => host, :device => device, :weight => weight }
295
+ ! @backend.set_weight(opts).nil?
296
+ end
297
+
266
298
  # reschedules all deferred replication, returns a hash with the number
267
299
  # of files rescheduled:
268
300
  #
@@ -330,18 +362,21 @@ class MogileFS::Admin < MogileFS::Client
330
362
  # Returns:
331
363
  #
332
364
  # [{"status"=>"alive",
333
- # "http_get_port"=>"",
334
- # "http_port"=>"",
335
- # "hostid"=>"1",
336
- # "hostip"=>"",
365
+ # "http_get_port"=>nil,
366
+ # "http_port"=>7600,
367
+ # "hostid"=>1,
368
+ # "hostip"=>"192.168.1.3",
337
369
  # "hostname"=>"rur-1",
338
- # "remoteroot"=>"/mnt/mogilefs/rur-1",
339
370
  # "altip"=>"",
340
371
  # "altmask"=>""}]
341
372
 
342
373
  def clean(count, prefix, res, underscore = true, to_i = [])
343
374
  empty = ""
344
375
  underscore = underscore ? '_' : empty
376
+
377
+ # convert array to hash for O(1) lookups
378
+ to_i = to_i.inject({}) { |m,k| m[k] = m }
379
+
345
380
  keys = res.keys
346
381
  (1..res[count].to_i).map do |i|
347
382
  re = /^#{prefix}#{i}#{underscore}/
@@ -114,6 +114,7 @@ class MogileFS::Backend
114
114
  add_idempotent_command :list_fids
115
115
  add_idempotent_command :stats
116
116
  add_idempotent_command :get_domains
117
+ add_command :create_device
117
118
  add_command :create_domain
118
119
  add_command :delete_domain
119
120
  add_command :create_class
@@ -124,6 +125,7 @@ class MogileFS::Backend
124
125
  add_command :update_host
125
126
  add_command :delete_host
126
127
  add_command :set_state
128
+ add_command :set_weight
127
129
  add_command :replicate_now
128
130
 
129
131
  def shutdown_unlocked(do_raise = false) # :nodoc:
data/test/fresh.rb CHANGED
@@ -124,12 +124,21 @@ EOF
124
124
  assert File.directory?("#@docroot/dev2")
125
125
  yield_for_monitor_update { @admin.get_hosts.empty? or break }
126
126
 
127
- # TODO: allow adding devices via our MogileFS::Admin class
128
- mogadm!("device", "add", "me", "dev1")
127
+ me = @admin.get_hosts.find { |x| x["hostname"] == "me" }
128
+ assert_instance_of Hash, me, me.inspect
129
+ assert_kind_of Integer, me["hostid"], me
130
+ assert_equal true, @admin.create_device(me["hostid"], 1)
129
131
  yield_for_monitor_update { @admin.get_devices.empty? or break }
130
132
  wait_for_usage_file "dev1"
131
- mogadm!("device", "add", "me", "dev2")
133
+ assert_equal true, @admin.create_device("me", 2)
132
134
  wait_for_usage_file "dev2"
135
+
136
+ # MogileFS::Server 2.60+ shows reject_bad_md5 monitor status
137
+ dev = @admin.get_devices[0]
138
+ if dev.include?("reject_bad_md5")
139
+ assert [true, false].include?(dev["reject_bad_md5"])
140
+ end
141
+
133
142
  out = err = nil
134
143
  tries = 0
135
144
  begin
data/test/test_fresh.rb CHANGED
@@ -6,6 +6,12 @@ class TestMogFresh < Test::Unit::TestCase
6
6
  alias setup setup_mogilefs
7
7
  alias teardown teardown_mogilefs
8
8
 
9
+ def test_change_device_weight
10
+ add_host_device_domain
11
+ assert_equal true, @admin.change_device_weight("me", 1, 50)
12
+ assert_equal 50, @admin.get_devices(1)[0]["weight"]
13
+ end
14
+
9
15
  def test_list_keys_invalid_domain
10
16
  add_host_device_domain
11
17
  domain = @domain + ".non-existent"
metadata CHANGED
@@ -1,208 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mogilefs-client
3
- version: !ruby/object:Gem::Version
4
- version: !binary |-
5
- My4yLjAucmMx
6
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 3
8
+ - 2
9
+ - 0
10
+ version: 3.2.0
7
11
  platform: ruby
8
- authors:
12
+ authors:
9
13
  - Eric Wong
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
- date: 2012-06-15 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-06-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
16
21
  name: hoe
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: '2.12'
23
- type: :development
24
22
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
26
24
  none: false
27
- requirements:
25
+ requirements:
28
26
  - - ~>
29
- - !ruby/object:Gem::Version
30
- version: '2.12'
31
- description: ! '["A MogileFS client library for Ruby. MogileFS is an open source\ndistributed
32
- filesystem, see: http://mogilefs.org for more details. This\nlibrary allows any
33
- Ruby application to read, write and delete files in a\nMogileFS instance."]'
34
- email:
27
+ - !ruby/object:Gem::Version
28
+ hash: 27
29
+ segments:
30
+ - 2
31
+ - 12
32
+ version: "2.12"
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: |-
36
+ A MogileFS client library for Ruby. MogileFS is an open source
37
+ distributed filesystem, see: http://mogilefs.org for more details. This
38
+ library allows any Ruby application to read, write and delete files in a
39
+ MogileFS instance.
40
+ email:
35
41
  - normalperson@yhbt.net
36
- executables:
37
- - !binary |-
38
- bW9n
42
+ executables:
43
+ - mog
39
44
  extensions: []
40
- extra_rdoc_files:
41
- - !binary |-
42
- TWFuaWZlc3QudHh0
43
- files:
44
- - !binary |-
45
- LmRvY3VtZW50
46
- - !binary |-
47
- LmdpdGlnbm9yZQ==
48
- - !binary |-
49
- Lndyb25nZG9jLnltbA==
50
- - !binary |-
51
- R0lULVZFUlNJT04tR0VO
52
- - !binary |-
53
- R05VbWFrZWZpbGU=
54
- - !binary |-
55
- SEFDS0lORw==
56
- - !binary |-
57
- SGlzdG9yeQ==
58
- - !binary |-
59
- TElDRU5TRQ==
60
- - !binary |-
61
- UkVBRE1F
62
- - !binary |-
63
- UmFrZWZpbGU=
64
- - !binary |-
65
- VE9ETw==
66
- - !binary |-
67
- YmluL21vZw==
68
- - !binary |-
69
- ZXhhbXBsZXMvc3RhbGVfZmlkX2NoZWNrZXIucmI=
70
- - !binary |-
71
- bGliL21vZ2lsZWZzLnJi
72
- - !binary |-
73
- bGliL21vZ2lsZWZzL2FkbWluLnJi
74
- - !binary |-
75
- bGliL21vZ2lsZWZzL2JhY2tlbmQucmI=
76
- - !binary |-
77
- bGliL21vZ2lsZWZzL2JpZ2ZpbGUucmI=
78
- - !binary |-
79
- bGliL21vZ2lsZWZzL2JpZ2ZpbGUvZmlsdGVyLnJi
80
- - !binary |-
81
- bGliL21vZ2lsZWZzL2NodW5rZXIucmI=
82
- - !binary |-
83
- bGliL21vZ2lsZWZzL2NsaWVudC5yYg==
84
- - !binary |-
85
- bGliL21vZ2lsZWZzL2NvcHlfc3RyZWFtLnJi
86
- - !binary |-
87
- bGliL21vZ2lsZWZzL2h0dHBfZmlsZS5yYg==
88
- - !binary |-
89
- bGliL21vZ2lsZWZzL2h0dHBfcmVhZGVyLnJi
90
- - !binary |-
91
- bGliL21vZ2lsZWZzL21vZ2lsZWZzLnJi
92
- - !binary |-
93
- bGliL21vZ2lsZWZzL215c3FsLnJi
94
- - !binary |-
95
- bGliL21vZ2lsZWZzL25ld19maWxlLnJi
96
- - !binary |-
97
- bGliL21vZ2lsZWZzL25ld19maWxlL2NvbW1vbi5yYg==
98
- - !binary |-
99
- bGliL21vZ2lsZWZzL25ld19maWxlL2NvbnRlbnRfcmFuZ2UucmI=
100
- - !binary |-
101
- bGliL21vZ2lsZWZzL25ld19maWxlL3N0cmVhbS5yYg==
102
- - !binary |-
103
- bGliL21vZ2lsZWZzL25ld19maWxlL3RlbXBmaWxlLnJi
104
- - !binary |-
105
- bGliL21vZ2lsZWZzL25ld19maWxlL3dyaXRlci5yYg==
106
- - !binary |-
107
- bGliL21vZ2lsZWZzL3BhdGhzX3NpemUucmI=
108
- - !binary |-
109
- bGliL21vZ2lsZWZzL3Bvb2wucmI=
110
- - !binary |-
111
- bGliL21vZ2lsZWZzL3NvY2tldC5yYg==
112
- - !binary |-
113
- bGliL21vZ2lsZWZzL3NvY2tldC9rZ2lvLnJi
114
- - !binary |-
115
- bGliL21vZ2lsZWZzL3NvY2tldC9wdXJlX3J1YnkucmI=
116
- - !binary |-
117
- bGliL21vZ2lsZWZzL3NvY2tldF9jb21tb24ucmI=
118
- - !binary |-
119
- bGliL21vZ2lsZWZzL3V0aWwucmI=
120
- - !binary |-
121
- c2V0dXAucmI=
122
- - !binary |-
123
- dGVzdC8uZ2l0aWdub3Jl
124
- - !binary |-
125
- dGVzdC9hZ2dyZWdhdGUucmI=
126
- - !binary |-
127
- dGVzdC9leGVjLnJi
128
- - !binary |-
129
- dGVzdC9mcmVzaC5yYg==
130
- - !binary |-
131
- dGVzdC9pbnRlZ3JhdGlvbi5yYg==
132
- - !binary |-
133
- dGVzdC9zZXR1cC5yYg==
134
- - !binary |-
135
- dGVzdC9zb2NrZXRfdGVzdC5yYg==
136
- - !binary |-
137
- dGVzdC90ZXN0X2FkbWluLnJi
138
- - !binary |-
139
- dGVzdC90ZXN0X2JhY2tlbmQucmI=
140
- - !binary |-
141
- dGVzdC90ZXN0X2JpZ2ZpbGUucmI=
142
- - !binary |-
143
- dGVzdC90ZXN0X2NsaWVudC5yYg==
144
- - !binary |-
145
- dGVzdC90ZXN0X2RiX2JhY2tlbmQucmI=
146
- - !binary |-
147
- dGVzdC90ZXN0X2ZyZXNoLnJi
148
- - !binary |-
149
- dGVzdC90ZXN0X2h0dHBfcmVhZGVyLnJi
150
- - !binary |-
151
- dGVzdC90ZXN0X21vZ2lsZWZzLnJi
152
- - !binary |-
153
- dGVzdC90ZXN0X21vZ2lsZWZzX2ludGVncmF0aW9uLnJi
154
- - !binary |-
155
- dGVzdC90ZXN0X21vZ2lsZWZzX2ludGVncmF0aW9uX2xhcmdlX3BpcGUucmI=
156
- - !binary |-
157
- dGVzdC90ZXN0X21vZ2lsZWZzX2ludGVncmF0aW9uX2xpc3Rfa2V5cy5yYg==
158
- - !binary |-
159
- dGVzdC90ZXN0X21vZ2lsZWZzX3NvY2tldF9rZ2lvLnJi
160
- - !binary |-
161
- dGVzdC90ZXN0X21vZ2lsZWZzX3NvY2tldF9wdXJlLnJi
162
- - !binary |-
163
- dGVzdC90ZXN0X21vZ3N0b3JlZF9yYWNrLnJi
164
- - !binary |-
165
- dGVzdC90ZXN0X21vZ3Rvb2xfYmlnZmlsZS5yYg==
166
- - !binary |-
167
- dGVzdC90ZXN0X215c3FsLnJi
168
- - !binary |-
169
- dGVzdC90ZXN0X3Bvb2wucmI=
170
- - !binary |-
171
- TWFuaWZlc3QudHh0
172
- - !binary |-
173
- Q2hhbmdlTG9n
174
- - !binary |-
175
- TkVXUw==
176
- - !binary |-
177
- bGliL21vZ2lsZWZzL3ZlcnNpb24ucmI=
45
+
46
+ extra_rdoc_files:
47
+ - Manifest.txt
48
+ files:
49
+ - .document
50
+ - .gitignore
51
+ - .wrongdoc.yml
52
+ - GIT-VERSION-GEN
53
+ - GNUmakefile
54
+ - HACKING
55
+ - History
56
+ - LICENSE
57
+ - README
58
+ - Rakefile
59
+ - TODO
60
+ - bin/mog
61
+ - examples/stale_fid_checker.rb
62
+ - lib/mogilefs.rb
63
+ - lib/mogilefs/admin.rb
64
+ - lib/mogilefs/backend.rb
65
+ - lib/mogilefs/bigfile.rb
66
+ - lib/mogilefs/bigfile/filter.rb
67
+ - lib/mogilefs/chunker.rb
68
+ - lib/mogilefs/client.rb
69
+ - lib/mogilefs/copy_stream.rb
70
+ - lib/mogilefs/http_file.rb
71
+ - lib/mogilefs/http_reader.rb
72
+ - lib/mogilefs/mogilefs.rb
73
+ - lib/mogilefs/mysql.rb
74
+ - lib/mogilefs/new_file.rb
75
+ - lib/mogilefs/new_file/common.rb
76
+ - lib/mogilefs/new_file/content_range.rb
77
+ - lib/mogilefs/new_file/stream.rb
78
+ - lib/mogilefs/new_file/tempfile.rb
79
+ - lib/mogilefs/new_file/writer.rb
80
+ - lib/mogilefs/paths_size.rb
81
+ - lib/mogilefs/pool.rb
82
+ - lib/mogilefs/socket.rb
83
+ - lib/mogilefs/socket/kgio.rb
84
+ - lib/mogilefs/socket/pure_ruby.rb
85
+ - lib/mogilefs/socket_common.rb
86
+ - lib/mogilefs/util.rb
87
+ - setup.rb
88
+ - test/.gitignore
89
+ - test/aggregate.rb
90
+ - test/exec.rb
91
+ - test/fresh.rb
92
+ - test/integration.rb
93
+ - test/setup.rb
94
+ - test/socket_test.rb
95
+ - test/test_admin.rb
96
+ - test/test_backend.rb
97
+ - test/test_bigfile.rb
98
+ - test/test_client.rb
99
+ - test/test_db_backend.rb
100
+ - test/test_fresh.rb
101
+ - test/test_http_reader.rb
102
+ - test/test_mogilefs.rb
103
+ - test/test_mogilefs_integration.rb
104
+ - test/test_mogilefs_integration_large_pipe.rb
105
+ - test/test_mogilefs_integration_list_keys.rb
106
+ - test/test_mogilefs_socket_kgio.rb
107
+ - test/test_mogilefs_socket_pure.rb
108
+ - test/test_mogstored_rack.rb
109
+ - test/test_mogtool_bigfile.rb
110
+ - test/test_mysql.rb
111
+ - test/test_pool.rb
112
+ - Manifest.txt
113
+ - ChangeLog
114
+ - NEWS
115
+ - lib/mogilefs/version.rb
178
116
  - .gemtest
179
117
  homepage: http://bogomips.org/mogilefs-client
180
118
  licenses: []
119
+
181
120
  post_install_message:
182
- rdoc_options:
121
+ rdoc_options:
183
122
  - --main
184
123
  - README
185
- require_paths:
124
+ require_paths:
186
125
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
126
+ required_ruby_version: !ruby/object:Gem::Requirement
188
127
  none: false
189
- requirements:
190
- - - ! '>='
191
- - !ruby/object:Gem::Version
192
- version: '0'
193
- required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
136
  none: false
195
- requirements:
196
- - - ! '>'
197
- - !ruby/object:Gem::Version
198
- version: 1.3.1
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
199
144
  requirements: []
145
+
200
146
  rubyforge_project: seattlerb
201
- rubygems_version: 1.8.23
147
+ rubygems_version: 1.8.24
202
148
  signing_key:
203
149
  specification_version: 3
204
150
  summary: MogileFS client library for Ruby
205
- test_files:
151
+ test_files:
206
152
  - test/test_http_reader.rb
207
153
  - test/test_mogilefs_integration_list_keys.rb
208
154
  - test/test_db_backend.rb