From 735093143695a8e0819d814cb54fbd72c22bfcee Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 8 Oct 2012 13:11:47 -0700 Subject: admin: minor speedups for get_hosts, get_devices, list_fids By avoiding #grep, installations with thousands of hosts/devices should be sped up considerably. list_fids should be roughly twice as fast. This is a followup to commit a309f22f835afe0e6be0e4e2f1a13eaead7434f2 --- lib/mogilefs/admin.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/mogilefs/admin.rb b/lib/mogilefs/admin.rb index 0a90cd6..1b16765 100644 --- a/lib/mogilefs/admin.rb +++ b/lib/mogilefs/admin.rb @@ -38,8 +38,9 @@ class MogileFS::Admin < MogileFS::Client def get_hosts(hostid = nil) to_i = %w(hostid http_port http_get_port) - clean('hosts', 'host', - @backend.get_hosts(hostid ? { :hostid => hostid } : {}), true, to_i) + want = %w(status hostip hostname altip altmask).concat(to_i) + rv = @backend.get_hosts(hostid ? { :hostid => hostid } : {}) + clean('hosts', 'host', rv, true, to_i, want) end ## @@ -60,8 +61,9 @@ class MogileFS::Admin < MogileFS::Client def get_devices(devid = nil) to_i = %w(mb_asof mb_free mb_used mb_total devid weight hostid) + want = %w(status).concat(to_i) rv = @backend.get_devices(devid ? { :devid => devid } : {}) - rv = clean('devices', 'dev', rv, true, to_i) + rv = clean('devices', 'dev', rv, true, to_i, want) rv.each do |row| u = row["utilization"] and row["utilization"] = nil == u ? nil : u.to_f @@ -96,9 +98,10 @@ class MogileFS::Admin < MogileFS::Client def list_fids(from_fid, count = 100) to_i = %w(fid devcount length) + want = %w(domain class key).concat(to_i) + rv = @backend.list_fids(:from => from_fid, :to => count) # :to is now :count internally in mogilefsd - clean('fid_count', 'fid_', - @backend.list_fids(:from => from_fid, :to => count), true, to_i) + clean('fid_count', 'fid_', rv, true, to_i, want) end ## -- cgit v1.2.3-24-ge0c7