diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -20,36 +20,6 @@ /* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */ - /* Just some notes -- Ethan Zonca - * ++ Make data availible for other apps to parse - * Server<==>Client Communication - * Upload while rendering - */ - - -/* XML notes -- - * - * First off, is XML in our build environment? - * Next, what files are we going to have?: - * - XML file sent with (.blend/.pov/.lux(xml)/whatever) by distren telling the server what to do - * + Includes submitter name, filename, emailaddress, etc - * - XML file on server storing info on current and finished jobs - * - XML file sent by distren when submitting a render to the server - - * - * Overall, we could use XML to make our client/server communication load - * a lot lighter, especially if clients are sent customized xml files telling - * them what frame(s) to render... although that would be inefficient if rendering - * single frames. Maybe not tell it what frames to render in the xml file, the server - * can spit out that info. - * - * Please edit my ramblings if you please, - * --ethanzonca - * - */ - - - #include "execio.h" #include "options.h" #include "distrenjob.h" @@ -64,12 +34,9 @@ #include - - - /* ******************* Structs ************************ */ -// Stores config info? editmycomment +// Gets config info from confs struct distrend_config { cfg_t *mycfg; @@ -87,9 +54,6 @@ struct distrend_config "1" - unassigned "2" - assigned to slave "3" - completed by slave and uploaded - - Have a script crawl through each job in the arrays, priority-biased, and assign a frame to each slave. - Then we will need some sort of watchdog to monitor slaves on the main server to check for stales. Maybe not worry about this for now. */ struct general_info { @@ -118,8 +82,6 @@ int highest_jobnum; // The job number of /* ********************** Functions ************************* */ -/* Functions to stubify */ - /** Performs command stored in a client's request. */ @@ -163,13 +125,17 @@ void remotio_send_to_client() // I am futile! } /** Fill variables after crash / shutdown from XML dumps */ -void start_data(){ +int start_data(){ if(1 == 0){ // retrieve total_finished_jobs and total_finished_frames from xml file + fprintf(stderr,"Parsing XML files and restoring previous state...\n"); + return 1; } else{ general_info.total_finished_jobs = 0; general_info.total_frames_rendered = 0; + fprintf(stderr,"Can't find XML dump, starting up fresh.\n"); + return 2; } } @@ -177,13 +143,12 @@ void start_data(){ void finish_frame(struct distrenjob *distrenjob, int frame){ distrenjob->frameset[frame].status = 2; distrenjob->frameset[frame].time_to_render = (clock() - distrenjob[jobnum].frameset[frame].start_time); // Consider changing time-to-render to time-for-frame or something? - general_info.total_frames_rendered++; // Increase total frames var for stats } /** Queuer: Adds files to the queue */ -void queue(struct distrenjob *distrenjob, int type, char *name, char *submitter, char *email, int priority, int mode, int spp, struct frameset *frameset) { +int queue(struct distrenjob *distrenjob, int type, char *name, char *submitter, char *email, int priority, int mode, int spp, struct frameset *frameset) { // Type: 1 = blender, add more types later // jobnum is the next available job number if(type == 1){ @@ -195,8 +160,11 @@ void queue(struct distrenjob *distrenjob } else{ // Throw error. + fprintf(stderr,"You tried to queue a job type that isn't supported by this version of DistRen.\nI have no idea how this would happen, but it just did.\n"); + return 0; // fail } jobnum++; // Advance the jobnumber for the next queued job +return 0; // OK } @@ -326,7 +294,7 @@ void frame_num_struct_builder(struct dis int frame_finder(struct distrenjob *head, struct distrenjob **job, struct frameset **frame) { int your_frame; // your_frame is an integer value that will be given to the client as the frame number to render - // UNUSED: int your_job; // @TODO: Fixme: do we need this var? you_job is an integer value that must ALSO be given to the client + int your_job; // @TODO: Fixme: do we need this var? you_job is an integer value that must ALSO be given to the client unsigned short int found; unsigned short int priority; @@ -373,9 +341,8 @@ int frame_finder(struct distrenjob *head /* should the job be removed now? */ fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum); } - } /* while(!found) */ + } - fprintf(stderr, "Missing apostrophe !!!!!!!!!!!!!!\n"); abort(); /* sets the value of the frame to 1, which means its taken !!!!!! MISSSING APOSTROPHE!!!!!!! */ distrenjob_ptr->frameset[your_frame].status++; @@ -387,14 +354,14 @@ int frame_finder(struct distrenjob *head return 0; } -/** Checks for dying slaves */ +/** Checks for dead, laggy, or stale slaves */ void blend_frame_watchdog(struct distrenjob *distrenjob_head) { unsigned short int watchdog_forgiveness; /*< seconds to wait on a frame before re-assigning it */ struct distrenjob *distrenjob_ptr; unsigned int counter; - watchdog_forgiveness = 3; /*< hours of forgiveness before frame is re-assigned */ + watchdog_forgiveness = 3; /*< hours of forgiveness before frame is re-assigned @TODO: Make this more user-configurable (maybe per-job), 3 hours is a LONG time */ distrenjob_ptr = distrenjob_head; for(distrenjob_ptr = distrenjob_head; distrenjob_ptr; distrenjob_ptr = distrenjob_ptr->next) @@ -435,7 +402,7 @@ struct distrenjob *distrenjob_get(struct /** - Removes a distrenjob from the distrenjob linkelist. + Removes a distrenjob from the distrenjob linked list. @arg head a double pointer. the head pointer will have to be changed if distrenjob == *head. Thus, make sure that the pointer points to the pointer to the head that all functions use. (I'm going to come back to this and misunderstand myself ;-)) */ @@ -467,10 +434,7 @@ void distrenjob_remove(struct distrenjob } -/* ************************** Main ************************* */ - - -// Begin non-working framework? +/* Grabs config info from confs */ int distrend_do_config(int argc, char *argv[], struct distrend_config **config) { cfg_opt_t myopts_listen[] = @@ -500,7 +464,7 @@ int distrend_do_config(int argc, char *a tmp = xml2distrenjob(&distrenjob, "distrenjob.xml.example"); if(tmp) fprintf(stderr, "xml2distrenjob() returned %d. Try to cd to distren/doc if you want to test out the xml2distrenjob() function. (This will only fix this error if the error is due to an inability of the xml library to access distrenjob.xml.example)\n", tmp); - else + else fprintf(stderr, "using email ``%s'' for user ``%s'' -- reading in XML files and pulling data from them using libxml2+XPath works!!!\n", distrenjob->email, distrenjob->submitter); fprintf(stderr, "%s:%d running config\n", __FILE__, __LINE__); @@ -522,7 +486,9 @@ int distrend_config_free(struct distrend return 0; } -// End non-working framework? + + +/* ************************** Main ************************* */ int main(int argc, char *argv[]) { @@ -535,7 +501,7 @@ int main(int argc, char *argv[]) struct distrend_listenset *listenset; struct distrend_config *config; - start_data(); // Starts fresh or loads data from xml dump + start_data(); // Starts fresh or loads data from xml dump. Should we grab the return? enum clientstatus { @@ -550,7 +516,7 @@ int main(int argc, char *argv[]) distrend_do_config(argc, argv, &config); distrend_listen(&listenset, config); - /* This is called the ``main loop'' */ + /* This is called the "main loop" */ while(cont) { struct distren_action *action;