Changeset 4552
- Timestamp:
- Jul 14, 2005, 8:18:09 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 2 added
- 13 edited
-
doc/scheduler.txt (modified) (1 diff)
-
include/scheduler.h (modified) (1 diff)
-
pantasks/ControllerOps.c (modified) (1 diff)
-
pantasks/Makefile (modified) (2 diffs)
-
pantasks/controller.c (modified) (2 diffs)
-
pantasks/controller_check.c (modified) (4 diffs)
-
pantasks/controller_status.c (modified) (3 diffs)
-
pantasks/delete.c (modified) (2 diffs)
-
pantasks/init.c (modified) (3 diffs)
-
pantasks/job.c (modified) (1 diff)
-
pantasks/kill.c (modified) (2 diffs)
-
pantasks/run.c (modified) (1 diff)
-
pantasks/status.c (added)
-
pantasks/stop.c (added)
-
pcontrol/check.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/doc/scheduler.txt
r4452 r4552 1 2 2005.07.14 3 4 I am still exploring the scheduler / controller interactions. the 5 automatic interactions seem to work pretty well now. The area of 6 confusion is in the user interface, both in terms of checking on the 7 status of things (both controller and scheduler) and in terms of 8 having user control over aspects of the controller. 9 10 I have defined user functions which execute the controller commands 11 'status' and 'check'. These are straightforeward since they simply 12 send a command to the controller and echo the output (or give an error 13 condition message). 14 15 Should the user have the ability to define a job, independent of a 16 task? This could be implemented purely as a controller action: the 17 controller commands 'job', 'kill', 'delete', 'stderr', 'stdout' would 18 be available from the scheduler, and the commands simply passed 19 along. This adds a bit to the complexity: if the 'delete' command is 20 passed along, nothing prevents the user from deleting a job scheduled 21 by the scheduler from a task. the scheduler may then get confused 22 when it tries to interact with that job in the future from the 23 automatic loop. 24 25 Another option is to simply have these commands interact with the 26 scheduler's job stack. this has the advantage of limiting the 27 scheduler / controller responsibility errors (scheduler, not user, is 28 always responsible to sending/harvesting jobs to/from the 29 controller, though we still need to handle the cases if a job is lost 30 or dropped by the controller). the diffficulty here is deciding how 31 to handle the job completion. we would need a way to define a set of 32 exit macros, which could then do something useful with the output. 33 34 Another possibility is to define limits on how many times a task may 35 spawn a job. There would then be no 'job' function. If we define 36 this limitation, we will still need a way of killing and deleting a 37 specific job. Thus a 'kill' and 'delete' function would examine and 38 modify the scheduler's job stack. The stderr and stdout functions are 39 then already part of the task commands. 40 41 Other task options might include: 42 43 - a list of allow / exclude time periods (which should be time-of-day 44 ranges and day-of-week ranges). 45 46 - a function to delete an existing task (which would have to stop the 47 spawning of new jobs, at least until no more jobs for that task 48 remain). 49 50 - allow the 'periods' command to define defaults when outside of a 51 task 52 53 - 1 54 2 55 2005.07.05 -
trunk/Ohana/src/opihi/include/scheduler.h
r4450 r4552 126 126 int CheckLocalJobStatus (Job *job); 127 127 void InitTaskTimers (); 128 Function *FindControllerCommand (char *cmd); -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r4452 r4552 3 3 # define CONNECT_TIMEOUT 300 4 4 5 int status = FALSE; 6 int stdin_cntl, stdout_cntl, stderr_cntl; 5 static int status = FALSE; 6 static int stdin_cntl, stdout_cntl, stderr_cntl; 7 8 int CheckControllerStatus () { 9 return (status); 10 } 7 11 8 12 int CheckControllerJob (Job *job) { -
trunk/Ohana/src/opihi/pantasks/Makefile
r4450 r4552 26 26 27 27 funcs = \ 28 $(SDIR)/init.$(ARCH).o \ 29 $(SDIR)/scheduler.$(ARCH).o \ 28 30 $(SDIR)/CheckJobs.$(ARCH).o \ 29 31 $(SDIR)/CheckSystem.$(ARCH).o \ … … 34 36 $(SDIR)/TaskOps.$(ARCH).o \ 35 37 $(SDIR)/IOBufferOps.$(ARCH).o \ 36 $(SDIR)/memstr.$(ARCH).o \ 37 $(SDIR)/init.$(ARCH).o 38 $(SDIR)/memstr.$(ARCH).o 38 39 39 40 cmds = \ 41 $(SDIR)/run.$(ARCH).o \ 42 $(SDIR)/stop.$(ARCH).o \ 43 $(SDIR)/status.$(ARCH).o \ 44 $(SDIR)/kill.$(ARCH).o \ 45 $(SDIR)/delete.$(ARCH).o \ 40 46 $(SDIR)/controller.$(ARCH).o \ 41 $(SDIR)/run.$(ARCH).o \ 42 $(SDIR)/scheduler.$(ARCH).o \ 47 $(SDIR)/controller_host.$(ARCH).o \ 48 $(SDIR)/controller_check.$(ARCH).o \ 49 $(SDIR)/controller_status.$(ARCH).o \ 43 50 $(SDIR)/task.$(ARCH).o \ 44 51 $(SDIR)/task_command.$(ARCH).o \ -
trunk/Ohana/src/opihi/pantasks/controller.c
r4539 r4552 1 1 # include "scheduler.h" 2 3 int controller_host PROTO((int, char **)); 4 int controller_status PROTO((int, char **)); 5 int controller_check PROTO((int, char **)); 2 6 3 7 static Command controller_cmds[] = { … … 34 38 35 39 for (i = 0; i < N; i++) { 36 if (!strcmp (controller_cmds[i].name, argv[1])) {40 if (!strcmp (controller_cmds[i].name, cmd)) { 37 41 return (controller_cmds[i].func); 38 42 } -
trunk/Ohana/src/opihi/pantasks/controller_check.c
r4539 r4552 1 1 # include "scheduler.h" 2 2 3 int controller_ host(int argc, char **argv) {3 int controller_check (int argc, char **argv) { 4 4 5 5 int status; … … 7 7 IOBuffer buffer; 8 8 9 if (argc != 3) { 10 fprintf (stderr, "USAGE: controller host (hostname)\n"); 11 return (FALSE); 9 if (argc != 3) goto usage; 10 if (strcasecmp (argv[2], "JOB") && 11 strcasecmp (argv[2], "HOST")) goto usage; 12 13 /* check if controller is running */ 14 status = CheckControllerStatus (); 15 if (!status) { 16 fprintf (stderr, "controller is not running\n"); 17 return (TRUE); 12 18 } 13 19 14 /* start controller connection (if needed) */ 15 StartController (); 16 17 sprintf (command, "host %s", argv[2]); 20 sprintf (command, "check %s %s", argv[2], argv[3]); 18 21 InitIOBuffer (&buffer, 0x100); 19 22 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); … … 32 35 case CONTROLLER_GOOD: 33 36 fprintf (stderr, "controller command sent\n"); 37 fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr); 34 38 return (TRUE); 35 39 … … 41 45 fprintf (stderr, "programming error: should not reach here\n"); 42 46 exit (1); 47 48 usage: 49 fprintf (stderr, "USAGE: controller check job (jobID)\n"); 50 fprintf (stderr, "USAGE: controller check host (hostID)\n"); 51 return (FALSE); 43 52 } -
trunk/Ohana/src/opihi/pantasks/controller_status.c
r4539 r4552 1 1 # include "scheduler.h" 2 2 3 int controller_ host(int argc, char **argv) {3 int controller_status (int argc, char **argv) { 4 4 5 5 int status; … … 8 8 9 9 if (argc != 3) { 10 fprintf (stderr, "USAGE: controller host (hostname)\n");10 fprintf (stderr, "USAGE: controller status\n"); 11 11 return (FALSE); 12 12 } 13 13 14 /* start controller connection (if needed) */ 15 StartController (); 14 /* check if controller is running */ 15 status = CheckControllerStatus (); 16 if (!status) { 17 fprintf (stderr, "controller is not running\n"); 18 return (TRUE); 19 } 16 20 17 sprintf (command, " host %s", argv[2]);21 sprintf (command, "status"); 18 22 InitIOBuffer (&buffer, 0x100); 19 23 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); … … 32 36 case CONTROLLER_GOOD: 33 37 fprintf (stderr, "controller command sent\n"); 38 fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr); 34 39 return (TRUE); 35 40 -
trunk/Ohana/src/opihi/pantasks/delete.c
r4539 r4552 1 # include " pcontrol.h"1 # include "scheduler.h" 2 2 3 int delete (int argc, char **argv) {3 int delete_job (int argc, char **argv) { 4 4 5 5 Job *job; … … 13 13 /* use a string interp to convert JobIDs to ints ? */ 14 14 15 job = PullJob (JobID, PCONTROL_JOB_PENDING); 16 if (job != NULL) goto found; 17 18 job = PullJob (JobID, PCONTROL_JOB_CRASH); 19 if (job != NULL) goto found; 20 21 job = PullJob (JobID, PCONTROL_JOB_EXIT); 22 if (job != NULL) goto found; 23 24 fprintf (stderr, "job %s not PENDING, CRASH, EXIT\n", argv[1]); 25 return (FALSE); 26 27 found: 28 { 29 int j; 30 fprintf (stderr, "deleting job %s %d ", job[0].hostname, job[0].argc); 31 for (j = 0; j < job[0].argc; j++) { 32 fprintf (stderr, "%s ", job[0].argv[j]); 33 } 34 PrintID (stderr, job[0].JobID); 35 fprintf (stderr, "\n"); 36 } 37 DelJob (job); 38 15 fprintf (stderr, "this function is not yet implemented\n"); 39 16 return (TRUE); 40 17 } -
trunk/Ohana/src/opihi/pantasks/init.c
r4539 r4552 1 # include "basic.h"2 1 # include "scheduler.h" 3 2 … … 10 9 int run PROTO((int, char **)); 11 10 int stop PROTO((int, char **)); 11 int status_sys PROTO((int, char **)); 12 int kill_job PROTO((int, char **)); 13 int delete_job PROTO((int, char **)); 12 14 13 15 static Command cmds[] = { … … 21 23 {"run", run, "run the scheduler"}, 22 24 {"stop", stop, "stop the scheduler"}, 25 {"status", status_sys, "get system status"}, 26 {"kill", kill_job, "kill job"}, 27 {"delete", delete_job, "delete job"}, 28 }; 23 29 30 /* these are functions which duplicate actions on the 31 controller. these could simply pass the command along 32 to the controller (and should then be in 'controller'), 33 or they could add / modify the jobs in the scheduler 34 job stack 35 36 {"job", job, "add job"}, 24 37 {"kill", kill_sh, "kill job"}, 25 38 {"delete", delete, "delete job"}, 26 {"job", job, "add job"}, 27 {"host", host, "add / delete / modify host"}, 28 {"check", check, "get job or host status"}, 29 {"status", status, "get system status"}, 30 {"stdout", stdout_pc, "get stdout buffer for job"}, 31 {"stderr", stderr_pc, "get stderr buffer for job"}, 32 }; 39 {"stdout", stdout_sh, "get stdout buffer for job"}, 40 {"stderr", stderr_sh, "get stderr buffer for job"}, 41 */ 33 42 34 43 void InitSched () { -
trunk/Ohana/src/opihi/pantasks/job.c
r4539 r4552 1 # include "pcontrol.h" 1 # include "scheduler.h" 2 3 /* this will require a bit of care: to define a job, we need 4 to specify: 5 - the command 6 this is defined in the job command: job argv0 argv1 argv2... 7 - timeout (an option to the command) 8 - exit macros? 9 do nothing by default? 10 - stderr / stdout disposal? 11 save in a specific buffer by default? 12 send to a file? 13 14 the command can look just like the controller equivalent one: 15 job [-host host] [-timeout timeout] args... 16 17 */ 2 18 3 19 int job (int argc, char **argv) { -
trunk/Ohana/src/opihi/pantasks/kill.c
r4539 r4552 1 # include " pcontrol.h"1 # include "scheduler.h" 2 2 3 int kill_ pc(int argc, char **argv) {3 int kill_job (int argc, char **argv) { 4 4 5 5 Job *job; … … 12 12 JobID = atoi (argv[1]); 13 13 14 job = PullJob (JobID, PCONTROL_JOB_BUSY); 15 if (job == NULL) { 16 fprintf (stderr, "job %s not BUSY\n", argv[1]); 17 return (FALSE); 18 } 19 KillJob (job); 14 /* not yet implemented */ 15 16 fprintf (stderr, "this function is not yet implemented\n"); 20 17 return (TRUE); 21 18 } 22 23 /* find job from jobID, kill locally or on controller */ -
trunk/Ohana/src/opihi/pantasks/run.c
r4450 r4552 14 14 return (TRUE); 15 15 } 16 17 int stop (int argc, char **argv) {18 19 if (argc != 1) {20 fprintf (stderr, "USAGE: stop\n");21 return (FALSE);22 }23 24 rl_event_hook = NULL;25 rl_set_keyboard_input_timeout (1000000);26 27 return (TRUE);28 } -
trunk/Ohana/src/opihi/pcontrol/check.c
r4450 r4552 10 10 11 11 if (argc != 3) { 12 fprintf (stderr, "USAGE: check (job)(JobID)\n");13 fprintf (stderr, "USAGE: check (host)(HostID)\n");12 fprintf (stderr, "USAGE: check job (JobID)\n"); 13 fprintf (stderr, "USAGE: check host (HostID)\n"); 14 14 return (FALSE); 15 15 }
Note:
See TracChangeset
for help on using the changeset viewer.
