Changeset 4552 for trunk/Ohana/src/opihi/pantasks
- Timestamp:
- Jul 14, 2005, 8:18:09 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 2 added
- 10 edited
-
ControllerOps.c (modified) (1 diff)
-
Makefile (modified) (2 diffs)
-
controller.c (modified) (2 diffs)
-
controller_check.c (modified) (4 diffs)
-
controller_status.c (modified) (3 diffs)
-
delete.c (modified) (2 diffs)
-
init.c (modified) (3 diffs)
-
job.c (modified) (1 diff)
-
kill.c (modified) (2 diffs)
-
run.c (modified) (1 diff)
-
status.c (added)
-
stop.c (added)
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.
