IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6249


Ignore:
Timestamp:
Jan 29, 2006, 9:36:21 AM (20 years ago)
Author:
eugene
Message:

adding to queue options, psched handling

Location:
trunk/Ohana/src/opihi
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/queuepop.c

    r4703 r6249  
    33int queuepop (int argc, char **argv) {
    44 
    5   int N;
     5  int N, Key;
    66  char *var;
    77  char *line;
     8  char *Value;
    89  Queue *queue;
    910
     
    1516  }
    1617
     18  Key = -1;
     19  if ((N = get_argument (argc, argv, "-key"))) {
     20    remove_argument (N, &argc, argv);
     21    Key = atoi (argv[N]);
     22    remove_argument (N, &argc, argv);
     23    Value = strcreate (argv[N]);
     24    remove_argument (N, &argc, argv);
     25  }
     26
     27
    1728  if (argc != 2) {
    18     fprintf (stderr, "USAGE: queuepop (queue) [-var variable]\n");
     29    fprintf (stderr, "USAGE: queuepop (queue) [-var variable] [-key N value]\n");
    1930    return (FALSE);
    2031  }
     
    2738  }
    2839
    29   line = PopQueue (queue);
    30   if (line == NULL) {
    31     fprintf (stderr, "ERROR: queue %s is empty\n", argv[1]);
    32     return (FALSE);
     40  if (Key == -1) {
     41      line = PopQueue (queue);
     42  } else {
     43      line = PopQueueMatch (queue, Key, Value);
    3344  }
    3445
    35   if (var == (char *) NULL) {
    36     fprintf (stderr, "%s\n", line);
     46  if (var == NULL) {
     47      if (line == NULL) {
     48          fprintf (stderr, "queue %s is empty or match not found\n", argv[1]);
     49          return (FALSE);
     50      } else {
     51          fprintf (stderr, "%s\n", line);
     52          return (TRUE);
     53      }
     54  }
     55
     56  if (line == NULL) {
     57    set_str_variable (var, "NULL");
    3758  } else {
    38     set_str_variable (argv[2], line);
     59    set_str_variable (var, line);
    3960  }
    4061
  • trunk/Ohana/src/opihi/include/psched.h

    r4763 r6249  
    7373
    7474  struct timeval last;
     75
     76  int Nsuccess;
     77  int Nfailure;
     78  int Ntimeout;
     79
    7580} Task;
    7681
  • trunk/Ohana/src/opihi/lib.data/queues.c

    r4704 r6249  
    281281  queue[0].Nlines --;
    282282
     283  /* shrink queue allocation if small enough */
    283284  NLINES_2 = MAX (16, queue[0].NLINES / 2);
    284285  if (queue[0].Nlines < NLINES_2) {
     
    289290}
    290291
     292/* pop the first entry which for which the key matches */
     293char *PopQueueMatch (Queue *queue, int Key, char *value) {
     294
     295  int i, choice, NLINES_2;
     296  char *line, *test;
     297
     298  if (queue[0].Nlines == 0) return (NULL);
     299
     300  /* find the matching key */
     301  choice = -1;
     302  for (i = 0; (i < queue[0].Nlines) && (choice == -1); i++) {
     303      test = ChooseKey (queue[0].lines[i], Key);
     304      if (test == NULL) continue;
     305      if (strcmp (value, test)) continue;
     306      choice = i;
     307  }
     308  if (choice == -1) return NULL;
     309
     310  line = queue[0].lines[choice];
     311
     312  for (i = choice; i < queue[0].Nlines - 1; i++) {
     313    queue[0].lines[i] = queue[0].lines[i+1];
     314  }
     315  queue[0].Nlines --;
     316
     317  /* shrink queue allocation if small enough */
     318  NLINES_2 = MAX (16, queue[0].NLINES / 2);
     319  if (queue[0].Nlines < NLINES_2) {
     320    queue[0].NLINES = NLINES_2;
     321    REALLOCATE (queue[0].lines, char *, queue[0].NLINES);
     322  }   
     323  return (line);
     324}
     325
    291326int PrintQueue (FILE *f, Queue *queue) {
    292327
  • trunk/Ohana/src/opihi/lib.shell/check_stack.c

    r4689 r6249  
    1414      stack[i].Float = strtod (stack[i].name, &c);
    1515      if (c == stack[i].name + strlen (stack[i].name)) {
     16        # if (0)
     17        if (Nstack == 1) {
     18          stack[i].type = 'W';
     19        } else {
     20          stack[i].ptr   = &(stack[i].Float);
     21          stack[i].type  = 'S';
     22        }
     23        # endif
    1624        stack[i].ptr   = &(stack[i].Float);
    1725        stack[i].type  = 'S';
  • trunk/Ohana/src/opihi/pantasks/CheckJobs.c

    r4763 r6249  
    66  Macro *macro;
    77  int i, status;
     8  char varname[64];
    89
    910  /** test all jobs: ready to test?  finished? **/
     
    3031        PushNamedQueue ("stdout", job[0].stdout.buffer);
    3132        PushNamedQueue ("stderr", job[0].stderr.buffer);
     33        /* set taskarg variables */
     34        for (i = 0; i < job[0].argc; i++) {
     35            sprintf (varname, "taskarg:%d", i);
     36            set_str_variable (varname, job[0].argv[i]);
     37        }
     38        set_int_variable ("taskarg:n", job[0].argc);
     39
    3240        /* XXX this will break on 0 values in output streams */
    3341        /* perhaps define PushNamedQueueBuffer */
     
    4351        PushNamedQueue ("stdout", job[0].stdout.buffer);
    4452        PushNamedQueue ("stderr", job[0].stderr.buffer);
     53        /* set taskarg variables */
     54        for (i = 0; i < job[0].argc; i++) {
     55            sprintf (varname, "taskarg:%d", i);
     56            set_str_variable (varname, job[0].argv[i]);
     57        }
     58        set_int_variable ("taskarg:n", job[0].argc);
     59
     60        /* update the exit status counters */
     61        if (job[0].exit_status) {
     62            job[0].task[0].Nfailure ++;
     63        } else {
     64            job[0].task[0].Nsuccess ++;
     65        }
     66
    4567        /* run corresponding task[0].exit macro, if it exists */
    4668        macro = job[0].task[0].defexit;
     
    6890      if (GetTaskTimer(job[0].start) < job[0].task[0].timeout_period) continue;
    6991      if (VerboseMode()) fprintf (stderr, "timeout on %s\n", job[0].task[0].name);
     92
     93      /* update the timeout counter */
     94      job[0].task[0].Ntimeout ++;
     95
    7096      if (!KillLocalJob (job)) {
    7197        job[0].state = JOB_HUNG;
     
    7399        continue;
    74100      }
     101
     102      /* set taskarg variables */
     103      for (i = 0; i < job[0].argc; i++) {
     104          sprintf (varname, "taskarg:%d", i);
     105          set_str_variable (varname, job[0].argv[i]);
     106      }
     107      set_int_variable ("taskarg:n", job[0].argc);
     108
     109
    75110      /* run task[0].timeout macro, if it exists */
    76111      if (job[0].task[0].timeout != NULL) {
  • trunk/Ohana/src/opihi/pantasks/TaskOps.c

    r4705 r6249  
    229229  /* init task timer (is reset by 'run') */ 
    230230  gettimeofday (&NewTask[0].last, (void *) NULL);
     231  NewTask[0].Nmax = 0;  /* default value means 'no limit' */
     232
    231233  NewTask[0].Njobs = 0;
    232   NewTask[0].Nmax = 0;  /* default value means 'no limit' */
    233 
     234  NewTask[0].Nsuccess = 0;
     235  NewTask[0].Nfailure = 0;
     236  NewTask[0].Ntimeout = 0;
    234237  return (NewTask);
    235238}
  • trunk/Ohana/src/opihi/pantasks/task_periods.c

    r4693 r6249  
    4242  task = GetNewTask ();
    4343  if (task == NULL) {
    44     fprintf (stderr, "ERROR: not defining or running a task\n");
    45     return (FALSE);
     44    task = GetActiveTask ();
     45    if (task == NULL) {
     46      fprintf (stderr, "ERROR: not defining or running a task\n");
     47      return (FALSE);
     48    }
    4649  }
    4750
Note: See TracChangeset for help on using the changeset viewer.