I made some other changes and I'll send this patch again, please ignore 
this one.

On 07/21/2010 11:03 AM, [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 |   17 +++++------------
>   1 files changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb
> index 155fa7d..484f53f 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)
>
> @@ -144,17 +144,10 @@ def condormatic_instances_sync_states
>         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|
> +      job_name = (v = jobs_ele.at_xpath('./a...@n="Cmd"]')) ? v.text : nil
> +      job_state= (v = jobs_ele.at_xpath('./a...@n="JobStatus"]')) ? 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

Reply via email to