Changeset - 754555c90530
[Not reviewed]
default
0 2 0
ethanzonca - 16 years ago 2009-09-03 22:39:53

Some structural updates and minor changes in a readthrough of the server code.
2 files changed with 23 insertions and 56 deletions:
0 comments (0 inline, 0 general)
TODO
Show inline comments
 
@@ -13,7 +13,7 @@ Master
 
 -Write more meat into the pseudo-code main() to pull everything together
 
 -Write a stub for getting info from the tarball/validifying the tarball. Read distren-job.xml, a file in the tarball, to find out 1. which rendering system to use (that system, e.g. blender/povray, can read more specifics, such as name of file to pass to blender and frames. Options common between different systems will be handled in common as best as possible)
 
 -Write a stub for publishing file and constructing job description so that the job can be shared
 
*-Other XML-writing/reading
 
*-Other XML-writing/reading such as current stats / jobs / data / etc, xml writing for job creation, ...
 
*-charsets: the program should operate in UTF-8. This is partially required by libxml2's (and XML's) usage of UTF-8. We want the program's internal charset to be UTF-8 and figure out if we need w_char/whatever to fulfill UTF-8. I don't believe we do... mabye we just need a declaration that al data stored must be in UTF-8 format.
 
 -rename some struct members and variables to be more program-agnostic and more sensible (e.g., no blender-specific stuff)
 

	
 
@@ -28,6 +28,7 @@ Slave
 
*-Fix line 194 (call to myjob struct that fails miserably)
 
B-Add tmpdir variable (just like the datadir variable) that is compile-time or whatever
 
*-Add code to delete old jobfiles (maybe based on timestamp, etc... make sure they're uploaded first)
 
 -Upload while rendering? Would be nice.
 

	
 
Options
 
 -Rewrite some stuff, try to make it simpler
src/server/distrend.c
Show inline comments
 
@@ -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 <time.h>
 

	
 

	
 

	
 

	
 

	
 
/* ******************* 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[] =
 
@@ -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;
0 comments (0 inline, 0 general)