Changeset 10693
- Timestamp:
- Dec 13, 2006, 8:55:12 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 6 edited
-
include/pcontrol.h (modified) (1 diff)
-
pcontrol/CheckSystem.c (modified) (2 diffs)
-
pcontrol/Makefile (modified) (1 diff)
-
pcontrol/init.c (modified) (2 diffs)
-
pcontrol/pcontrol.c (modified) (1 diff)
-
pcontrol/run.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/pcontrol.h
r8424 r10693 32 32 PCONTROL_HOST_OFF, 33 33 } HostStat; 34 35 typedef enum { 36 PCONTROL_RUN_UNKNOWN, 37 PCONTROL_RUN_NONE, 38 PCONTROL_RUN_HOSTS, 39 PCONTROL_RUN_REAP, 40 PCONTROL_RUN_ALL, 41 } RunLevels; 34 42 35 43 /* stack special positions */ -
trunk/Ohana/src/opihi/pcontrol/CheckSystem.c
r10668 r10693 3 3 4 4 static 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; 5 static RunLevels RunLevel = PCONTROL_RUN_NONE; 6 7 RunLevels SetRunLevel (RunLevels level) { 8 RunLevels oldlevel; 9 oldlevel = RunLevel; 10 RunLevel = level; 11 return oldlevel; 12 } 13 14 RunLevels GetRunLevel () { 15 return RunLevel; 12 16 } 13 17 … … 65 69 TestCheckPoint (); 66 70 67 // don't run the system checks if Run Systemis FALSE71 // don't run the system checks if RunLevel is FALSE 68 72 // XXX stop should not suspend all checks: we should continue 69 73 // to harvest completed jobs and migrate idle machines to down 70 if ( !RunSystem) {71 usleep ( 50000); // idle if RunSystem is FALSE74 if (RunLevel == PCONTROL_RUN_NONE) { 75 usleep (100000); // idle if we are running nothing 72 76 continue; 73 77 } 74 75 Njobchecks = 0;76 Nhostchecks = 0;77 78 // we want to give each block a maximum allowed time79 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 ();90 78 91 79 /* always allow at least one test */ 92 80 /* most tests require about 2ms per host. 93 81 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 } 94 107 95 108 // 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)) { 97 110 CheckLiveHosts(0.040); 98 111 usleep (100000); // idle if no jobs are waiting 99 112 } 100 113 101 114 if (DEBUG) { 102 115 Stack *stack; -
trunk/Ohana/src/opihi/pcontrol/Makefile
r10342 r10693 50 50 $(SDIR)/kill.$(ARCH).o \ 51 51 $(SDIR)/pulse.$(ARCH).o \ 52 $(SDIR)/stop.$(ARCH).o \53 52 $(SDIR)/run.$(ARCH).o \ 54 53 $(SDIR)/status.$(ARCH).o \ -
trunk/Ohana/src/opihi/pcontrol/init.c
r8424 r10693 10 10 int status PROTO((int, char **)); 11 11 int run PROTO((int, char **)); 12 int stop PROTO((int, char **));13 12 int stderr_pc PROTO((int, char **)); 14 13 int stdout_pc PROTO((int, char **)); 15 14 int verbose PROTO((int, char **)); 16 int version PROTO((int, char **));15 int version PROTO((int, char **)); 17 16 18 17 // pulse is only available in the un-threaded version … … 23 22 {"hoststack", hoststack, "list hosts for a single stack"}, 24 23 {"status", status, "get system status"}, 25 {"stop", stop,"stop controller processing"},26 {"run", run, "s tart controller processing"},24 {"stop", run, "stop controller processing"}, 25 {"run", run, "set controller runlevel"}, 27 26 {"verbose", verbose, "set the verbose mode for job"}, 28 27 {"version", version, "show version information"}, -
trunk/Ohana/src/opihi/pcontrol/pcontrol.c
r10649 r10693 31 31 rl_attempted_completion_function = command_completer; 32 32 # ifdef THREADED 33 SetRun System (TRUE);33 SetRunLevel (PCONTROL_RUN_ALL); 34 34 pthread_create (&clientsThread, NULL, &CheckSystem_Threaded, NULL); 35 35 rl_event_hook = NULL; -
trunk/Ohana/src/opihi/pcontrol/run.c
r8424 r10693 3 3 int run (int argc, char **argv) { 4 4 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"); 7 44 return (FALSE); 8 45 } 9 46 10 47 # ifdef THREADED 11 SetRun System (TRUE);48 SetRunLevel (level); 12 49 # 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 } 14 55 # endif 15 56 … … 17 58 } 18 59 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.
