IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4602


Ignore:
Timestamp:
Jul 23, 2005, 9:13:00 PM (21 years ago)
Author:
eugene
Message:

added valid time ranges and elements of Njobs, status

Location:
trunk/Ohana/src/opihi
Files:
3 added
13 edited

Legend:

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

    r2598 r4602  
    2626int           dms_format            PROTO((char *line, double value));
    2727int           hh_hm                 PROTO((double hh, int *hr, double *mn));
     28int           day_to_sec            PROTO((char *string, time_t *second));
     29int           hms_to_sec            PROTO((char *string, time_t *second));
    2830
    2931char         *meade_deg_to_str      PROTO((double deg));
  • trunk/Ohana/src/opihi/include/scheduler.h

    r4576 r4602  
    2626} ControllerStat;
    2727
     28enum {RANGE_ABS, RANGE_DAY, RANGE_WEEK};
     29
    2830/* socket / pipe communication buffer */
    2931typedef struct {
     
    3436  int   Nbuffer;
    3537} IOBuffer;
     38
     39typedef struct {
     40  time_t start;
     41  time_t stop;
     42  char type;
     43  char keep;
     44} TimeRange;
    3645
    3746/* a task is a description of the wrapping of a job */
     
    7887// keep: FALSE: do not perform action within this time period
    7988 
    80 typedef struct {
    81   e_time start;
    82   e_time stop;
    83   char type;
    84   char keep;
    85 } TimeRange;
    86 
    8789typedef struct {
    8890  int JobID;                            /* internal ID for job */
     
    141143int CheckTasks ();
    142144int CheckSystem ();
     145int CheckTimeRanges (TimeRange *ranges, int Nranges);
    143146int GetJobOutput (char *channel, int pid, IOBuffer *buffer, int Nbytes);
    144147int CheckControllerJob (Job *job);
  • trunk/Ohana/src/opihi/lib.data/convert.c

    r2598 r4602  
    11# include "convert.h"
     2# define _XOPEN_SOURCE /* glibc2 needs this */
     3# include <time.h>
     4
     5char *strptime(const char *s, const char *format, struct tm *tm);
     6
    27 
    38int hh_hms (double hh, int *hr, int *mn, double *sc) {
     
    160165
    161166  return (status);
     167}
     168
     169/***** convert 00:00:00 or 00:00 to 0 - 86400 ****/
     170int hms_to_sec (char *string, time_t *second) {
     171 
     172  char *p;
     173  struct tm time;
     174
     175  p = strptime (string, "%H:%M:%S", &time);
     176  if (p != NULL) goto valid;
     177
     178  p = strptime (string, "%H:%M", &time);
     179  if (p != NULL) goto valid;
     180
     181  return (FALSE);
     182   
     183valid:
     184  if (*p) return (FALSE);
     185  *second = time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;
     186  return (TRUE);
     187}
     188
     189/***** convert Mon[@00:00:00] or 00:00 to 0 - 86400*7 ****/
     190int day_to_sec (char *string, time_t *second) {
     191 
     192  char *p;
     193  struct tm time;
     194
     195  bzero (&time, sizeof(time));
     196  p = strptime (string, "%A@%H:%M:%S", &time);
     197  if (p != NULL) goto valid;
     198
     199  p = strptime (string, "%A@%H:%M", &time);
     200  if (p != NULL) goto valid;
     201
     202  p = strptime (string, "%A@%H", &time);
     203  if (p != NULL) goto valid;
     204
     205  p = strptime (string, "%A", &time);
     206  if (p != NULL) goto valid;
     207
     208  return (FALSE);
     209
     210valid:
     211  if (*p) return (FALSE);
     212  *second = time.tm_wday*86400 + time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;
     213  return (TRUE);
    162214}
    163215
  • trunk/Ohana/src/opihi/pantasks/CheckJobs.c

    r4452 r4602  
    1414    /* check for timeout - only local jobs timeout here */
    1515    if ((job[0].mode == JOB_LOCAL) && (GetTaskTimer(job[0].start) >= job[0].task[0].timeout_period)) {
    16       fprintf (stderr, "timeout on %s\n", job[0].task[0].name);
     16      if (VerboseMode()) fprintf (stderr, "timeout on %s\n", job[0].task[0].name);
    1717      /* run task[0].timeout macro, if it exists */
    1818      if (job[0].task[0].timeout != NULL) {
     
    3030    switch (status) {
    3131      case JOB_PENDING:
    32         fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID);
     32        if (VerboseMode()) fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID);
    3333        break;
    3434
    3535      case JOB_BUSY:
    36         fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID);
     36        if (VerboseMode()) fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID);
    3737        break;
    3838
     
    4141        /* set the stdout and stderr variables with job.stdout, job.stderr */
    4242        /* XXX this will break on 0 values in output streams */
    43         fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
     43        if (VerboseMode()) fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
    4444        set_str_variable ("stdout", job[0].stdout.buffer);
    4545        set_str_variable ("stderr", job[0].stderr.buffer);
     
    5252
    5353      case JOB_EXIT:
    54         fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
     54        if (VerboseMode()) fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
    5555        set_str_variable ("stdout", job[0].stdout.buffer);
    5656        set_str_variable ("stderr", job[0].stderr.buffer);
     
    6969
    7070      default:
    71         fprintf (stderr, "unknown exit status: %d\n", status);
     71        if (VerboseMode()) fprintf (stderr, "unknown exit status: %d\n", status);
    7272        /** do something more useful here ?? **/
    7373        break;
  • trunk/Ohana/src/opihi/pantasks/CheckTasks.c

    r4450 r4602  
    1515    if (GetTaskTimer(task[0].last) < task[0].exec_period) continue;
    1616
     17    /* need to check if the current time is within valid/invalid periods */
     18    if (!CheckTimeRanges (task[0].ranges, task[0].Nranges)) continue;
     19
    1720    SetCurrentTask (task[0].name);
    18     fprintf (stderr, "trying task %s\n", task[0].name);
    1921
    2022    /* ready to run? : run task.exec macro */
     
    3537    /* reset timer on task (don't do this if Create/Submit fails)*/
    3638    gettimeofday (&task[0].last, (void *) NULL);
     39    task[0].Njobs ++;
    3740  }
    3841  return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r4573 r4602  
    339339  int Nread;
    340340
     341  if (!status) return (TRUE);
     342
    341343  /* read stdout buffer */
    342344  Nread = ReadtoIOBuffer (&stdout_buffer, stdout_cntl);
  • trunk/Ohana/src/opihi/pantasks/LocalJob.c

    r4451 r4602  
    1515  pid = fork ();
    1616  if (!pid) { /* must be child process */
    17     fprintf (stderr, "starting local job\n");
     17    if (VerboseMode()) fprintf (stderr, "starting local job\n");
    1818
    1919    /* close the other ends of the pipes */
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r4573 r4602  
    3131$(SDIR)/CheckSystem.$(ARCH).o \
    3232$(SDIR)/CheckTasks.$(ARCH).o \
     33$(SDIR)/CheckTimeRanges.$(ARCH).o \
    3334$(SDIR)/ControllerOps.$(ARCH).o \
    3435$(SDIR)/LocalJob.$(ARCH).o \
     
    4445$(SDIR)/kill.$(ARCH).o \
    4546$(SDIR)/delete.$(ARCH).o \
     47$(SDIR)/verbose.$(ARCH).o \
    4648$(SDIR)/controller.$(ARCH).o \
    4749$(SDIR)/controller_host.$(ARCH).o \
     
    5355$(SDIR)/task_host.$(ARCH).o \
    5456$(SDIR)/task_macros.$(ARCH).o \
     57$(SDIR)/task_trange.$(ARCH).o \
    5558$(SDIR)/task_periods.$(ARCH).o
    5659
  • trunk/Ohana/src/opihi/pantasks/TaskOps.c

    r4450 r4602  
    3737void ListTasks () {
    3838
    39   int i;
     39  int i, valid;
    4040
    4141  for (i = 0; i < Ntasks; i++) {
    42     fprintf (stderr, "%-15s %20s\n", tasks[i].name, tasks[i].argv[0]);
     42    valid = CheckTimeRanges (tasks[i].ranges, tasks[i].Nranges);
     43    if (valid) {
     44      fprintf (stderr, "+ ");
     45    } else {
     46      fprintf (stderr, "- ");
     47    }
     48    fprintf (stderr, "%-15s %4d %20s\n", tasks[i].name, tasks[i].Njobs, tasks[i].argv[0]);
    4349  }
    4450  return;
     
    126132  tasks[Ntasks].timeout_period = 1.0;
    127133
     134  tasks[Ntasks].Nranges = 0;
     135  ALLOCATE (tasks[Ntasks].ranges, TimeRange, 1);
     136
    128137  /* init task timer (is reset by 'run') */ 
    129138  gettimeofday (&tasks[Ntasks].last, (void *) NULL);
     139  tasks[Ntasks].Njobs = 0;
    130140
    131141  Ntasks ++;
  • trunk/Ohana/src/opihi/pantasks/init.c

    r4552 r4602  
    44int task            PROTO((int, char **));
    55int task_host       PROTO((int, char **));
     6int task_trange     PROTO((int, char **));
    67int task_macros     PROTO((int, char **));
    78int task_command    PROTO((int, char **));
     
    1213int kill_job        PROTO((int, char **));
    1314int delete_job      PROTO((int, char **));
     15int verbose         PROTO((int, char **));
    1416
    1517static Command cmds[] = { 
     
    1719  {"task",       task,         "define a schedulable task"},
    1820  {"host",       task_host,    "define host machine for a task"},
     21  {"trange",     task_trange,  "define valid/invalid time periods for a task"},
    1922  {"task.exit",  task_macros,  "define exit macros for a task"},
    2023  {"task.exec",  task_macros,  "define pre-exec macro for a task"},
     
    2629  {"kill",       kill_job,     "kill job"},
    2730  {"delete",     delete_job,   "delete job"},
     31  {"verbose",    verbose,      "set/toggle verbose mode"},
    2832};
    2933
  • trunk/Ohana/src/opihi/pantasks/status.c

    r4552 r4602  
    33int status_sys (int argc, char **argv) {
    44
     5  if (rl_event_hook == NULL) {
     6    fprintf (stderr, "scheduler is stopped\n");
     7  } else {
     8    fprintf (stderr, "scheduler is running\n");
     9  }
    510  ListTasks ();
    611  ListJobs ();
  • trunk/Ohana/src/opihi/pantasks/task.c

    r4451 r4602  
    22# define prompt "> "
    33
    4 enum {TASK_NONE, TASK_EMPTY, TASK_COMMENT, TASK_END, TASK_HOST, TASK_COMMAND, TASK_PERIODS, TASK_EXIT, TASK_EXEC};
     4enum {TASK_NONE, TASK_EMPTY, TASK_COMMENT, TASK_NMAX, TASK_TRANGE, TASK_END, TASK_HOST, TASK_COMMAND, TASK_PERIODS, TASK_EXIT, TASK_EXEC};
    55
    66int task (int argc, char **argv) {
     
    6868
    6969      case TASK_END:
     70        /* I need to add in a test here to see if all task elements
     71           have been defined.  delete the task if not */
    7072        free (input);
    7173        return (TRUE);
    7274        break;
    7375
     76      case TASK_TRANGE:
     77      case TASK_NMAX:
    7478      case TASK_HOST:
    7579      case TASK_EXIT:
     
    104108  if (!strcasecmp (command, "END"))       hash = TASK_END;
    105109  if (!strcasecmp (command, "HOST"))      hash = TASK_HOST;
     110  if (!strcasecmp (command, "NMAX"))      hash = TASK_NMAX;
     111  if (!strcasecmp (command, "TRANGE"))    hash = TASK_TRANGE;
    106112  if (!strcasecmp (command, "COMMAND"))   hash = TASK_COMMAND;
    107113  if (!strcasecmp (command, "PERIODS"))   hash = TASK_PERIODS;
  • trunk/Ohana/src/opihi/scripts/sched.pro

    r4462 r4602  
    33
    44task test
    5   command sched.test
     5  command date
    66  periods -poll 1.0
    7   periods -exec 2.0
    8   periods -timeout 8.0
    9   # host local
    10   host localhost
     7  periods -exec 5.0
     8  periods -timeout 10.0
     9  trange 07:09 07:10
     10  trange -exclude 07:09:30 07:09:45
     11  host local
     12  # host localhost
    1113  # local is default
    1214
    1315  task.exec
    14     echo "starting job sched.test"
     16    # echo "starting job sched.test"
    1517  end
    1618
Note: See TracChangeset for help on using the changeset viewer.