Parsing origins too and using them.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 19 Jun 2007 14:07:05 +0000 (14:07 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 19 Jun 2007 14:07:05 +0000 (14:07 +0000)
Queries on multiple program names (needed for data from Karma and for hybrids).

org.glite.jp.index/examples/pch06/pch.pm
org.glite.jp.index/examples/pch06/query2.pl
org.glite.jp.index/examples/pch06/query4.pl
org.glite.jp.index/examples/pch06/query5.pl
org.glite.jp.index/examples/pch06/query6.pl

index 75c0250..46e5be2 100644 (file)
@@ -133,9 +133,11 @@ sub jobs_handler {
 
        $xmlattribute = $xmljobs->first_child('attributes');
        while ($xmlattribute) {
-               my ($xmlname, $xmlvalue);
+               my ($xmlname, $xmlvalue, $xmlorigin);
                my @values = ();
+               my @origins = ();
                my %attribute = ();
+               my $nvalues = 0;
 
                $xmlname = $xmlattribute->first_child('name');
                die "No name on '".$xmlattribute->text."'" if (!$xmlname);
@@ -148,14 +150,26 @@ sub jobs_handler {
                        @values = @{$attribute{value}};
                }
 #print "  prev values: ".Dumper(@values)."\n";
+               if (exists $attribute{origin}) {
+                       @origins = @{$attribute{origin}};
+               }
+#print "  prev origins: ".Dumper(@origins)."\n";
                $xmlvalue = $xmlattribute->first_child('value');
                while ($xmlvalue) {
 #print "  to add: ".$xmlvalue->text."\n";
                        push @values, $xmlvalue->text;
                        $xmlvalue = $xmlvalue->next_sibling('value');
+                       $nvalues = $nvalues + 1;
                }
                @{$attribute{value}} = @values;
 #print "  new values: ".Dumper($attribute{value})."\n";
+               $xmlorigin = $xmlattribute->first_child('origin');
+               for ($nvalues..1) {
+                       if ($xmlorigin and $xmlorigin->text) { push @origins, $xmlorigin->text; }
+                       else { push @origins, undef; }
+               }
+               @{$attribute{origin}} = @origins;
+#print "  new origins: ".Dumper($attribute{origin})."\n";
                $attribute{timestamp} = $xmlattribute->first_child('timestamp')->text;
                $xmlattribute = $xmlattribute->next_sibling('attributes');
 
index 43206c6..ba45fcb 100644 (file)
@@ -16,7 +16,7 @@ use Data::Dumper;
 
 my $ps=$pch::ps;
 my $is=$pch::is;
-my $program_name = "softmean";
+my %program_names = (softmean => 1);
 
 my @according_jobs = (); # sequencially jobid list
 my %according_jobs = (); # hash jobid list
@@ -29,7 +29,12 @@ if ($#ARGV + 1 < 1) {
        exit 1
 }
 $output = $ARGV[0];
-if ($#ARGV + 1 > 1) { $program_name = $ARGV[1]; }
+if ($#ARGV + 1 > 1) {
+       %program_names = ();
+       foreach (split(/  */,$ARGV[1])) {
+               $program_names{$_} = 1;
+       }
+}
 
 # debug calls
 $pch::debug = 0;
@@ -73,8 +78,8 @@ foreach my $jobid (@according_jobs) {
        # stop on given program name
        @program = pch::psquery($ps, $jobid, "$pch::jplbtag:IPAW_PROGRAM");
        die "More program names of $jobid?" if ($#program > 0);
-       if ($program[0] eq $program_name) { 
-               print "$jobid is $program_name, stop here\n" if $debug;
+       if (exists $program_names{$program[0]}) { 
+               print "$jobid is $program[0], stop here\n" if $debug;
                next;
        }
 
index 82d9759..3520875 100644 (file)
@@ -17,7 +17,7 @@ use Data::Dumper;
 
 my $ps=$pch::ps;
 my $is=$pch::is;
-my $program_name='align_warp';
+my %program_names=(align_warp => 1);
 my $program_params='-m 12';
 my $runday=1;
 #my $runday=4;
@@ -31,13 +31,24 @@ my $according_count = 0;
 $pch::debug = 0;
 my $debug = 0;
 
-if ($#ARGV + 1 > 1) { $program_name=$ARGV[0]; }
+if ($#ARGV + 1 > 1) {
+       %program_names = ();
+       foreach (split(/  */, $ARGV[1])) {
+               $program_names{$_} = 1;
+       }
+}
+
 
 #
 # find out processes with given name ant parameters
 #
+my @query_programs = ();
+foreach (keys %program_names) {
+       my @qitem = ['EQUAL', "<string>$_</string>"];
+       push @query_programs, @qitem;
+}
 my @jobs = pch::isquery($is, [
-       ["$pch::jplbtag:IPAW_PROGRAM", ['EQUAL', "<string>$program_name</string>"]],
+       ["$pch::jplbtag:IPAW_PROGRAM", @query_programs],
        ["$pch::jplbtag:IPAW_PARAM", ['EQUAL', "<string>$program_params</string>"]],
 ], \@attributes);
 print Dumper(@jobs) if ($debug);
@@ -50,12 +61,26 @@ die "...so exit on error" if ($pch::err);
 $according_count = 0;
 foreach my $job (@jobs) {
        my %job = %$job;
-       my @time;
+       my (@time, @timesep, @origin);
+       my $itime;
 
        print "Handling $job{jobid} ($according_count.)\n" if ($debug);
 
-       @time =@{ $job{attributes}{"$pch::jpsys:regtime"}{value}};
-       my @timesep = gmtime($time[0]);
+       # search first regtime with origin USER,
+       # be satisfied with first regime too if no value has USER origin
+       @time = @{$job{attributes}{"$pch::jpsys:regtime"}{value}};
+       @origin = @{$job{attributes}{"$pch::jpsys:regtime"}{origin}};
+       @timesep = ();
+       foreach $itime (0..$#time) {
+#print "check ".$time[$itime]." ".$origin[$itime]."\n";
+               if ($origin[$itime] eq 'USER') {
+                       @timesep = gmtime($time[$itime]);
+                       last;
+               }
+       }
+       if ($#timesep == -1) { @timesep = gmtime($time[0]); }
+#print join(',', @timesep)."\n";
+
        if ($timesep[6] == $runday) {
                if (!exists $according_jobs{$job{jobid}}) {
                        $according_jobs{$job{jobid}} = \%job;
index 3f700a5..4394c7d 100644 (file)
@@ -17,8 +17,8 @@ use Data::Dumper;
 
 my $ps=$pch::ps;
 my $is=$pch::is;
-my $program_name='align_warp';
-my $end_program_name='convert';
+my %program_names=(align_warp => 1);
+my %end_program_names=(convert => 1);
 my $header="GLOBAL_MAXIMUM=4095"; # test for exact equal (scripts already prepared it)
 
 my @according_jobs = (); # sequencially jobid list
@@ -30,14 +30,29 @@ my $according_count = 0;
 $pch::debug = 0;
 my $debug = 0;
 
-if ($#ARGV + 1 >= 1) { $program_name = $ARGV[0]; }
-if ($#ARGV + 1 >= 2) { $end_program_name = $ARGV[1]; }
+if ($#ARGV + 1 >= 1) {
+       %program_names = ();
+       foreach (split(/  */, $ARGV[0])) {
+               $program_names{$_} = 1;
+       }
+}
+if ($#ARGV + 1 >= 2) {
+       %end_program_names = ();
+       foreach (split(/  */, $ARGV[1])) {
+               $end_program_names{$_} = 1;
+       }
+}
 
 #
 # find out processes with given name and parameters
 #
+my @query_programs = ();
+foreach (keys %program_names) {
+       my @qitem = ['EQUAL', "<string>$_</string>"];
+       push @query_programs, @qitem;
+}
 my @jobs = pch::isquery($is, [
-       ["$pch::jplbtag:IPAW_PROGRAM", ['EQUAL', "<string>$program_name</string>"]],
+       ["$pch::jplbtag:IPAW_PROGRAM", @query_programs],
        ["$pch::jplbtag:IPAW_HEADER", ['EQUAL', "<string>$header</string>"]],
 ], \@pch::view_attributes);
 print Dumper(@jobs) if ($debug);
@@ -76,11 +91,13 @@ undef @jobs;
 $according_count = 0;
 foreach my $jobid (@according_jobs) {
        my @succs;
+       my $pname;
 
        print "Handling $jobid (position $according_count)\n" if ($debug);
 
-       if ($according_jobs{$jobid}{attributes}{"$pch::IPAW_PROGRAM"}{value}[0] eq $end_program_name) {
-               print "It's $end_program_name\n" if $debug;
+       $pname = $according_jobs{$jobid}{attributes}{"$pch::IPAW_PROGRAM"}{value}[0];
+       if (exists $end_program_names{$pname}) {
+               print "It's $pname\n" if $debug;
                next;
        }
 
index 8c1d851..16b93ad 100644 (file)
@@ -19,9 +19,9 @@ use Data::Dumper;
 
 my $ps=$pch::ps;
 my $is=$pch::is;
-my $program_name='align_warp';
+my %program_names=(align_warp=>1);
 my $program_param='-m 12';
-my $end_program_name='softmean';
+my %end_program_names=(softmean=>1);
 
 #my %jobs = ();          # just information cache
 my @workflow_jobs = (); # sequencially jobid list
@@ -35,14 +35,29 @@ my $workflow_count = 0;
 $pch::debug = 0;
 my $debug = 0;
 
-if ($#ARGV + 1 >= 1) { $program_name = $ARGV[0]; }
-if ($#ARGV + 1 >= 2) { $end_program_name = $ARGV[1]; }
+if ($#ARGV + 1 >= 1) {
+       %program_names = ();
+       foreach (split(/  */, $ARGV[0])) {
+               $program_names{$_} = 1;
+       }
+}
+if ($#ARGV + 1 >= 2) {
+       %end_program_names = ();
+       foreach (split(/  */, $ARGV[1])) {
+               $end_program_names{$_} = 1;
+       }
+}
 
 #
 # find out processes with given name and parameters
 #
+my @query_programs = ();
+foreach (keys %program_names) {
+       my @qitem = ['EQUAL', "<string>$_</string>"];
+       push @query_programs, @qitem;
+}
 my @jobs = pch::isquery($is, [
-       ["$pch::jplbtag:IPAW_PROGRAM", ['EQUAL', "<string>$program_name</string>"]],
+       ["$pch::jplbtag:IPAW_PROGRAM", @query_programs],
        ["$pch::jplbtag:IPAW_PARAM", ['EQUAL', "<string>$program_param</string>"]],
 ], ["$pch::jpwf:successor", @pch::view_attributes]);
 print Dumper(@jobs) if ($debug);
@@ -71,12 +86,14 @@ undef @jobs;
 $workflow_count = 0;
 foreach my $jobid (@workflow_jobs) {
        my @succs;
+       my $pname;
 
        print "Handling $jobid (position $workflow_count)\n" if ($debug);
        print "  progname: ".$workflow_jobs{$jobid}{attributes}{"$pch::jplbtag:IPAW_PROGRAM"}{value}[0]."\n" if ($debug);
 
-       if ($workflow_jobs{$jobid}{attributes}{"$pch::jplbtag:IPAW_PROGRAM"}{value}[0] eq $end_program_name) {
-               print "It's $end_program_name, adding\n" if $debug;
+       $pname = $workflow_jobs{$jobid}{attributes}{"$pch::jplbtag:IPAW_PROGRAM"}{value}[0];
+       if (exists $end_program_names{$pname}) {
+               print "It's $pname, adding\n" if $debug;
                $according_jobs{$jobid} = \%{$workflow_jobs{$jobid}};
                next;
        }