Changeset - 5a4b1484f2ba
[Not reviewed]
default
0 2 0
LordOfWar - 16 years ago 2009-09-15 01:14:05

-re-wrote frame finder to work with any type of job and the linked list
-i did not finish destroying status_report_generator()
-added variable is_job_done to distrenjob structure... so frame finder can find a job, then find the components of the not done job by looking at its type
2 files changed with 36 insertions and 44 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -153,12 +153,13 @@ int start_data(){
 

	
 
/** Finish-Setter: Sets a frame to the "completed" status.*/
 
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?
 
  distrenjob->avg_render_time = ((distrenjob->avg_render_time*(distrenjob->completed_frames - 1)) + distrenjob->frameset[frame].time_to_render)/distrenjob->completed_frames;
 
  distrenjob->completed_frames++;
 
  general_info.total_frames_rendered++; // Increase total frames var for stats
 
}
 

	
 

	
 
/**
 
   creates a structure from starting data, then calls another function to actually add that struct to the queue
 
@@ -370,71 +371,61 @@ void change_job_priority(struct distrenj
 
  Notice that this function starts by looking at the oldest job first
 

	
 
	TODO: Link this up with the main() function to check if there are frames available or not and provide jobnum/framenum to the client
 

	
 
  @return 0 success, other: error
 
*/
 
/*@TODO: change frame_finder to job_finder */
 
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
 

	
 
  int your_frame = 0;  // your_frame is an integer value that will be given to the client as the frame number to render
 
  short int your_job_type = 0;
 
  unsigned short int found;
 
  unsigned short int priority;
 

	
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  found = 0;
 

	
 
  while(!found)
 
  {
 
    /* iterate through jobs from first to last */
 
    for(distrenjob_ptr = head->next; !found && !distrenjob_ptr; distrenjob_ptr = distrenjob_ptr->next)
 
      {
 
        if(distrenjob_ptr->is_job_done)
 
          distrenjob_ptr->type = your_job_type;
 
      }
 

	
 
    switch(your_job_type)
 
    {
 
      /* enumerate through priority levels */
 
      for(priority = 10;
 
        priority > 0
 
            && !found;
 
           priority --)
 
	/* Find the job with the highest priority */
 
        for(distrenjob_ptr = head;
 
            distrenjob_ptr != NULL
 
            && !found;
 
            distrenjob_ptr = distrenjob_ptr->next)
 
          if(distrenjob_ptr->priority == priority)
 
	    found = 1;
 

	
 
      case 1: // blender
 
        found = 0;
 
        for(your_frame; !found; your_frame++)
 
          {
 
            if(distrenjob_ptr->frameset[your_frame].status == 0)
 
              {
 
                found = 1;
 
                distrenjob_ptr->frameset[your_frame].status = 1;
 
                distrenjob_ptr->frameset[your_frame].start_time = clock();
 
                break;
 
              }
 
          }
 
    }
 
  } // end of while statement... job must be found or linked list must be ended to get out of here
 
      if(!found)
 
        {
 
          fprintf(stderr, "No more jobs to render\n");
 
          return 1;
 
        }
 

	
 
      found = 0;
 
      for(your_frame = 0;
 
        your_frame < distrenjob_ptr->total_frames;
 
        your_frame ++)
 
        if(distrenjob_ptr->frameset[your_frame].status == 0)
 
          found = 1;
 

	
 
      if(!found)
 
        {
 
          /* there are no frames left in this job */
 
          distrenjob_ptr->priority --;
 
    // the actual frame number to be rendered by the client is start_frame + your_frame
 
    // @TODO: refine how we want to return data from this
 
    //struct framejob { distrenjob_ptr; distrenjob_ptr->(&frameset[your_frame])};
 

	
 
	  /* If that job had no open frames for some reason, run the status report generator so that */
 
          status_report_generator(&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);
 
          /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */
 
        }
 
    }
 

	
 
  /* Sets the value of the frame to 1, which means it is taken */
 
  distrenjob_ptr->frameset[your_frame].status++;
 

	
 
  distrenjob_ptr->frameset[your_frame].start_time = clock();
 

	
 
  *job = distrenjob_ptr;
 
  *frame =  &distrenjob_ptr->frameset[your_frame];
 
      /* should the job be removed now? ANSWER: well, if a computer decides not to return their frame then we lost our data... so its not done yet. */
 
      fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum);
 
      /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */
 

	
 
  return 0;
 
}
 

	
 
/** Checks for dead, laggy, or stale slaves */
 
void blend_frame_watchdog(struct distrenjob *distrenjob_head)
src/server/distrenjob.h
Show inline comments
 
@@ -31,13 +31,14 @@ typedef unsigned int jobnum_t;
 

	
 
/**
 
   Stores Blender Job Info
 
*/
 
struct distrenjob {
 
  struct distrenjob *next; /*< next will be NULL unless if there is another distrenjob */
 
  int type; // 1:Blender, 2:something else
 
  short int type; // 1:Blender, 2:something else
 
  short int is_job_done; // so job finder can tell if the job is done no matter what type of job it is
 
  char *name;
 
  char *submitter;
 
  char *email; /*< This should be looked up based on the value of submitter, not stored in this struct */
 
  jobnum_t jobnum;
 
  int priority;  // 1 is lowest, 10 is highest, 0 means the job is done
 
  float percent_done;
0 comments (0 inline, 0 general)