[Oar-commits] OAR branch 2.5 updated. 2.5.3+rc4-12-gb55c19e

Nicolas Capit capitn at ff-scm-v4-prod.irisa.fr
Mon Apr 15 21:39:05 CEST 2013


The branch, 2.5 has been updated
       via  b55c19e33d280609b1f9cd55d492e3fb80e0c3ff (commit)
       via  e642f83147af842a703d6e853f2d65ba87b9e10f (commit)
      from  08edb322e4ea61058a2f4fb6bc42445caf74cf2b (commit)


- Log -----------------------------------------------------------------
commit b55c19e
Author: capitn <nicolas.capit at imag.fr>
Date:   Mon Apr 15 21:37:24 2013 +0200

    [scheduler] Update job messages for reservations
---
 .../core/server/lib/OAR/Schedulers/Scheduler.pm    |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sources/core/server/lib/OAR/Schedulers/Scheduler.pm b/sources/core/server/lib/OAR/Schedulers/Scheduler.pm
index 6183a46..6520d81 100644
--- a/sources/core/server/lib/OAR/Schedulers/Scheduler.pm
+++ b/sources/core/server/lib/OAR/Schedulers/Scheduler.pm
@@ -347,6 +347,10 @@ sub treate_waiting_reservation_jobs($$){
                 }
                 if ($#resa_resources > $#resa_alive_resources){
                     OAR::IO::add_new_event($dbh,"SCHEDULER_REDUCE_NB_NODES_FOR_RESERVATION",$job->{job_id},"[OAR::Schedulers::Scheduler] Reduce the number of resources for the job $job->{job_id}.");
+                    my $nbr = $#resa_alive_resources + 1;
+                    if ($job->{message} =~ s/R\=\d+/R\=$nbr/g){
+                        OAR::IO::set_job_message($dbh,$job->{job_id},$job->{message});
+                    }
                 }
             }
         }
@@ -568,6 +572,10 @@ sub check_jobs_to_launch($){
             OAR::IO::set_gantt_job_startTime($dbh,$jobs_to_launch{$i}->[0],$current_time_sec);
             oar_warn("[OAR::Schedulers::Scheduler] Reduce job ($i) walltime to $max_time instead of $mold->{moldable_walltime}\n");
             OAR::IO::add_new_event($dbh,"REDUCE_RESERVATION_WALLTIME",$i,"Change walltime from $mold->{moldable_walltime} to $max_time");
+            my $w = OAR::IO::duration_to_sql($max_time);
+            if ($job->{message} =~ s/W\=\d+\:\d+\:\d+/W\=$w/g){
+                OAR::IO::set_job_message($dbh,$i,$job->{message});
+            }
         }
         my $running_date = $current_time_sec;
         if ($running_date < $job->{submission_time}){
commit e642f83
Author: capitn <nicolas.capit at imag.fr>
Date:   Mon Apr 15 20:43:42 2013 +0200

    [oarstat] Add job duration in alternative output
    
    Add the column duration in the output format 2 in oarstat.
---
 sources/core/common-libs/lib/OAR/Stat.pm |   14 ++++++++++++++
 sources/core/man/man1/oarstat.pod        |    2 ++
 sources/core/qfunctions/oarstat          |   17 ++++++++++-------
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/sources/core/common-libs/lib/OAR/Stat.pm b/sources/core/common-libs/lib/OAR/Stat.pm
index 6ecffbc..d9b87b4 100644
--- a/sources/core/common-libs/lib/OAR/Stat.pm
+++ b/sources/core/common-libs/lib/OAR/Stat.pm
@@ -8,6 +8,7 @@ use OAR::IO;
 use OAR::Conf qw(init_conf dump_conf get_conf is_conf);
 
 my $base;
+my $current_date = -1;
 
 # Read config
 init_conf($ENV{OARCONFFILE});
@@ -557,6 +558,19 @@ sub compact_arrays($){
   return $newjobs;
 }
 
+# Use the current date in seconds from the EPOCH to determine the duration of a
+# running job (start_time>0)
+sub get_job_duration($){
+    my $start_date = shift;
 
+    if ($current_date < 0){
+        $current_date = OAR::IO::get_date($base);
+    }
+    my ($h,$m,$s) = (0,0,0);
+    if (($start_date > 0) and ($start_date < $current_date)){
+        ($h,$m,$s) = OAR::IO::duration_to_hms($current_date - $start_date);
+    }
+    return(sprintf("%i:%02i:%02i", $h,$m,$s));
+}
 
 1;
diff --git a/sources/core/man/man1/oarstat.pod b/sources/core/man/man1/oarstat.pod
index 9ff4853..cf96437 100644
--- a/sources/core/man/man1/oarstat.pod
+++ b/sources/core/man/man1/oarstat.pod
@@ -65,6 +65,8 @@ select the text output format. Available values are:
   1: default
   2: prints system messages
 
+The users can use the environment variable OAR_OARSTAT_OUTPUT_FORMAT to select the output format 1 or 2.
+
 =item B<-D, --DUMPER>
 
 Print result in DUMPER format.
diff --git a/sources/core/qfunctions/oarstat b/sources/core/qfunctions/oarstat
index c74572d..7abd12c 100755
--- a/sources/core/qfunctions/oarstat
+++ b/sources/core/qfunctions/oarstat
@@ -63,8 +63,9 @@ my $events_query;
 my $properties_query;
 my $usage;
 my $version;
-my $text_format = get_conf_with_default_param("OARSTAT_DEFAULT_OUTPUT_FORMAT", "1");
 my $user;
+my $text_format = get_conf_with_default_param("OARSTAT_DEFAULT_OUTPUT_FORMAT", "1");
+$text_format = $ENV{OAR_OARSTAT_OUTPUT_FORMAT} if (defined($ENV{OAR_OARSTAT_OUTPUT_FORMAT}));
 ### END Variables declaration ###
 
 
@@ -392,18 +393,19 @@ sub print_job_data($){
                     if ($text_format eq "2"){
     					if ($Printed_jobs == 0){
 	    					print <<EOS;
-Job id     A. id      A. index S User         System message
----------- ---------- -------- - ------------ --------------------------------
+Job id    A. id     index S User     Duration   System message
+--------- --------- ----- - -------- ---------- --------------------------------
 EOS
 		    			}
 					    $job_info->{job_name} = '' if (!defined($job_info->{job_name}));
 					    $job_info->{message} = '' if (!defined($job_info->{message}));
-    					printf("%-10.10s %-10.10s %-8.8s %1.1s %-12.12s %s\n",
+    					printf("%-9.9s %-9.9s %-5.5s %1.1s %-8.8s %-10.10s %s\n",
 	    					$job_info->{job_id},
                             $job_info->{'array_id'},
                             $job_info->{'array_index'},
 					    	$hashestat{$job_info->{state}},
 			    			$job_info->{job_user},
+                            OAR::Stat::get_job_duration($job_info->{start_time}),
 						    $job_info->{message}
     					);
                         $Printed_jobs ++;
@@ -432,16 +434,17 @@ EOS
                     if ($text_format eq "2"){
     					if ($Printed_jobs == 0){
 	    					print <<EOS;
-Job id     S User         System message
----------- - ------------ ----------------------------------------------------
+Job id    S User     Duration   System message
+--------- - -------- ---------- ------------------------------------------------
 EOS
 		    			}
 					    $job_info->{job_name} = '' if (!defined($job_info->{job_name}));
 					    $job_info->{message} = '' if (!defined($job_info->{message}));
-    					printf("%-10.10s %1.1s %-12.12s %s\n",
+    					printf("%-9.9s %1.1s %-8.8s %-10.10s %s\n",
 	    					$job_info->{job_id},
 					    	$hashestat{$job_info->{state}},
 			    			$job_info->{job_user},
+                            OAR::Stat::get_job_duration($job_info->{start_time}),
 						    $job_info->{message}
     					);
                     }else{
-----------------------------------------------------------------------

Summary of changes:
 sources/core/common-libs/lib/OAR/Stat.pm           |   14 ++++++++++++++
 sources/core/man/man1/oarstat.pod                  |    2 ++
 sources/core/qfunctions/oarstat                    |   17 ++++++++++-------
 .../core/server/lib/OAR/Schedulers/Scheduler.pm    |    8 ++++++++
 4 files changed, 34 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
OAR



More information about the Oar-commits mailing list