On Fri, 2010-07-23 at 16:28 -0400, Jason Guiditta wrote:
> Ian is further reviewing this, but minor nit on this inline.
>
> On Wed, 2010-07-21 at 16:21 +0200, [email protected] wrote:
> > From: Jan Provaznik <[email protected]>
> >
> > Use Nokogiri for parsing condor output improves noticeably
> > performance of listing instances in pool.
> > ---
> > src/app/util/condormatic.rb | 35 +++++------------------------------
> > 1 files changed, 5 insertions(+), 30 deletions(-)
> >
> > diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb
> > index 155fa7d..5fba43e 100644
> > --- a/src/app/util/condormatic.rb
> > +++ b/src/app/util/condormatic.rb
> > @@ -17,7 +17,7 @@
> > # MA 02110-1301, USA. A copy of the GNU General Public License is
> > # also available at http://www.gnu.org/copyleft/gpl.html.
> >
> > -require 'rexml/document'
> > +require 'nokogiri'
> >
> > def condormatic_instance_create(task)
> >
> > @@ -126,35 +126,10 @@ def condormatic_instances_sync_states
> > instance.save!
> > end
> >
> > - def find_value_int(job_ele, attrib)
> > - if job_ele.attributes['n'] == attrib
> > - cmd = job_ele.elements.each('i') do |i|
> > - return i.text
> > - end
> > - end
> > - return nil
> > - end
> > -
> > - def find_value_str(job_ele, attrib)
> > - if job_ele.attributes['n'] == attrib
> > - cmd = job_ele.elements.each('s') do |s|
> > - return s.text
> > - end
> > - end
> > - return nil
> > - end
> > -
> > - doc = REXML::Document.new(xml)
> > - doc.elements.each('classads/c') do |jobs_ele|
> > - job_name = nil
> > - job_state = nil
> > -
> > - jobs_ele.elements.each('a') do |job_ele|
> > - value = find_value_str(job_ele, 'Cmd')
> > - job_name = value if value != nil
> > - value = find_value_int(job_ele, 'JobStatus')
> > - job_state = value if value != nil
> > - end
> > + doc = Nokogiri::XML(xml)
> > + doc.xpath('/classads/c').each do |jobs_ele|
>
> I know you were just following the convention from the old version here,
> but I think the code would be clearer if you changed all instances of
> 'jobs_ele' to 'job'.
Agreed.
Ian
> > + job_name = (v = jobs_ele.at_xpath('./a...@n="Cmd"]/s')) ? v.text :
> > nil
> > + job_state= (v = jobs_ele.at_xpath('./a...@n="JobStatus"]/i')) ?
> > v.text : nil
> >
> > Rails.logger.info "job name is #{job_name}"
> > Rails.logger.info "job state is #{job_state}"
>
>
> _______________________________________________
> deltacloud-devel mailing list
> [email protected]
> https://fedorahosted.org/mailman/listinfo/deltacloud-devel
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel