Changeset - 8b4176963ede
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-07-15 19:51:44
ohnobinki@ohnopublishing.net
fixed some references to status_report_generator()
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -61,97 +61,97 @@ struct distrend_config
 
  "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 {
 
	short int jobs_in_queue; //
 
	unsigned short int free_clients;
 
	unsigned short int rendering_clients;//
 
	unsigned short int total_finished_jobs; //
 
	unsigned int total_frames_rendered; //
 
} general_info;
 

	
 
// Stores Blender Job Info
 
struct blendjob {
 
  struct blendjob *next; /* next will be NULL unless if there is another blendjob */
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  jobnum_t jobnum;
 
  int priority;  // 1 is lowest, 10 is highest, 0 means the job is done
 
  int percent_done;
 
  int completed_frames; // number of completed frames for stats/etc
 
  int assigned_frames; // number of assigned frames (that are not yet completed) for stats/etc
 
  int total_frames; // how many frames are in the animation for stats/etc (unassigned frames)
 
  int avg_render_time; // average seconds it took to render a frame
 
  unsigned int time_remaining; // estimated seconds remaining till render is complete (up to 49, 710 days)
 
							   // we can have the client computer convert it into days, hours, etc if they wish to view it
 
  struct frameset *frameset;
 
};
 

	
 

	
 
// Frameset Structure
 
struct frameset {
 
	int frame_num; // frame number to render
 
	char slave_name; // user that frame is assigned to
 
	int frame_status; // status of frame, 0= unassigned, 1= taken, 2= done
 
	clock_t start_time; // time the frame was started
 
	int time_to_render; // the total seconds it took to render the frame
 
} frameset[]; // Frameset array is generated by status_report_generator function
 
                         // Using this method to save memory, because if animation starts on a high frame number, it would waste a lot of RAM on empty structures
 

	
 

	
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void status_report_generator();
 
void status_report_generator(struct blendjob **blendjobs_head);
 
void blendjob_remove(struct blendjob **head, struct blendjob *bj);
 

	
 
struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum);
 

	
 
/* Global Vars, try to cut down on these */
 
jobnum_t jobnum = 0; // The next job number to create in the queue
 
int hcfjob; // Highest consecutively finished job
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 

	
 
/* ********************** Functions ************************* */
 

	
 
void start_data(){
 

	
 
	if(1 == 0){
 
		// retrieve total_finished_jobs and total_finished_frames from xml file
 
	}
 
	else{
 
		general_info.total_finished_jobs = 0;
 
		general_info.total_frames_rendered = 0;
 
	}
 
}
 

	
 
// **** Finish-Setter: Sets a frame to the "completed" status.
 
void finish_frame(struct blendjob *blendjob, int frame){
 
  blendjob->frameset[frame].frame_status = 2;
 
  blendjob->frameset[frame].time_to_render = (clock() - blendjob[jobnum].frameset[frame].start_time); // Consider changin 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 blendjob *blendjob, 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){
 
    blendjob->name = name;
 
    blendjob->submitter = submitter;
 
    blendjob->email = email;
 
    blendjob->priority = priority;
 
    blendjob->frameset = frameset;
 
  }
 
  else{
 
    // Throw error.
 
  }
 
jobnum++; // Advance the jobnumber for the next queued job
 
}
 
@@ -266,97 +266,97 @@ void frame_num_struct_builder(struct ble
 

	
 
	highest_jobnum++; // After it has created the job, it adds one to the highest_jobnum interger
 
}
 

	
 

	
 

	
 
// Frame Assigner: matches your computer up with a lovely frame to render
 
// Major issue here, the client needs to know the frame number, AND the job number!
 
int frame_finder(){
 
	int your_frame = 0;  // your_frame is an interger value that will be given to the client as the frame number to render
 
	int finder_jobnum = 0;
 
	int frameset_count = 0; // the frameset number, note* frames in an animation don't start at zero
 
	short int done = 0;
 
	short int priority = 10;
 

	
 
	while(priority >= 1){ // start the scan for the next job with the highest priority, decreases priority before it loops
 
		finder_jobnum = hcfjob + 1; // reset it to start scanning at first uncompleted job for the pass at each priority level
 

	
 
		while(finder_jobnum <= highest_jobnum){  // This keeps increasing the finder_jobnum until it is higher than the highest_jobnum
 
			if(blendjob[finder_jobnum].priority == priority){  // looks for a job with the current priority value
 
				done = 1;									  // notice it starts by looking at the oldest job first
 
				break;
 
			}
 

	
 
			if((done) == 1)  // If it has found a job with the current priority value, it will break out of the loop
 
				break;    // If none is found it goes to the next job to see if it is of the current priority value
 
			else
 
				finder_jobnum++;
 
		} // End of increasing finder_jobnum
 

	
 
		if(done == 1) // if job has been found, it lets it out of the priority changer loop
 
			break;
 

	
 
		priority--; // end of decreasing priority
 
	}
 

	
 
	while(your_frame < blendjob[finder_jobnum].total_frames){ // Finds the frameset number with a frame that needs to be rendered
 
		if (blendjob[finder_jobnum].frameset[frameset_count].frame_status == 0)  // If frame that is not assigned has been found, frameset_count is not changed
 
			break;																// and frameset_count is used to give the frame number later in this funciton
 

	
 
		frameset_count++;  // If frame is assigned or done, it goes to next frame
 
	}
 

	
 
blendjob[jobnum].frameset[frameset_count].frame_status++; // sets the value of the frame to 2, which means its taken
 

	
 
your_frame = blendjob[jobnum].frameset[frameset_count].frame_num; //  Takes the frameset found in the while statement above, and extracts the frame number from it and assigns it to the int your_frame
 

	
 
if(your_frame == 0)  // If that job had no open frames for some reason, run the status report generator so that
 
	status_report_generator();  //the job priority can be changed to 0
 
	status_report_generator(blendjobs_head);  //the job priority can be changed to 0
 

	
 
blendjob[jobnum].frameset[frameset_count].start_time = clock();
 

	
 
return your_frame; // your_frame is returned as the frame to be rendered
 
}
 

	
 
void blend_frame_watchdog(struct blendjob *blendjob_head)
 
{
 
  unsigned short int watchdog_forgiveness; /*< seconds to wait on a frame before re-assigning it */
 
  struct blendjob *blendjob_ptr;
 
  unsigned int counter;
 

	
 
  watchdog_forgiveness = 3; /*< hours of forgiveness before frame is re-assigned */
 
  blendjob_ptr = blendjob_head;
 

	
 
  for(blendjob_ptr = blendjob_head; blendjob_ptr; blendjob_ptr = blendjob_ptr->next)
 
    /* iterate through jobs */
 

	
 
    for(counter = 0; counter < blendjob_ptr->total_frames; counter ++)
 
      /* iterate through all frames for this job*/
 
      {
 
	if((blendjob_ptr->frameset[counter].start_time + (watchdog_forgiveness * 3600)) < clock()) 
 
	  /*
 
	    If frame is not completed within the number of hours specified by watchdog_forgiveness 
 
	    Then change the frame status to unassigned
 
	  */
 
	  blendjob_ptr->frameset[counter].frame_status = 0;
 
      }
 

	
 
}
 

	
 
/**
 
   Finds a blendjob struct based on the jobnum
 
   @arg jobnum job number to search for
 
   @return NULL on job doesn't exist
 
 */
 
struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum)
 
{
 
  struct blendjob *blendjob_ptr;
 
  
 
  /*
 
    The conditions of the for loop will leave blendjob_ptr at NULL if the end of the list is reached. It will leave it pointing to the correct job if it is found.
 
   */
 
  for(blendjob_ptr = head;
 
      blendjob_ptr
 
	&& blendjob_ptr->jobnum != jobnum;
 
      blendjob_ptr = blendjob_ptr->next);
 
  
0 comments (0 inline, 0 general)