Support for defining terminal job states through status.T
authorZdeněk Šustr <sustr4@cesnet.cz>
Fri, 5 Aug 2011 14:17:35 +0000 (14:17 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Fri, 5 Aug 2011 14:17:35 +0000 (14:17 +0000)
org.glite.lb.common/interface/jobstat.h.T
org.glite.lb.common/src/status.c.T
org.glite.lb.types/MultiStruct.pm
org.glite.lb.types/status.T

index 760b6a0..a147269 100644 (file)
@@ -95,6 +95,8 @@ typedef enum _edg_wll_JobStatCode {
        EDG_WLL_NUMBER_OF_STATCODES /**< Number of meaningful status codes */
 } edg_wll_JobStatCode;
 
+extern const int EDG_WLL_JOB_TERMINAL_STATE[EDG_WLL_NUMBER_OF_STATCODES];
+
 /*!
  *
  * Pair tag = value.
index 413bd5b..32635d8 100644 (file)
@@ -26,6 +26,16 @@ limitations under the License.
 
 static const struct timeval null_timeval = {0,0};
 
+@@@{
+        my $sep = "const int EDG_WLL_JOB_TERMINAL_STATE[EDG_WLL_NUMBER_OF_STATCODES] = {0, ";
+        for my $term ($status->getTerminalStatusOrdered) {
+                gen qq{$sep $term};
+        $sep = ", ";
+        }
+        $sep = ", 0};";
+        gen qq{$sep};
+@@@}
+
 
 void edg_wll_FreeStatus(edg_wll_JobStat *stat)
 { 
index 3ab6d4b..629660c 100644 (file)
@@ -9,6 +9,7 @@ sub new {
        $self->{fields} = {};   # typ->{ name->StructField, ... }
        $self->{order} = {};
        $self->{flesh} = {};
+       $self->{terminal} = "";
 
        bless $self;
 }
@@ -81,6 +82,11 @@ sub load {
                        next;
                }
 
+               if (/^\@terminal\s+(\S+)$/) {
+                       $self->{terminal} = $self->{terminal} . " " . $1;
+                       next;
+               }
+
                s/^\s*//;
                my ($ftype,$fname,$comment) = split /\s+/,$_,3;
                if ($ftype eq '_code_') {
@@ -145,6 +151,16 @@ sub getTypesOrdered {
        } @names;
 }
 
+sub getTerminalStatusOrdered {
+       my $self = shift;
+       for my $stat ($self->getTypesOrdered) {
+               if ($self->{terminal} =~ m/\b$stat\b/) { 
+                       push(@out, 1); }
+               else { push(@out, 0); }
+       }
+       @out;
+}
+
 sub getTypeComment {
        my $self = shift;
        my $type = shift || $self->{type};
index d64f2ad..c216ee2 100644 (file)
@@ -191,3 +191,7 @@ _pad_       20
 @type Unknown          Status cannot be determined.
 @type Purged           Job has been purged from bookkeeping server (for LB-RGMA interface).
 
+@terminal Done
+@terminal Running
+@terminal Cleared
+@terminal Purged