Changeset - 43a343738d88
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-07-05 13:21:16

tweaked the blendjob structure

tweaked my functions to support the two new global variables hcfjob and highest_jobnum. Need to check functions for 100% accuracy due to start frame - end frame not = 0 frames to be rendered.

added a bit more to the status report generator

for the frame_finder function... it only returns a interger for the frame to be rendered... but the slave also needs the name of the folder the source files are stored in, and the name of the blend file to open to render the frame. Maybe return a string? and have the slave parse it for variables?
1 file changed with 13 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -229,164 +229,167 @@ void loginuser(char *username, int secre
 
  "--gid",
 
  "541",
 
  username,
 
  (char *)NULL
 
  };
 
  size_t readlen;
 
  fprintf(stderr, "Opening stream:\n", execio_open(&testrem, "ssh", execargv));
 
  buf[9] = '\0'; // null-terminating the array...
 
  while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff?
 
    {
 
      if(readlen > 9) {
 
	fprintf(stderr, "!!!! Something is terribly wrong!\n");
 
      }
 
      if(buf == 0) {
 
	fprintf(stderr, "**** Operation successful, or so we hope. We got no output. Just kidding. You will never see this. Something else should catch this though!");
 
      }
 
    buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is?
 
    fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
}
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
/*
 
 frame[frame] Assignments:
 
  "0" - cancelled
 
  "1" - unassigned
 
  "2" - assigned to slave
 
  "3" - completed by slave and uploaded
 
 Have a script crawl through each job in the arrays, ordered by priority?, and assign a certain number of frames to each slave.
 
 Then we will need some sort of watchdog to monitor slaves on the main server to check for stales.
 
*/
 

	
 

	
 
/* This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */
 
void frame_num_struct_builder(int sframe, int eframe) {
 
	int jobnum_new = highest_jobnum + 1;
 
	int total = sframe - eframe;
 
	int fcount = sframe; // Used to create all the frames in the structure from sframe to eframe
 
	int x = 0;
 

	
 
	blendjob[jobnum_new].total_frames = total; // sets the total number of frames in animation for status purposes
 

	
 
	while(x < total){
 
		blendjob[jobnum_new].frameset[x].frame_num = fcount;
 
		x++;
 
		fcount++;
 
	}
 

	
 
	highest_jobnum++;
 
}
 

	
 
// matches your computer up with a lovely frame to render
 
int frame_finder(){
 
	int your_frame = null;  // 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, because frames in an animation don't start at zero
 
	short int done = 0;
 

	
 
	for(int priority = 10; priority >= 1; priority--){ // start the scan for the next job with the highest priority
 
		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){
 
			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++;
 
		}
 

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

	
 
	while(your_frame <= (sframe - eframe)){ // 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
 

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

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

	
 
your_frame = blendjob[jobnum].frameset[x].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 = null)  // 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
 

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

	
 
// This figures out how much of the job is done, where jobnum corresponds to the job number
 
// This uses pointers, so when it is run it updates certain values in memory
 
void status_report_generator(){
 
	int num1 = hcfjob+1;
 
	int num2 = 0;
 
	int num3 = 0;
 
	int num1 = hcfjob+1; // to scan through jobs
 
	int num2 = 0;		 // to scan through frames
 

	
 
	if(blendjob[num1].priority = 0)
 
	if(blendjob[num1].priority = 0)  //If the job after the highest consecutively finished job is finished
 
		hcfjob+1;  // adds 1 to the highest consecutively finished job
 

	
 
	while(blendjob[num1].frameset[num2].name != null){
 
		if(blendjob[num1].priority = 0) // if job is done, go to next one
 
			num1++;
 

	
 
		if(blendjob[num1].frameset[num2].priority !=0)
 
			break;
 
	while(num1 <= highest_jobnum){
 
		if(blendjob[num1].frameset[num2].priority != 0){
 
			while(num2 <= blendjob[jobnum].total_frames){
 
				int finished_frames = 0;
 
				if(blendjob[jobnum].frameset[num2])
 
					finished_frames++;
 
			}
 
		}
 
	}
 

	
 
}
 

	
 
// This function makes the value of the frame 2, which means its completed.
 
void the_finisher(int frame){
 
	blendjob[jobnum].frameset[frame]++;
 
}
 

	
 
// Queuer: this function should add files to the queue
 
// Type: 0 = blender, 1 = luxrender
 
// jobnum is the current job number
 

	
 
void queue(int type, char *name, char *submitter, char *email, int priority, int mode, int spp, *frameset) {
 
  if(type == 1){
 
    blendjob[jobnum].name = name;
 
    blendjob[jobnum].submitter = submitter;
 
    blendjob[jobnum].email = email;
 
    blendjob[jobnum].priority = priority;
 
    blendjob[jobnum].frameset =  frameset;
 
  }
 
  if(type == 2){
 
    luxjob[jobnum].name = name;
 
    luxjob[jobnum].submitter = submitter;
 
    luxjob[jobnum].email = email;
 
    luxjob[jobnum].priority = priority;
 
    luxjob[jobnum].mode = mode;
 
    luxjob[jobnum].spp = spp;
 
    luxjob[jobnum].frameset = frameset;
 
    // handle lux modes somehow.
 
}
 
  else{
 
    // Throw error.
 
  }
 
jobnum++;
 
}
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
/*
 
Slave execution code lies below
0 comments (0 inline, 0 general)