diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-12 09:22:56 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-12 09:27:41 +0000 |
commit | d48dcc1d1e4679cf7dbd428fa4d2e7932f9839d3 (patch) | |
tree | 6a566dadd9af948bf1f798fb4fcf139cd2e0d3b4 /lib/mogilefs/mogilefs.rb | |
parent | ec7e00ad0a277c3b760d0f88482108bd0624224e (diff) | |
download | mogilefs-client-d48dcc1d1e4679cf7dbd428fa4d2e7932f9839d3.tar.gz |
When multiple queryworkers are used in the tracker, it's possible to receive responses out-of-order. We need to hold onto responses while the pipeline is being processed and only make callbacks when they can be made in the order the keys were given to us in.
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 5f22152..cfbf082 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -250,10 +250,17 @@ class MogileFS::MogileFS < MogileFS::Client def list_keys_verbose(keys, block) # :nodoc: # emulate the MogileFS::Mysql interface, slowly... + ordered = keys.dup + ready = {} on_file_info = lambda do |info| Hash === info or raise info file_info_cleanup(info) - block.call(info["key"], info["length"], info["devcount"]) + + # deal with trackers with multiple queryworkers responding out-of-order + ready[info["key"]] = info + while info = ready.delete(ordered[0]) + block.call(ordered.shift, info["length"], info["devcount"]) + end end opts = { :domain => @domain } keys.each do |key| |