about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-10-08 13:11:47 -0700
committerEric Wong <normalperson@yhbt.net>2012-10-08 13:37:32 -0700
commit735093143695a8e0819d814cb54fbd72c22bfcee (patch)
tree4c28994468492c0ffe19aeba13082e5d42675f17
parenta309f22f835afe0e6be0e4e2f1a13eaead7434f2 (diff)
downloadmogilefs-client-735093143695a8e0819d814cb54fbd72c22bfcee.tar.gz
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
-rw-r--r--lib/mogilefs/admin.rb13
1 files 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
 
   ##