IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10693


Ignore:
Timestamp:
Dec 13, 2006, 8:55:12 AM (20 years ago)
Author:
eugene
Message:

added run level

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

Legend:

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

    r8424 r10693  
    3232  PCONTROL_HOST_OFF,
    3333} HostStat;
     34
     35typedef enum {
     36  PCONTROL_RUN_UNKNOWN,
     37  PCONTROL_RUN_NONE,
     38  PCONTROL_RUN_HOSTS,
     39  PCONTROL_RUN_REAP,
     40  PCONTROL_RUN_ALL,
     41} RunLevels;
    3442
    3543/* stack special positions */
  • trunk/Ohana/src/opihi/pcontrol/CheckSystem.c

    r10668 r10693  
    33
    44static struct timeval lastlive = {0, 0};
    5 static int RunSystem = FALSE;
    6 
    7 int SetRunSystem (int state) {
    8   int oldstate;
    9   oldstate = RunSystem;
    10   RunSystem = state;
    11   return oldstate;
     5static RunLevels RunLevel = PCONTROL_RUN_NONE;
     6
     7RunLevels SetRunLevel (RunLevels level) {
     8  RunLevels oldlevel;
     9  oldlevel = RunLevel;
     10  RunLevel = level;
     11  return oldlevel;
     12}
     13
     14RunLevels GetRunLevel () {
     15  return RunLevel;
    1216}
    1317
     
    6569    TestCheckPoint ();
    6670
    67     // don't run the system checks if RunSystem is FALSE
     71    // don't run the system checks if RunLevel is FALSE
    6872    // XXX stop should not suspend all checks: we should continue
    6973    // to harvest completed jobs and migrate idle machines to down
    70     if (!RunSystem) {
    71       usleep (50000); // idle if RunSystem is FALSE
     74    if (RunLevel == PCONTROL_RUN_NONE) {
     75      usleep (100000); // idle if we are running nothing
    7276      continue;
    7377    }
    74 
    75     Njobchecks = 0;
    76     Nhostchecks = 0;
    77 
    78     // we want to give each block a maximum allowed time
    79     Nhostchecks += CheckIdleHosts(0.020); /* submit a new job */
    80     TestCheckPoint ();
    81 
    82     Njobchecks  += CheckBusyJobs(0.020);  /* get job status */
    83     Njobchecks  += CheckDoneJobs(0.020);  /* harvest job stdout/stderr */
    84     Njobchecks  += CheckKillJobs(0.020);  /* harvest job stdout/stderr */
    85     TestCheckPoint ();
    86 
    87     Nhostchecks += CheckDoneHosts(0.020); /* reset the host */
    88     Nhostchecks += CheckDownHosts(0.100); /* launch the host */
    89     TestCheckPoint ();
    9078
    9179    /* always allow at least one test */
    9280    /* most tests require about 2ms per host. 
    9381       CheckDoneJobs must depend on the size of the output buffer */
     82    /* the max delay times are fairly arbitrary and do not impact
     83       the user interface.
     84     */
     85
     86    Njobchecks = 0;
     87    Nhostchecks = 0;
     88
     89    if ((RunLevel == PCONTROL_RUN_ALL) || (RunLevel == PCONTROL_RUN_REAP)) {
     90      Njobchecks  += CheckBusyJobs(0.020);  /* get job status */
     91      Njobchecks  += CheckDoneJobs(0.020);  /* harvest job stdout/stderr */
     92      Njobchecks  += CheckKillJobs(0.020);  /* harvest job stdout/stderr */
     93      TestCheckPoint ();
     94    }
     95
     96    if (RunLevel != PCONTROL_RUN_NONE) {
     97      Nhostchecks += CheckDoneHosts(0.020); /* reset the host */
     98      Nhostchecks += CheckDownHosts(0.100); /* launch the host */
     99      TestCheckPoint ();
     100    }
     101
     102    if (RunLevel == PCONTROL_RUN_ALL) {
     103      // we want to give each block a maximum allowed time
     104      Nhostchecks += CheckIdleHosts(0.020); /* submit a new job */
     105      TestCheckPoint ();
     106    }
    94107
    95108    // there is nothing on the stacks.  test the hosts and wait a bit
    96     if (!Njobchecks && !Nhostchecks) {
     109    if (!Njobchecks && !Nhostchecks && (RunLevel != PCONTROL_RUN_NONE)) {
    97110      CheckLiveHosts(0.040);
    98111      usleep (100000); // idle if no jobs are waiting
    99112    }
    100 
     113   
    101114    if (DEBUG) {
    102115      Stack *stack;
  • trunk/Ohana/src/opihi/pcontrol/Makefile

    r10342 r10693  
    5050$(SDIR)/kill.$(ARCH).o \
    5151$(SDIR)/pulse.$(ARCH).o \
    52 $(SDIR)/stop.$(ARCH).o \
    5352$(SDIR)/run.$(ARCH).o \
    5453$(SDIR)/status.$(ARCH).o \
  • trunk/Ohana/src/opihi/pcontrol/init.c

    r8424 r10693  
    1010int status      PROTO((int, char **));
    1111int run         PROTO((int, char **));
    12 int stop        PROTO((int, char **));
    1312int stderr_pc   PROTO((int, char **));
    1413int stdout_pc   PROTO((int, char **));
    1514int verbose     PROTO((int, char **));
    16 int version         PROTO((int, char **));
     15int version     PROTO((int, char **));
    1716
    1817// pulse is only available in the un-threaded version
     
    2322  {"hoststack", hoststack, "list hosts for a single stack"},
    2423  {"status",    status,    "get system status"},
    25   {"stop",      stop,      "stop controller processing"},
    26   {"run",       run,       "start controller processing"},
     24  {"stop",      run,       "stop controller processing"},
     25  {"run",       run,       "set controller runlevel"},
    2726  {"verbose",   verbose,   "set the verbose mode for job"},
    2827  {"version",   version,   "show version information"},
  • trunk/Ohana/src/opihi/pcontrol/pcontrol.c

    r10649 r10693  
    3131  rl_attempted_completion_function = command_completer;
    3232# ifdef THREADED
    33   SetRunSystem (TRUE);
     33  SetRunLevel (PCONTROL_RUN_ALL);
    3434  pthread_create (&clientsThread, NULL, &CheckSystem_Threaded, NULL);
    3535  rl_event_hook = NULL;
  • trunk/Ohana/src/opihi/pcontrol/run.c

    r8424 r10693  
    33int run (int argc, char **argv) {
    44
    5   if (argc != 1) {
    6     gprint (GP_ERR, "USAGE: run\n");
     5  RunLevels level;
     6
     7  if ((argc > 2) ||
     8      get_argument (argc, argv, "help") ||
     9      get_argument (argc, argv, "-h") ||
     10      get_argument (argc, argv, "--help"))
     11  {
     12    if (!strcmp (argv[0], "run")) {
     13      gprint (GP_ERR, "USAGE: run [level]\n");
     14      gprint (GP_ERR, "  allowed levels:\n");
     15      gprint (GP_ERR, "  all (default) : manage machines, spawn jobs, harvest jobs\n");
     16      gprint (GP_ERR, "  reap          : manage machines, harvest jobs\n");
     17      gprint (GP_ERR, "  hosts         : manage machines, not jobs\n");
     18      gprint (GP_ERR, "  none          : all stop\n");
     19    } else {
     20      gprint (GP_ERR, "USAGE: stop (immediate processing halt)\n");
     21    }
     22    return (FALSE);
     23  }
     24
     25  level = PCONTROL_RUN_UNKNOWN;
     26  if (argc == 1) {
     27    if (!strcasecmp (argv[0], "run")) level = PCONTROL_RUN_ALL;
     28    if (!strcasecmp (argv[0], "stop")) level = PCONTROL_RUN_NONE;
     29  } else {
     30    if (!strcasecmp (argv[1], "all")) level = PCONTROL_RUN_ALL;
     31    if (!strcasecmp (argv[1], "reap")) level = PCONTROL_RUN_REAP;
     32    if (!strcasecmp (argv[1], "host")) level = PCONTROL_RUN_HOSTS;
     33    if (!strcasecmp (argv[1], "hosts")) level = PCONTROL_RUN_HOSTS;
     34    if (!strcasecmp (argv[1], "none")) level = PCONTROL_RUN_NONE;
     35  }
     36
     37  if (level == PCONTROL_RUN_UNKNOWN) {
     38    gprint (GP_ERR, "  unknown run level %s\n", argv[1]);
     39    gprint (GP_ERR, "  allowed levels:\n");
     40    gprint (GP_ERR, "  all (default) : manage machines, spawn jobs, harvest jobs\n");
     41    gprint (GP_ERR, "  reap          : manage machines, harvest jobs\n");
     42    gprint (GP_ERR, "  hosts         : manage machines, not jobs\n");
     43    gprint (GP_ERR, "  none          : all stop\n");
    744    return (FALSE);
    845  }
    946
    1047# ifdef THREADED
    11   SetRunSystem (TRUE);
     48  SetRunLevel (level);
    1249# else
    13   rl_event_hook = CheckSystem;
     50  if (level == PCONTROL_RUN_NONE) {
     51    rl_event_hook = NULL;
     52  } else {
     53    rl_event_hook = CheckSystem;
     54  }
    1455# endif
    1556
     
    1758}
    1859
     60/*
     61   run levels:
     62   all (manage machines, spawn jobs, harvest jobs)
     63   reap (manage machines, harvest jobs)
     64   hosts (manage machines, not jobs)
     65   none (all stop)
     66*/
Note: See TracChangeset for help on using the changeset viewer.