From: František Dvořák Date: Fri, 8 Sep 2006 11:59:19 +0000 (+0000) Subject: Fourth "Monday" query. X-Git-Tag: glite-jp-index_R_1_2_2~6 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=b51d2fdf58c3d1d89f8a7b437f620788f890e746;p=jra1mw.git Fourth "Monday" query. --- diff --git a/org.glite.jp.index/examples/pch06/query4.pl b/org.glite.jp.index/examples/pch06/query4.pl new file mode 100644 index 0000000..604ebd6 --- /dev/null +++ b/org.glite.jp.index/examples/pch06/query4.pl @@ -0,0 +1,121 @@ +#! /usr/bin/perl + +# +# 4. query: +# +# Find all invocations of procedure align_warp using a twelfth order nonlinear +# 1365 parameter model (see model menu describing possible values of parameter +# "-m 12" of align_warp) that ran on a Monday. +# +# call: +# ./query4.pl OUTPUT_FILE_NAME 2>/dev/null +# + +use strict; +use pch; +use Data::Dumper; + +my $ps='https://skurut1.cesnet.cz:8901'; +my $is='https://skurut1.cesnet.cz:8902'; +my $program_name='align_warp'; +my $program_params='-m 12'; +my $runday=1; +my @view_attributes = ("$pch::jplbtag:IPAW_STAGE", "$pch::jplbtag:IPAW_PROGRAM", "$pch::jplbtag:IPAW_PARAM", "$pch::jplbtag:IPAW_INPUT", "$pch::jplbtag:IPAW_OUTPUT", "$pch::lbattr:CE"); +my @attributes = ("$pch::jpsys:jobId", "$pch::jpwf:ancestor", @view_attributes); + +my @according_jobs = (); # sequencially jobid list +my %according_jobs = (); # hash jobid list +my $according_count = 0; + + +# debug calls +$pch::debug = 0; +my $debug = 0; + +# +# find out processes with given name ant parameters +# +my @jobs = pch::isquery($is, [ + ["$pch::jplbtag:IPAW_PROGRAM", ['EQUAL', "$program_name"]], + ["$pch::jplbtag:IPAW_PARAM", ['EQUAL', "$program_params"]], +], \@attributes); +print Dumper(@jobs) if ($debug); +die "...so exit on error" if ($pch::err); + +# +# initial set from index server +# +foreach my $job (@jobs) { + my %job = %$job; + my %attributes = %{$job{attributes}}; + + if (!exists $according_jobs{$job{jobid}}) { + push @according_jobs, $job{jobid}; + $according_jobs{$job{jobid}} = \%job; + } +} +undef @jobs; + + +# +# collect all jobs (tree browsing) +# +$according_count = 0; +foreach my $jobid (@according_jobs) { + my @ancs; + + print "Handling $jobid (position $according_count)\n" if ($debug); + @ancs = pch::isquery($is, [["$pch::jpwf:successor", ['EQUAL', "$jobid"]]], \@attributes); + die "...so exit on error" if ($pch::err); + + for my $anc (@ancs) { + my %anc = %$anc; + print "Considered: $anc{jobid}\n" if ($debug); + if (!exists $according_jobs{$anc{jobid}}) { + $according_jobs{$anc{jobid}} = \%anc; + push @according_jobs, $anc{jobid}; + print "Added $anc{jobid} to $#according_jobs\n" if ($debug); + } + else { + print "Already existing $anc{jobid}\n" if ($debug); + } + } + $according_count++; +} + + +# +# queries on result set +# +print "Results\n"; +print "=======\n"; +print "\n"; +foreach my $jobid (sort { $according_jobs{$b}{attributes}{"$pch::jplbtag:IPAW_STAGE"}{value}[0] <=> $according_jobs{$a}{attributes}{"$pch::jplbtag:IPAW_STAGE"}{value}[0] } keys %according_jobs) { + my %job = %{$according_jobs{$jobid}}; + my %attributes = %{$job{attributes}}; + + my @time = pch::psquery($ps, $jobid, "$pch::jpsys:regtime"); + my @timesep = gmtime($time[0]); + if ($timesep[6] == $runday) { + print "jobid $jobid:\n"; + + # query & output all desired atributes + foreach my $attr (@view_attributes) { + my $attr_name = $attr; $attr_name =~ s/.*://; + + print " attr $attr_name: "; + if (exists $attributes{$attr}) { + my %attr = %{$attributes{$attr}}; + + print join(", ", @{$attr{value}}); print "\n"; + } else { + print "N/A\n"; + } + } + print " attr REGTIME: ".gmtime($time[0])." (".join(", ", @time).")\n"; + + print "\n"; + } else { + print "Job $jobid ran at day $timesep[6] (0=Sun, ...): ".gmtime($time[0])."\n" if $debug; + } +}