[Backgroundrb-devel] Query All Worker

Orion Delwaterman orion at mh2o.com
Tue Jan 22 17:48:07 EST 2008


Hi Hemant,

I am fine with removing the idea of results from BackgrounDRb.  I'll
adjust my code to work with that.

I just updated my BackgrounDRb but I the method register_result() is
still in the trunk (repository:
http://svn.devjavu.com/backgroundrb/trunk at revision 312). Do I have
the wrong repository or is something else going on with the subversion
server?

Orion

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

Hi Orion,

In trunk or new version of bdrb there is no register_result and hence
you are getting nil objects when quering the workers using
query_all_workers. I know perhaps its a bit confusing, but in new
version status and result objects are the same,

Also worker status is stored in reactor object, which is generally
updated through meta_pimp. I am glad that you poked through the code.

I know nomenclature is a bit confusing, but just accept the fact that
in new version, there is NO register_result method and status objects
have replaced result objects.

On Jan 22, 2008 11:01 PM, Orion Delwaterman <orion at mh2o.com> wrote:
> 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}

Yeah, so change register_result to register_status and everything will
be fine.

>
> 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().
>
Hmm, may be it needs a cleanup. I will think it through.

> 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).

Again, new version result and status are the same.
>
> 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?

query_all_workers() is supposed to return status objects of all the
workers that has been registered through register_status.
>
> 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.

You are welcome.
>
> 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
>



-- 
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