IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8129


Ignore:
Timestamp:
Aug 4, 2006, 2:19:21 AM (20 years ago)
Author:
eugene
Message:

adding task options

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

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/include/pantasks.h

    r7960 r8129  
    4141      TASK_HOST,
    4242      TASK_COMMAND,
     43      TASK_OPTIONS,
    4344      TASK_PERIODS,
    4445      TASK_EXIT,
     
    6667  int     argc;
    6768  char  **argv;
     69
     70  int     optc;
     71  char  **optv;
     72
    6873  char   *host;
    6974  int     host_required;
     
    112117  int     argc;
    113118  char  **argv;
     119
     120  int     optc;
     121  char  **optv;
     122
    114123  Task   *task;
    115124
  • trunk/Ohana/src/opihi/pantasks/CheckJobs.c

    r7917 r8129  
    2626
    2727      case JOB_CRASH:
    28         /* run task[0].crash macro, if it exists */
     28      case JOB_EXIT:
    2929        /* push output buffer data to the stdout and stderr queues */
    30         if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
     30        /* XXX this will break on 0 values in output streams */
    3131        PushNamedQueue ("stdout", job[0].stdout.buffer);
    3232        PushNamedQueue ("stderr", job[0].stderr.buffer);
     33
    3334        /* set taskarg variables */
    3435        for (i = 0; i < job[0].argc; i++) {
     
    3839        set_int_variable ("taskarg:n", job[0].argc);
    3940
    40         /* XXX this will break on 0 values in output streams */
    41         /* perhaps define PushNamedQueueBuffer */
    42         if (job[0].task[0].crash != NULL) {
    43           exec_loop (job[0].task[0].crash);
     41        /* set options variables */
     42        for (i = 0; i < job[0].optc; i++) {
     43            sprintf (varname, "options:%d", i);
     44            set_str_variable (varname, job[0].optv[i]);
    4445        }
    45         DeleteJob (job);
    46         continue;
    47         break;
     46        set_int_variable ("options:n", job[0].optc);
    4847
    49       case JOB_EXIT:
    50         if (VerboseMode()) gprint (GP_LOG, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
    51         PushNamedQueue ("stdout", job[0].stdout.buffer);
    52         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]);
     48        if (status == JOB_CRASH) {
     49          /* XXX add an Ncrash element? */
     50          job[0].task[0].Nfailure ++;
     51
     52          /* run task[0].crash macro, if it exists */
     53          /* perhaps define PushNamedQueueBuffer */
     54
     55          if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
     56          if (job[0].task[0].crash != NULL) {
     57            exec_loop (job[0].task[0].crash);
     58          }
    5759        }
    58         set_int_variable ("taskarg:n", job[0].argc);
     60        if (status == JOB_EXIT) {
     61          /* update the exit status counters */
     62          if (job[0].exit_status) {
     63            job[0].task[0].Nfailure ++;
     64          } else {
     65            job[0].task[0].Nsuccess ++;
     66          }
    5967
    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 ++;
     68          /* run corresponding task[0].exit macro, if it exists */
     69          if (VerboseMode()) gprint (GP_LOG, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
     70          macro = job[0].task[0].defexit;
     71          for (i = 0; i < job[0].task[0].Nexit; i++) {
     72            if (job[0].exit_status == atoi(job[0].task[0].exit[i][0].name)) {
     73              macro = job[0].task[0].exit[i];
     74              break;
     75            }
     76          }
     77          if (macro != NULL) exec_loop (macro);
    6578        }
    6679
    67         /* run corresponding task[0].exit macro, if it exists */
    68         macro = job[0].task[0].defexit;
    69         for (i = 0; i < job[0].task[0].Nexit; i++) {
    70           if (job[0].exit_status == atoi(job[0].task[0].exit[i][0].name)) {
    71             macro = job[0].task[0].exit[i];
    72             break;
    73           }
    74         }
    75         if (macro != NULL) exec_loop (macro);
    7680        DeleteJob (job);
    7781        continue;
     
    107111      set_int_variable ("taskarg:n", job[0].argc);
    108112
     113      /* set options variables */
     114      for (i = 0; i < job[0].optc; i++) {
     115        sprintf (varname, "options:%d", i);
     116        set_str_variable (varname, job[0].optv[i]);
     117      }
     118      set_int_variable ("options:n", job[0].optc);
    109119
    110120      /* run task[0].timeout macro, if it exists */
  • trunk/Ohana/src/opihi/pantasks/JobOps.c

    r7917 r8129  
    103103  job[0].argv[i] = 0;
    104104
     105  /* we need our own copy of task[0].optv: optc is the number of valid opts.  */
     106  job[0].optc = task[0].optc;
     107  ALLOCATE (job[0].optv, char *, MAX (task[0].optc, 1));
     108  for (i = 0; i < job[0].optc; i++) {
     109    job[0].optv[i] = strcreate (task[0].optv[i]);
     110  }
     111
    105112  /* Other data from the task is needed by the job. We carry a pointer back to the task.  Changes to an
    106113     executing task are applied to the existing jobs (exit macros, poll_period, timeout) */
     
    136143  free (job[0].argv);
    137144
     145  for (i = 0; i < job[0].optc; i++) {
     146    free (job[0].optv[i]);
     147  }
     148  free (job[0].optv);
     149
    138150  FreeIOBuffer (&job[0].stdout);
    139151  FreeIOBuffer (&job[0].stderr);
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r7960 r8129  
    6363$(SDIR)/task_periods.$(ARCH).o \
    6464$(SDIR)/task_command.$(ARCH).o \
     65$(SDIR)/task_options.$(ARCH).o \
    6566$(SDIR)/version.$(ARCH).o
    6667
  • trunk/Ohana/src/opihi/pantasks/TaskOps.c

    r7917 r8129  
    116116  gprint (GP_LOG, "\n\n");
    117117
     118  gprint (GP_LOG, "\n options: ");
     119  for (i = 0; i < task[0].optc; i++) {
     120    gprint (GP_LOG, "%s ", task[0].optv[i]);
     121  }
     122  gprint (GP_LOG, "\n\n");
     123
    118124  if (task[0].host == NULL) {
    119125    gprint (GP_LOG, " task runs locally\n");
     
    169175    free (task[0].argv);
    170176  }
     177  if (task[0].optv != NULL) {
     178    for (i = 0; i < task[0].optc; i++) {
     179      free (task[0].optv[i]);
     180    }
     181    free (task[0].optv);
     182  }
    171183  if (task[0].exec != NULL) {
    172184    FreeMacro (task[0].exec);
     
    209221  NewTask[0].argc = 0;
    210222  NewTask[0].argv = NULL;
     223
     224  NewTask[0].optc = 0;
     225  NewTask[0].optv = NULL;
    211226
    212227  NewTask[0].exec = NULL;
     
    346361  if (!strcasecmp (command, "TRANGE"))    hash = TASK_TRANGE;
    347362  if (!strcasecmp (command, "COMMAND"))   hash = TASK_COMMAND;
     363  if (!strcasecmp (command, "OPTIONS"))   hash = TASK_OPTIONS;
    348364  if (!strcasecmp (command, "PERIODS"))   hash = TASK_PERIODS;
    349365  if (!strcasecmp (command, "TASK.EXIT")) hash = TASK_EXIT;
  • trunk/Ohana/src/opihi/pantasks/init.c

    r7960 r8129  
    88int task_macros     PROTO((int, char **));
    99int task_command    PROTO((int, char **));
     10int task_options    PROTO((int, char **));
    1011int task_periods    PROTO((int, char **));
    1112int run             PROTO((int, char **));
     
    2728  {"task.exec",  task_macros,  "define pre-exec macro for a task"},
    2829  {"command",    task_command, "define executed command for a task"},
     30  {"options",    task_options, "define optional variables associated with the job task"},
    2931  {"periods",    task_periods, "define time scales for a task"},
    3032  {"run",        run,          "run the scheduler"},
  • trunk/Ohana/src/opihi/pantasks/task.c

    r7960 r8129  
    9595      case TASK_EXEC:
    9696      case TASK_COMMAND:
     97      case TASK_OPTIONS:
    9798      case TASK_PERIODS:
    9899        status = command (input, &outline, TRUE);
Note: See TracChangeset for help on using the changeset viewer.