[Backgroundrb-devel] Query All Worker

Orion Delwaterman orion at mh2o.com
Tue Jan 22 12:31:59 EST 2008


Hi Hemant,

I just checked out the trunk into my project and ran my test again with
the same results.  I double checked that I have the latest code from the
trunk:

Worker:
class OriontestWorker < BackgrounDRb::MetaWorker
  set_worker_name :oriontest_worker
#  set_no_auto_load true
  
  def create(args = nil)
    # this method is called, when worker is loaded for the first time
    register_status(rand(200))
    res = RAILS_ENV
    log res
    register_result(res)
  end
  
  def get_methods
    self.methods.sort
  end
  
  def test_results
    res = rand(200)
    log res
    register_result(res)
    res
  end
  
  def get_msg_writer
    self.msg_writer.inspect
  end
  
  def get_worker_proxy
    self.class.worker_proxy.inspect
  end
  
end

IRB:
[orion at OrionFoot hydra]$ ruby script/console
Loading development environment.
>> MiddleMan.query_all_workers
=> {:log_worker=>nil, :oriontest_worker=>nil}
>> MiddleMan.send_request :worker => :oriontest_worker, :worker_method
=> :test_results
=> {:data=>69, :type=>:response, :client_signature=>14}
>> MiddleMan.query_all_workers
=> {:log_worker=>nil, :oriontest_worker=>nil}

I've taken a look through the source code and found it somewhat
confusing.  I saw the bug fix in server/master_worker.rb (line 67):

    def query_all_worker_status(p_data)
      dumpable_status = { }
      reactor.live_workers.each { |key,value| dumpable_status[key] =
value.worker_status }
      send_object(dumpable_status)
    end 
   
was changed to

   def query_all_worker_status(p_data)
      dumpable_status = { }
      reactor.live_workers.each { |key,value| dumpable_status[key] =
reactor.result_hash[key] }
      send_object(dumpable_status)
    end


However if you take a look at framework/meta_pimp.rb (line 37) you can
see that the results aren't saved on the reactor:

  def save_worker_result(data_options = { })
    @worker_result = data_options[:data]
  end

and if you look just below that on line 41 you see:

  def save_worker_status(data_options = { })
    # @worker_status = data_options[:data]
    reactor.update_result(worker_key,data_options[:data])
  end

It's confusing to see the save_worker_status() use the reactor's result
object to store its status, and also have a method save_worker_result().

This is where I get really confused about the method
'query_all_workers()'?  Previous you said that '[query_all_workers()]
returns status/result objects for all the available workers.'  This is a
little confusing because the workers have two methods: register_status()
(which I presume is supposed to record what the worker is currently
doing e.g. idle, processing, completed, etc.), and register_results
(which I presume is supposed to hold the results of the worker).

Is the results object of the workers a holdover from the 0.2.X versions?
Is the results object and the status object supposed to be the same? Or
are they different and the nomenclature is just a bit confusing, and
query_all_workers() is supposed to return the status of the worker?

Also I just wanted to say, I know how hard it can be to take over an
opensource project.  I applaud you for what you are doing, I am just
trying to clarify the situation.  I am also happy to try and resolve
this bug and give you a diff, but I'd like to know what you want to do
with results vs. status thing I mentioned above.

Orion


-----Original Message-----
From: hemant [mailto:gethemant at gmail.com] 
Sent: Tuesday, January 22, 2008 4:47 AM
To: Orion Delwaterman
Cc: backgroundrb-devel at rubyforge.org
Subject: Re: [Backgroundrb-devel] Query All Worker

Hi Orion,

There was a bug with query_all_workers, I fixed it. So you can sync
with latest source code from trunk and get it working.

On Jan 21, 2008 9:33 PM, Orion Delwaterman <orion at mh2o.com> wrote:
> Whoops mixup in my code here, I fixed it but I am still getting the
same
> issue where either register_result does not properly log the result or
> query_all_workers() is not returning the result:
>
> CODE:
>
> class OriontestWorker < BackgrounDRb::MetaWorker
>   set_worker_name :oriontest_worker
> #  set_no_auto_load true
>
>   def create(args = nil)
>     # this method is called, when worker is loaded for the first time
>     register_status(rand(200))
>     res = RAILS_ENV
>     log res
>     register_result(res)
>   end
>
>   def get_methods
>     self.methods.sort
>   end
>
>   def test_results
>     res = rand(200)
>     log res
>     register_result(res)
>     res
>   end
>
>   def get_msg_writer
>     self.msg_writer.inspect
>   end
>
> end
>
> IRB:
>
> [orion at OrionFoot hydra]$ ruby script/console
> Loading development environment.
> >> MiddleMan.query_all_workers
> => {:log_worker=>nil, :oriontest_worker=>nil}
> >> MiddleMan.send_request :worker => :oriontest_worker, :worker_method
> => :test_results
> => {:data=>73, :client_signature=>12, :type=>:response}
> >> MiddleMan.query_all_workers
> => {:log_worker=>nil, :oriontest_worker=>nil}
> >>
>
> -----Original Message-----
> From: Orion Delwaterman
> Sent: Monday, January 21, 2008 10:12 AM
> To: 'hemant'
> Cc: backgroundrb-devel at rubyforge.org
>
> Subject: RE: [Backgroundrb-devel] Query All Worker
>
> Maybe I am doing something wrong but query_all_workers() does not
appear
> to return any results from my workers.  Does the results object have
to
> be some kind of hash or is this just some weird bug?
>
> Worker:
>
> class OriontestWorker < BackgrounDRb::MetaWorker
>   set_worker_name :oriontest_worker
> #  set_no_auto_load true
>
>   def create(args = nil)
>     # this method is called, when worker is loaded for the first time
>   end
>
>   def get_random
>     register_status(rand(200))
>     register_result(RAILS_ENV)
>     true
>   end
>
> end
>
> IRB testing:
> Loading development environment.
> >> MiddleMan.query_all_workers
> => {:log_worker=>nil, :oriontest_worker=>nil}
>
> -----Original Message-----
> From: hemant [mailto:gethemant at gmail.com]
> Sent: Saturday, January 19, 2008 6:58 AM
> To: Orion Delwaterman
> Cc: backgroundrb-devel at rubyforge.org
> Subject: Re: [Backgroundrb-devel] Query All Worker
>
> On Jan 19, 2008 4:42 AM, Orion Delwaterman <orion at mh2o.com> wrote:
> >
> >
> >
> >
> > What does the method query_all_workers() do?  There is no
> documentation on
> > what this method returns (1.0.1 version).
>
> It returns status/result objects for all the available workers.
>



-- 
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org


More information about the Backgroundrb-devel mailing list