IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4706


Ignore:
Timestamp:
Aug 4, 2005, 7:51:09 AM (21 years ago)
Author:
eugene
Message:

added test of exit/crash job stacks

Location:
trunk/Ohana/src/opihi
Files:
2 added
11 edited

Legend:

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

    r4705 r4706  
    145145int CheckHost (Host *host);
    146146Stack *GetJobStack (int StackID);
     147Stack *GetJobStackByName (char *name);
    147148int PutJob (Job *job, int StackID, int where);
    148149Job *GetJob (int StackID, int where);
  • trunk/Ohana/src/opihi/pantasks/CheckSystem.c

    r4693 r4706  
    33int CheckSystem () {
    44
     5  /* need to make a timeout: if this process lasts too long,
     6     we should return so the user can get input in.  this cannot
     7     just be a return, because we need to hit each of the elements
     8     eventually
     9  */
     10
    511  CheckTasks ();
    612  CheckJobs ();
     13  CheckController ();
    714  CheckControllerOutput ();
    815  return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r4705 r4706  
    2424    GetJobOutput ("stdout", job[0].pid, &job[0].stdout, job[0].stdout_size);
    2525    GetJobOutput ("stderr", job[0].pid, &job[0].stderr, job[0].stderr_size);
     26    DeleteControllerJob (job);
    2627  } 
    2728  return (TRUE);
    2829}
    2930
     31int DeleteControllerJob (Job *job) {
     32
     33  int status;
     34  char cmd[128];
     35  IOBuffer buffer;
     36
     37  sprintf (cmd, "delete %d", job[0].pid);
     38  InitIOBuffer (&buffer, 0x100);
     39  status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
     40  FreeIOBuffer (&buffer);
     41  return (status);
     42}
     43 
    3044/* ask controller about job status */
    3145int CheckControllerJobStatus (Job *job) {
     
    3953  InitIOBuffer (&buffer, 0x100);
    4054  status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
    41 
    42   /* check on success of controller command */
    43   switch (status) {
    44     case CONTROLLER_DOWN:
    45       if (VerboseMode()) fprintf (stderr, "controller is down\n");
    46       FreeIOBuffer (&buffer);
    47       return (FALSE);
    48 
    49     case CONTROLLER_HUNG:
    50       if (VerboseMode()) fprintf (stderr, "controller is not responding\n");
    51       FreeIOBuffer (&buffer);
    52       return (FALSE);
    53 
    54     case CONTROLLER_GOOD:
    55       if (VerboseMode()) fprintf (stderr, "message received (CheckControllerJobStatus)\n");
    56       break;
    57 
    58     default:
    59       if (VerboseMode()) fprintf (stderr, "unknown status for controller command: programming error\n"); 
    60       exit (1);
     55  if (!status) {
     56    FreeIOBuffer (&buffer);
     57    return (FALSE);
    6158  }
    6259
     
    137134int SubmitControllerJob (Job *job) {
    138135
    139   int i, Nchar;
     136  int i, Nchar, status;
    140137  char *cmd, *p, string[64];
    141138  IOBuffer buffer;
     
    177174
    178175  InitIOBuffer (&buffer, 0x100);
    179   ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
     176  status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
    180177  free (cmd);
    181178
     
    317314  /* send command, is pipe still open? */
    318315  status = write_fmt (stdin_cntl, "%s\n", cmd);
    319   if ((status == -1) && (errno == EPIPE)) return (CONTROLLER_DOWN);
     316  if ((status == -1) && (errno == EPIPE)) {
     317    ControllerStatus = FALSE;
     318    if (VerboseMode()) fprintf (stderr, "controller is down\n");
     319    return (FALSE);
     320  }
    320321 
    321322  /* watch for response - wait up to 1 second */
     
    329330  if (status ==  0) {
    330331    ControllerStatus = FALSE;
    331     return (CONTROLLER_DOWN);
    332   }
    333   if (status == -1) return (CONTROLLER_HUNG);
     332    if (VerboseMode()) fprintf (stderr, "controller is down\n");
     333    return (FALSE);
     334  }
     335  if (status == -1) {
     336    if (VerboseMode()) fprintf (stderr, "controller is not responding\n");
     337    return (FALSE);
     338  }
    334339
    335340  /* need to strip off the prompt */
     
    339344    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
    340345  }
    341   return (CONTROLLER_GOOD);
     346  if (VerboseMode()) fprintf (stderr, "message received\n");
     347  return (TRUE);
    342348}
    343349
     
    396402  InitIOBuffer (&buffer, 0x100);
    397403  status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
     404  FreeIOBuffer (&buffer);
     405  return (status);
    398406
    399407  /** need to interpret output message & free things **/
    400   FreeIOBuffer (&buffer);
    401   return (TRUE);
    402408}
    403409
  • trunk/Ohana/src/opihi/pantasks/JobOps.c

    r4705 r4706  
    172172    CheckLocalJob (job);
    173173  } else {
    174     CheckControllerJob (job);
     174    /* controller jobs are now checked en masse by CheckController */
     175    /* CheckControllerJob (job); */
    175176  }
    176177  return (job[0].state);
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r4705 r4706  
    3030$(SDIR)/CheckJobs.$(ARCH).o \
    3131$(SDIR)/CheckSystem.$(ARCH).o \
     32$(SDIR)/CheckController.$(ARCH).o \
    3233$(SDIR)/CheckTasks.$(ARCH).o \
    3334$(SDIR)/CheckTimeRanges.$(ARCH).o \
  • trunk/Ohana/src/opihi/pantasks/controller_check.c

    r4705 r4706  
    2727  }
    2828  FreeIOBuffer (&buffer);
    29 
    30   /* check on success of controller command */
    31   switch (status) {
    32     case CONTROLLER_DOWN:
    33       fprintf (stderr, "controller is down\n");
    34       return (FALSE);
    35 
    36     case CONTROLLER_HUNG:
    37       fprintf (stderr, "controller is not responding\n");
    38       return (FALSE);
    39 
    40     case CONTROLLER_GOOD:
    41       return (TRUE);
    42 
    43     default:
    44       fprintf (stderr, "unknown status for controller command: programming error\n"); 
    45       exit (1);
    46   }
    47 
    48   fprintf (stderr, "programming error: should not reach here\n"); 
    49   exit (1);
     29  return (TRUE);
    5030
    5131usage:
  • trunk/Ohana/src/opihi/pantasks/controller_host.c

    r4705 r4706  
    1818  InitIOBuffer (&buffer, 0x100);
    1919  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    20   fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
     20  if (status) fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
    2121  FreeIOBuffer (&buffer);
    2222
    23   /* check on success of controller command */
    24   switch (status) {
    25     case CONTROLLER_DOWN:
    26       fprintf (stderr, "controller is down\n");
    27       return (FALSE);
    28 
    29     case CONTROLLER_HUNG:
    30       fprintf (stderr, "controller is not responding\n");
    31       return (FALSE);
    32 
    33     case CONTROLLER_GOOD:
    34       return (TRUE);
    35 
    36     default:
    37       fprintf (stderr, "unknown status for controller command: programming error\n"); 
    38       exit (1);
    39   }
    40 
    41   fprintf (stderr, "programming error: should not reach here\n"); 
    42   exit (1);
    4323}
  • trunk/Ohana/src/opihi/pantasks/controller_status.c

    r4705 r4706  
    2222  InitIOBuffer (&buffer, 0x100);
    2323  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
     24  if (status) fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
     25  FreeIOBuffer (&buffer);
     26  return (TRUE);
    2427
    25   /* check on success of controller command */
    26   switch (status) {
    27     case CONTROLLER_DOWN:
    28       fprintf (stderr, "controller is down\n");
    29       FreeIOBuffer (&buffer);
    30       return (FALSE);
    31 
    32     case CONTROLLER_HUNG:
    33       fprintf (stderr, "controller is not responding\n");
    34       FreeIOBuffer (&buffer);
    35       return (FALSE);
    36 
    37     case CONTROLLER_GOOD:
    38       fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
    39       FreeIOBuffer (&buffer);
    40       return (TRUE);
    41 
    42     default:
    43       fprintf (stderr, "unknown status for controller command: programming error\n"); 
    44       exit (1);
    45   }
    46 
    47   fprintf (stderr, "programming error: should not reach here\n"); 
    48   exit (1);
    4928}
  • trunk/Ohana/src/opihi/pcontrol/JobOps.c

    r4705 r4706  
    3535}
    3636
     37Stack *GetJobStackByName (char *name) {
     38
     39  if (!strcasecmp (name, "pending"))
     40    return (JobPool_Pending);
     41  if (!strcasecmp (name, "busy"))
     42    return (JobPool_Busy);
     43  if (!strcasecmp (name, "done"))
     44    return (JobPool_Done);
     45  if (!strcasecmp (name, "exit"))
     46    return (JobPool_Exit);
     47  if (!strcasecmp (name, "crash"))
     48    return (JobPool_Crash);
     49  return (NULL);
     50}
     51
    3752Job *FindJobStack (IDtype JobID) {
    3853
  • trunk/Ohana/src/opihi/pcontrol/Makefile

    r4693 r4706  
    4848
    4949cmds = \
     50$(SDIR)/check.$(ARCH).o \
     51$(SDIR)/delete.$(ARCH).o \
     52$(SDIR)/host.$(ARCH).o \
    5053$(SDIR)/job.$(ARCH).o \
    51 $(SDIR)/host.$(ARCH).o \
     54$(SDIR)/jobstack.$(ARCH).o \
    5255$(SDIR)/kill.$(ARCH).o \
    53 $(SDIR)/delete.$(ARCH).o \
    54 $(SDIR)/check.$(ARCH).o \
    5556$(SDIR)/status.$(ARCH).o \
    5657$(SDIR)/stdout.$(ARCH).o \
  • trunk/Ohana/src/opihi/pcontrol/init.c

    r4689 r4706  
    11# include "pcontrol.h"
    22
     3int check       PROTO((int, char **));
     4int delete      PROTO((int, char **));
     5int host        PROTO((int, char **));
     6int job         PROTO((int, char **));
     7int jobstack    PROTO((int, char **));
    38int kill_pc     PROTO((int, char **));
    4 int delete      PROTO((int, char **));
    5 int job         PROTO((int, char **));
    6 int host        PROTO((int, char **));
    7 int check       PROTO((int, char **));
    89int status      PROTO((int, char **));
     10int stderr_pc   PROTO((int, char **));
     11int stdout_pc   PROTO((int, char **));
    912int verbose     PROTO((int, char **));
    10 int stdout_pc   PROTO((int, char **));
    11 int stderr_pc   PROTO((int, char **));
    1213
    1314static Command cmds[] = { 
     15  {"check",     check,     "get job or host status"},
     16  {"delete",    delete,    "delete job"},
     17  {"host",      host,      "add / delete / modify host"},
     18  {"job",       job,       "add job"},
     19  {"jobstack",  jobstack,  "list jobs for a single stack"},
    1420  {"kill",      kill_pc,   "kill job"},
    15   {"delete",    delete,    "delete job"},
    16   {"job",       job,       "add job"},
    17   {"host",      host,      "add / delete / modify host"},
    18   {"check",     check,     "get job or host status"},
    1921  {"status",    status,    "get system status"},
     22  {"stderr",    stderr_pc, "get stderr buffer for job"},
    2023  {"stdout",    stdout_pc, "get stdout buffer for job"},
    21   {"stderr",    stderr_pc, "get stderr buffer for job"},
    2224  {"verbose",   verbose,   "set the verbose mode for job"},
    2325};
Note: See TracChangeset for help on using the changeset viewer.